function stopError() {
  return true;
}

window.onerror = stopError;

function clearInput(input)
{
	if (input.value == "Search...")
	{
		input.value = "";	
	}
	else
	{
		input.style.backgroundImage = "none";	
	}
}

function returnInput(input)
{
	if (input.value == "")
	{
		input.value = "Search...";
	}
}

function returnEmail(input)
{
	if (input.value == "")
	{
		input.style.backgroundImage = "url(../images/input_email.gif)";
	}
}

function returnPassword(input)
{
	if (input.value == "")
	{
		input.style.backgroundImage = "url(../images/input_password.gif)";
	}
}

			function recalcPrice(productID) {
				var content;
				eval("thisPrice = baseprice"+productID+";");
				eval("thisPriceExTax = basepriceExTax"+productID+";");
				eval("thisPriceIncTax = basepriceIncTax"+productID+";");
				eval("thisPriceTax = basepriceTax"+productID+";");
				eval("thisOOPrice = oobaseprice"+productID+";");
				eval("thisOOPriceExTax = oobasepriceExTax"+productID+";");
				eval("thisOOPriceIncTax = oobasepriceIncTax"+productID+";");
				eval("thisOOPriceTax = oobasepriceTax"+productID+";");
				currentValues = new Array(efcount);
				if (doesFormElementExist("productForm"+productID,"qty"+productID)) {
					qty = getFormElementValue("productForm"+productID,"qty"+productID);
				} else {
					qty = 1;
				}
				for (f = 0; f < efcount; f++) {
					currentValues[extrafields[f]] = "";

					elementExists = doesFormElementExist("productForm"+productID,extrafields[f]);
					fieldtype = getFormElementType("productForm"+productID,extrafields[f]);
					if (extrafieldstype[f] == "CHECKBOXES") {
						elementExists = doesFormElementExist("productForm"+productID,extrafields[f]+"1");
						fieldtype = getFormElementType("productForm"+productID,extrafields[f]+"1");
					}
					if (extrafieldstype[f] == "RADIOBUTTONS") {
						elementExists = doesFormElementExist("productForm"+productID,extrafields[f]);
						elem = getFormElement("productForm"+productID,extrafields[f]);
						if (elem.length > 0) {
							elementExists = true;
							fieldtype = "radio";
						} else {
							elementExists = false;
						}
					}

					if (elementExists) {
						if (fieldtype=="select-one") {
							currentValues[extrafields[f]] = getFormElementValue("productForm"+productID,extrafields[f]);
						}
						if (fieldtype=="checkbox") {
							content = "";
							thisOne = 1;
							result = getFormElement("productForm"+productID,extrafields[f]+thisOne);
							while (result) {
								if (result.checked == true) {
									if (content != "") {
										content = content+";";
									}
									content = content + result.value;
								}
								thisOne++;
								result = getFormElement("productForm"+productID,extrafields[f]+thisOne);
							}
							currentValues[extrafields[f]] = content;
						}
						if (fieldtype=="radio") {
							buttons = getFormElement("productForm"+productID,extrafields[f]);
							radlength = buttons.length;
							for (g = 0; g < radlength; g++) {
								thisoption = buttons[g].checked;
								if (thisoption) {
									currentValues[extrafields[f]] = buttons[g].value;
								}
							}
						}
					}
				}
				eval ("arraylength = p"+productID+".length;");
				eval ("advArray = p"+productID+";");
				for (f = 0; f <  arraylength; f++) {		
					applicable = false;
					doesExist = false;
					for (var h in advArray[f]) {
						if (h == "qtyfrom") {
							doesExist = true;
						}
					}
					if (doesExist) {
						if (parseInt(advArray[f]["qtyfrom"]) != -1 && parseInt(advArray[f]["qtyto"]) != -1 && parseInt(advArray[f]["qtyto"]) != 0) {
							//quantity is applicable here
							if (parseInt(qty) >= parseInt(advArray[f]["qtyfrom"]) && parseInt(qty) <= parseInt(advArray[f]["qtyto"])) {
								applicable = true;
							}
						} else {
							applicable = true;
						}
					} else {
						applicable = true;
					}
					thisapplic = true;
					foundMatches = 0;
					for (g = 0; g < efcount; g++) {
						doesExist = false;
						for (var h in advArray[f]) {
							if (h == extrafields[g]) {
								doesExist = true;
							}
						}
						if (doesExist) {
							if (advArray[f][extrafields[g]] != "" && advArray[f][extrafields[g]] != "0") {
								splitCheck = advArray[f][extrafields[g]].split(";");
								splitapplic = false;
								for (k = 0; k < splitCheck.length; k++) {
									splitValues = currentValues[extrafields[g]].split(";");
									for (l = 0; l < splitValues.length; l++) {
										if ((splitCheck[k] == splitValues[l] && splitCheck[k] != "" && splitValues[l] != "")) {
											splitapplic = true;
											if (extrafieldstype[g] == "CHECKBOXES") {
												foundMatches = foundMatches + 1;
											}
										}
									}
								}
								if (splitapplic == true && thisapplic == true) {
									thisapplic = true;
								} else {
									thisapplic = false;
								}
							}
						}
					}
					if (thisapplic == true && applicable == true) {
						applicable = true;
					} else {
						applicable = false;
					}
					if (applicable == true) {
						//new base price
						if (foundMatches == 0) { foundMatches =1; }
						npPercentage = 0;
						npPrice = 0;
						npPriceExTax = 0;
						npPriceIncTax = 0;
						npPriceTax = 0;
						for (var h in advArray[f]) {
							if (h == "percentage") {
								npPercentage = eval(advArray[f]["percentage"]);
							}
							if (h == "price") {
								npPrice = eval(advArray[f]["price"]);
							}
							if (h == "priceExTax") {
								npPriceExTax = eval(advArray[f]["priceExTax"]);
							}
							if (h == "priceIncTax") {
								npPriceIncTax = eval(advArray[f]["priceIncTax"]);
							}
							if (h == "priceTax") {
								npPriceTax = eval(advArray[f]["priceTax"]);
							}
						}

						if (parseInt(advArray[f]["priceType"]) == 0) {
							if (parseFloat(advArray[f]["percentage"]) > 0) {
								thisPrice = thisPrice + (thisPrice  * (npPercentage/100));
								thisPriceExTax = thisPriceExTax + (thisPriceExTax  * (npPercentage/100));
								thisPriceIncTax = thisPriceIncTax + (thisPriceIncTax  * (npPercentage/100));
								thisPriceTax = thisPriceTax + (thisPriceTax  * (npPercentage/100));
							}
							if (parseFloat(advArray[f]["percentage"]) < 0) {
								thisPrice = thisPrice - (thisPrice  * (Math.abs(npPercentage)/100));
								thisPriceExTax = thisPriceExTax - (thisPriceExTax  * (Math.abs(npPercentage)/100));
								thisPriceIncTax = thisPriceIncTax - (thisPriceIncTax  * (Math.abs(npPercentage)/100));
								thisPriceTax = thisPriceTax - (thisPriceTax  * (Math.abs(npPercentage)/100));
							}
							if (parseFloat(advArray[f]["percentage"]) == 0) {
								thisPrice = npPrice;
								thisPriceExTax = npPriceExTax;
								thisPriceIncTax = npPriceIncTax;
								thisPriceTax = npPriceTax;
							}
						}
						if (parseInt(advArray[f]["priceType"]) == 1) {
							if (parseFloat(advArray[f]["percentage"]) > 0) {
								for (m = 1; m <= foundMatches; m++) {
									thisPrice = thisPrice + (thisPrice  * (npPercentage/100));
									thisPriceExTax = thisPriceExTax + (thisPriceExTax  * (npPercentage/100));
									thisPriceIncTax = thisPriceIncTax + (thisPriceIncTax  * (npPercentage/100));
									thisPriceTax = thisPriceTax + (thisPriceTax  * (npPercentage/100));
								}
							}
							if (parseFloat(advArray[f]["percentage"]) < 0) {
								for (m = 1; m <= foundMatches; m++) {
									thisPrice = thisPrice - (thisPrice  * (Math.abs(npPercentage)/100));
									thisPriceExTax = thisPriceExTax - (thisPriceExTax  * (Math.abs(npPercentage)/100));
									thisPriceIncTax = thisPriceIncTax - (thisPriceIncTax  * (Math.abs(npPercentage)/100));
									thisPriceTax = thisPriceTax - (thisPriceTax  * (Math.abs(npPercentage)/100));
								}
							}
							if (parseFloat(advArray[f]["percentage"]) == 0) {
								for (m = 1; m <= foundMatches; m++) {
									thisPrice = thisPrice + npPrice;
									thisPriceExTax = thisPriceExTax + npPriceExTax;
									thisPriceIncTax = thisPriceIncTax + npPriceIncTax;
									thisPriceTax = thisPriceTax + npPriceTax;
								}
							}
						}	
						if (parseInt(advArray[f]["priceType"]) == 2) {
							if (parseFloat(advArray[f]["percentage"]) > 0) {
								for (m = 1; m <= foundMatches; m++) {
									thisPrice = thisPrice - (thisPrice * (npPercentage/100));
									thisPriceExTax = thisPriceExTax - (thisPriceExTax * (npPercentage/100));
									thisPriceIncTax = thisPriceIncTax - (thisPriceIncTax * (npPercentage/100));
									thisPriceTax = thisPriceTax - (thisPriceTax * (npPercentage/100));
								}
							}
							if (parseFloat(advArray[f]["percentage"]) < 0) {
								for (m = 1; m <= foundMatches; m++) {
									thisPrice = thisPrice - (thisPrice * (Math.abs(npPercentage)/100));
									thisPriceExTax = thisPriceExTax - (thisPriceExTax * (Math.abs(npPercentage)/100));
									thisPriceIncTax = thisPriceIncTax - (thisPriceIncTax * (Math.abs(npPercentage)/100));
									thisPriceTax = thisPriceTax - (thisPriceTax * (Math.abs(npPercentage)/100));
								}
							}
							if (parseFloat(advArray[f]["percentage"]) == 0) {
								for (m = 1; m <= foundMatches; m++) {
									thisPrice = thisPrice - npPrice;
									thisPriceExTax = thisPriceExTax - npPriceExTax;
									thisPriceIncTax = thisPriceIncTax - npPriceIncTax;
									thisPriceTax = thisPriceTax - npPriceTax;
								}
							}
						}	
						if (parseInt(advArray[f]["priceType"]) == 4) {
							if (parseFloat(advArray[f]["percentage"]) > 0) {
								for (m = 1; m <= foundMatches; m++) {
									thisOOPrice = thisOOPrice - (thisOOPrice * (npPercentage/100));
									thisOOPriceExTax = thisOOPriceExTax - (thisOOPriceExTax * (npPercentage/100));
									thisOOPriceIncTax = thisOOPriceIncTax - (thisOOPriceIncTax * (npPercentage/100));
									thisOOPriceTax = thisOOPriceTax - (thisOOPriceTax * (npPercentage/100));
								}
							}
							if (parseFloat(advArray[f]["percentage"]) < 0) {
								for (m = 1; m <= foundMatches; m++) {
									thisOOPrice = thisOOPrice - (thisPrice * (Math.abs(npPercentage)/100));
									thisOOPriceExTax = thisOOPriceExTax - (thisOOPriceExTax * (Math.abs(npPercentage)/100));
									thisOOPriceIncTax = thisOOPriceIncTax - (thisOOPriceIncTax * (Math.abs(npPercentage)/100));
									thisOOPriceTax = thisOOPriceTax - (thisOOPriceTax * (Math.abs(npPercentage)/100));
								}
							}
							if (parseFloat(advArray[f]["percentage"]) == 0) {
								for (m = 1; m <= foundMatches; m++) {
									thisOOPrice = npPrice;
									thisOOPriceExTax = npPriceExTax;
									thisOOPriceIncTax = npPriceIncTax;
									thisOOPriceTax = npPriceTax;
								}
							}
						}																
					}							
				}
				displayPrice = presentValue(thisPrice,cDP,cPreT,cMidT,cPostT);
				changeContent("priceSpan"+productID,"priceLayer"+productID,displayPrice);
				displayPrice = presentValue(thisPriceExTax,cDP,cPreT,cMidT,cPostT);
				changeContent("priceExTaxSpan"+productID,"priceExTaxLayer"+productID,displayPrice);
				displayPrice = presentValue(thisPriceIncTax,cDP,cPreT,cMidT,cPostT);
				changeContent("priceIncTaxSpan"+productID,"priceIncTaxLayer"+productID,displayPrice);
				displayPrice = presentValue(thisPriceTax,cDP,cPreT,cMidT,cPostT);
				changeContent("priceTaxSpan"+productID,"priceTaxLayer"+productID,displayPrice);
				
				displayPrice = presentValue(thisOOPrice,cDP,cPreT,cMidT,cPostT);
				changeContent("oopriceSpan"+productID,"oopriceLayer"+productID,displayPrice);
				displayPrice = presentValue(thisOOPriceExTax,cDP,cPreT,cMidT,cPostT);
				changeContent("oopriceExTaxSpan"+productID,"oopriceExTaxLayer"+productID,displayPrice);
				displayPrice = presentValue(thisOOPriceIncTax,cDP,cPreT,cMidT,cPostT);
				changeContent("oopriceIncTaxSpan"+productID,"oopriceIncTaxLayer"+productID,displayPrice);
				displayPrice = presentValue(thisOOPriceTax,cDP,cPreT,cMidT,cPostT);
				changeContent("oopriceTaxSpan"+productID,"oopriceTaxLayer"+productID,displayPrice);
			}
			
			isNS4 = (document.layers) ? true : false;
isIE4 = (document.all && !document.getElementById) ? true : false;
isIE5 = (document.all && document.getElementById) ? true : false;
isNS6 = (!document.all && document.getElementById) ? true : false;
			
function changeContent(theDiv,theLayer,newText) {
	if (isNS4){
	   elm = document.layers[theLayer];
	   elm.document.open();
       elm.document.write(newText);
       elm.document.close();

	}
	else if (isIE4) {
	   elm = document.all[theDiv];
	   elm.innerText = newText;
	}
	else if (isIE5) {
	   elm = document.getElementById(theDiv);
		if (elm) {
	   		elm.innerText = newText;
	   	}
	}
	else if (isNS6) {
		var elmw = document.getElementById(theDiv);
    	if (elmw) {
    		elmw.childNodes[0].nodeValue = newText;
    	}	
	}
}			

    function presentValue(value,dp,pt,mt,at) {
        if(value<=0.9999) {
            newPounds='0';
        } else {
            newPounds=parseInt(value);
        }
        dec='1';
        for (var i=1; i<=dp;i++) {
            dec=dec+'0';
        }
        if (value>0) {
            newPence=Math.round((eval(value)+.000008 - newPounds)*(eval(dec)));
        } else {
            newPence=0;
        }
        compstring='9';
        for (var i=1; i <=dp-1;i++) {
            if (eval(newPence) <= eval(compstring)) newPence='0'+newPence;
            compstring=compstring+'9';
        }
        if (dp>0) {
            if (newPence==eval(dec)) { newPounds++; newPence='00'; }
            newString=pt+newPounds+mt+newPence+at;
        } else {
            newString=pt+newPounds+at;
        }
        return (newString);
    }

	function doesFormElementExist(formName,elementName) {
		if (document.getElementById(formName)) {
			theForm = document.getElementById(formName);
			if (theForm.elements[elementName]) {
				return true;
			}
		}
		if (document.forms[formName]) {
			if (document.forms[formName].elements[elementName]) {
				return true;
			}
		}
		return false;
	}

	function getFormElementValue(formName,elementName) {
		if (document.getElementById(formName)) {
			theForm = document.getElementById(formName);
			if (theForm.elements[elementName]) {
				return theForm.elements[elementName].value;
			}
		}
		if (document.forms[formName]) {
			if (document.forms[formName].elements[elementName]) {
				return document.forms[formName].elements[elementName].value;
			}
		}
		return "";
	}

	function getFormElementType(formName,elementName) {
		if (document.getElementById(formName)) {
			theForm = document.getElementById(formName);
			if (theForm.elements[elementName]) {
				return theForm.elements[elementName].type;
			}
		}
		if (document.forms[formName]) {
			if (document.forms[formName].elements[elementName]) {
				return document.forms[formName].elements[elementName].type;
			}
		}
		return "";
	}

	function getFormElement(formName,elementName) {
		if (document.getElementById(formName)) {
			theForm = document.getElementById(formName);
			if (theForm.elements[elementName]) {
				return theForm.elements[elementName];
			}
		}
		if (document.forms[formName]) {
			if (document.forms[formName].elements[elementName]) {
				return document.forms[formName].elements[elementName];
			}
		}
		return "";
	}

	function jss_openWindow(url) {
		window.open(url,"JSSWindow","height=500,width=500,resizable=1");
	}
	

/***********************************************
* Contractible Headers script- © Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use. Last updated Mar 23rd, 2004.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

var enablepersist="on" //Enable saving state of content structure using session cookies? (on/off)
var collapseprevious="no" //Collapse previously open content when opening present? (yes/no)

if (document.getElementById){
document.write('<style type="text/css">')
document.write('.switchcontent{display:none;}')
document.write('</style>')
}

function getElementbyClass(classname){
ccollect=new Array()
var inc=0
var alltags=document.all? document.all : document.getElementsByTagName("*")
for (i=0; i<alltags.length; i++){
if (alltags[i].className==classname)
ccollect[inc++]=alltags[i]
}
}

function contractcontent(omit){
var inc=0
while (ccollect[inc]){
if (ccollect[inc].id!=omit)
ccollect[inc].style.display="none"
inc++
}
}

function expandcontent(cid){
if (typeof ccollect!="undefined"){
if (collapseprevious=="yes")
contractcontent(cid)
document.getElementById(cid).style.display=(document.getElementById(cid).style.display!="block")? "block" : "none"
}
}

function revivecontent(){
contractcontent("omitnothing")
selectedItem=getselectedItem()
selectedComponents=selectedItem.split("|")
for (i=0; i<selectedComponents.length-1; i++)
document.getElementById(selectedComponents[i]).style.display="block"
}

function get_cookie(Name) { 
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) { 
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function getselectedItem(){
if (get_cookie(window.location.pathname) != ""){
selectedItem=get_cookie(window.location.pathname)
return selectedItem
}
else
return ""
}

function saveswitchstate(){
var inc=0, selectedItem=""
while (ccollect[inc]){
if (ccollect[inc].style.display=="block")
selectedItem+=ccollect[inc].id+"|"
inc++
}

document.cookie=window.location.pathname+"="+selectedItem
}

function do_onload()
{
	uniqueidn=window.location.pathname+"firsttimeload"
	getElementbyClass("switchcontent")
	if (enablepersist=="on" && typeof ccollect!="undefined")
	{
		document.cookie=(get_cookie(uniqueidn)=="")? uniqueidn+"=1" : uniqueidn+"=0" 
		firsttimeload=(get_cookie(uniqueidn)==1)? 1 : 0 //check if this is 1st page load
		if (!firsttimeload)
		revivecontent()
	}
}


if (window.addEventListener)
window.addEventListener("load", do_onload, false)
else if (window.attachEvent)
window.attachEvent("onload", do_onload)
else if (document.getElementById)
window.onload=do_onload

if (enablepersist=="on" && document.getElementById)
window.onunload=saveswitchstate