


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

// add a number of screenshot items to the page as the number passed in
function addScreenshots(number)	{
	for(a=1;a<=number;a++)	{
		if(a<10)	{
			sshotname = "screenshot0" + a;
		} else {
			sshotname = "screenshot" + a;
		}
		new addScreenItem(sshotname);
	}
}

// Creates a screen item
function addScreenItem(name)	{
	this.name = name;
	this.bigimage 	= imagepath + name + ".jpg";
	this.smalloff 	= imagepath + "sm/" + name + "_sm.gif";
	this.smallon 	= imagepath + "sm/" + name + "_sm_on.gif";
	this.state 		= "off";
	this.isCached 	= "no"
	navArray[navArray.length] = this;
	function addScreenItem_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 = addScreenItem_swap;
}

// creats the Navitem
function addNavItem(name)	{
	this.name = name;
	this.bigimage 	= imagepath + name + "_center.jpg";
	this.smalloff 	= imagepath + name + "_enemies_sm.gif";
	this.smallon 	= imagepath + name + "_enemies_sm_on.gif";
	this.state 		= "off";
	this.isCached 	= "no"
	navArray[navArray.length] = this;
	
	function addNavItem_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 = addNavItem_swap;
}

function swapImage(num)	{
	navArray[slotArray[0+num]].swap(num);
}


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

// Subtracts one from the number in the slotArray or changes it to the length
// of the slot array if it would make it less then 0
function back()	{	
	for(a=0;a<slotArray.length;a++)	{
		if((slotArray[a]) > 0)	{
			slotArray[a]--;
		} else {
			slotArray[a] = navArray.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 slotArray
function updateNav()	{
	document.images["item1"].src = navArray[slotArray[0]].smalloff;
	document.images["item2"].src = navArray[slotArray[1]].smalloff;
	document.images["item3"].src = navArray[slotArray[2]].smalloff;
	document.images["item4"].src = navArray[slotArray[3]].smalloff;
	document.images["item5"].src = navArray[slotArray[4]].smalloff;
	cacheRollover(navArray[slotArray[0]]);
	cacheRollover(navArray[slotArray[4]]);
}

// Changes the src of the centerimage to be the bigimage of the navArray number
// of the number stored in the slotArray of the slotArray number passed in
function changeBig(num)	{
	document.images["centerimage"].src = navArray[slotArray[num]].bigimage;
}

// 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";
	}
}