///////////////////////////////////////////////////////////
//
//  common.js
//  JavaScript Functions
//  Original author: Sridhar Ganji
//  
///////////////////////////////////////////////////////////
//  Modification history:
//  
//
///////////////////////////////////////////////////////////

browserName = navigator.appName;
browserVer = parseInt(navigator.appVersion);

if (browserName == "Netscape" && browserVer >= 3 || browserName == "Microsoft Internet Explorer" && browserVer >= 4)  
	version = "n3";
else 
	version = "n2";

if (version == "n3") 
{
	//These are the active images on the side next to the border
	cartOn = new Image(32,  197);
	//cartOn.src = "/images/icon_cart_red.gif";
	cartOn.src = "images/icon_cart3.gif";

	//These are the inactive images on the top menu bar
	cartOff = new Image(42,  197);
	cartOff.src = "images/icon_cart3.gif";
}
	
function img_act(imgName) 
{
	if (version == "n3") 
	{
		imgOn = eval(imgName + "On.src");
		document[imgName].src = imgOn;
	}
}

function img_inact(imgName) 
{
	if (version == "n3") 
	{
		imgOff = eval(imgName + "Off.src");
		document[imgName].src = imgOff;
	}
}

//to disallow submit action upon text box entry
function PreventEnter()
{
	return !(window.event && window.event.keyCode == 13);
}

//set the focus on the form element -- login request
function SetFocus()
{
	if (document.frmLoginRequest.txtEmail)
		document.frmLoginRequest.txtEmail.focus();
	else if (document.frmLoginRequest.txtEmail1)
		document.frmLoginRequest.txtEmail1.focus();
}

function getWindowSize() 
{
	if (document.getElementById('ProductList') != null)
	{
		//alert('in getWindowSize()');
		if (navigator.appName.indexOf("Netscape") == -1) 
		{
			winWidth = document.body.clientWidth;
			winHeight = document.body.clientHeight;
		}
		else
		{
			winWidth = window.innerWidth;
			winHeight = window.innerHeight;
		}
		
		if (winHeight <= 450)
			document.getElementById('ProductList').style.height = '225px';
		else 
			document.getElementById('ProductList').style.height = '370px';
	}
}

function SetBillTo()
{
	// set default
	document.getElementById("ctlCheckout_ddlBilling_State_Province").selectedIndex = 0;
   	
   				
   	// View source to see auto-generated names used below; Make sure consistent among different version of .Net Framework
   	// Use getElementById because auto-added "name" attribute contains a ":", which freaks out Javascript
   	//if (document.getElementById("setBillTo").getAttribute("checked"))
   	if (document.getElementById("ctlCheckout_chkSame_Shipping_Billing_Address").checked) // (getAttribute doesn't work for checked property in NS)
   	{
   		document.getElementById("ctlCheckout_txtBilling_First_Name").setAttribute("value",document.getElementById("ctlCheckout_txtShipping_First_Name").getAttribute("value"));
   		document.getElementById("ctlCheckout_txtBilling_Last_Name").setAttribute("value",document.getElementById("ctlCheckout_txtShipping_Last_Name").getAttribute("value"));
   		//document.getElementById("billing_companyName").setAttribute("value",document.getElementById("shipping_companyName").getAttribute("value"));
   		document.getElementById("ctlCheckout_txtBilling_Address1").setAttribute("value",document.getElementById("ctlCheckout_txtShipping_Address1").getAttribute("value"));
   		document.getElementById("ctlCheckout_txtBilling_Address2").setAttribute("value",document.getElementById("ctlCheckout_txtShipping_Address2").getAttribute("value"));
   		document.getElementById("ctlCheckout_txtBilling_City").setAttribute("value",document.getElementById("ctlCheckout_txtShipping_City").getAttribute("value"));
   		//document.getElementById("billing_state").setAttribute("value",document.getElementById("shipping_state").getAttribute("value"));
   		//document.getElementById("billing_state").setAttribute("selectedIndex",document.getElementById("shipping_state").getAttribute("selectedIndex"));
   		document.getElementById("ctlCheckout_ddlBilling_State_Province").selectedIndex = document.getElementById("ctlCheckout_ddlShipping_State_Province").selectedIndex;
   		document.getElementById("ctlCheckout_txtBilling_Zip_Postal_Code").setAttribute("value",document.getElementById("ctlCheckout_txtShipping_Zip").getAttribute("value"));
   		document.getElementById("ctlCheckout_txtBilling_Country").setAttribute("value",document.getElementById("ctlCheckout_txtShipping_Country").getAttribute("value"));
   		document.getElementById("ctlCheckout_txtBilling_Email").setAttribute("value",document.getElementById("ctlCheckout_txtShipping_Email").getAttribute("value"));
   		document.getElementById("ctlCheckout_txtBilling_Daytime_Phone").setAttribute("value",document.getElementById("ctlCheckout_txtShipping_Daytime_Phone").getAttribute("value"));
   	}
   	else
   	{
   		document.getElementById("ctlCheckout_txtBilling_First_Name").setAttribute("value","");
   		document.getElementById("ctlCheckout_txtBilling_Last_Name").setAttribute("value","");
   		//document.getElementById("billing_companyName").setAttribute("value","");
   		document.getElementById("ctlCheckout_txtBilling_Address1").setAttribute("value","");
   		document.getElementById("ctlCheckout_txtBilling_Address2").setAttribute("value","");
   		document.getElementById("ctlCheckout_txtBilling_City").setAttribute("value","");
   		//if (navigator.userAgent.indexOf("IE")>-1)
   		document.getElementById("ctlCheckout_ddlBilling_State_Province").selectedIndex = 0;
   		//document.getElementById("billing_state").setAttribute("value","");
   		document.getElementById("ctlCheckout_txtBilling_Zip_Postal_Code").setAttribute("value","");
   		document.getElementById("ctlCheckout_txtBilling_Country").setAttribute("value","");
   		document.getElementById("ctlCheckout_txtBilling_Email").setAttribute("value","");
   		document.getElementById("ctlCheckout_txtBilling_Daytime_Phone").setAttribute("value","");
   	}	
}


