/* ===========================================================
||     Sitewise Javascript						|| 
 ===========================================================*/

function updatePrice(item,attrib,price,vat) {
	var currentPrice = document.getElementById(item);
	var itembox = item + '_box';
	var priceDisplay = document.getElementById(itembox);
	var newPrice = (price)*1;
	newPrice = newPrice * attrib.value;        
	newPrice = Math.round((newPrice)*100)/100;
	newPrice = ''+newPrice;
	np = newPrice.split(".");
	if (np[1]) { if (np[1].length == 1) { np[1] = np[1]+"0"; newPrice = np[0]+'.'+np[1]; } }
	priceDisplay.innerHTML = '&pound;'+newPrice;
	return true;
}
 
function navi(a) { window.location.href = a; }

function checkAttr(form) {
	var allow = true;
	if (form.attrib1 != null && allow == true) {
		if (form.attrib1.options[form.attrib1.options.selectedIndex].value == '') {
			alert("Please make sure all fields have been correctly filled out.");
			return false;
		}
	}
	if (form.attrib2 != null && allow == true) {
		if (form.attrib2.options[form.attrib2.options.selectedIndex].value == '') {
		 alert("Please make sure all fields have been correctly filled out.");
		 return false;
		}
	}
	if (form.attrib3 != null && allow == true) {
		if (form.attrib3.options[form.attrib3.options.selectedIndex].value == '') {
		 alert("Please make sure all fields have been correctly filled out.");
		 return false;
		}
	}
	if (form.attrib4 != null && allow == true) {
		if (form.attrib4.options[form.attrib4.options.selectedIndex].value == '') {
		 alert("Please make sure all fields have been correctly filled out.");
		 return false;
		}
	}

	if (form.attrib5 != null && allow == true) {
		if (form.attrib5.options[form.attrib5.options.selectedIndex].value == '') {
		 alert("Please make sure all fields have been correctly filled out.");
		 return false;
		}
	}
	if (form.attrib6 != null && allow == true) {
		if (form.attrib6.options[form.attrib6.options.selectedIndex].value == '') {
		 alert("Please make sure all fields have been correctly filled out.");
		 return false;
		}
	}
	if (form.attrib7 != null && allow == true) {
		if (form.attrib7.options[form.attrib7.options.selectedIndex].value == '') {
		 alert("Please make sure all fields have been correctly filled out.");
		 return false;
		}
	}
	if (form.attrib8 != null && allow == true) {
		if (form.attrib8.options[form.attrib8.options.selectedIndex].value == '') {
		 alert("Please make sure all fields have been correctly filled out.");
		 return false;
		}
	}
	if (form.attrib9 != null && allow == true) {
		if (form.attrib9.options[form.attrib9.options.selectedIndex].value == '') {
		 alert("Please make sure all fields have been correctly filled out.");
		 return false;
		}
	}
	if (form.attrib10 != null && allow == true) {
		if (form.attrib10.options[form.attrib10.options.selectedIndex].value == '') {
		 alert("Please make sure all fields have been correctly filled out.");
		 return false;
		}
	}
	return true;
}

var secwin_opened = false;

function secwin() {
if (document.getElementById('basket_tickbox')) {
	if (!document.getElementById('basket_tickbox').checked) {
		alert('You must agree to our terms and services before proceeding to checkout. Please confirm that you agree by ticking the box.');
		return false;
	}
}
secwindow = window.open ("http://resource.havnet.net/shopwise/loading.html", 'odwin', 'width=525,height=400,scrollbars=yes,toolbar=no,location=no,copyhistory=no,status=yes,menubar=no');
secwin_opened = true;
return true; 
}

function secwin_close() { if (secwin_opened == true) { secwindow.close(); } }

function change_country(SelObj) { location.href = "/cgi-bin/sitewise.pl?act=cc&country=" + SelObj.options[SelObj.selectedIndex].value; }

function change_order(SelObj) { 
	if (document.getElementById('orderform').act.value == 'checkout') {
		document.getElementById('orderform').act.value='login';
		document.getElementById('orderform').target='odwin';
		document.getElementById('orderform').action='https://secure.havnet.net/shopwise/secure_order.pl';
		document.getElementById('orderform').onsubmit = function () { return secwin(); }
	}
	
	if (SelObj.options[SelObj.selectedIndex].value == "SEL") { document.orderform.submit.disabled = 1; } else { document.orderform.submit.disabled = 0; } 
	if (SelObj.options[SelObj.selectedIndex].value == "EPDQ") {
		document.getElementById('orderform').act.value='checkout';
		document.getElementById('orderform').target='_self';
		document.getElementById('orderform').action='/cgi-bin/sitewise.pl?act=checkout&pay=epdqcpi';
		document.getElementById('orderform').onsubmit = null;
	}
}
function checkpassword(fieldone,fieldtwo) {
	if ((fieldone != "" && fieldone != "") && fieldone != fieldtwo) { alert('The passwords you entered do not match. Please check and try again.'); return false; }
	document.getElementById('subscribesubmit').value = 'Registering...'; document.getElementById('subscribesubmit').disabled = true;
}
/* ===========================================================*/
