function SwapImage(imagename){
	document.getElementById('productimage').src = '/product_images/' + imagename;
}

function SwapImage_Sku(imagename,productsku){
	document.getElementById('productimage').src = '/product_images/' + imagename;
	var sel = 0;
	for (var i=0;i<document.addtocartform.itemsku.options.length;i++)
	{
		if(document.addtocartform.itemsku.options[i].value==productsku)
		{
			document.addtocartform.itemsku.selectedIndex = i;
		}
	}
}

function SwapImage_Sku(imagename,productsku,pricing)
{
	document.getElementById('productimage').src = '/product_images/' + imagename;
	var sel = 0;
	for (var i=0;i<document.addtocartform.itemsku.options.length;i++)
	{
		if(document.addtocartform.itemsku.options[i].value==productsku)
		{
			document.addtocartform.itemsku.selectedIndex = i;
			document.getElementById("show_price").innerHTML = " " + pricing;
		}
	}
}

function SwapImage_DropDown()
{
	var indx = document.addtocartform.itemsku.selectedIndex;
	var imgfile = document.addtocartform.style_imagefile.options[indx].value;
	var orgprc = document.addtocartform.style_originalprice.options[indx].value;
	var saleprc = document.addtocartform.style_saleprice.options[indx].value;
	if (saleprc != "$0.00")
	{
		document.getElementById("show_price").innerHTML = " " + "<font style='text-decoration:line-through;'>" + orgprc + "</font> " + saleprc;
	}
	else
	{
		document.getElementById("show_price").innerHTML = " " + orgprc;
	}
	SwapImage(imgfile);
}

function toggleshipsame(action)
{
   if (action == "flip")
   {
   
      if (document.registerform.shipsame.checked)
      {
        
		 document.registerform.shipsame.checked=true;
         
         document.registerform.shippingfirstname.value = document.registerform.billingfirstname.value;
         document.registerform.shippinglastname.value = document.registerform.billinglastname.value;
		 document.registerform.shippingcompany.value = document.registerform.billingcompany.value;
		 document.registerform.shippingaddress1.value = document.registerform.billingaddress1.value;
		 document.registerform.shippingaddress2.value = document.registerform.billingaddress2.value;
		 document.registerform.shippingcity.value = document.registerform.billingcity.value;
		 document.registerform.shippingstate.value = document.registerform.billingstate.value;
		 document.registerform.shippingzip.value = document.registerform.billingzip.value;
		 document.registerform.shippingphone1.value = document.registerform.billingphone1.value;
    
	  }
      
      else
      {
         document.registerform.shipsame.checked=false;
      }
   
   }
   
   else
   {
      document.registerform.shipsame.checked=false;
   }
}

function updateBillingStates(strFormName)
{
	if (document.forms[strFormName].billingcountry.value == "United States")
	{
		document.forms[strFormName].billingstate.style.display = "";
		document.forms[strFormName].billingstate_txt.style.display = "none";
	}
	else
	{
		document.forms[strFormName].billingstate.style.display = "none";
		document.forms[strFormName].billingstate_txt.style.display = "";
	}
	document.forms[strFormName].billingstate_txt.value = "";
}

function updateShippingStates(strFormName)
{
	if (document.forms[strFormName].shippingcountry.value == "United States")
	{
		document.forms[strFormName].shippingstate.style.display = "";
		document.forms[strFormName].shippingstate_txt.style.display = "none";
	}
	else
	{
		document.forms[strFormName].shippingstate.style.display = "none";
		document.forms[strFormName].shippingstate_txt.style.display = "";
	}
	document.forms[strFormName].shippingstate_txt.value = "";
}

function ShowSecurityCode()
{
	var xpos = (window.parent.screen.width - 600) / 2;
	var ypos = (window.parent.screen.height - 320) / 3;
	
	window.open('/scripts/securitycode.cfm', 'window', 'width=600,height=320,' + ', left=' + xpos + ', top=' + ypos + ',scrollbars=no,resizable=no,menubar=0');
}

