var mtimer=new Array();
	var ls=-1;
	function getObj(nm) {
		if (document.getElementById) {
			return document.getElementById(nm);
		} else if (document.all) {
			return document.all[nm];
		} else {
			return eval("document." + nm);
		}
	}

function menuOn(whatMenu, image) {
	getObj("menuHeaderImage" + whatMenu).src = "graphics/button_" + image + "_on.gif";
}

function menuOut(whatMenu, image) {
	getObj("menuHeaderImage" + whatMenu).src = "graphics/button_" + image + "_off.gif";
}

function buttonSwapOn(whatMenu, image) {
	getObj("buttonImage" + whatMenu).src = "graphics/button_" + image + "_on.gif";
}

function buttonSwapOff(whatMenu, image) {
	getObj("buttonImage" + whatMenu).src = "graphics/button_" + image + "_off.gif";
}

function gotToSecPay() {
	document.forms["goToSecPay"].submit();
}

function arena_4_ecommerce_validShippingForm() {
	valid = 1;
	message = "You have now completed all the required fields, please check:\n";
	formName = document.forms["checkoutShippingForm"];
	if (formName.elements['shipping_name'].value == "") {
		valid = 0;
		message += "Name\n";
		getObj("shipping_name").style.border = "#aa0000 solid 1px";
	} else {
		getObj("shipping_name").style.border = "#A5ACB2 solid 1px";
	}

	if (formName.elements["shipping_address"].value == "") {
		valid = 0;
		message += "Address\n";
		getObj("shipping_address").style.border = "#aa0000 solid 1px";
	} else {
		getObj("shipping_address").style.border = "#A5ACB2 solid 1px";
	}
	
	if (formName.elements["shipping_postcode"].value == "") {
		valid = 0;
		message += "Postcode\n";
		getObj("shipping_postcode").style.border = "#aa0000 solid 1px";
	} else {
		getObj("shipping_postcode").style.border = "#A5ACB2 solid 1px";
	}

	if (formName.elements["shipping_country"].value == "0") {
		valid = 0;
		message += "Country\n";
		getObj("shipping_country").style.color = "#aa0000";
	} else {
		getObj("shipping_country").style.color = "#000000";
	}

	if (formName.elements["shipping_posttype"].value == 0) {
		valid = 0;
		message += "Postage option";
		getObj("shipping_posttype").style.color = "#aa0000";
	} else {
		getObj("shipping_posttype").style.color = "#000000";
	}

	if (valid == 0) {
		alert(message);
	} else {
		formName.submit();
	}
}

function checkEmail(email)
{
	email = email.toLowerCase(); 
	//rics super cool e-mail validor
	if (email.match(/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/)) {
		return true;
	} else {
		return false;
	}
}

function arena_4_ecommerce_validBillingForm() {
	valid = 1;
	message = "You have now completed all the required fields, please check:\n";
	formName = document.forms['checkoutBillingForm'];

	if (formName.elements["billing_name"].value == "") {
		valid = 0;
		message += "Name\n";
		getObj("billing_name").style.border = "#aa0000 solid 1px";
	} else {
		getObj("billing_name").style.border = "#A5ACB2 solid 1px";
	}

	if (formName.elements["billing_email"].value == "") {
		valid = 0;
		message += "Email Address\n";
		getObj("billing_email").style.border = "#aa0000 solid 1px";
	} else {
		if (checkEmail(formName.elements["billing_email"].value) == false) {
			valid = 0;
			message += "The e-mail address is valid\n";
			getObj("billing_email").style.border = "#aa0000 solid 1px";
		} else {
			getObj("billing_email").style.border = "#A5ACB2 solid 1px";
		}
	}

	if (formName.elements["billing_address"].value == "") {
		valid = 0;
		message += "Address\n";
		getObj("billing_address").style.border = "#aa0000 solid 1px";
	} else {
		getObj("billing_address").style.border = "#A5ACB2 solid 1px";
	}
	
	if (formName.elements["billing_postcode"].value == "") {
		valid = 0;
		message += "Postcode\n";
		getObj("billing_postcode").style.border = "#aa0000 solid 1px";
	} else {
		getObj("billing_postcode").style.border = "#A5ACB2 solid 1px";
	}

	if (formName.elements["billing_country"].value == "0") {
		valid = 0;
		message += "Country\n";
		getObj("billing_country").style.color = "#aa0000";
	} else {
		getObj("billing_country").style.color = "#000000";
	}

	if (valid == 0) {
		alert(message);
	} else {
		formName.submit();
	}
}

/********************************************************************************/
/* For all the general JS functions                                             */
/* edk 22 april 2004                                                            */
/********************************************************************************/

/********************************************************************************/
/* To allow a window to open for a full image view                              */
/********************************************************************************/
function show(s, t) {
	//alert("hello");
	window.open("image.asp?s=" + escape(s) + "&t=" + escape(t), "imgWin", "scrollbars=0,toolbar=0,resize=0,width=0,height=50");
}

/********************************************************************************/
/* To work with the show() function above with imag pop ups                     */
/********************************************************************************/
function openWin( windowURL, windowName, windowFeatures ) { 
	return window.open( windowURL, windowName, windowFeatures ) ; 
} 


/********************************************************************************/
/* To edit the modify item cart item                                            */
/********************************************************************************/
function editCartItem() { 
	document.modifyCartForm.submit();
} 

/********************************************************************************/
/* To delete the modify item cart item                                          */
/********************************************************************************/
function deleteCartItem(cartItemID, cartUserID){
	if (confirm('Are you sure you wish to delete this item?')){
		document.location.href="byteart_ecommerce_4_cartItemModifyDelete.asp?cartItemID=" + cartItemID + "&cartUserID=" + cartUserID
	}
}

/****************************************************************************************************/
/* added to chk the customer form prior to going to the PSP                                         */
/* used by : byteart_ecommerce_4_checkoutCustomerDetails.asp                                        */
/* relies upon : form in byteart_ecommerce_4_checkoutCustomerDetails.asp being filled out correctly */
/* updates : sends form to byteart_ecommerce_4_checkoutCustomerDetailsSave.asp                      */
/****************************************************************************************************/
function submitCustomerDetailsForm() {
	c_name = document.forms["customerDetailsForm"].elements["billingName"].value;
	c_address = document.forms["customerDetailsForm"].elements["billingAddress"].value; 
	c_postcode = document.forms["customerDetailsForm"].elements["billingPostcode"].value;
	c_email = document.forms["customerDetailsForm"].elements["billingEmail"].value;
	
	deliveryName = document.forms["customerDetailsForm"].elements["deliveryName"].value;
	deliveryAddress = document.forms["customerDetailsForm"].elements["deliveryAddress"].value;
	deliveryPostcode = document.forms["customerDetailsForm"].elements["deliveryPostcode"].value;
	deliveryCountry = document.forms["customerDetailsForm"].elements["deliveryCountry"].value;
	
	
	if (c_name=="") {
		alert("Please enter your full name");
	} else if (c_address=="") {
		alert("Please enter your billing address");
	} else if (c_postcode=="") {
		alert("Please enter your postcode number");
	} else if (c_email == ""){
		alert ("Please enter an email address");
	} else if (deliveryName == ""){
		alert ("Please enter a delivery name");
	} else if (deliveryAddress == ""){
		alert ("Please enter a delivery address");
	} else if (deliveryPostcode == ""){
		alert ("Please enter a delivery postcode");
	} else if (deliveryCountry == ""){
		alert ("Please enter a delivery country");
	} else {
		//alert("hey + + + ");
		document.forms["customerDetailsForm"].submit();
	}
}

/****************************************************************************************************/
/* added to chk the payment form prior to going to the PSP                                          */
/* used by : byteart_ecommerce_4_paymentCustomerDetails.asp                                         */
/* relies upon : form in byteart_ecommerce_4_paymentCustomerDetails.asp being filled out correctly  */
/* updates : sends form to PSP pages                                                                */
/****************************************************************************************************/
function submitPaymentDetailsForm() {
	card_name = document.forms["paymentDetailsForm"].elements["cardName"].value;
	card_number = document.forms["paymentDetailsForm"].elements["cardNumber"].value;
	card_cv2 = document.forms["paymentDetailsForm"].elements["cardCV2"].value;
	
	if (card_name=="") {
		alert("Please enter the name on the card");
	} else if (card_number=="") {
		alert("Please enter the card number");
	} else if (card_cv2 == ""){
		alert ("Please turn the card over and enter the three digit CV2 number");
	} else {
		//alert("hey + + + ");
		document.forms["paymentDetailsForm"].submit();
	}
}

/****************************************************************************************************/
/* To make the correct link from the productItemList page to the productDetail page                 */
/* edk 27 april 2004                                                                                */
/* REMEMBER - need to send large digits as strings or else JS will decrement by one.... madness     */
/****************************************************************************************************/
function showProductVariation (formID, catID, subCatID, cartUserID) {
	flag = document.forms["productListForm" + formID].elements["flagVar"].value;
	//alert (flag);
	if (flag == "0"){
		productID = document.forms["productListForm" + formID].elements["productID"].value;
	}
	else {
		productID = document.forms["productListForm" + formID].elements["productID"].options[document.forms["productListForm" + formID].elements["productID"].selectedIndex].value
	}
	document.location.href="byteart_ecommerce_4_productItemDetail.asp?categoryID=" + catID + "&subcategoryID=" + subCatID + "&productID=" + productID + "&cartUserID=" + cartUserID
}


/****************************************************************************************************/
/* dan wrote this - I accept no responsibility - edk 4 May 2004                                     */
/* for the client side to allow you to jump between categories when on a product list page*/
/****************************************************************************************************/
function catjump() {
	selectedItem = document.forms.catChange.catList.value;
	window.location = selectedItem;
}


/****************************************************************************************************/
/* To allow for client to click on link in case of pop up blockers                                  */
/* edk 26 May 2004                                                                                  */
/****************************************************************************************************/
function goToSecpay(cartUserID, orderReferenceID) {
	//alert (">> " + cartUserID);
	t=(screen.height/2)-250;
	l=(screen.width/2)-250;
	spwindow=window.open('byteart_ecommerce_4_goToSecpay.asp?orderReferenceID=' + orderReferenceID, 'spWin', 'height=500,width=500,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,directories=no,status=yes,left=' + l + ',top=' + t);
	window.location.href="byteart_ecommerce_4_paymentCustomerDetails.asp?cartUserID=" + cartUserID + "&action=atsecpay" + "&orderReferenceID=" + orderReferenceID;
}

/****************************************************************************************************/
/* To display the correct postage for the billing and delivery page                                 */
/* redirect to an email page if the postage is for other areas (value is 5)                         */
/* edk 1 june 2004 - 7 june 2004                                                                    */
/****************************************************************************************************/
function addPostage(cartUserID) {
	pp = document.forms.customerDetailsForm.deliveryPP.value;
	if (pp == 5) {
		 document.location.href="byteart_ecommerce_4_checkoutCustomerDeliveryQuote.asp?cartUserID=" + cartUserID
	}
	else {
		document.location.href="byteart_ecommerce_4_checkoutCustomerDetails.asp?cartUserID=" + cartUserID + "&pp=" + pp
	}
}



/****************************************************************************************************/
/* To allow the billing address to be copyied to the delivery address                               */
/* switches the copy on and off by checking the checkbox etc                                        */
/* edk 1 june 2004                                                                                  */
/****************************************************************************************************/
var deliveryName = "";
var deliveryAddress = "";
var deliveryPostcode = "";
var deliveryCountry = "";

function saveVariables(form) {
	deliveryName = form.deliveryName.value;
	deliveryAddress = form.deliveryAddress.value;
	deliveryPostcode = form.deliveryPostcode.value;
	deliveryCountry = form.deliveryCountry.value;
}

function ShipToBillPerson(form) {
	if (form.copyAddress.checked) {
		saveVariables(form);
		form.deliveryName.value = form.billingName.value;
		form.deliveryAddress.value = form.billingAddress.value;
		form.deliveryPostcode.value = form.billingPostcode.value;
		form.deliveryCountry.value = form.billingCountry.value;
	}
	else {
		form.deliveryName.value = deliveryName;
		form.deliveryAddress.value = deliveryAddress;
		form.deliveryPostcode.value = deliveryPostcode;
		form.deliveryCountry.value = deliveryCountry;
   }
}


/****************************************************************************************************/
/*  to print a single order either order or despatch                                                */
/* edk 2 june 2004                                                                                  */
/****************************************************************************************************/
function printSingleOrder (orderID) { 
	var newwin=window.open("byteart_ecommerce_4_adminPrintList.asp?printIDs=" + orderID, "printPage", "width=450,height=700,location=0,menubar=0,personalbar=0,status=1,scrollbars=1,resizable=1")
}


/****************************************************************************************************/
/*  To change the status of the order from open to closed (0 or 1 to 2)                   */
/* edk 3 June 2004                                                                                  */
/****************************************************************************************************/
function closeOrder(orderID, reRoute){
	if (confirm('You are closing this transaction (ie Paid & Sent). Proceed?')){
		document.location.href="byteart_ecommerce_4_adminOrderClose.asp?orderID=" + orderID + "&reRoute=" + reRoute
	}
}
/****************************************************************************************************/
/* To view the order                                                                                */
/* edk 3 June 2004                                                                                  */
/****************************************************************************************************/
function viewOrder(orderID){
	document.location.href="byteart_ecommerce_4_adminOrderView.asp?orderID=" + orderID
}
/****************************************************************************************************/
/*  to view the customer details and transaction details for the new dispatches                     */
/* edk 3 June 2004                                                                                  */
/****************************************************************************************************/
function viewOrderDespatch(orderID){
	document.location.href="byteart_ecommerce_4_adminOrderViewDespatch.asp?orderID=" + orderID
}

/****************************************************************************************************/
/*  to check all or uncheck all the check boxes for the print page                                  */
/* edk 3 june 2004                                                                                  */
/****************************************************************************************************/
function checkPrint(field) {
	if (checkflagPrint == "false") {
		for (i = 0; i < field.length; i++) {
			field[i].checked = true;
		}
		checkflagPrint = "true";
		return "Uncheck"; 
	}
	else {
		for (i = 0; i < field.length; i++) {
			field[i].checked = false; 
		}
		checkflagPrint = "false";
		return "Check"; 
	}
}

// To do rollover button for the check / uncheck functionality see checkPrint() function- edk 3 june 2004
function alterBG(obj, backgroundcolour, textcolour) {
	obj.style.background=backgroundcolour;
	obj.style.color=textcolour;
}


/****************************************************************************************************/
/* To delete declined or failed orders from the system                                              */
/* edk 3 june 2004                                                                                  */
/****************************************************************************************************/
function deleteOrder(orderID, reRoute){
	if (confirm('You are deleting this failed order. Proceed?')){
		document.location.href="byteart_ecommerce_4_adminOrderDelete.asp?orderID=" + orderID + "&reRoute=" + reRoute
	}
}

/**********************************************************************************************************/
/* added to chk the delivery form prior to sending the email                                              */
/* used by : byteart_ecommerce_4_checkoutCustomerDeliveryQuote.asp                                        */
/* relies upon : form in byteart_ecommerce_4_checkoutCustomerDeliveryQuote.asp being filled out correctly */
/* updates : sends form to byteart_ecommerce_4_checkoutCustomerDetailsSave.asp                            */
/**********************************************************************************************************/
function submitDeliveryQuoteForm() {
	q_name = document.forms["customerDeliveryQuoteForm"].elements["quoteName"].value;
	q_address = document.forms["customerDeliveryQuoteForm"].elements["quoteAddress"].value; 
	q_postcode = document.forms["customerDeliveryQuoteForm"].elements["quotePostcode"].value;
	q_country = document.forms["customerDeliveryQuoteForm"].elements["quoteCountry"].value;
	q_email = document.forms["customerDeliveryQuoteForm"].elements["quoteEmail"].value;
	
	if (q_name=="") {
		alert("Please enter your full name");
	} else if (q_address=="") {
		alert("Please enter your address");
	} else if (q_postcode=="") {
		alert("Please enter your postcode number");
	} else if (q_country=="") {
		alert("Please enter your country");
	} else if (q_email == ""){
		alert ("Please enter an email address");
	} else {
		//alert("hey + + + ");
		document.forms["customerDeliveryQuoteForm"].submit();
	}
}

/********************************************************************************/
/* To send the search form                                                      */
/* edk 8 june 2004                                                              */
/********************************************************************************/
function submitSearch() { 
	document.Search.submit();
} 


/********************************************************************************/
/* To send the e-newsletter form                                                */
/* edk 9 june 2004                                                              */
/********************************************************************************/
function submitEnews() { 
	e_name = document.forms["customerEnewsForm"].elements["enewsName"].value;
	e_email = document.forms["customerEnewsForm"].elements["enewsEmail"].value;
	
	if (e_name=="") {
		alert("Please enter your full name");
	} else if (e_email == ""){
		alert ("Please enter an email address");
	} else {
		document.customerEnewsForm.submit();
	}
}

function openWin( windowURL, windowName, windowFeatures ) { 
	return window.open( windowURL, windowName, windowFeatures ) ; 
} 

function emailpage(){	
	var emailpage=window.open("emailpage.asp?pageurl=" + escape(document.location.href), "emailpage", "width=340,height=310,locationbar=0,menubar=0,personalbar=0,status=0,scrollbars=0,resizable=0");
}
