var pageLoadFunctions = [];
function Page_Load() {
	if (pageLoadFunctions.length > 0)
		eval(pageLoadFunctions.join(";"));
}

function CheckBasketCookie() {
	if(document.cookie.indexOf("CookieID=") < 0) {
		location.href='/CookiesEnabled.aspx';
	}
}

function openDimension(productID, unit, catID) {
	var winWidth = 650
	var winHeight = 475
	window.open("/Catalog/Dimensions.asp?ID=" + productID + "&CATID=" + catID + "&UNIT=" + unit, "Win" + productID + unit, "width=" + winWidth + ",height=" + winHeight + ",status=no,menubar=no,resizable=yes,scrollbars=yes,toolbar=no");
}

function openRelLink(catID) {
	//alert(document.form1.RelatedLinks.value);
	if (document.Form1.RelatedLinks.value == "") {
		alert("You must select a link from the dropdown menu.")
		document.Form1.RelatedLinks.focus();
	}
	else {
		window.open("/Catalog/Category/OpenDoc.asp?/Catalog/Category/" + catID + "/" + escape(document.Form1.RelatedLinks.options[document.Form1.RelatedLinks.selectedIndex].value), "new", "location=no,menubar=no,status=no,toolbar=no,resizable=yes,scrollbars=yes");
	}
}

function addToCart(catID, prodID)
{
	quantity = document.forms[0]["Q" + prodID];
	if (quantity)
	{
		isValid = true;
		if (isNaN(quantity.value))
		{
			alert("You must enter a numeric value for the quantity");
			isValid = false;
		}
		if (quantity.value < 1)
		{
			alert("You must enter a quantity of at least 1");
			isValid = false;
		}
		if (isValid)
			document.location = "/Basket/AddToBasket.aspx?id=" + catID + "&productID=" + prodID + "&q=" + quantity.value + "&lastViewedURL=" + escape(location.href);
	}
}

function ContinueShopping()
{
	var theForm = document.forms[0];
	var lastViewedURL = "/";
	if (theForm && theForm["lastViewedURL"] && theForm["lastViewedURL"].value.length > 0)
	{
		lastViewedURL = theForm["lastViewedURL"].value;
	}
	location.href = lastViewedURL;	
}

function EditAddressPopUp(addressID)
{
	popUpManager.WindowOpen("AddEditAddressWin", "/Basket/AddEditAddress.aspx?id=" + addressID + "&type=1", "AddEditAddress", "toolbar=0,menubar=0,scrollbars=1,resizable=1,width=650,height=500", false)	
}

function NewsletterPopUpWindow()
{
	if (typeof(popUpManager) != "undefined")
	{
		popUpManager.WindowOpen('NewsletterWin', '/Newsletter.aspx', 'newsWin', 'status=no,scrollbars=yes,resizable=yes,toolbar=no,location=no,width=490,height=500,left=10,top=10');
	}
}

function NewsletterDirectPopUpWindow()
{
	if (typeof(popUpManager) != "undefined")
	{
		popUpManager.WindowOpen('NewsletterWin', 'http://www.opt1in.com/optin.aspx?id=1170', 'newsWin', 'status=no,scrollbars=yes,resizable=yes,toolbar=no,location=no,width=490,height=500,left=10,top=10');
	}
}

function LanguagePopUpWindow()
{
	if (typeof(popUpManager) != "undefined")
	{
		popUpManager.WindowOpen('LanguageWin', '/Language.aspx', 'langWin', 'status=no,scrollbars=yes,resizable=yes,toolbar=no,location=no,width=400,height=250,left=100,top=100');
	}
}
