var screenNum = 0;
var videos = new Array();

MM_preloadImages('/img/games/pop_btn_next_over.gif','/img/games/pop_btn_prev_over.gif');

function setContent() {
	setVideo(screenNum);
}

function Video(fileURL,width,height,title) {
	this._fileURL = fileURL;
	this._width = width;
	this._height = height;
	this._title = title;
	this.getFileURL = function() {
		return this._fileURL;
	}
	this.getWidth = function() {
		return this._width;
	}
	this.getHeight = function() {
		return this._height;
	}
	this.getTitle = function() {
		return this._title;
	}
	videos.push(this);
}

function setPageNav() {
	$("popScreenPageNumDiv").style.display="block";
	$("currentPageNumDiv").style.display="block";
	$("totalPageNumDiv").style.display="block";
	$("pageNumDividerDiv").style.display="block";

	if (videos.length>1) {
		if (screenNum>0) {
			$("popBtnPrevId").style.display="block";			
		} else {
			$("popBtnPrevId").style.display="none";			
		}
		if ((screenNum+1)<videos.length) {
			$("popBtnNextId").style.display="block";
		} else {
			$("popBtnNextId").style.display="none";			
		}
	}
}

function setPageNum() {
	$("totalPageNumDiv").innerHTML = videos.length;
	$("currentPageNumDiv").innerHTML = screenNum+1; //bump it up by one because it's a zero based array
}

function setTitle(mainTitle) {
	$("gameTitle").style.visibility="hidden";
	$("gameTitle").className="popGameTitle";
	$("gameTitle").innerHTML=mainTitle;
	if(typeof sIFR == "function") {
	    sIFR.replaceElement("#gameTitle", named({sFlashSrc: "/meta/swf/conduit_itc_medium.swf", sColor: "#FFFFFF", sCase: "upper", sBgColor: "#000000", sWmode: "transparent"}));
	}
	$("gameTitle").style.visibility="visible";
}

function writeVideo(vidURL,vidWidth,vidHeight) {
	var myQTObject = new QTObject(vidURL, "videoplayer", vidWidth, vidHeight+15); //15 added to vidHeight for control bar
	myQTObject.addParam("showlogo", "false");	
	myQTObject.addParam("autostart", "true");
	myQTObject.write("videoCell");
}

function setVideo(videoNumber) {
	screenNum=videoNumber;
	setPageNum();
	setPageNav();
	setTitle(videos[videoNumber].getTitle());
	writeVideo(videos[screenNum].getFileURL(),videos[screenNum].getWidth(),videos[screenNum].getHeight());
}

function navButton(nextOrPrev) {
	if (nextOrPrev == "next") {
		setVideo(screenNum+1)
	} else if (nextOrPrev == "prev") {
		setVideo(screenNum-1)		
	}	
}