// JavaScript Document

	var numA = 8;  // number of items in array
	var pathImage = "img/products/";
	var thumbSelected = "thumb_01";

	function SetContent(indexProduct) 
	{ 
		if (indexProduct > 0) indexProduct = indexProduct - 1;
		document.getElementById("idTitle").innerHTML = products[indexProduct][0];
		document.getElementById("idDimension").innerHTML 	= products[indexProduct][1];
		document.getElementById("idDescription").innerHTML 	= products[indexProduct][2];
		document.getElementById("idCost").innerHTML 		= products[indexProduct][3];
		document.getElementById("idAvailability").innerHTML = products[indexProduct][4];
		document.getElementById("idRef").innerHTML 			= products[indexProduct][5];
		document.getElementById("idImageProduct").src 		= pathImage + products[indexProduct][6];
		document.getElementById("idPostage").innerHTML 			= products[indexProduct][8];
		
		SetMoreImages(indexProduct);
	}
	  
	function SetMoreImages(indexProduct) 
	{
		var elem = document.getElementById("idMoreImages");
		while (elem.hasChildNodes()) 
		{
			elem.removeChild(elem.lastChild);
		}

		posImages = numA - 1;
		if (products[indexProduct][posImages] != "") 
		{		
			elem.style.display = "block";
			for (var i=0; i < products[indexProduct][posImages].length; i++) 
			{	
				var aLink 	= document.createElement("a");
				aLink.setAttribute("href", pathImage + products[indexProduct][posImages][i]);
				aLink.setAttribute("rel","lightbox[products]");
				
				if (i > 0) 
					aLink.setAttribute("title","");
				else 
					aLink.innerHTML = "view more photos";
				document.getElementById("idMoreImages").appendChild(aLink);
			}
			initLightbox();
		}
		else 
		{
			elem.style.display = "none";
		}
	}
	
	function SetSelection(thumbName) 
	{
		document.getElementById(thumbSelected).className = "thumb";
		thumbSelected = thumbName;
		document.getElementById(thumbSelected).className = "thumb-selected";
	}
