function stopError() {
  return true;
}
var path = "http://"+document.domain+"/";

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 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 = 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 = 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) {
		lowerneedle = unescape(word.toLowerCase());
		lowerhaystack = line.toLowerCase();
		pos = lowerhaystack.indexOf(lowerneedle);
		bit = line.substr(pos,lowerneedle.length);
		line = line.replace(bit,"<span class=\"suggest_link_highlight\">"+bit+"</span>");
		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;
					jss_searchSuggestResults.push(str);
					var thisone = jss_searchSuggestHighlightWords(str,jss_searchRequestString,"<span class=\"suggest_link_highlight\">"+jss_searchRequestString+"</span>");
					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 = unescape(value);
		jss_searchSuggestEnd();
		jss_searchRequestParentForm.submit();
	}


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

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

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

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

	function jss_hideTR(id) {
		elem = document.getElementById(id);
		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 = 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");
			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');
		} 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"]));
		}
		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"]));
		if (shippingEnabled) {
			changeContent("jss_1stepShippingTotal","",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.value != "") {
					reference = escape(elem.value);
				} else {
					additional  = "";
				}	
			}
			if (additional == "giftcert") {
				elem = document.getElementById("xGiftCertSerial");
				if (elem.value != "") {
					reference = escape(elem.value);
				} 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) {
			var ss = document.getElementById('search_suggest')
			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;
					f = j + 1;
					totalsArray[f] = new Array();
					totalsArray[f]["shippingID"] = shippingID;
					totalsArray[f]["name"] = 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;
				}
				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");
					elem.style.visibility = "hidden";
					elem.style.display = "none";
				} else {
					elem = document.getElementById("jss_1stepOfferCodeError");
					elem.style.visibility = "visible";
					elem.style.display = "inline";
				}
			}
			if (additionalType == "giftcert") {
				if (additionalResult == "OK") {
					elem = document.getElementById("jss_1stepGiftCertError");
					elem.style.visibility = "hidden";
					elem.style.display = "none";
				} else {
					elem = document.getElementById("jss_1stepGiftCertError");
					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;
			}
		}
	}

function on_off_contact(ob)
{
	if (document.getElementById) 
	{	
		   document.getElementById('default').style.display='none';
		   document.getElementById('shipping').style.display='none';
		   document.getElementById('ordering').style.display='none';
		   document.getElementById('samples').style.display='none';
		   document.getElementById('payment').style.display='none';
		   document.getElementById('payment_opt').style.display='none';
		   document.getElementById('artwork').style.display='none';
		   document.getElementById('website').style.display='none';
		   document.getElementById('refp').style.display='none';
		   document.getElementById('pp').style.display='none';
		   document.getElementById('aff').style.display='none';
		   document.getElementById('contact').style.display='none';
		   document.getElementById('other').style.display='none';
		   document.getElementById(ob).style.display='';
	}
	if(document.layers) 
	{ 
		   document.layers['default'].style.display='none';
		   document.layers['shipping'].style.display='none';
		   document.layers['ordering'].style.display='none';
		   document.layers['samples'].style.display='none';
		   document.layers['payment'].style.display='none';
		   document.layers['payment_opt'].style.display='none';
		   document.layers['artwork'].style.display='none';
		   document.layers['website'].style.display='none';
		   document.layers['refp'].style.display='none';
		   document.layers['pp'].style.display='none';
		   document.layers['aff'].style.display='none';
		   document.layers['contact'].style.display='none';
		   document.layers['other'].style.display='none';
		   document.layers[ob].style.display='';
	}
}

function on_off(ob)
{
	if (document.getElementById) 
	{	
		 if (document.getElementById(ob).style.display=='none')
		  {  
		   document.getElementById(ob).style.display='';
//		   document.location=lx;
          }
		 else
		  {
		   document.getElementById(ob).style.display='none';  
		  }
	}
	if(document.layers) 
	{ 
		if (document.layers[ob].style.display=='none')
		  {  
		   document.layers[ob].style.display='';
		   //document.location=lx;
		  }
		 else
		  {
		   document.layers[ob].style.display='none';  
		  }	  
	}
}

function reloadImage(ipath){
	$('.product-image').get(0).src = ipath;
	return false;
}

function closeThisWin(){
	//var p = parent;
	apic.closeWindow();
	apic.delDarkScreen();
	return false;
}
	
function win_con(src,w,h){
	return '<iframe src="'+src+'" marginheight="0" marginwidth="0" frameborder="0" style="overflow:hidden; width:'+w+'px; height:'+h+'px;">';
}

var click_edit = null;
function editProductDetail(pid, t){
	click_edit = t;
	var data = {'width':200, 'height':200, 'position':'center'};
	var src = "http://www.water4fish.co.uk/templates/frame_tpls/edit_prod.php?pid="+pid;
	apic.createWindowContent();
	apic.addToWindowContent('<span style="display:block; background-color:#fff; border:3px solid #000; padding:5px;">'+win_con(src,980,520)+'</span>')
	if(!apic.issetDarkScreen())
		apic.setDarkScreen();
	apic.openWindow(data);
}

var click_edit_price = null;
function editProductPrice(pid, t){
	click_edit_price = t;
	var data = {'width':980, 'height':520, 'position':'center'};
	var src = "http://www.water4fish.co.uk/templates/frame_tpls/edit_prod_price.php?pid="+pid;
	apic.createWindowContent();
	apic.addToWindowContent('<span style="display:block; background-color:#fff; border:3px solid #000; padding:5px;">'+win_con(src,data.width,data.height)+'</span>')
	if(!apic.issetDarkScreen())
		apic.setDarkScreen();
	apic.openWindow(data);
}

function click_group(){
	var data = {'width':980, 'height':560, 'position':'center'};
	var src = "http://www.water4fish.co.uk/templates/frame_tpls/group_admin.php";
	apic.createWindowContent();
	apic.addToWindowContent('<span style="display:block; background-color:#fff; border:3px solid #000; padding:5px;">'+win_con(src,data.width,data.height)+'</span>')
	if(!apic.issetDarkScreen())
		apic.setDarkScreen();
	apic.openWindow(data);
}
function buyWarning(code, minmax){
	var data = {'width':460, 'height':180, 'position':'center'};
	var src = "http://www.water4fish.co.uk/templates/frame_tpls/warning_buy.php?code="+code+"&minmax="+minmax;
	apic.createWindowContent();
	apic.addToWindowContent('<span style="display:block; background-color:#fff; border:2px solid #000; padding:5px;">'+win_con(src,data.width,data.height)+'</span>')
	if(!apic.issetDarkScreen())
		apic.setDarkScreen();
	apic.openWindow(data);
}

function sendQuoteAlert(){
	var data = {'width':460, 'height':180, 'position':'center'};
	var src = "http://www.water4fish.co.uk/templates/frame_tpls/sendQuoteAlert.php";
	apic.createWindowContent();
	apic.addToWindowContent('<span style="display:block; background-color:#fff; border:2px solid #000; padding:5px;">'+win_con(src,data.width,data.height)+'</span>')
	if(!apic.issetDarkScreen())
		apic.setDarkScreen();
	apic.openWindow(data);
}

function savemyquote(code){
	var data = {'width':460, 'height':280, 'position':'center'};
	var src = "http://www.water4fish.co.uk/templates/frame_tpls/savemyquote.php?code="+code;
	apic.createWindowContent();
	apic.addToWindowContent('<span style="display:block; background-color:#fff; border:3px solid #000; padding:5px;">'+win_con(src,data.width,data.height)+'</span>')
	if(!apic.issetDarkScreen())
		apic.setDarkScreen();
	apic.openWindow(data);
	return false;
}

function setNewProdName(pname){
	$(click_edit).parents('.prodname').find('.prod_name').html(pname);
}
function setNewProdDesc(pname){
	$(click_edit).parents('.prodname').find('.prod_desc').html(pname);
}
function setNewProdPrintSize(pname){
	$(click_edit).parents('.prodname').find('.prod_printsize').html(pname);
}

function saveToSec(t, c){
	var pid = t;
	link = "http://www.water4fish.co.uk/templates/frame_tpls/update_prod.php?sid_pid="+pid+"&check="+c+"&return=true";
	return goTo(link);
}

var addToGroup_v = null;
function addToGroup(t, c, o){
	addToGroup_v = o;
	var pid = t;
	link = "http://www.water4fish.co.uk/templates/frame_tpls/update_group_list.php?pid="+pid+"&value="+c+"&return=true";
	$('#tosection').attr('action',link).submit();
	
	//return goTo(link);
}
/*
ustawienie nowego linku dla objektu przycisku oraz
zmiana html textu
*/
function addToGroupAction(link, text){
	$(addToGroup_v).attr('value', link);
	addToGroup_v.innerHTML = text;
}

function goTo(url, target)
{
		var a = document.createElement('A');
		if(!a.click) //for IE
		{
			window.location = url; //location nie wysyla referera dla IE
			return true;
		}
		
		a.setAttribute("href", url);
		a.style.display = "none";
		if(typeof target != 'undefined')
			a.target = target;
		document.body.appendChild(a);
		a.click();
		return true;
}

var c=0;
function show_text()
{
	if(c == 0)
	{
		//alert(getelement("textintropr").childNodes[0].tagName);
		if(getelement("textintropr2").childNodes[0].tagName != "TABLE")
			getelement("w4fmarketing").appendChild(getelement("textintropr2").childNodes[1]);
		else
			getelement("w4fmarketing").appendChild(getelement("textintropr2").childNodes[0]);
		c++;
	}
}

function imageMoverInitProd(listaimg, divnavi, hiddenImageText){
					
					$(divnavi+' span:first').click(function(){
						var i = this.parentNode.imgelement;
						moveImage(i,'L');
						$(divnavi).css('display','none');
					});
					
					$($(divnavi+' span').get(3)).click(function(){
						var i = this.parentNode.imgelement;
						moveImage(i,'R');	
						$(divnavi).css('display','none');
					});
					
					$(divnavi+' span.on').click(function(){
						var i = this.parentNode.imgelement;
						i.activeElement = true;
						i.style.border = "1px solid #00cc00";
						moveImage(i,'');
					});
					
					$(divnavi+' span.off').click(function(){
						var i = this.parentNode.imgelement;
						i.activeElement = false;
						i.style.border = "1px solid #cc0000";
						moveImage(i,'');
					});
					
					function moveImage(i,pos) {
						
						var posimg = 0; var min=1; var max=0; var par = i.parentNode;
						var lista = $(par).find('img.el').get();
						for(var o in lista){
							if(lista[o].tagName == 'IMG'){
								if(lista[o].src == i.src) posimg = o;
								par.removeChild(lista[o]);
								max++;
							}
						}
							
						if(pos == "L"){
							if(posimg >= min){
								var lista_t = lista[posimg-1];
								lista[posimg-1] = lista[posimg];
								lista[posimg] = lista_t;
							}
						}
	
						if(pos == "R"){
							if(posimg < max-1){
								var lista_t = lista[posimg];
								lista[posimg] = lista[parseInt(posimg)+1];
								lista[parseInt(posimg)+1] = lista_t;
							}
						}
						
						var text = $('#'+hiddenImageText).get(0);
						text.value = "";
						for(var o in lista){
							if(lista[o].tagName == 'IMG'){
								par.appendChild(lista[o]);
								if(lista[o].activeElement){
									if(text.value != "")
										text.value += ',';
									text.value += lista[o].alt;
								}
							}
						}
					}
					
					$(listaimg+' img.el').mouseover(function() {
						var position = $(this).position();
						$(divnavi).css('left',position.left);
						$(divnavi).css('top',position.top);
						$(divnavi).css('display','');
						if(this.activeElement){
							$(divnavi).find('span.off').css('display','');
							$(divnavi).find('span.on').css('display','none');
						}else{
							$(divnavi).find('span.on').css('display','');
							$(divnavi).find('span.off').css('display','none');
						}
						$(this.parentNode).find(divnavi).get(0).imgelement = this;
					}).mouseout(function() {
						//$('div.navi').css('display','none');
					});
					
					
					function initImage(){
						var text = $('#'+hiddenImageText).get(0);
						var lista1 = text.value.split(",");
						var lista2 = $(listaimg+' img.el').get();
						
						for(var i1 in lista1){
							for(var i2 in lista2){
								if(lista1[i1] == lista2[i2].alt){
									lista2[i2].activeElement = true;
								}
							}
						}
						
						imageOrganize(lista1);
					}
					
					function imageOrganize(ar1){
						var lista = $(listaimg+" img.el").get();
						var par = lista[0].parentNode;
						
						var tt1=new Array();
						var tt2=new Array();
						var x1=0;
						var x2=0;
						for(var i1 in ar1){
							for(var i2 in lista){
								if(ar1[i1] == lista[i2].alt){
									tt1[x1++] = lista[i2];
								}else{
									if(lista[i2].activeElement != true)
										tt2[x2++] = lista[i2];
								}
							}
						}
						
						for(var i2 in tt1){
							tt1[i2].style.border = "1px solid #00cc00";
							par.appendChild(tt1[i2]);
						}
						
						for(var i2 in tt2){
							tt2[i2].style.border = "1px solid #cc0000";
							par.appendChild(tt2[i2]);
						}
						
					}
					
					initImage();
				}
				
function addLogoFile(ciid){
	var data = {'width':420, 'height':300, 'position':'center'};
	var src = "http://www.water4fish.co.uk/templates/frame_tpls/uploadLogoFile.php?ciid="+ciid;
	apic.createWindowContent();
	apic.addToWindowContent('<span style="display:block; background-color:#fff; border:3px solid #000; padding:5px;">'+win_con(src,data.width,data.height)+'</span>')
	if(!apic.issetDarkScreen())
		apic.setDarkScreen();
	apic.openWindow(data);
	
	return false;
}

/*function upload file*/

function uploaderFile(){
	
	var filetypelist = null;
	var targetlist = null;
	var input_file_name = null;
	var _this = null;
	var bafter = null;
	
};

uploaderFile.prototype={
		_that:null,
		setTargetList:function (target){
			this._that = this;
			this.targetlist = target;
		},
	
		setEvent:function (o, name){
			o.onchange = this.newFuntion;
			o.parent = this;
			this.input_file_name = name;
			this.bafter = 'first';
		},
		newFuntion:function (e) {
			var UF = this.parent;
			var file_name = UF.getFileName(this.value)
			
			if(UF.checkFile(file_name)){
				this.nextSibling.innerHTML = file_name+'&nbsp;<a href="#" onclick="return new uploaderFile().removeFile(this);">delete</a>';
				//print_r(file_name);
				$($(this).css("display","none").get(0).nextSibling).css("display","");
			}else{
				var l1 = this.parentNode;
				var u1 = l1.parentNode;
				u1.removeChild(l1);
				
				alert("Not supported file extension");
			}
			
			var l = document.createElement("LI");
			l.innerHTML = '<input class="'+UF.input_file_name+'" type="file" max="999" min="1" multiple="true" name="filetmp[]"><div style="display:none"></div>';
			UF.addNewFile(l);
			UF.setEvent($(l).find("input").get(0));
		},
					
		getFileName:function (file_name){
			var end = (file_name.indexOf("?") == -1) ? file_name.length : file_name.indexOf("?");
			return file_name.substring(file_name.lastIndexOf("\\")+1, end);
		},
					
		getFileNameURL:function (file_name){
		    var end = (file_name.indexOf("?") == -1) ? file_name.length : file_name.indexOf("?");
			return file_name.substring(file_name.lastIndexOf("/")+1, end);
		},
					
		checkFile:function (f){
			var r = f.split('.');
			switch(r[r.length-1].toLowerCase()){
				//case "jpg":
				//case "pdf":
				case "cdr":
				case "ai":
				case "eps":
				case "tif":
				//case "png":
						return true;
					break;
				default:
						return false;
					break;
			}
		},
					
		addNewFile:function (c){
			switch(this.bafter){
				case 'first':{
						//insertBefore
						var ch = $(this.targetlist).get(0).firstChild;
						$(ch).before(c);
					}
					break;
				default:
					$(this.targetlist).get(0).appendChild(c);
					break;
			}	
		},
					
		getSize:function (filepath)
		{
			var myFSO = new ActiveXObject("Scripting.FileSystemObject");
			//var filepath = document.upload.file.value;
			var thefile = myFSO.getFile(filepath);
			var size = thefile.size;
			alert(size + " bytes");
		},
					
		print_r:function (o){
			var t = "";
			for(var i in o){
				t += i+" "+o[i]+"\n";
			}
			alert(t);
		},
					
		removeFile:function (o){
			var UF = new uploaderFile();
			UF.removeMe(o.parentNode.parentNode);
			return false;
		},
					
		removeMe:function (o){
			o.parentNode.removeChild(o);
		}
}
/*function upload file*/
function colorized(target){
	$(target).mouseover(function(){
		var n = apic.nextObj(this);
		var f = apic.getChild(n);
		$(f).css('color','#c00').css('fontWeight','bold');
		$(apic.nextObj(f)).css('color','#c00').css('fontWeight','bold');
	}).mouseout(function(){
		var n = apic.nextObj(this);
		var f = apic.getChild(n);
		$(f).css('color','').css('fontWeight','');
		$(apic.nextObj(f)).css('color','').css('fontWeight','');
	});
}

function showHintSec(t, _this){
	var opt = { 'marginTop':4, 'autohiden':600 };
	showHint(t,_this,'.hint_bl','left','right',opt);
}

function showHintProdName(t, _this){
	var opt = { 'marginTop':-24, 'autohiden':1000 };
	showHint(t,_this,'.hint_bl','down','left',opt);
}


//function()
var apic = {
	
	/*
	dark_screen start
	*/
	domain:document.domain,
	url:'http://'+document.domain+'/',
	darkScreenOnOff:null,
	
	createDarkScreen:function(){
		var d = this.newElement("DIV");
	
		d.className = 'darkcan';
		$(d).css('width',$(document).width()).css('height',$(document).height()).css('position','absolute')
		.css('left',0).css('top',0).css('backgroundColor','#000000').css('opacity','0.5').css('zIndex','100');
		
		document.body.appendChild(d);
		this.darkScreenOnOff = true;
	},
	
	setDarkScreen:function(){
		if(!this.darkScreenOnOff)
			this.createDarkScreen();
		else
			this.showDarkScreen();
	},
	
	showDarkScreen:function(){
		$('div.darkcan').css('display','');
	},
	
	closeDarkScreen:function(){
		$('div.darkcan').css('display','none');
	},
	
	hiddenDarkScreen:function(){
		this.closeDarkScreen();
	},
	
	delDarkScreen:function(){
		$('div.darkcan').remove();
		this.darkScreenOnOff = false;
	},
	
	issetDarkScreen:function(){
		if(this.darkScreenOnOff)
			return true;
		return false;
	},
	
	/*
	dark_screen end
	*/
	/*
	windows functions
	*/
	createWindowContent:function(){
		
		if(!this.isdefined($('.wincontent').get(0))){
			$(document.body).append('<div class="wincontent"></div>');
			$('.wincontent').css("position","absolute").css("display","none").css('zIndex','110');;
		}
		
	},
	
	addToWindowContent:function(html){
		if(this.isdefined($('.wincontent').get(0)))
			$('.wincontent').html(html);
	},
	
	openWindow:function(data){
		if(this.isdefined($('.wincontent').get(0))){
			
			//var width = data.width;
			//var height = data.height;
			var width = $('.wincontent').outerWidth();
			var height = $('.wincontent').outerHeight();
			
			var left = 0;
			var top = 0;
			var position = data.position;
			var scrollY = 0;
			
			if(this.isdefined(window.scrollY))
				scrollY = window.scrollY;
			else
				scrollY = $(window).scrollTop();
			
			switch(position){
				case "center":
					left = ( $(window).width()/2 ) - width/2;
					top = ( ( $(window).height()/2 ) - height/2 ) + scrollY;
					break;
			}
			
			$('.wincontent').css("left",left).css("top",top).css("display","");
			
		}
	},
	
	closeWindow:function(){
		if(this.isdefined($('.wincontent').get(0)))
			$('.wincontent').css("display","none");
	},
	/*
	windows functions end
	*/
	
	addChild:function(e){
		
	},
	
	newElement:function(e){
		return document.createElement(e);
	},
	
	delElement:function(e){
		this.getParent(e).removeChild(e);
	},
	
	/*boolean function*/
	isdefined:function(o){
		if(typeof o == 'undefined')
			return false;
		return true;
	},
	
	isNull:function(o){
	  if(o == null)
	   return true;
	  return false;
	},
	
	isTag:function(o, t){
		if(this.toupper(o.tagName) == this.toupper(t)){
			return true;
		}
		return false;
	},
	
	isTextNode:function(t){
		if(t.nodeName == "#text")
			return true;
		return false;
	},
	/*boolean function*/
	
	/*string function*/
	toupper:function(str){
    	return (str + '').toUpperCase();
	},
	
	tolower:function(str){
		return (str + '').toLowerCase();
	},
	
	strpos:function(haystack, needle, offset) {
	    // http://kevin.vanzonneveld.net
	    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
	    // +   improved by: Onno Marsman    
	    // +   bugfixed by: Daniel Esteban
	    // +   improved by: Brett Zamir (http://brett-zamir.me)
	    // *     example 1: strpos('Kevin van Zonneveld', 'e', 5);
	    // *     returns 1: 14
	
	    var i = (haystack+'').indexOf(needle, (offset || 0));
	    return i === -1 ? false : i;
	},
	
	strrpos:function(haystack, needle, offset) {
	    // http://kevin.vanzonneveld.net
	    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
	    // +   bugfixed by: Onno Marsman
	    // +   input by: saulius
	    // +   bugfixed by: Brett Zamir (http://brett-zamir.me)
	    // *     example 1: strrpos('Kevin van Zonneveld', 'e');
	    // *     returns 1: 16
	    // *     example 2: strrpos('somepage.com', '.', false);
	    // *     returns 2: 8
	    // *     example 3: strrpos('baa', 'a', 3);
	    // *     returns 3: false
	    // *     example 4: strrpos('baa', 'a', 2);
	    // *     returns 4: 2
	
	    var i = -1;
	    if (offset) {
	        i = (haystack+'').slice(offset).lastIndexOf(needle); // strrpos' offset indicates starting point of range till end,
	        // while lastIndexOf's optional 2nd argument indicates ending point of range from the beginning
	        if (i !== -1) {
	            i += offset;
	        }
	    }
	    else {
	        i = (haystack+'').lastIndexOf(needle);
	    }
	    return i >= 0 ? i : false;
	},
	trim2:function(str) {
		var whitespace = ' \n\r\t\f\x0b\xa0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u3000';
		for (var i = 0; i < str.length; i++) {
			if (whitespace.indexOf(str.charAt(i)) === -1) {
				str = str.substring(i);
				break;
			}
		}
		for (i = str.length - 1; i >= 0; i--) {
			if (whitespace.indexOf(str.charAt(i)) === -1) {
				str = str.substring(0, i + 1);
				break;
			}
		}
		return whitespace.indexOf(str.charAt(0)) === -1 ? str : '';
	},
	trim:function(str) {
		str = str.replace(/^\s+/, '');
		for (var i = str.length - 1; i >= 0; i--) {
			if (/\S/.test(str.charAt(i))) {
				str = str.substring(0, i + 1);
				break;
			}
		}
		return str;
	},

	
	/*string function*/
	
	/*
	dodac drugi parametr okreslajacy ktory element jako nastepny wyszukac narazie 
	drugi parametr nieistnieje a okreslany jest jako pierwszy kolejny po 
	okreslonym objekcie
	*/
	nextObj:function(t){
		var o = t.nextSibling;
		if(this.isNull(o))
		  return null;
		if(this.isTextNode(o))
			return this.nextObj(o);
		return o;
	},
	prevObj:function(t){
		var o = t.previousSibling;
		if(this.isNull(o))
		  return null;
		if(this.isTextNode(o))
			return this.prevObj(o);
		return o;
	},
	
	getParent:function(t){
    	return t.parentNode;
	},
	
	findParent:function(t,tagName){
    var par = t.parentNode;
    if(typeof par == 'undefined' || par == null) return false;
    if( !this.isTag(par,tagName) )
      return this.findParent(par, tagName);
    else
      return par;
  },
	firstChild:function(t){
    var c = t.firstChild;

    while( this.isTextNode(c) ){
      c = this.nextObj(c);
      if(this.isNull(c))
        return undefined;
    }
    
    return c;
	},
	/*
   * t = object
   * n = number position child
  */
	getChild:function(t, n){
	  if(!this.isdefined(t.children)){
	    
	    var ar = {};
	    var wsk = 0;
	    var c = this.firstChild(t);
      ar[wsk++] = c;  
      while( true ){
        c = this.nextObj(c);
        if(this.isNull(c))
          break;
        ar[wsk++] = c;
      }
      ar['length'] = wsk;
      t.children = ar;
	  }
	  
	  if(this.isdefined(n)){
	    
	    switch(n){
	      case 'first':
	         n = 0;
	       break;
	      case 'last':
	         n = this.getChild(t).length-1;
	       break;
	    }
	    if(n == 'all')
        return t.children;
	    else
        return t.children[n];
    }
    else
      return t.children;
	},
	
	getChild_old:function(t, n, tag){
	  /*
     * old version
     * if function on up dont work 
     * must runing om down functions
     */

    var tag_bit = false;
    if(this.isdefined(tag))
      tag_bit = true;
      
    if(!this.isdefined(n))
      n = 1;
    if(n == 0)
      return undefined;
    
    if(n == 'first' || n == 1){
      if(!this.isdefined(t.children) || tag_bit){
        var c = t.firstChild;
        
        while( this.isTextNode(c) || ( !this.isTag(c,tag) && tag_bit ) ){
          c = this.nextObj(c);
          if(this.isNull(c))
            return undefined;
        }
        
        return c;
      }else{
        return t.children[0];
      }
    }
    
    if(n > 0){
      return t.children[n-1];
    }
    
    if(n == 'last'){
      return t.children[t.children.length-1];
    }
    
    return undefined;
	},
	/*
   * t = object
   * n = number position child
   * tag = tagName searching object
  */
	findChild:function(t, n, tag){
	  
    var pos = 0;
	  var wsk = 0;
	  var lista = this.getElements(t, tag);
	  switch(n){
      case 'first':
        n = 0;
      break;
      case 'last':
        n = lista.length-1;
      break;
    }
	  return lista[n];
	},
	/*
	 * private function
	 * 
	*/
	getElements:function(t, tag){
	  var ar = {};
    var pos = 0;
    var wsk = 0;
    var tag_bit = false;
    if(this.isdefined(tag))
      tag_bit = true;
      
    if(!tag_bit){
      return this.getChild(t,'all');
    }
      
    while(true){
      var c = this.getChild(t,pos++)
      if(this.isNull(c))
        break;
      if(this.isTag(c,tag))
        ar[wsk++] = c;
    }
    ar.length = wsk;
    return ar;
	}

};//() //end apic

/*HINT*/
var hinttimeout=0;
var hintatimeout=0;
/*
txt = text message
tar = target must by text format like jquery
hitar = this is div or any object target must by text format like jquery
p1 = left, right, down - position arrow for box
p2 = left, right, center  - position arrow for wall
option = more options
*/
function showHint(txt, tar, hitar, p1, p2, option){
	var p = $(tar);
	var offset1 = p.offset();
	var offset = p.position();
	
	if(typeof option  == 'undefined') option = {};
	if(option == null) option = {};
	
	if(typeof option.marginLeft == 'undefined') marginL = 0; else marginL = option.marginLeft;
	if(typeof option.marginTop  == 'undefined') marginT = 0; else marginT = option.marginTop;
	if(typeof option.width  == 'undefined') hint_width = 0; else hint_width = option.width;
	if(typeof option.zIndex  == 'undefined') hint_zIndex = 0; else hint_zIndex = option.zIndex;
	if(typeof option.autowrap  == 'undefined') autowrap = true; else autowrap = option.autowrap;
	if(typeof option.position  == 'undefined') position = ''; else position = option.position;
	if(typeof option.autohiden  == 'undefined') autohiden = 0; else autohiden = option.autohiden;

	var hitaro = $(hitar);
	clearTimeout(hinttimeout);
	clearTimeout(hintatimeout);
	
	if(autohiden > 0){
		hintatimeout = setTimeout(function(){closeHint(10);},autohiden);
	}
	
	if(marginT == 'up'){
		position = 'up';
		marginT = 0;
	}
	if(position == 'up'){
		marginT += -1*hitaro.height();
	}
	
	var ptop = marginT+offset1.top;
	var pleft = marginL+offset1.left;
	
	var pos = apic.strpos(txt,' ',0);
	if(hint_width > 0 && autowrap && pos == false){
		var l = txt.length;
		var txt2='';
		
		for(var x=0; x<l; x++){
			txt2 += txt.charAt(x);
			if(x%14==0 && x>0){
				txt2 += " ";
			}
		}
		txt = txt2;
	}
	
	if(hint_zIndex > 0)
		hitaro.css('zIndex',hint_zIndex);
		
	hitaro.css('opacity',1).css('display','').css('top',ptop-4+'px').find('div.txt').html(txt);
	if(hint_width > 0){
		hitaro.css('width',hint_width+'px');
	}else{
		hitaro.css('width','auto');
	}
	
	var c = hitaro.find("div.c");
		
	switch(p1){
		case "left":
			{
				c.css('border-color', 'transparent #000000').css('border-style','solid').css('border-width', '9px 0 9px 9px').css('top','0px').
				css('right','0').css('margin','0px').css('left','auto').css('top','0').css('bottom','auto');
				hitaro.css('left',pleft-hitaro.outerWidth()+'px').css('padding-right','9px');
			}
			break;
		case "right":
			{
				c.css('border-color', 'transparent #000000').css('border-style','solid').css('border-width', '9px 9px 9px 0').css('top','0px').
					css('left','0').css('margin','0px').css('right','auto').css('top','0').css('bottom','auto');
				hitaro.css('left',pleft+p.outerWidth()+9+'px').css('padding-left','9px');
			}
			break;
		case "down":
		{
			hitaro.css('padding','0px 0px 8px 0px');
			c.css('border-color', '#000000 transparent').css('border-style','solid').css('border-width', '8px 8px 0px').css('top','auto').css('bottom','0px');
			switch(p2){
				case 'left':
					c.css('left','0px').css('right','auto').css('margin-left','0');
					hitaro.css('left',pleft+'px');
					break;
				case 'right':
					c.css('right','0px').css('left','auto').css('margin-left','0');
					hitaro.css('left',pleft-(hitaro.width()-16)+'px');
					break;
				case 'center':
					c.css('left','50%').css('right','auto').css('margin-left','-8px');
					hitaro.css('left',pleft-(hitaro.width()-16)/2+'px');
					break;
			}
		}
		break;
	}
}

function closeHint(sleep){
	clearTimeout(hintatimeout);
	if(typeof sleep == 'undefined') sleep = 0;
	if(sleep > 0){
		closeHintSleep($('.hint_bl'), sleep, 100);
	}else{
		$('.hint_bl').css('display','none');
	}
}

function closeHintSleep(ob, sleep, o){
	ob.css('opacity',o/100);
	if(sleep-- >0){
		hinttimeout = setTimeout(function(){closeHintSleep(ob, sleep, o-10);},50);
	}else{
		ob.css('display','none');
	}
}
/*HINT*/

/*
 * dodawnia fun clone dla objectow
 * w jquery przy css powoduje bledy prawdopodobnie problemem jest recurencja
*/
/*Object.prototype.clone = function() {
      var newObj = (this instanceof Array) ? [] : {};
      for (i in this) {
        if (i == 'clone') continue;
        if (this[i] && typeof this[i] == "object") {
          newObj[i] = this[i].clone();
        } else newObj[i] = this[i]
      } return newObj;
    };*/
    
var css;
function include_css(css_file) {
    var html_doc = document.getElementsByTagName('head')[0];
    css = document.createElement('link');
    css.setAttribute('rel', 'stylesheet');
    css.setAttribute('type', 'text/css');
    css.setAttribute('href', css_file);
    html_doc.appendChild(css);

    // alert state change
    css.onreadystatechange = function () {
        if (css.readyState == 'complete') {
            alert('CSS onreadystatechange fired');
        }
    }
    css.onload = function () {
        alert('CSS onload fired');
    }
    return false;
}

var js;
function include_js(file) {
    var html_doc = document.getElementsByTagName('head')[0];
    js = document.createElement('script');
    js.setAttribute('type', 'text/javascript');
    js.setAttribute('src', file);
    html_doc.appendChild(js);

    js.onreadystatechange = function (t) {
        //IE6
        //loading, interactive, loaded
        switch(js.readyState){
          case 'complete':
          case 'loaded':
              alert('JS onreadystate fired');
            break;
        }
    }

    js.onload = function () {
        alert('JS onload fired');
    }
    return false;
}

/*
Source: http://www.phpied.com/javascript-include-ready-onload/
Results

As you can probably guess, the results are different in IE and FF.

    * CSS inclusion - IE fires both events, onload first, then onreadystatechange. FF fires nothing.
    * JS inclusion - IE fires onreadystatechange. FF fires onload. Both will execute the script before firing the event.

Conclusion

1. So there is, after all, a cross-browser way to tell when a JavaScript is actually included and that is to attach two event listeners - onload and onreadystatechange.
2. In IE you have two ways to tell when a CSS is included.
*/

var checkCss = ( function ( ) { 
        var div = document. createElement ( 'div' ) , 
        vendors = 'Khtml Ms O Moz Webkit' . split ( ' ' ) , 
        len = vendors. length ; 
  
        return function ( prop ) { 
  
          if ( prop in div. style ){
            return true ; 
          }
          prop = prop. replace ( /^[az]/ , function ( val ) {
            return val. toUpperCase ( ) ; 
          }) ; 
  
          while ( len -- ) { 
            if ( vendors [ len ] + prop in div. style ) { 
              // browser supports box-shadow.  Do what you need. 
              // Or use a bang (!) to test if the browser doesn't. 
              return true ; 
            }
          } 
          return false ; 
        }; 
      }) () ;

var BrowserDetect = {
  init: function () {
    this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
    this.version = this.searchVersion(navigator.userAgent)
      || this.searchVersion(navigator.appVersion)
      || "an unknown version";
    this.OS = this.searchString(this.dataOS) || "an unknown OS";
    this.engine = navigator.product;
    this.engineVer = navigator.productSub;
  },
  searchString: function (data) {
    for (var i=0;i<data.length;i++) {
      var dataString = data[i].string;
      var dataProp = data[i].prop;
      this.versionSearchString = data[i].versionSearch || data[i].identity;
      if (dataString) {
        if (dataString.indexOf(data[i].subString) != -1)
          return data[i].identity;
      }
      else if (dataProp)
        return data[i].identity;
    }
  },
  searchVersion: function (dataString) {
    var index = dataString.indexOf(this.versionSearchString);
    if (index == -1) return;
    return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
  },
  dataBrowser: [
    {
      string: navigator.userAgent,
      subString: "Chrome",
      identity: "Chrome"
    },
    {   string: navigator.userAgent,
      subString: "OmniWeb",
      versionSearch: "OmniWeb/",
      identity: "OmniWeb"
    },
    {
      string: navigator.vendor,
      subString: "Apple",
      identity: "Safari",
      versionSearch: "Version"
    },
    {
      prop: window.opera,
      identity: "Opera"
    },
    {
      string: navigator.vendor,
      subString: "iCab",
      identity: "iCab"
    },
    {
      string: navigator.vendor,
      subString: "KDE",
      identity: "Konqueror"
    },
    {
      string: navigator.userAgent,
      subString: "Firefox",
      identity: "Firefox"
    },
    {
      string: navigator.vendor,
      subString: "Camino",
      identity: "Camino"
    },
    {   // for newer Netscapes (6+)
      string: navigator.userAgent,
      subString: "Netscape",
      identity: "Netscape"
    },
    {
      string: navigator.userAgent,
      subString: "MSIE",
      identity: "Explorer",
      versionSearch: "MSIE"
    },
    {
      string: navigator.userAgent,
      subString: "Gecko",
      identity: "Mozilla",
      versionSearch: "rv"
    },
    {     // for older Netscapes (4-)
      string: navigator.userAgent,
      subString: "Mozilla",
      identity: "Netscape",
      versionSearch: "Mozilla"
    }
  ],
  dataOS : [
    {
      string: navigator.platform,
      subString: "Win",
      identity: "Windows"
    },
    {
      string: navigator.platform,
      subString: "Mac",
      identity: "Mac"
    },
    {
      string: navigator.userAgent,
      subString: "iPhone",
      identity: "iPhone/iPod"
    },
    {
      string: navigator.platform,
      subString: "Linux",
      identity: "Linux"
    }
  ]

};
BrowserDetect.init();

function clickProduct(a, pid, sid, pos){
	//var src = path+"mod/stats.php?pr="+pid+"&se="+sid+"&loc="+URLEncode(l).replace(/\+/g,"%2B")+"&t="+i;
	var src = path+"mod/stats.php?pr="+pid+"&se="+sid+"&pos="+pos;
	var url = a.href;
	return clk(src, url);
}

function clickProductIndexAZ(a, pid, sid, pos){
	//var src = path+"mod/stats.php?pr="+pid+"&se="+sid+"&loc="+URLEncode(l).replace(/\+/g,"%2B")+"&t="+i;
	var src = path+"mod/stats.php?pr="+pid+"&se="+sid+"&pos="+pos+"&target=indexaz";
	var url = a.href;
	return clk(src, url);
}

var roimg;
function clk(src, url)
{
	if(document.images)
	{
		var a=encodeURIComponent||escape,b=new Image;
		roimg=b;
		b.onerror=b.onload=b.onabort=function(){
			delete roimg
			if(url && url != "")
			{
				goTo(url);
			}
		};
		var l=window.location+"";
		var i=(new Date).getTime();
		b.src=src;
	}
	return false;

};

function URLEncode (clearString) {
  var output = '';
  var x = 0;
  alert('dd1');
  clearString = clearString.toString();
  var regex = /(^[a-zA-Z0-9_.]*)/;
  alert('dd2');
  while (x < clearString.length) {
    var match = regex.exec(clearString.substr(x));
    if (match != null && match.length > 1 && match[1] != '') {
    	output += match[1];
      x += match[1].length;
    } else {
      if (clearString[x] == ' ')
        output += '+';
      else {
        var charCode = clearString.charCodeAt(x);
        var hexVal = charCode.toString(16);
        output += '%' + ( hexVal.length < 2 ? '0' : '' ) + hexVal.toUpperCase();
      }
      x++;
    }
  }
  return output;
}

function addfav(url,title)
{
	if (document.all)
	{
		window.external.AddFavorite (url,title)
	}
}

function pop_gallery(url) 
{
	var name='';
	var args='WIDTH=630,HEIGHT=600,scrollbars=yes';
	if (typeof(popupWin1) != "object")
	{
		popupWin1 = window.open(url, name, args);
	} 
	else 
	{
		if (!popupWin1.closed)
	  	{ 
	  		popupWin1.location.href = url;
	  	} 
	  	else 
	  	{
	  		popupWin1 = window.open(url,  name, args);
	  	}
	}
	popupWin1.focus();
}



