var imagepath = "http://www.japan.ea.com/mohfl/videos/"
var videoArray = new Array();
var videoSlotArray = new Array(0,1,2,3,4);
var sshotname = "";

// creats the Navitem
function addVideoItem(name)	{
	this.name 			= 	name;
	this.smallon		= 	"http://www.japan.ea.com/mohfl/videos/" + name + "lo_sm_on.gif";
	this.smalloff  		= 	"http://www.japan.ea.com/mohfl/videos/" + name + "_sm.gif";
	this.state 			= 	"off";
	this.isCached 		= 	"no"
	videoArray[videoArray.length] = this;
	
	function addVideoItem_swap(num)	{
		var thisitem = "item" + (1 + num);
		if(this.state == "off")	{
			document.images[thisitem].src = this.smallon;
			this.state = "on";
		} else {
			document.images[thisitem].src = this.smalloff;
			this.state = "off";
		}
	}	
	this.swap = addVideoItem_swap;
}

function swapImage(num)	{
	videoArray[videoSlotArray[num]].swap(num);
}


// Adds one to the number in the videoSlotArray or, changes it to 0 if greater then
// or equal to the videoArray length, then calls updateNav to update the images.
function next()	{	
	for(a=0;a<videoSlotArray.length;a++)	{
		if((videoSlotArray[a]+1) < videoArray.length)	{
			videoSlotArray[a]++;
		} else {
			videoSlotArray[a] = 0;
		}		
	}
	updateNav();
}

// Subtracts one from the number in the videoSlotArray or changes it to the length
// of the slot array if it would make it less then 0
function back()	{	
	for(a=0;a<videoSlotArray.length;a++)	{
		if((videoSlotArray[a]) > 0)	{
			videoSlotArray[a]--;
		} else {
			videoSlotArray[a] = videoArray.length-1;
		}		
	}
	updateNav();
}

// Updates all the images with the small off images of the object in the
// nav array equal to the number stored in the videoSlotArray
function updateNav()	{
	document.images["item1"].src = videoArray[videoSlotArray[0]].smalloff;
	document.images["item2"].src = videoArray[videoSlotArray[1]].smalloff;
	document.images["item3"].src = videoArray[videoSlotArray[2]].smalloff;
	document.images["item4"].src = videoArray[videoSlotArray[3]].smalloff;
	document.images["item5"].src = videoArray[videoSlotArray[4]].smalloff;
	cacheRollover(videoArray[videoSlotArray[0]]);
	cacheRollover(videoArray[videoSlotArray[4]]);
}

// Changes the src of the centerimage to be the bigimage of the videoArray number
// of the number stored in the videoSlotArray of the videoSlotArray number passed in
function changePage(num)	{
	document.location = videoArray[videoSlotArray[num-1]].url;
}

// Caches the smallon version of the object named
function cacheRollover(name)	{
	if(name.isCached = "no")	{
 		var anImage = new Image();
  		anImage.src = name.smallon;
		name.isCached = "yes";
	}
}

function openTo(num)	{
	videoSlotArray[0] = num-1;
	for(a=1;a<videoSlotArray.length;a++)	{
		if(videoSlotArray[a-1]+1 < videoArray.length)	{
			videoSlotArray[a] = videoSlotArray[a-1]+1;
		} else {
			videoSlotArray[a]=0;
		}
	}
	updateNav();
}

new addVideoItem("videos01");
new addVideoItem("videos02");
new addVideoItem("videos03");
new addVideoItem("videos04");
new addVideoItem("videos05");
new addVideoItem("videos06");
new addVideoItem("videos07");
new addVideoItem("videos08");
new addVideoItem("videos09");
new addVideoItem("videos10");
