var browser=navigator.appName;
var version=navigator.appVersion;
var ns4 = false;
var ie4 = false;
if (browser == "Netscape") { var versionnumber=version.substring(0,3); }
else { var msie=version.lastIndexOf("MSIE");
	var versionnumber=version.substring(msie+5,msie+8); }

function getplatform(osversion){
if (navigator.platform >= "Win") {
	return osversion="Win";
	} else {
	return osversion="Mac"; }
}

function itsNetscape() {
	ns4 = true; 
	var osversion = getplatform();
	if (osversion == "Win") {
		//document.write("<link rel=\"stylesheet\" href=\"byteartNS.css\" type=\"text/css\">")
	}}	  

function itsMsie() {
	var osversion = getplatform();
	if (osversion =="Win") {
		if (versionnumber >= 4.0) {
			ie4 = true		
			document.write("<link rel=\"stylesheet\" href=\"\" type=\"text/css\">") }
		
	}
	else if (osversion == "Mac") {
		if (versionnumber >= 4.5) {
			ie4 = true		
			document.write('<link rel=\"stylesheet\" href=\"byteartMac.css\" type=\"text/css\">'); }
		
	}
}

if ((browser == "Netscape") && (versionnumber >= 4)) { itsNetscape(); }
else  { itsMsie(); }

function getObj(nm) {
	if (document.getElementById) {
		return document.getElementById(nm);
	} else if (document.all) {
		return document.all[nm];
	} else {
		return eval("document." + nm);
	}
}

function toggleDiv(d) {
	var osversion = getplatform();
	// pc menu
	if (osversion == "Win") {
		if (!states[d]) {
			states[d]=0;
		}
		//
		if (states[d]==0) {
			states[d]=1;
			closeAllDivs();
			expandDiv(d);
		} else {
			states[d]=0;
			contractDiv(d);
		}
		
	}
	else if (osversion == "Mac") {
		// mac menu, as macs suck they get a sh¡t menu
		for (i = 0; i <= 10; i++) {
			if (getObj("subMenu" + i)) {
				// hide all menus if they exist
				getObj("subMenu" + i).style.display="none";
			}
		}
		// turn on clicked menu
		getObj("subMenu" + d).style.display="inline";
	}
}
//

function getObj(nm) {
	if (document.getElementById) {
		return document.getElementById(nm);
	} else if (document.all) {
		return document.all[nm];
	} else {
		return eval("document." + nm);
	}
}
//buttons
function buttonOn(buttonID, image) {
	getObj("buttonImage" + buttonID).src = "graphics/button_" + image + "_on.gif";
}
//
function buttonOut(buttonID, image) {
	getObj("buttonImage" + buttonID).src = "graphics/button_" + image + "_off.gif";
}
// Turns a menu on
function menuOn(whatMenu, image) {
	getObj("menuHeaderImage" + whatMenu).src = "buttons/nav/" + image + "_2.gif";
}
//
// Called when mouse is moved away from a menu
function menuOut(whatMenu, image) {
	getObj("menuHeaderImage" + whatMenu).src = "buttons/nav/" + image + "_1.gif";
}
//
<!--
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=300,locationbar=0,menubar=0,personalbar=0,status=0,scrollbars=0,resizable=0");
}

function arena_4_ecommerce_validShippingForm() {
	valid = 1;
	message = "You have not 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_PostageValue"].value == 0) {
		valid = 0;
		message += "Delivery option";
		if (getObj("shipping_posttype")) {
			getObj("shipping_posttype").style.color = "#aa0000";
		}
	} else {
		if (getObj("shipping_posttype")) {
			getObj("shipping_posttype").style.color = "#000000";
		}
	}
	
	if (formName.elements["ArrivalDate"].value == "0" ) {
		valid = 0;
		message += "Arrival Date";
		if (getObj("ArrivalDate")) {
			getObj("ArrivalDate").style.color = "#aa0000";
		}
	} else {
		if (getObj("ArrivalDate")) {
			getObj("ArrivalDate").style.color = "#000000";
		}
	}
	

	if (valid == 0) {
		alert(message);
	} else {
		formName.submit();
	}
}


function arena_4_ecommerce_validDetailsForm() {
	valid = 1;
	message = "You have not completed all the required fields, please check:\n";
	formName = document.forms["DetailsForm"];
	
	//alert(formName.elements["Messaggio"].value);

	if (formName.elements['FirstName'].value == "") {
		valid = 0;
		message += "Name\n";
		getObj("FirstName").style.border = "#aa0000 solid 1px";
	} else {
		getObj("FirstName").style.border = "#A5ACB2 solid 1px";
	}

	if (formName.elements['Surname'].value == "") {
		valid = 0;
		message += "Surname\n";
		getObj("Surname").style.border = "#aa0000 solid 1px";
	} else {
		getObj("Surname").style.border = "#A5ACB2 solid 1px";
	}
	
	if (formName.elements["Address"].value == "") {
		valid = 0;
		message += "Address\n";
		getObj("Address").style.border = "#aa0000 solid 1px";
	} else {
		getObj("Address").style.border = "#A5ACB2 solid 1px";
	}
	
	if (formName.elements["Town"].value == "") {
		valid = 0;
		message += "Town\n";
		getObj("Town").style.border = "#aa0000 solid 1px";
	} else {
		getObj("Town").style.border = "#A5ACB2 solid 1px";
	}

	if (formName.elements["Country"].value == "0") {
		valid = 0;
		message += "Country\n";
		getObj("Country").style.color = "#aa0000";
	} else {
		getObj("Country").style.color = "#000000";
	}
	
	if (formName.elements["Postcode"].value == "") {
		valid = 0;
		message += "Postcode\n";
		getObj("Postcode").style.border = "#aa0000 solid 1px";
	} else {
		getObj("Postcode").style.border = "#A5ACB2 solid 1px";
	}
	
	/*if (formName.elements["Messaggio"].value == "") {
		valid = 0;
		message += "Message\n";
		getObj("Messaggio").style.border = "#aa0000 solid 1px";
	} else {
		getObj("Messaggio").style.border = "#A5ACB2 solid 1px";
	}*/
	/*maxchar=90
	var Messaggio=formName.elements["Messaggio"].value
	Messaggio=Messaggio.replace(/\n/gi,"")
	if (Messaggio.length > maxchar) {
		valid = 0;
		message += "Message: Maximum length " + maxchar + " characters\n";
		getObj("Messaggio").style.border = "#aa0000 solid 1px";
	} else {
		getObj("Messaggio").style.border = "#A5ACB2 solid 1px";
	}*/
	
	if (formName.elements["ArrivalDate2"].value == "click here to select dispatch date" ) {
		valid = 0;
		message += "Dispatch Date";
		if (getObj("ArrivalDate2")) {
			getObj("ArrivalDate2").style.color = "#aa0000";
		}
	} else {
		if (getObj("ArrivalDate2")) {
			getObj("ArrivalDate2").style.color = "#000000";
		}
	}

	if (valid == 0) {
		alert(message + " ");
	} else {
		formName.submit();
	}
}

function arena_4_ecommerce_validReturnsForm() {
	valid = 1;
	message = "You have now completed all the required fields, please check:\n";
	formName = document.forms['ReturnsForm'];

	if (formName.elements["returns_email"].value == "") {
		valid = 0;
		message += "Email Address\n";
		getObj("returns_email").style.border = "#aa0000 solid 1px";
	} else {
		if (checkEmail(formName.elements["returns_email"].value) == false) {
			valid = 0;
			message += "The email address is valid\n";
			getObj("returns_email").style.border = "#aa0000 solid 1px";
		} else {
			getObj("returns_email").style.border = "#A5ACB2 solid 1px";
		}
	}
	
	if (valid == 0) {
		alert(message);
	} else {
		formName.submit();
	}
}

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 email 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_phone"].value == "") {
		valid = 0;
		message += "Phone Number\n";
		getObj("billing_phone").style.border = "#aa0000 solid 1px";
	} else {
		getObj("billing_phone").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();
	}
}

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;
	}
}

// evil dw stuff
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function goToSecPay() {
	document.forms["goToSecPay"].submit();
}

function updatePostagePricesArea(priceBand) {
	postageOption = document.forms["checkoutShippingForm"].elements["shipping_country"].value;
	if (priceBand == 2) {
		if (postageOption == 1) {
			getObj("postageUK").style.display = "block";
			updatePostagePrices(0);
		} else {
			getObj("postageUK").style.display = "none";
			updatePostagePrices(postageOption);
			
		}
	} else {
		updatePostagePrices(postageOption);
	}
}

function updatePostagePrices(postageOption) {

	postagePrices = new Array();
	postagePrices[0] = 0;
	postagePrices[1] = 6.50;
	postagePrices[2] = 9.95;
	postagePrices[3] = 30.00;
	postagePrices[4] = 2.50;
	postagePrices[5] = 5.50;
		
	if (postageOption == -1) {
		
		postageOption = document.forms["checkoutShippingForm"].elements["shipping_posttype"].value;
	}
	document.forms["checkoutShippingForm"].elements["shipping_PostageValue"].value = postageOption;
	showTotalPrice(postagePrices[postageOption]);
}

function showTotalPrice(postagePrice) {
	//alert("hi3=" + postagePrice)
	if (postagePrice != 0) {
		if (postagePrice.toFixed) {
			getObj("totalPrice").innerHTML = "£" + postagePrice.toFixed(2);
		} else {
			getObj("totalPrice").innerHTML = "£" + postagePrice
		}
	} else {
		getObj("totalPrice").innerHTML = "Please select your country/delivery option.";
	}
}


function divScroller(moveThis, finalPos, drag)
{
var osversion = getplatform();

	if (navigator.appName == "Microsoft Internet Explorer") {
		finalPosition = finalPos;
		if (divScrollAmount < finalPosition) {
			difference = finalPosition - divScrollAmount;
			divMoveBy = difference / drag;
			divScrollAmount += divMoveBy;
			getObj(moveThis).style.left = divScrollAmount;
			//slide in second together
			if (getObj("overlay1")) {
				getObj("overlay1").style.left = divScrollAmount;
			}
			if (getObj("overlay1Short")) {
				getObj("overlay1Short").style.left = divScrollAmount;
			}
			divScrollAmount += 1;
			setTimeout("divScroller('" + moveThis + "', '" + finalPos + "', '" + drag + "');", 1);
		}
	} else {
		if (getObj("overlay1")) {
			getObj("overlay1").style.left = 224;
		}
		if (getObj("overlay1Short")) {
			getObj("overlay1Short").style.left = 224;
		}
		getObj(moveThis).style.left = 224;
	}
}
function externalLinks()
{
	if(!document.getElementsByTagName)
	{
		return;
	}
	var anchors=document.getElementsByTagName("a");
	for(var i=0;i<anchors.length;i++)
	{
		var anchor=anchors[i];
		if(anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")
		{
			anchor.target = "_blank";
			anchor.title = (anchor.title != "") ? anchor.title+" (opens in a new window)" : "opens in a new window";
			anchor.className = (anchor.className != '') ? anchor.className+' external' : 'external';
		}
	}
}
function init()
{
	externalLinks();
}