function MovieCategory(_owner, _id, _title, _content, _position) {
	this.owner = _owner;
	this.id = _id;
	this.title = _title;
	this.content = _content;
	this.position = _position;
	this.list = new Array();
	this.container = null;
	this.playerContainer = null;
}

MovieCategory.prototype.setPlayerContainer = function(_playerContainer) {
	this.playerContainer = _playerContainer;
}

MovieCategory.prototype.draw = function(parentContainer) {
	var div = document.createElement("div");
	div.id = "category_" + this.id;
	div.className = "categoryHidden";
	if (parentContainer) {
		parentContainer.appendChild(div);
		this.container = div;
		this.show();
	}
}

MovieCategory.prototype.show = function() {
	this.list = new Array();
	$.post("templates/8/servlet.php", {action : "getMoviesForCategory", parent : this.id}, this.setMovies);
}

/**
 * Ustawa video w galerii.
 */
MovieCategory.prototype.setMovies = function(moviesJSON) {
	var movies = eval(moviesJSON);
	if (!movies) return;
	var category = null;
	for (var i=0;i<movies.length;i++) {
		var params = movies[i];
		var movie = new Movie(params[0], params[1], params[2], params[3], params[4], params[5], params[6]);
		if (!category) {
			category = Movies.getCategory(movie.getParent());
		}
		if (category) {
			movie.setContainer(category.playerContainer);
			category.addMovie(movie);
		}
	}
	if (category) {
		category.change();
	}
}

MovieCategory.prototype.change = function() {
	this.drawAsync();
	/* więcej akcji */
}

MovieCategory.prototype.drawAsync = function() {
	var title = document.createElement("div");
	title.className = "categoryTitle";
	title.innerHTML = this.title;
	var content = document.createElement("div");
	content.className = "categoryContent";
	var movies = document.createElement("div");
	movies.className = "categoryMovies";
	this.container.appendChild(title);
	if (this.content) {
		this.container.appendChild(content);
	}
	this.container.appendChild(movies);
	for (var i=0;i<this.list.length;i++) {
		this.list[i].drawLink(movies, this.p);
	}
	this.container.className = "categoryVisible";
}

MovieCategory.prototype.addMovie = function(movie) {
	this.list[this.list.length] = movie;
}

MovieCategory.prototype.getId = function() {
	return this.id;
}

