<!--
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) { //v3.0
  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); 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 MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}

function MM_displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.MM_returnValue = true;
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function Processing(form,button){

	var thisButton = document.forms[form][button];
	thisButton.value = "Please Wait..";
	thisButton.disabled = true;
	return true;

}

function checkVoucher(){
	var objForm = document.forms['Voucher_Details'];
	var strVoucher = objForm['Voucher'].value;
	
	if (strVoucher == "ShowReps"){
		v = "show";
		d = "";
		if ((obj=MM_findObj("SalesReps"))!=null){
			if (obj.style){
				obj=obj.style;
				v=(v=='show')?'visible':(v='hide')?'hidden':v;
				obj.visibility=v;
				obj.display=d;
			}
		}
		objForm.action = "confirm.asp?action=confirm_details&showreps=1";
		document.location.href = "#Reps";
	} else {
		objForm.submit();
	}
}

function checkNotes(is_checked){
	if (is_checked == true){
		v = "show";
		d = "";
	} else {
		v = "hide";
		d = "none";
	}
	if ((obj=MM_findObj("notes"))!=null){
		if (obj.style){
			obj=obj.style;
			v=(v=='show')?'visible':(v='hide')?'hidden':v;
			obj.visibility=v;
			obj.display=d;
		}
	}
}

var currency_symbol = "£";

function formatMoney(thisPrice){
	TPrice = String(thisPrice)
	if(TPrice.indexOf('.') == -1){
		TPrice += ".00"
	} else {
		tempPrice = TPrice.split(".");
		if(tempPrice[1].length < 2){
			Filler = "";
			for(var i = tempPrice[1].length; i < 2; ++i){
				Filler += "0";
			}
			TPrice = tempPrice[0] + "." + tempPrice[1] + Filler;
		} else {
			if(tempPrice[1].length > 2){
				TPrice = tempPrice[0] + "." + tempPrice[1].substring(0,2);
			}
		}
	}
	return TPrice
}

// multiple products selection

function changeMultiplePrice(product_id, thisPrice){
	tPrice = "Product Price: £" + formatMoney(thisPrice);
	document.forms['ProductOptions_' + product_id]['productprice_' + product_id].value = tPrice;
}

function getMultipleProductOption(product_id, thisOption){
	var pLength = eval("POptions_" + product_id + ".length");
	for (i = 0; i< pLength; i++){
		if ((eval("POptions_" + product_id + "[i]") - thisOption) == 0){
			thisOption = i;
		}
	}
	return thisOption;
}

function getMultipleProductPrice(product_id, thisOption){
	var thisPrice = 0.00;
	var pLength = eval("POptionPrices_" + product_id + ".length");
	for (i = 0; i< pLength; i++){
		if ((i - thisOption) == 0){
			thisPrice = eval("POptionPrices_" + product_id + "[i]");
		}
	}
	return thisPrice;
}

function setMultipleProductPrice(product_id, thisOption){
	var thisPrice = 0.00;
	var pLength = eval("POptionPrices_" + product_id + ".length");
	for (i = 0; i< pLength; i++){
		if ((i - thisOption) == 0){
			thisPrice = eval("POptionPrices_" + product_id + "[i]");
		}
	}
	changeMultiplePrice(product_id, thisPrice);
}

function updateMultipleProductPrice(product_id, thisOption){
	var thisValue = "";
	var PQty = 1;
	var thisPrice = 0.00;
	var POption = getMultipleProductOption(product_id, thisOption);
	var tempPrice = getMultipleProductPrice(product_id, POption);
	PQty = document.forms['ProductOptions_' + product_id]['Qty_' + product_id + '_' + thisOption].value;
	tempPrice = tempPrice*PQty;
	tempPrice = Math.round(tempPrice*100) / 100;
	changeMultiplePrice(product_id, tempPrice);
}

function showMultipleProductOptions(product_id, thisOption){
	var pLength = eval("POptions_" + product_id + ".length");
	for (i = 0; i< pLength; i++){
		TOption = eval("POptions_" + product_id + "[i]");
		if (document.all||document.getElementById){
			obj = document.getElementById("ProductOptions_" + product_id + "_" + TOption)
		} else {
			obj = MM_findObj("ProductOptions_" + product_id + "_" + TOption)
		}
		if (obj != null){
			if ((TOption - thisOption) == 0){
				v = "show";
				d = "";
			} else {
				v = "hide";
				d = "none";
			}
		}
		if (obj.style){
			obj=obj.style;
			v=(v=='show')?'visible':(v='hide')?'hidden':v;
			obj.visibility=v;
			obj.display=d;
		}
	}
	updateMultipleProductPrice(product_id, thisOption)
}

// end of multiple products selection

function changePrice(thisPrice){
	tPrice = "Product Price: " + currency_symbol + formatMoney(thisPrice) + " Excl VAT";
	if (document.all||document.getElementById){
		obj = document.getElementById("productprice")
	} else {
		obj = MM_findObj("productprice")
	}
	obj.innerHTML = tPrice;	
}

function getProductOption(thisOption){
	for (i = 0; i< POptions.length; i++){
		if ((POptions[i] - thisOption) == 0){
			thisOption = i;
		}
	}
	return thisOption;
}

function getProductPrice(thisOption){
	var thisPrice = 0.00;
	for (i = 0; i< POptionPrices.length; i++){
		if ((i - thisOption) == 0){
			thisPrice = POptionPrices[i];
		}
	}
	return thisPrice;
}

function setProductPrice(thisOption){
	var thisPrice = 0.00;
	for (i = 0; i< POptionPrices.length; i++){
		if ((i - thisOption) == 0){
			thisPrice = POptionPrices[i];
		}
	}
	changePrice(thisPrice);
}

function updateProductPrice(thisOption){
	var thisValue = "";
	var PQty = 1;
	var thisPrice = 0.00;
	var checkStock = false;
	var POption = getProductOption(thisOption);
	//var POStock = POptionStock[POption];
	var stockQty = 0;
	var tempPrice = getProductPrice(POption);
	var strStockWarning = "";
	TORange = eval("PPRange_" + thisOption);
	/*
	OStock = POStock.split("|");
	if (OStock[0] == 1) {
		checkStock = true;
		stockQty = parseInt(OStock[1]);
	}
	*/
	PQty = parseInt(document.forms['ProductOptions']['Qty_' + thisOption].value);
	var rangeFound = false;
	for (j = 0; j < TORange.length && !rangeFound; j++){
		ORange = TORange[j].split("|");
		if(PQty >= parseInt(ORange[0])){
			if(ORange[1] == 0){
				tempPrice = ORange[2];
				rangeFound = true;
			} else {
				if(PQty <= parseInt(ORange[1])){
					tempPrice = ORange[2];
					rangeFound = true;
				}
			}
		}
	}
	TOptions = eval("PSOptions_" + thisOption);
	itemFound = false;
	if(TOptions.length >= 1){
		for (i = 0; i < TOptions.length && !itemFound; i++){
			ODetails = TOptions[i].split("|");
			SItem = eval("document.forms['ProductOptions']['ProductSubOption_" + ODetails[0] + "']");
			if (SItem.value != null && SItem.value == ODetails[1] && SItem.value != 0){	
				if (ODetails[2] != null){
					if (ODetails[2] == "+"){
						tempPrice = parseFloat(tempPrice) + parseFloat(ODetails[3]);
					} else {
						if (ODetails[2] == "-"){
							tempPrice = parseFloat(tempPrice) - parseFloat(ODetails[3]);
						} else {
							tempPrice = tempPrice;
						}
					}
					//itemFound = true;
				} else {
					tempPrice = tempPrice
				}
				if (ODetails[4] == 1) {
					checkStock = true;
					stockQty = parseInt(ODetails[5]);
				}
			} else {
				tempPrice = tempPrice;
			}
		}
	}
	/*
	if (checkStock == true) {
		if (PQty > stockQty) {
			if (stockQty > 0){
				PQty = stockQty;
				if (PQty != 1){
					strStockWarning = "Sorry, there are only " + stockQty + " items left in stock.";
				} else {
					strStockWarning = "Sorry, there is only " + stockQty + " item left in stock.";
				}
			} else {
				PQty = 0;
				strStockWarning = "Sorry this product is currently out of stock, please call 01792 616616 for availability.";
			}
			document.forms['ProductOptions']['Qty_' + thisOption].value = PQty;
		}
	}
	if (document.all||document.getElementById){
		obj = document.getElementById("Stock_" + thisOption)
	} else {
		obj = MM_findObj("Stock_" + thisOption)
	}
	obj.innerHTML = strStockWarning;
	*/
	tempPrice = tempPrice*PQty;
	tempPrice = Math.round(tempPrice*100) / 100;
	changePrice(tempPrice);
}

function showProductOptions(thisOption){
	for (i = 0; i< POptions.length; i++){
		TOption = POptions[i]
		if (document.all||document.getElementById){
			obj = document.getElementById("ProductOptions_" + TOption)
		} else {
			obj = MM_findObj("ProductOptions_" + TOption)
		}
		if (obj != null){
			if ((TOption - thisOption) == 0){
				v = "show";
				d = "";
			} else {
				v = "hide";
				d = "none";
			}
		}
		if (obj.style){
			obj=obj.style;
			v=(v=='show')?'visible':(v='hide')?'hidden':v;
			obj.visibility=v;
			obj.display=d;
		}
	}
	updateProductPrice(thisOption)
}

function onOver(id,cellclass){

	if (document.all||document.getElementById){
		document.getElementById(id).className=cellclass;
		document.getElementById(id).style.cursor='hand';
	} else {
		id.className=cellclass;
		id.style.cursor='hand';
	}
}

function onOut(id,cellclass){

	if (document.all||document.getElementById){
		document.getElementById(id).className=cellclass;
		document.getElementById(id).style.cursor='default';
	} else {
		id.className=cellclass;
		id.style.cursor='default';
	}
}

function getBrowserHeight() {
	var bHeight = 0;
	if (navigator.userAgent.indexOf("MSIE") > 0) {
		bHeight = document.body.clientHeight;
		return bHeight;
	} else {                                                
		bHeight = window.outerHeight;
		return bHeight;
	}
	return;      
}

function MakeNumeric(form,field){
	var thisField = document.forms[form][field];
	if(thisField.value != ""){
		if(isNaN(thisField.value)){
			thisField.value = thisField.value.slice(0, (thisField.value.length - 1));
			thisField.focus();
		}
	}
}

function PaymentDetails(){

var fieldnames = new Array (3)
	fieldnames[0] = "Card Number "
	fieldnames[1] = "Card Type "
	fieldnames[2] = "Valid From "
	fieldnames[3] = "Expires "

	var onoff=0
	var alertboxnames = ""

	var fields = new Array (3)
	fields[0] = document.forms['Payment_Details'].CardNumber.value.length
	fields[1] = document.forms['Payment_Details'].CardType.value.length
	fields[2] = document.forms['Payment_Details'].StartDate.value.length
	fields[3] = document.forms['Payment_Details'].ExpiryDate.value.length   
	if (fields[0] > 0 && fields[0] < 16) {	
    	alertboxnames = alertboxnames + "Invalid Card Number \n";        
        onoff ++;
	}   
	for (var i=0; i < fields.length; i++) {
        if (fields[i] == 0) {
    		alertboxnames = alertboxnames + fieldnames[i] + "\n";
        	onoff ++;
		}                    
	}   
	if (onoff == 0) {
		return true
	} else {
		if (onoff == 1) {
			var catness = alertboxnames.substring (0, alertboxnames.indexOf("\n"));
			alert ("Error found:\n \n" + catness + "\n \nPlease Rectify Before Proceeding.");
		} else {
			var catness = alertboxnames.substring (0, alertboxnames.length-2)
			alert ("Errors Found:\n \n" + catness + "\n \nPlease Rectify Before Proceeding."); 
		}
		return false
	}
}

function NewAddress(){

var fieldnames = new Array (4)
	fieldnames[0] = "Missing Address Line 1 "
	fieldnames[1] = "Missing Town "
	fieldnames[2] = "Missing County "
	fieldnames[3] = "Missing Postcode "
	fieldnames[4] = "Missing Telephone Number "

	var onoff=0
	var alertboxnames = ""

	var fields = new Array (4)
	fields[0] = document.forms['New_Billing_Address'].Address_Line1.value.length
	fields[1] = document.forms['New_Billing_Address'].Town.value.length
	fields[2] = document.forms['New_Billing_Address'].County.value.length
	fields[3] = document.forms['New_Billing_Address'].Postcode.value.length
	fields[4] = document.forms['New_Billing_Address'].Telephone.value.length
	for (var i=0; i < fields.length; i++) {
        if (fields[i] == 0) {
    		alertboxnames = alertboxnames + fieldnames[i] + "\n";
        	onoff ++;
		}              
	}
	if (onoff == 0) {
		return true
	} else {
		if (onoff == 1) {
			var catness = alertboxnames.substring (0, alertboxnames.indexOf("\n"));
			alert ("Error found:\n \n" + catness + "\n \nPlease Rectify Before Proceeding.");
		} else {
			var catness = alertboxnames.substring (0, alertboxnames.length-2)
			alert ("Errors Found:\n \n" + catness + "\n \nPlease Rectify Before Proceeding."); 
		}
		return false
	}
}

function NewDeliveryAddress(){

var fieldnames = new Array (5)
	fieldnames[0] = "Missing Forename "
	fieldnames[1] = "Missing Surname "
	fieldnames[2] = "Missing Address Line 1 "
	fieldnames[3] = "Missing Town "
	fieldnames[4] = "Missing County "
	fieldnames[5] = "Missing Postcode "

	var onoff=0
	var alertboxnames = ""

	var fields = new Array (5)
	fields[0] = document.forms['New_Delivery_Address'].Forename.value.length
	fields[1] = document.forms['New_Delivery_Address'].Surname.value.length
	fields[2] = document.forms['New_Delivery_Address'].Address1.value.length
	fields[3] = document.forms['New_Delivery_Address'].Town.value.length
	fields[4] = document.forms['New_Delivery_Address'].County.value.length
	fields[5] = document.forms['New_Delivery_Address'].Postcode.value.length
	for (var i=0; i < fields.length; i++) {
        if (fields[i] == 0) {
    		alertboxnames = alertboxnames + fieldnames[i] + "\n";
        	onoff ++;
		}              
	}
	if (onoff == 0) {
		return true
	} else {
		if (onoff == 1) {
			var catness = alertboxnames.substring (0, alertboxnames.indexOf("\n"));
			alert ("Error found:\n \n" + catness + "\n \nPlease Rectify Before Proceeding.");
		} else {
			var catness = alertboxnames.substring (0, alertboxnames.length-2)
			alert ("Errors Found:\n \n" + catness + "\n \nPlease Rectify Before Proceeding."); 
		}
		return false
	}
}

function CheckPersonal(){

var fieldnames = new Array (7)
	fieldnames[0] = "Missing Forename "
	fieldnames[1] = "Missing Surname "
	fieldnames[2] = "Missing Email "
	fieldnames[3] = "Missing Address Line 1 "
	fieldnames[4] = "Missing Town "
	fieldnames[5] = "Missing County "
	fieldnames[6] = "Missing Postcode "
	fieldnames[7] = "Missing Telephone "

	var onoff=0
	var alertboxnames = ""

	var fields = new Array (7)
	fields[0] = document.forms['Register'].Forename.value.length
	fields[1] = document.forms['Register'].Surname.value.length
	fields[2] = document.forms['Register'].Email.value.length
	fields[3] = document.forms['Register'].Address1.value.length
	fields[4] = document.forms['Register'].Town.value.length
	fields[5] = document.forms['Register'].County.value.length
	fields[6] = document.forms['Register'].Postcode.value.length
	fields[7] = document.forms['Register'].Telephone.value.length
	for (var i=0; i < fields.length; i++) {
        if (fields[i] == 0) {
    		alertboxnames = alertboxnames + fieldnames[i] + "\n";
        	onoff ++;
		}              
	}
	if (onoff == 0) {
		return true
	} else {
		if (onoff == 1) {
			var catness = alertboxnames.substring (0, alertboxnames.indexOf("\n"));
			alert ("Error found:\n \n" + catness + "\n \nPlease Rectify Before Proceeding.");
		} else {
			var catness = alertboxnames.substring (0, alertboxnames.length-2)
			alert ("Errors Found:\n \n" + catness + "\n \nPlease Rectify Before Proceeding."); 
		}
		return false
	}
}

function NewCustomer(){

var fieldnames = new Array (2)
	fieldnames[0] = "Missing Forename "
	fieldnames[1] = "Missing Surname "
	fieldnames[2] = "Missing Email "

	var onoff=0
	var alertboxnames = ""

	var fields = new Array (2)
	fields[0] = document.forms['New_Customer'].Forename.value.length
	fields[1] = document.forms['New_Customer'].Surname.value.length
	fields[2] = document.forms['New_Customer'].Email.value.length
	for (var i=0; i < fields.length; i++) {
        if (fields[i] == 0) {
    		alertboxnames = alertboxnames + fieldnames[i] + "\n";
        	onoff ++;
		}              
	}
	if (onoff == 0) {
		return true
	} else {
		if (onoff == 1) {
			var catness = alertboxnames.substring (0, alertboxnames.indexOf("\n"));
			alert ("Error found:\n \n" + catness + "\n \nPlease Rectify Before Proceeding.");
		} else {
			var catness = alertboxnames.substring (0, alertboxnames.length-2)
			alert ("Errors Found:\n \n" + catness + "\n \nPlease Rectify Before Proceeding."); 
		}
		return false
	}
}

function VerifyEmail(form_name){

Form = eval(form_name + "['Email'].value");

	if((Form == "" || Form.indexOf('@', 0) == -1) || Form.indexOf('.') == -1) {  
	alert ("A valid Email address is required");   
	return false;
	} else {
	return true;
	}
}

function Top(){
scroll(0,0)
}

function Back(){
history.go(-1)
}

function GoURL(url){
document.location.href = url;
}

function GoWindowURL(url,width,height){
var left = ((screen.width / 2) - (width / 2));
var top = ((screen.height / 2) - (height / 2));
var winoptions = "0,0,0,0,0,scrollbars=yes,resizable=yes,width=" + width + ",height=" + height + ",top=" + top + ",left=" + left;
window.open(url, 'new_window',winoptions)
}

function setTimer(url,time){
setTimeout("GoURL('" + url + "');", time);
}

function GoAffiliate(url){
var left = ((screen.width / 2) - (200 / 2));
var top = ((screen.height / 2) - (200 / 2));
var winoptions = "0,0,0,0,0,scrollbars=yes,resizable=yes,width=400,height=400,top=" + top + ",left=" + left;
window.open(url, 'affiliate_window',winoptions)
}

function StockRequest(product_id,option_id){
var url = "stockrequest.asp?pid=" + product_id + "&oid=" + option_id;
var left = ((screen.width / 2) - (300 / 2));
var top = ((screen.height / 2) - (150 / 2));
var winoptions = "0,0,0,0,0,scrollbars=no,resizable=no,width=300,height=150,top=" + top + ",left=" + left;
window.open(url, 'stock_request',winoptions)
}

function TechInfo(link_id,related_id){
link_info = link_id + "&RID=" + related_id
window.open('tech_info.asp?ID=' + link_info,'technical_information','0,0,0,0,0,scrollbars=yes,resizable=no,width=580,height=425,top=5,left=5')
}

function CompanyInfo(company_id){
window.open('manufacturers.asp?CID=' + company_id, 'company_information','0,0,0,0,0,scrollbars=yes,resizable=no,width=580,height=425,top=5,left=5')
}

function DisplayImage(image_url, backlink, title){
var url = "enlarge_image.asp?IMAGE=" + image_url + "&CLOSE=0&RETURNTEXT=" + backlink + "&TITLE=" + title
document.location.href = url;
}

function EnlargeImage(image_url, title){
var url = "enlarge_image.asp?IMAGE=" + image_url + "&CLOSE=1&TITLE=" + title
window.open(url, 'enlarge_image','0,0,0,0,0,scrollbars=no,resizable=no,width=580,height=425,top=5,left=5')
}

//-->