// ***************************************************************************************************************************************
// Category page - paging function
// ***************************************************************************************************************************************
// Function - Used to validate entered page number and if valid then goto the page
function GoToPage()
{
	// Paging for which form? top or bottom?
	strPageAction = document.frmPaging;
	intPageNoToGo = document.frmPaging.txtGoToPage.value;
	
	// Validate user input and for valid page number send to appropriate page
	if (intPageNoToGo == "")
	{
		alert("Please enter the page number.");
	}
	else if (IsNumeric(intPageNoToGo) == false)
	{
		alert("Please enter a valid page number.");
	}
	else if (parseInt(intPageNoToGo) == parseInt(intCurrPageNo))
	{
		alert("Please enter the page number.");
	}
	else if (parseInt(intPageNoToGo) > parseInt(intTotalPageCnt))
	{
		alert("Please enter a valid page number.");
	}
	else if (parseInt(intPageNoToGo) == 0)
	{
		alert("Please enter a valid page number.");
	}
	else if (parseInt(intPageNoToGo) == 1)
	{
		strPageAction.action = strPageAction.action + ".htm";
		return true;
	}
	else if (parseInt(intPageNoToGo) > 1)
	{
		strPageAction.action = strPageAction.action + "/page" + parseInt(intPageNoToGo) + ".htm";
		return true;
	}
	
	document.frmPaging.txtGoToPage.focus();
	return false;
}
// ***************************************************************************************************************************************
// Product details page - On mouse over function
// ***************************************************************************************************************************************
// Function - Used to display selected extra image on MouseOver event
function ShowImage(intTotalExtras, intExtraImageNo, strExtraImageName)
{
	document.ExtraImage.src = "/images/prods-extra/" + strExtraImageName;
	
	document.btnExtra1.src = "/images/buttons/extra-1-off.jpg";
	document.btnExtra2.src = "/images/buttons/extra-2-off.jpg";
	document.btnExtra3.src = "/images/buttons/extra-3-off.jpg";
	if (intTotalExtras >= 5)
		document.btnExtra4.src = "/images/buttons/extra-4-off.jpg";
	if (intTotalExtras == 6)
		document.btnExtra5.src = "/images/buttons/extra-5-off.jpg";
	
	if (intExtraImageNo == 1)
		document.btnExtra1.src = "/images/buttons/extra-1-on.jpg";
	else if (intExtraImageNo == 2)
		document.btnExtra2.src = "/images/buttons/extra-2-on.jpg";
	else if (intExtraImageNo == 3)
		document.btnExtra3.src = "/images/buttons/extra-3-on.jpg";
	else if (intExtraImageNo == 4)
		document.btnExtra4.src = "/images/buttons/extra-4-on.jpg";
	else if (intExtraImageNo == 5)
		document.btnExtra5.src = "/images/buttons/extra-5-on.jpg";
}
// ***************************************************************************************************************************************
// View Cart page - For client side Postage cost updation
// ***************************************************************************************************************************************
// Function - Used to update order cost according to the Postage selection
function PostageCost(strSelPostageIs)
{
	var intCalOrderCost;
	
	if (strSelPostageIs == "Postage within UK")
	{
		intCalOrderCost = 3.95;
		intCalOrderCost = parseFloat(intCalOrderCost) + parseFloat(document.frmUpdateCart.hidTotalCost.value.replace("£",""));
		intCalOrderCost = parseFloat(intCalOrderCost) - parseFloat(document.getElementById('PromoDiscount').innerHTML.replace("£",""));
		
		document.getElementById('PostageCost').innerHTML = "£3.95";
		document.getElementById('TotalOrderCost').innerHTML = "£" + intCalOrderCost.toFixed(2);
	}
	else
	{
		intCalOrderCost = 5;
		intCalOrderCost = parseFloat(intCalOrderCost) + parseFloat(document.frmUpdateCart.hidTotalCost.value.replace("£",""));
		intCalOrderCost = parseFloat(intCalOrderCost) - parseFloat(document.getElementById('PromoDiscount').innerHTML.replace("£",""));
		
		document.getElementById('PostageCost').innerHTML = "£5.00";
		document.getElementById('TotalOrderCost').innerHTML = "£" + intCalOrderCost.toFixed(2);
	}
}
// ***************************************************************************************************************************************
// Function - Used to mark clicked button and redirect to the corresponding page
function MarkButtonClick(strActionName)
{
	document.frmUpdateCart.hidGotoPage.value = strActionName;
}
// ***************************************************************************************************************************************
// Checkout page - For client side Postage cost updation
// ***************************************************************************************************************************************
// Function - Used to reflect Shipping data same as that of Billing data if marked
function fnSameShipAddress()
{
	if (document.frmCheckout.chkSameShipAddr.checked)
	{
		document.frmCheckout.cmbShipTitle.selectedIndex 	= 	document.frmCheckout.cmbTitle.selectedIndex;
		document.frmCheckout.txtShipFirstName.value 		= 	document.frmCheckout.txtFirstName.value;
		document.frmCheckout.txtShipLastName.value 			= 	document.frmCheckout.txtLastName.value;
		document.frmCheckout.txtShipAddress1.value 			= 	document.frmCheckout.txtAddress1.value;
		document.frmCheckout.txtShipAddress2.value 			= 	document.frmCheckout.txtAddress2.value;
		document.frmCheckout.txtShipCity.value				=	document.frmCheckout.txtCity.value;
		document.frmCheckout.txtShipCounty.value			=	document.frmCheckout.txtCounty.value;
		document.frmCheckout.txtShipPostCode.value			=	document.frmCheckout.txtPostCode.value;
		document.frmCheckout.cmbShipCountry.selectedIndex	=   document.frmCheckout.cmbCountry.selectedIndex;
		document.frmCheckout.txtShipEmail.value				=   document.frmCheckout.txtEmail.value;
		document.frmCheckout.txtShipDayPhone.value     		=   document.frmCheckout.txtDayPhone.value;
		document.frmCheckout.txtShipEvePhone.value     		=   document.frmCheckout.txtEvePhone.value;
	}
}
// ***************************************************************************************************************************************
// Function - Used to display popup for Terms and Conditions
function TermsAndConditions()
{
	window.open("/cart/terms-n-conditions.asp", "TermsConditions", "width=670,height=600,status=yes,scrollbars=yes,resizable=No,top=0,left=0");
}
// ***************************************************************************************************************************************