function UpdateHiddenValues(ImageName,ProductID)
{
	//ImageName =  ImageName;	
	document.getElementById("hdProductID").value = ProductID;
	document.getElementById("hdImageURL").value = ImageName;
}

function ShowLargeImage(ImageName,ProductID,e)
{
	ImageName = "Large" + ImageName;	
	document.getElementById("LargeImage").src=ImageName;		
	document.getElementById("PopUpLargeImage").style.display = "block";		
	document.getElementById("hdProductID").value = ProductID;
	document.getElementById("hdImageURL").value = ImageName;
	window.scroll(250,740);
	/*var ev=(!e)?window.event:e;//IE:Moz
	if (ev.pageX){//Moz
	posx=ev.clientX;
	posy=ev.clientY;
	}
	else 
	{//IE
	posx=ev.clientX;
	posy=ev.clientY;
	}
	document.getElementById("PopUpLargeImage").style.top=(posy -100) + "px";
	
	
    var viewportwidth;
 	var viewportheight;	
   if (typeof window.innerWidth != 'undefined')
   {
      viewportwidth = window.innerWidth,
      viewportheight = window.innerHeight
   }// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
  else if (typeof document.documentElement != 'undefined'
     && typeof document.documentElement.clientWidth !=
     'undefined' && document.documentElement.clientWidth != 0)
   {
       viewportwidth = document.documentElement.clientWidth,
       viewportheight = document.documentElement.clientHeight
   } // older versions of IE 
 else
 {
       viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
       viewportheight = document.getElementsByTagName('body')[0].clientHeight
 }

	document.getElementById("PopUpLargeImage").style.left= (viewportwidth/2) - 175 + "px";
*/	
}
function HideLargeImage()
{	
	document.getElementById("PopUpLargeImage").style.display = "none";	
	document.getElementById("LargeImage").src="images/imageloader.gif";
}

function AddShellNoPopUp(ImageName,ProductID,e)
{
	//ImageName = "Large" + ImageName;	
	//document.getElementById("LargeImage").src=ImageName;		
	//document.getElementById("PopUpLargeImage").style.display = "block";		
	document.getElementById("hdProductID").value = ProductID;
	document.getElementById("hdImageURL").value = ImageName;
	AddShellToCart();

}


/*function AddShellToCart(imageURL , ProductID)
{
	var objShell = document.getElementById("hdShellCounter");
	shellCount = parseInt(objShell.value);	
	switch (shellCount) 
	{
	case 0: document.imgShell1.src=imageURL;shellCount=shellCount + 1;break;
	case 1: document.imgShell2.src=imageURL;shellCount=shellCount + 1; break;
	case 2: document.imgShell3.src=imageURL;shellCount=shellCount + 1; break;
	case 3: document.imgShell4.src=imageURL;shellCount=shellCount + 1; break;
	default: alert('You already have four Shells in Cart. To add this item remove one of the Shells from below.'); break;
	}	
	document.getElementById("hdShellCounter").value = shellCount;
	if(shellCount <= 4)
	{
	hdShell = "hdShell" + shellCount;
	document.getElementById(hdShell).value = parseInt(ProductID);	
	}	
	ShowShells();
	window.scroll(50,660);
}*/
function AddShell(imageURL , ProductID)
{
	document.getElementById("hdImageURL").value = imageURL;
    document.getElementById("hdProductID").value = ProductID;
    AddShellToCart();

}
function AddShellToCart()
{
	imageURL = document.getElementById("hdImageURL").value;
	imageURL = imageURL .replace("Large","");
	ProductID = document.getElementById("hdProductID").value;
	AddShellFlag = true;
	var objShell = document.getElementById("hdShellCounter");
	shellCount = parseInt(objShell.value);	
	ScrollToCart();

	switch (shellCount) 
	{
	case 0: document.imgShell1.src=imageURL;shellCount=shellCount + 1; break;
	case 1: document.imgShell2.src=imageURL;shellCount=shellCount + 1; break;
	case 2: document.imgShell3.src=imageURL;shellCount=shellCount + 1; break;
	case 3: document.imgShell4.src=imageURL;shellCount=shellCount + 1; break;
	default: ScrollToCart(); AddShellFlag = false;alert('You already have Three Shells + 1 Free Shell in Cart. To add this item remove one of the Shells from right below shell selection area and add this item.'); break;
	}	 
	document.getElementById("hdShellCounter").value = shellCount;
	if(shellCount <= 4 && AddShellFlag == true )
	{
	hdShell = "hdShell" + shellCount;
	document.getElementById(hdShell).value = parseInt(ProductID);	
	}		
	ShowShells();
	
}

function RemoveShellFromCart(shellNo)
{
	if(shellCount > 0)
	{
		var objShell = document.getElementById("hdShellCounter");
		shellCount = parseInt(objShell.value);
		shellCount = shellCount - 1;
		document.getElementById("hdShellCounter").value = shellCount;
	}	
	if(shellNo == 4)
	{
		document.imgShell4.src="images/bw_bags.jpg";
		document.getElementById("hdShell4").value	 = "";
	}
	if(shellNo == 3)
	{
		var imageURL = document.imgShell4.src;
		document.imgShell3.src=imageURL;
		ShellID = document.getElementById("hdShell4").value;
		document.getElementById("hdShell3").value = ShellID;
		document.imgShell4.src="images/bw_bags.jpg";	
		document.getElementById("hdShell4").value = "";
		
	}
	if(shellNo == 2)
	{
		var imageURL = document.imgShell3.src;
		document.imgShell2.src=imageURL;
		var ShellID = document.getElementById("hdShell3").value;
		document.getElementById("hdShell2").value = ShellID;
		imageURL = document.imgShell4.src;
		document.imgShell3.src=imageURL;
		ShellID = document.getElementById("hdShell4").value;
		document.getElementById("hdShell3").value = ShellID;		
		document.imgShell4.src="images/bw_bags.jpg";	
		document.getElementById("hdShell4").value = "";
		
	}
	if(shellNo == 1)
	{
		var imageURL = document.imgShell2.src;
		document.imgShell1.src=imageURL;
		var ShellID = document.getElementById("hdShell2").value;
		document.getElementById("hdShell1").value = ShellID;
		imageURL = document.imgShell3.src;
		document.imgShell2.src=imageURL;
		ShellID = document.getElementById("hdShell3").value;
		document.getElementById("hdShell2").value = ShellID;
		imageURL = document.imgShell4.src;
		document.imgShell3.src=imageURL;
		ShellID = document.getElementById("hdShell4").value;
		document.getElementById("hdShell3").value = ShellID;			
		document.imgShell4.src="images/bw_bags.jpg";
		document.getElementById("hdShell4").value = "";			
	}	
	
	
	ShowShells();
}
function ShowShells()
{
		var objShell = document.getElementById("hdShellCounter");
		shellCount = parseInt(objShell.value);
		if(shellCount == 0)
		{			
			document.getElementById("divShells").style.display = "block";
			document.getElementById("remove1").style.display = "none";
			for(i=1; i<=4;i++)
			{			
			document.getElementById("divShell" + i).onclick = Scroll;
			document.getElementById("imgShell"+ i).style.cursor="pointer";
			}
		}
		else
		{	
			document.getElementById("divShells").style.display = "block";
			for(i=1;i<=shellCount;i++)
			{
				document.getElementById("divShell" + i).style.display = "block";
				document.getElementById("remove" + i).style.display = "block";
				document.getElementById("divShell" + i).onclick = null;	
				document.getElementById("imgShell"+ i).style.cursor="";	
			}
			for(i=shellCount+1;i<=4;i++)
			{
				document.getElementById("divShell" + i).style.display = "block";
				document.getElementById("remove" + i).style.display = "none";
				document.getElementById("imgShell"+ i).style.cursor="pointer";
				document.getElementById("divShell" + i).onclick = Scroll;
			}

		}
		
}
function IsTwoSelected()
{
	var objShell = document.getElementById("hdShellCounter");
	shellCount = parseInt(objShell.value);
	if(shellCount < 4)
	{
		alert("Please select your 4 favorite SHELLS above.");
		return false;
	}	
}



function Scroll()
{
window.scroll(0,600);
}
function ScrollToPopUp()
{
window.scroll(0,600);
}
function ScrollToCart()
{
window.scroll(0,2300);

}
function ScrollToOrder()
{
window.scroll(0,2300);
}

