//Script to change the main image on the collections page

///////////////////////////////////////////////////////////////
//Function to add leading zeros to IDs - do not edit
function zeroPad(num,count)
{
	var numZeropad = num + '';
	while(numZeropad.length < count) {
	numZeropad = "0" + numZeropad;
	}
	return numZeropad;
}
//End function to add leading zeros to IDs
///////////////////////////////////////////////////////////////


///////////////////////////////////////////////////////////////
//Function to change image and text - do not edit - for COLLECTIONS
function changeImgAndTextCollections(theID,theCollection,numOfImgs,theColl,theDir)
{

		//Set the path for the new image
		var imgSRC = theDir + '/' + theCollection + '/nomia_' + theCollection + '_' + theID + '.jpg';
	
		//Get the correct description from the arrays above
		//Turn the ID into a usable number and subtract 1 to get the array position			
		var arrNum = (parseInt(theID,10)-1); //The 10 number says to parse as decimal
		
		//This gets the corresponding description from the arrays
		var theDescription = theColl[arrNum][1];
		
		//Set the number for the next-up image
		var nextImgNum = (parseInt(theID,10)+1);
		if (nextImgNum > numOfImgs) {nextImgNum = 1;}
		var nextImgID = zeroPad(nextImgNum,3);
	
		//Set the string to write into the page
		var theImageChange = '<a href="#" onclick="javascript:changeCollItem(\'' + nextImgID + '\',\'' + theCollection + '\');">' + '<img src="' + imgSRC + '" alt="NOMIA Collection - Fall / Winter 2009" id="mainCollImage" height="580" /></a><br />' + '<p class="coll_desc gray">' + theDescription + '</p>';

		//Change the image on the page
		document.getElementById('cell_mainimage').innerHTML = theImageChange;
}
//End function to change image and text
///////////////////////////////////////////////////////////////




///////////////////////////////////////////////////////////////
//Function to change image and text - do not edit - for COLLABORATIONS
function changeImgAndText(theID,theCollection,numOfImgs,theColl,theDir)
{

		//Set the path for the new image
		var imgSRC = theDir + '/' + theCollection + '/nomia_' + theCollection + '_' + theID + '.jpg';
	
		//Get the correct description from the arrays above
		//Turn the ID into a usable number and subtract 1 to get the array position			
		var arrNum = (parseInt(theID,10)-1); //The 10 number says to parse as decimal
		
		//This gets the corresponding description from the arrays
		var theDescription = theColl[arrNum][1];
		
		//Set the number for the next-up image
		var nextImgNum = (parseInt(theID,10)+1);
		if (nextImgNum > numOfImgs) {nextImgNum = 1;}
		var nextImgID = zeroPad(nextImgNum,3);
	
		//Set the string to write into the page
		var theImageChange = '<a href="#" onclick="javascript:changeImageColl(\'' + nextImgID + '\',\'' + theCollection + '\');">' + '<img src="' + imgSRC + '" alt="NOMIA Collection - Fall / Winter 2009" id="mainCollImage" height="580" /></a><br />' + '<p class="coll_desc gray">' + theDescription + '</p>';
	alert (theImageChange);
		//Change the image on the page
		document.getElementById('cell_mainimage').innerHTML = theImageChange;
}
//End function to change image and text
///////////////////////////////////////////////////////////////


		
///////////////////////////////////////////////////////////////
//Change from link - if user click on link in the left bar for COLLABORATIONS ONLY
function changeImageColl(theID,theCollection){
		
    if (theCollection == "ab01") { //COLLABORATION 1 !
		
		//This number must be set to the max number of images
			var numOfImgs = 10;

			var theColl = new Array();					
			 theColl[0] = new Array("001","");
			 theColl[1] = new Array("002","");
			 theColl[2] = new Array("003","");
			 theColl[3] = new Array("004","");
			 theColl[4] = new Array("005","");
			 theColl[5] = new Array("006","");
			 theColl[6] = new Array("007","");
			 theColl[7] = new Array("008","");
			 theColl[8] = new Array("009","");
			 theColl[9] = new Array("010","");

			
			theDir = "img_collaborations";
			changeImgAndText (theID,theCollection,numOfImgs,theColl,theDir);		
		
		
		} else if (theCollection == "ab02") { //COLLABORATION 2 !
		
		//This number must be set to the max number of images
			var numOfImgs = 9;

			var theColl = new Array();					
			 theColl[0] = new Array("001","");
			 theColl[1] = new Array("002","");
			 theColl[2] = new Array("003","");
			 theColl[3] = new Array("004","");
			 theColl[4] = new Array("005","");
			 theColl[5] = new Array("006","");
			 theColl[6] = new Array("007","");
			 theColl[7] = new Array("008","");
			 theColl[8] = new Array("009","");

			
			theDir = "img_collaborations";
			changeImgAndText (theID,theCollection,numOfImgs,theColl,theDir);		
		
		
		} 
///////////////////////////////////////////////////////////////		


}