function Album(_owner, _id, _title, _content, _position, _cover) {
	this.owner = _owner;
	this.id = _id;
	this.title = _title;
	this.content = _content;
	this.position = _position;
	this.cover = _cover;
	this.list = new Array();
	this.container = null;
	this.playerContainer = null;
}

Album.prototype.setPlayerContainer = function(_playerContainer) {
	this.playerContainer = _playerContainer;
}

Album.prototype.draw = function(parentContainer) {
	var div = document.createElement("div");
	div.id = "album_" + this.id;
	div.className = "albumHidden";
	if (parentContainer) {
		parentContainer.appendChild(div);
		this.container = div;
		this.show();
	}
}

Album.prototype.show = function() {
	this.list = new Array();
	$.post("templates/8/servlet.php", {action : "getAudioTracks", parent : this.id}, this.setAudioTracks);
}

/**
 * Ustawa video w galerii.
 */
Album.prototype.setAudioTracks = function(audioTracksJSON) {
	try {
		var audioTracks = eval(audioTracksJSON);
	} catch (e) {}
	if (!audioTracks) return;
	var album = null;
	for (var i=0;i<audioTracks.length;i++) {
		var params = audioTracks[i];
		var audioTrack = new AudioTrack(params[0], params[1], params[2], params[3], params[4]);
		if (!album) {
			album = Albums.get(audioTrack.getParent());
		}
		if (album) {
			audioTrack.setContainer(album.playerContainer);
			album.addAudioTrack(audioTrack);
		}
	}
	if (album) {
		album.change();
	}
}

Album.prototype.change = function() {
	this.drawAsync();
	/* więcej akcji */
}

Album.prototype.drawAsync = function() {
	var title = document.createElement("div");
	title.className = "albumTitle";
	title.innerHTML = this.title;
	var content = document.createElement("div");
	content.className = "albumContent";
	if (this.cover) {
		var img = document.createElement("img");
		img.src = this.cover;
		content.appendChild(img);
	}
	var audioTracks = document.createElement("div");
	audioTracks.className = "albumTracks";
	for (var i=0;i<this.list.length;i++) {
		this.list[i].drawLink(audioTracks, this.playerContainer);
	}
	/*var brfix = document.createElement("div");
	brfix.className = "brfix";
	audioTracks.appendChild(brfix);*/
	this.container.appendChild(title);
	if (this.cover) {
		this.container.appendChild(content);
	}
	this.container.appendChild(audioTracks);
	this.container.className = "albumVisible";
}

Album.prototype.addAudioTrack = function(audioTrack) {
	this.list[this.list.length] = audioTrack;
}

Album.prototype.getId = function() {
	return this.id;
}

