function stopError() {
  return true;
}

window.onerror = stopError;

			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+";");

				eval("thisRRP = rrpprice"+productID+";");
				eval("thisRRPExTax = rrppriceExTax"+productID+";");
				eval("thisRRPIncTax = rrppriceIncTax"+productID+";");
				eval("thisRRPTax = rrppriceTax"+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;
						npRRP = 0;
						npRRPExTax = 0;
						npRRPIncTax = 0;
						npRRPTax = 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 (h == "rrp") {
								npRRP = eval(advArray[f]["rrp"]);
							}
							if (h == "rrpExTax") {
								npRRPExTax = eval(advArray[f]["rrpExTax"]);
							}
							if (h == "rrpIncTax") {
								npRRPIncTax = eval(advArray[f]["rrpIncTax"]);
							}
							if (h == "rrpTax") {
								npRRPTax = eval(advArray[f]["rrpTax"]);
							}

						}

						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) {
								if (npPrice > 0) {
									thisPrice = npPrice;
									thisPriceExTax = npPriceExTax;
									thisPriceIncTax = npPriceIncTax;
									thisPriceTax = npPriceTax;
								}
							}
							if (npRRP > 0) {
								thisRRP = npRRP;
								thisRRPExTax = npRRPExTax;
								thisRRPIncTax = npRRPIncTax;
								thisRRPTax = npRRPTax;
							}
						}
						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);

				pricediff = thisRRP - thisPrice;
				displayPrice = presentValue(pricediff,cDP,cPreT,cMidT,cPostT);
				changeContent("pricediffSpan"+productID,"pricediffLayer"+productID,displayPrice);

				pricePercent = ((100/thisRRP) * thisPrice)-100;
				pricePercent = pricePercent.toFixed(2);
				if (pricePercent < 0) {
					pricePercent = Math.abs(pricePercent);
				} else {
					pricePercent = "+" + pricePercent;
				}
					
				pricePercent = pricePercent + "%";
				changeContent("pricediffpercSpan"+productID,"pricediffpercLayer"+productID,pricePercent);

				displayPrice = presentValue(thisRRP,cDP,cPreT,cMidT,cPostT);
				changeContent("rrpSpan"+productID,"rrpLayer"+productID,displayPrice);
				displayPrice = presentValue(thisRRPExTax,cDP,cPreT,cMidT,cPostT);
				changeContent("rrpExTaxSpan"+productID,"rrpExTaxLayer"+productID,displayPrice);
				displayPrice = presentValue(thisRRPIncTax,cDP,cPreT,cMidT,cPostT);
				changeContent("rrpIncTaxSpan"+productID,"rrpIncTaxLayer"+productID,displayPrice);
				displayPrice = presentValue(thisRRPTax,cDP,cPreT,cMidT,cPostT);
				changeContent("rrpTaxSpan"+productID,"rrpTaxLayer"+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=400,width=500,resizable=1,scrollbars=1");
	}

	RegExp.escape = function(str) {
	  var specials = new RegExp("[.*+?|()\\[\\]{}\\\\]", "g"); // .*+?|()[]{}\
	  return str.replace(specials, "\\$&");
	}

	function jss_getElementPosition(obj){
		var topValue= 0,leftValue= 0;
		while(obj){
			leftValue+= obj.offsetLeft;
			topValue+= obj.offsetTop;
			obj= obj.offsetParent;
		}
		return [leftValue,topValue];
	}

	//Jshop Server API Functions
	function jss_apiRequestObject() {
		if (window.XMLHttpRequest) {
			return new XMLHttpRequest();
		} else if(window.ActiveXObject) {
			return new ActiveXObject("Microsoft.XMLHTTP");
		}
	}

	function jss_apiMakeCall(command,vars,returnFunction,requestObject) {
		requestObject.open("GET", 'api.php?c='+command+'&'+vars, true);
		requestObject.onreadystatechange = returnFunction; 
		requestObject.send(null);
	}

	//JShop Server Search Suggest Functions
	var jss_searchRequest = jss_apiRequestObject();

	var jss_searchRequestFormField = "";

	var jss_searchRequestString = "";
	var jss_searchRequestParentForm = "";
	var jss_searchSuggestCount = 0;
	var jss_searchSuggestHilite = -1;
	var jss_searchSuggestResults = [];



function html_entity_decode(str) {
  var ta=document.createElement("textarea");
  ta.innerHTML=str.replace(/</g,"&lt;").replace(/>/g,"&gt;");
  return ta.value;
}

	function jss_searchSuggest(formField,limit,form,e) {
		var str = escape(formField.value);
		var evt = (window.event) ? window.event : e;
		if (evt) {
			var stopProc = false;
			if (jss_searchSuggestCount != 0) {
				switch (evt.keyCode) {
					case 13:
						stopProc = true;
						break;
					case 38:
						//up
						stopProc = true;
						if (jss_searchSuggestHilite > -1) {
							if (jss_searchSuggestHilite != -1 && jss_searchSuggestHilite < jss_searchSuggestCount) {
								var elem = document.getElementById('searchSuggest'+jss_searchSuggestHilite);
								jss_searchSuggestOut(elem,jss_searchSuggestHilite);
							}
							jss_searchSuggestHilite--;
							if (jss_searchSuggestHilite > -1) {
								var elem = document.getElementById('searchSuggest'+jss_searchSuggestHilite);
								jss_searchSuggestOver(elem,jss_searchSuggestHilite);
								jss_searchRequestFormField.value = html_entity_decode(jss_searchSuggestResults[jss_searchSuggestHilite]);
							} else {
								jss_searchSuggestHilite = -1;
								jss_searchRequestFormField.value = jss_searchRequestString;
							}
						}
						break;      
					case 40:
						//down
						stopProc = true;
						if (jss_searchSuggestHilite < (jss_searchSuggestCount)) {
							if (jss_searchSuggestHilite != -1) {
								var elem = document.getElementById('searchSuggest'+jss_searchSuggestHilite);
								jss_searchSuggestOut(elem,jss_searchSuggestHilite);
							}
							jss_searchSuggestHilite++;
							if (jss_searchSuggestHilite < (jss_searchSuggestCount)) {
								var elem = document.getElementById('searchSuggest'+jss_searchSuggestHilite);
								jss_searchSuggestOver(elem,jss_searchSuggestHilite);
								jss_searchRequestFormField.value = html_entity_decode(jss_searchSuggestResults[jss_searchSuggestHilite]);
							} else {
								jss_searchRequestFormField.value = jss_searchRequestString;
								jss_searchSuggestHilite = jss_searchSuggestCount;
							}
						}
						break;    
				 }
			}
		}
		if (!stopProc) {
			if (str.length == 0) {
				jss_searchSuggestCount = 0;
				jss_searchSuggestResults = [];
				document.getElementById('search_suggest').style.visibility = "hidden";
			} else {
				if (str.length >= limit) {
					jss_searchRequestFormField = formField;
					formElem = formField;
					pos = jss_getElementPosition(formElem);
					searchelem = document.getElementById("search_suggest");
					pos[1] = pos[1] + formElem.offsetHeight;
					searchelem.style.top = pos[1]+"px";
					searchelem.style.left = pos[0]+"px";
					searchelem.style.width = formElem.offsetWidth+"px";
					jss_searchRequestParentForm = form;
					if (jss_searchRequest.readyState != 4 && jss_searchRequest.readyState != 0) {
						jss_searchRequest.abort();
					}
					if (jss_searchRequest.readyState == 4 || jss_searchRequest.readyState == 0) {
						jss_searchRequestString = str;
						jss_apiMakeCall("searchsuggest","&xSearch=" + str,jss_searchSuggestResult,jss_searchRequest);
					}		
				} else {
					search = document.getElementById("search_suggest");
					search.style.visibility = "hidden";
				}
			}
		}
	}

	var jss_searchSuggestTimer;

	function jss_searchSuggestDelayBlur() {
		jss_searchSuggestTimer = window.setTimeout(jss_searchSuggestEnd, 300);
	}

	function jss_searchSuggestEnd() {
		searchSuggestDiv = document.getElementById("search_suggest");
		searchSuggestDiv.style.visibility = "hidden";
	}

	function jss_searchSuggestHighlightWords(line, word,replacement) {
		//eturn line;
		lowerneedle = unescape(word.toLowerCase());
		lowerhaystack = line.toLowerCase();
		pos = lowerhaystack.indexOf(lowerneedle);
		bit = line.substr(pos,lowerneedle.length);
		line = line.replace(bit,replacement);
		return line;
	}

	function jss_searchSuggestResult() {
		if (jss_searchRequest.readyState == 4) {
			var ss = document.getElementById('search_suggest')
			ss.innerHTML = '';
			xmldoc = jss_searchRequest.responseXML;
			resultcode = xmldoc.getElementsByTagName('code')[0].firstChild.data;
			resulttext = xmldoc.getElementsByTagName('literal')[0].firstChild.data;
			if (resultcode != 1) {
				return;
			}
			results = xmldoc.getElementsByTagName("result");
			if (results.length != 0) {
				jss_searchSuggestResults = [];
				jss_searchSuggestCount = results.length;
				jss_searchSuggestHilite = -1;
				for (j = 0; j < results.length; j++) {
					str = results[j].getElementsByTagName("name")[0].firstChild.data;
					strhi = results[j].getElementsByTagName("hilite")[0].firstChild.data;
					jss_searchSuggestResults.push(str);
					//var thisone = jss_searchSuggestHighlightWords(str,jss_searchRequestString,"<span class=\"suggest_link_highlight\">"+jss_searchRequestString+"</span>");
					var thisone = jss_searchSuggestHighlightWords(strhi,"@@","<span class=\"suggest_link_highlight\">");
					thisone = jss_searchSuggestHighlightWords(thisone,"@","</span>");
					//thisone = strhi;
					var suggest = '<div id="searchSuggest'+j+'" onmouseover="javascript:jss_searchSuggestOver(this,'+j+');" ';
					suggest += 'onmouseout="javascript:jss_searchSuggestOut(this,'+j+');" ';
					suggest += 'onclick="javascript:jss_searchSuggestSetSearch(\''+escape(str)+'\');"';
					suggest += 'class="suggest_link">' + thisone + '</div>';
					ss.innerHTML += suggest;
				}
				document.getElementById('search_suggest').style.visibility = "visible";
			} else {
				jss_searchSuggestCount = 0;
				jss_searchSuggestResults = [];
				document.getElementById('search_suggest').style.visibility = "hidden";
			}
		}
	}

	function jss_searchSuggestOver(theDiv,hi) {
		if (jss_searchSuggestHilite > -1 && jss_searchSuggestHilite < (jss_searchSuggestCount)) {
			var elem = document.getElementById('searchSuggest'+jss_searchSuggestHilite);
			jss_searchSuggestOut(elem,jss_searchSuggestHilite);
		}
		jss_searchSuggestHilite = hi;
		theDiv.className = 'suggest_link_over';
	}

	function jss_searchSuggestOut(theDiv,hi) {
		jss_searchSuggestHilite = hi;
		theDiv.className = 'suggest_link';
	}

	function jss_searchSuggestSetSearch(value) {
		jss_searchRequestFormField.value = html_entity_decode(unescape(value));
		jss_searchSuggestEnd();
		jss_searchRequestParentForm.submit();
	}


	function jss_1stepCheckout(url) {
		self.location.href = url;
	}

	function jss_showId(id) {
		elem = document.getElementById(id);
		if (elem != null) {
			elem.style.visibility='visible';
			elem.style.display='block';
		}
	}

	function jss_showIdInline(id) {
		elem = document.getElementById(id);
		if (elem != null) {
			elem.style.visibility='visible';
			elem.style.display='inline';
		}
	}

	function jss_hideId(id) {
		elem = document.getElementById(id);
		if (elem != null) {
			elem.style.visibility='hidden';
			elem.style.display='none';
		}
	}

	function jss_showTR(id) {
		elem = document.getElementById(id);
		if (elem != null) {
			elem.style.display='';
		}
	}

	function jss_hideTR(id) {
		elem = document.getElementById(id);
		if (elem != null) {
			elem.style.display='none';
		}
	}

	var jss_1stepRequest = jss_apiRequestObject();

	function jss_replaceChars(str) {
		str = str.replace("&pound;","£");
		return str;
	}

	function jss_1stepFillShipping() {
		if (shippingEnabled) {
			elem = document.getElementById("xShippingSelect");
			for(i=elem.options.length-1; i>=0; i--) {
				elem.remove(i);
			}
			for (f=1; f<totalsArray.length ;f++ ) {
				var optn = document.createElement("OPTION");
				optn.text = jss_replaceChars(totalsArray[f]["name"]);
				optn.value = totalsArray[f]["shippingID"];
				if (totalsArray[f]["shippingID"] == selectedShippingID) {
					optn.selected = true;
				}
				elem.options.add(optn);
			}
		}
		jss_1stepUpdateTotals();
	}

	function jss_1stepUpdateTotals() {
		selectedOption = 0;
		if (shippingEnabled) {
			elem = document.getElementById("xShippingSelect");
			if (elem != null) {
				selectedOption = elem.options.selectedIndex;
			}
		}
		selectedOption++;
		if (selectedOption < 1) {
			selectedOption = 1;
		}
		changeContent("jss_1stepGoodsTotal","jss_1stepGoodsTotal",jss_replaceChars(totalsArray[selectedOption]["goodsTotal"]));
		if (totalsArray[selectedOption]["isDiscount"] == "Y") {
			jss_showTR('jss_1stepDiscountLine');
			if (totalsArray[selectedOption]["offerCode"] != "") {
				elem = document.getElementById("jss_1stepOfferCode");
				if (elem != null) {
					elem.style.visibility = "hidden";
					elem.style.display = "none";
				}
				jss_showIdInline('jss_1stepDiscountLine_offerCode');
				elem = document.getElementById("jss_1stepDiscountLine_offerCode_code");
				if (elem != null) {
					elem.innerHTML = totalsArray[selectedOption]["offerCode"];
				}
			} else {
				elem = document.getElementById("jss_1stepOfferCode");
				if (elem != null) {
					elem.style.visibility = "visible";
					elem.style.display = "inline";
				}
				jss_hideId('jss_1stepDiscountLine_offerCode');
			}
		} else {
			jss_hideTR('jss_1stepDiscountLine');
		}
		changeContent("jss_1stepDiscountTotal","",jss_replaceChars(totalsArray[selectedOption]["discountTotal"]));
		if (document.getElementById("jss_1stepTaxTotal")) {
			changeContent("jss_1stepTaxTotal","",jss_replaceChars(totalsArray[selectedOption]["taxTotal"]));
			changeContent("jss_1stepTaxTotal2","",jss_replaceChars(totalsArray[selectedOption]["taxTotal"]));
		}
		if (totalsArray[selectedOption]["isGiftCertificate"] == "Y") {
			jss_showTR('jss_1stepGiftCertificateLine');
		} else {
			jss_hideTR('jss_1stepGiftCertificateLine');
		}
		changeContent("jss_1stepGiftCertTotal","",jss_replaceChars(totalsArray[selectedOption]["giftCertTotal"]));
		changeContent("jss_1stepOrderTotal","",jss_replaceChars(totalsArray[selectedOption]["orderTotal"]));
		changeContent("jss_1stepOrderTotal2","",jss_replaceChars(totalsArray[selectedOption]["orderTotal"]));
		if (shippingEnabled) {
			changeContent("jss_1stepShippingTotal","",jss_replaceChars(totalsArray[selectedOption]["shippingTotal"]));
			changeContent("jss_1stepShippingTotal2","",jss_replaceChars(totalsArray[selectedOption]["shippingTotal"]));
		}
		selectedShippingID = totalsArray[selectedOption]["shippingID"];
	}

	function jss_1stepMakeCall(vars,returnFunction,requestObject) {
		requestObject.open("GET", oneStepAjaxURL+'&'+vars, true);
		requestObject.onreadystatechange = returnFunction; 
		requestObject.send(null);
	}

	function jss_1stepGo(additional) {
		if (jss_1stepRequest.readyState != 4 && jss_1stepRequest.readyState != 0) {
			jss_1stepRequest.abort();
		}
		if (jss_1stepRequest.readyState == 4 || jss_1stepRequest.readyState == 0) {
			
			form = document.getElementById("checkoutForm");
			selectedCounty = "";
			selectedCountry = form.elements["country"].options[form.elements["country"].selectedIndex].value;
			if (fieldCountyAsSelect) {
				selectedCounty = form.elements["county"].options[form.elements["county"].selectedIndex].value;
			}
			selectedaid = "";
			if (shippingAllowed) {
				deliveryType = jss_1stepDeliveryType();
				if (deliveryType != "billing") {
					if (deliveryType == "new") {
						selectedCountry = form.elements["deliveryCountry"].options[form.elements["deliveryCountry"].selectedIndex].value;
						if (fieldCountyAsSelect) {
							selectedCounty = form.elements["deliveryCounty"].options[form.elements["deliveryCounty"].selectedIndex].value;
						}
					} else {
						selectedaid = deliveryType;
					}
				}
			}
			reference = "";
			if (additional == "offercode") {
				elem = document.getElementById("xOfferCode");
				if (elem != null) {
					if (elem.value != "") {
						reference = escape(elem.value);
					} else {
						additional  = "";
					}	
				} else {
					additional = "";
				}
			}
			if (additional == "giftcert") {
				elem = document.getElementById("xGiftCertSerial");
				if (elem != null) {
					if (elem.value != "") {
						reference = escape(elem.value);
					} else {
						additional  = "";
					}	
				} else {
					additional = "";
				}
			}
			jss_1stepMakeCall("&country=" + selectedCountry+"&county="+selectedCounty+"&selectedaid="+selectedaid+"&additional="+additional+"&reference="+reference,jss_1setResult,jss_1stepRequest);
		}		
	}

	function jss_1setResult() {
		if (jss_1stepRequest.readyState == 4) {
			xmldoc = jss_1stepRequest.responseXML;
			resultcode = xmldoc.getElementsByTagName('code')[0].firstChild.data;
			resulttext = xmldoc.getElementsByTagName('literal')[0].firstChild.data;
			if (resultcode != 1) {
				return;
			}
			results = xmldoc.getElementsByTagName("shipping");
			totalsArray = new Array();
			if (results.length != 0) {
				for (j = 0; j < results.length; j++) {
					shippingID = results[j].getElementsByTagName("shippingID")[0].firstChild.data;
					name = results[j].getElementsByTagName("name")[0].firstChild.data;
					goodsTotal = results[j].getElementsByTagName("goodsTotal")[0].firstChild.data;
					isDiscount = results[j].getElementsByTagName("isDiscount")[0].firstChild.data;
					discountTotal = results[j].getElementsByTagName("discountTotal")[0].firstChild.data;
					taxTotal = results[j].getElementsByTagName("taxTotal")[0].firstChild.data;
					isGiftCertificate = results[j].getElementsByTagName("isGiftCertificate")[0].firstChild.data;
					giftCertTotal = results[j].getElementsByTagName("giftCertTotal")[0].firstChild.data;
					orderTotal = results[j].getElementsByTagName("orderTotal")[0].firstChild.data;
					shippingTotal = results[j].getElementsByTagName("shippingTotal")[0].firstChild.data;
					offerCode = results[j].getElementsByTagName("offerCode")[0].firstChild.data;
					if (offerCode == "null") {
						offerCode = "";
					}
					f = j + 1;
					totalsArray[f] = new Array();
					totalsArray[f]["shippingID"] = shippingID;
					totalsArray[f]["name"] = jss_replaceChars(name);
					totalsArray[f]["goodsTotal"] = goodsTotal;
					totalsArray[f]["isDiscount"] = isDiscount;
					totalsArray[f]["discountTotal"] = discountTotal;
					totalsArray[f]["taxTotal"] = taxTotal;
					totalsArray[f]["isGiftCertificate"] = isGiftCertificate;
					totalsArray[f]["giftCertTotal"] = giftCertTotal;
					totalsArray[f]["orderTotal"] = orderTotal;
					totalsArray[f]["shippingTotal"] = shippingTotal;
					totalsArray[f]["offerCode"] = offerCode;
				}
				if (shippingEnabled) {
					jss_1stepFillShipping();
				}
			} else {
				if (shippingEnabled) {
					jss_1stepFillShipping();
				}
			}
			results = xmldoc.getElementsByTagName("additional");
			additionalType = results[0].getElementsByTagName("type")[0].firstChild.data;
			additionalReference = results[0].getElementsByTagName("ref")[0].firstChild.data
			additionalResult = results[0].getElementsByTagName("result")[0].firstChild.data;
			if (additionalType == "offercode") {
				if (additionalResult == "OK") {
					elem = document.getElementById("jss_1stepOfferCode");
					if (elem != null) {
						elem.style.visibility = "hidden";
						elem.style.display = "none";
					}
					elem = document.getElementById("jss_1stepDiscountLine_offerCode");
					if (elem != null) {
						elem.style.visibility = "visible";
						elem.style.display = "inline";
					}
				} else {
					elem = document.getElementById("jss_1stepOfferCodeError");
					if (elem != null) {
						elem.style.visibility = "visible";
						elem.style.display = "inline";
					}
					elem = document.getElementById("jss_1stepDiscountLine_offerCode");
					if (elem != null) {
						elem.style.visibility = "hidden";
						elem.style.display = "none";
					}
				}
			}
			if (additionalType == "offercoderemove") {
				if (additionalResult == "OK") {
					jss_1stepUpdateTotals();
					elem = document.getElementById("jss_1stepOfferCode");
					if (elem != null) {
						elem.style.visibility = "visible";
						elem.style.display = "inline";
					}
				}
			}
			if (additionalType == "giftcert") {
				if (additionalResult == "OK") {
					elem = document.getElementById("jss_1stepGiftCertError");
					if (elem != null) {
						elem.style.visibility = "hidden";
						elem.style.display = "none";
					}
				} else {
					elem = document.getElementById("jss_1stepGiftCertError");
					if (elem != null) {
						elem.style.visibility = "visible";
						elem.style.display = "inline";
					}
				}
			}
			jss_1stepUpdateTotals();
		}
	}

	function jss_1stepDeliveryType() {
		elem = getFormElement("checkoutForm","xDeliveryAddressSelection");
		for (index=0; index < elem.length; index++) {
			if (elem[index].checked) {
				return elem[index].value;
			}
		}
	}

