﻿function ImageOnClick(key)
{	
	var ImgIndex = document.getElementById("hidPicIndex").value;
	if (key == 0){
		for (i=0; i<3; i++)
			{	
				var strCode = "if (imgUrls[ImgIndex].Pic" + (i + 1).toString() + ".indexOf(\"no_pic.jpg\") >= 0)";
				strCode += "{";
				strCode +="	document.getElementById(\"small_pic_" + (i+1).toString() + "\").style.display = \"none\";";
				strCode +="}";
				strCode +="else";
				strCode +="{";
				strCode +="	document.getElementById(\"small_pic_" + (i+1).toString() + "\").style.display = \"block\";";
				strCode +="}";
				eval(strCode);
			}
		return;
	}
	if (imgUrls.length > 0)
	{
		document.getElementById("MainImage").src = imgUrls[ImgIndex].Pic1;
		document.getElementById("smallPic_1").src = smallImgUrls[ImgIndex].Pic1;
		document.getElementById("smallPic_2").src = smallImgUrls[ImgIndex].Pic2;
		document.getElementById("smallPic_3").src = smallImgUrls[ImgIndex].Pic3;
	
		for (i=0; i<3; i++)
		{
			if ((i+1) == key)
			{
				eval("document.getElementById(\"MainImage\").src = imgUrls[ImgIndex].Pic" + (i+1).toString());
				eval("document.getElementById(\"hidZoomPicUrl\").value = zoomImgUrls[ImgIndex].Pic" + (i+1).toString());
				document.getElementById("small_pic_" + (i+1).toString()).className = "prod_detail_small_pic_on";
			}
			else
			{
				document.getElementById("small_pic_" + (i+1).toString()).className = "prod_detail_small_pic";
			}
		}

		if (key == 1)
		{
			for (i=0; i<3; i++)
			{	
				var strCode = "if (imgUrls[ImgIndex].Pic" + (i + 1).toString() + ".indexOf(\"no_pic.jpg\") >= 0)";
				strCode += "{";
				strCode +="	document.getElementById(\"small_pic_" + (i+1).toString() + "\").style.display = \"none\";";
				strCode +="}";
				strCode +="else";
				strCode +="{";
				strCode +="	document.getElementById(\"small_pic_" + (i+1).toString() + "\").style.display = \"block\";";
				strCode +="}";
				eval(strCode);
			}
		}
	}
	else
	{
		for (i=0; i<3; i++)
		{	
			document.getElementById("small_pic_" + (i+1).toString()).style.display = "none";
		}
	}
}

function ZoomPic()
{
	window.open(document.getElementById("hidZoomPicUrl").value);
}