function YTBox() {
	this.videos = null;
	this.videoHolder = null;
	this.numbersObj = null;
	this.arrowLeft = null;
	this.arrowRight = null;
	this.titleObj = null;
	this.currentVideo=0;
	this.id = null;
	
	this.goLeft = function() {
		if (this.currentVideo==0) this.currentVideo = this.videos.length-1;
		else this.currentVideo--;
		this.launch();
	}
	
	this.goRight = function() {
		if (this.currentVideo==this.videos.length-1) this.currentVideo = 0;
		else this.currentVideo++;
		this.launch();
	}
	
	this.launch = function() {
		this.writeYTObj();
		this.writeNumbers();
		this.writeTitle();
	}
	
	this.writeNumbers = function() {
		this.numbersObj.innerHTML = (this.currentVideo+1)+"/"+this.videos.length;
	}
	
	this.writeTitle = function() {
		this.titleObj.innerHTML = this.videos[this.currentVideo].title.replace(/&quot;/g,'"');
	}
	
	this.writeYTObj = function() {
		this.videoHolder.innerHTML = "";		
    swfobject.embedSWF(
      "http://www.youtube.com/v/"+this.videos[this.currentVideo].id+"&hl=pl&fs=1&color1=0x3a3a3a&color2=0x999999", this.videoHolder.id, "300", "240",
      "9.0.0", "expressInstall.swf",
      null,
      {"allowFullScreen":"true", "allowscriptaccess":"always"}
      );
	}
	
	this.initialize = function(id,data) {
		this.id = id;
		this.videos = data;
		this.videoHolder = document.getElementById('JS_'+id+'_VideoHolder');
		this.numbersObj = document.getElementById('JS_'+id+'_Numbers');
		this.writeNumbers();
		this.numbersObj.parentNode.style.display = "block";
		this.arrowLeft = document.getElementById('JS_'+id+'_ArrowLeft');
		this.arrowLeft.YTBox = this;
		this.arrowLeft.onclick = function() {
			this.YTBox.goLeft();
			
		}
		this.arrowRight = document.getElementById('JS_'+id+'_ArrowRight');
		this.arrowRight.YTBox = this;
		this.arrowRight.onclick = function() {
			this.YTBox.goRight();
		}
		this.titleObj = document.getElementById('JS_'+id+'_Title');
		
		this.launch();
	}
}