function getCartItem(nIndex)
{var act_cart=getCookie("CART_CONTENT")
var sTemp=(act_cart!=null)?sTemp=act_cart.split("\t"):0;return(sTemp.length>0)?sTemp[nIndex]:0;}
function GotoAnchor(sAnchor)
{window.location.hash=sAnchor;}
(function(s){var m={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'};s.parseJSON=function(filter){try{if(/^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/.
test(this)){var j=eval('('+this+')');if(typeof filter==='function'){function walk(k,v){if(v&&typeof v==='object'){for(var i in v){if(v.hasOwnProperty(i)){v[i]=walk(i,v[i]);}}}
return filter(k,v);}
j=walk('',j);}
return j;}}catch(e){}
throw new SyntaxError("parseJSON");};})(String.prototype);function ajaxObject(url,callbackFunction)
{var that=this;this.updating=false;this.abort=function()
{if(that.updating)
{that.updating=false;that.AJAX.abort();that.AJAX=null;}}
this.update=function(passData,postMethod)
{if(that.updating){return false;}
that.AJAX=null;if(window.XMLHttpRequest)
{that.AJAX=new XMLHttpRequest();}
else
{that.AJAX=new ActiveXObject("Microsoft.XMLHTTP");}
if(that.AJAX==null)
{return false;}
else
{that.AJAX.onreadystatechange=function()
{if(that.AJAX.readyState==4)
{that.updating=false;that.callback(that.AJAX.responseText,that.AJAX.status,that.AJAX.responseXML);that.AJAX=null;}}
that.updating=new Date();if(/post/i.test(postMethod))
{var uri=urlCall+'?'+that.updating.getTime();that.AJAX.open("POST",uri,true);that.AJAX.setRequestHeader("Content-type","application/x-www-form-urlencoded");that.AJAX.setRequestHeader("Content-Length",passData.length);that.AJAX.send(passData);}
else
{var uri=urlCall+'?'+passData+'&timestamp='+(that.updating.getTime());that.AJAX.open("GET",uri,true);that.AJAX.send(null);}
return true;}}
var urlCall=url;this.callback=callbackFunction||function(){};}
function getStockNodes()
{var arrOut=new Array();if(document.evaluate)
{var xpathString="//*[@class='ActinicRTS']"
var xpathResult=document.evaluate(xpathString,document,null,0,null);while((arrOut[arrOut.length]=xpathResult.iterateNext())){}
arrOut.pop();}
else if(document.getElementsByTagName)
{var aEl=document.getElementsByTagName('*');for(var i=0,j=aEl.length;i<j;i+=1)
{if(aEl[i].className=='ActinicRTS')
{arrOut.push(aEl[i]);};};};return arrOut;}
function getSectionStock(sURL,sSID,sProdRefs,sStockList,sShopID)
{var mapStockByRef={};if(sURL.indexOf("file://")==0)
{var arrProds=sProdRefs.split("|");var arrStock=sStockList.split("|");for(var i=0;i<arrProds.length;i++)
{var aRef=arrProds[i].split("!");var sKey=aRef[aRef.length-1];mapStockByRef[sKey]=arrStock[i];}
updateStockDisplay(mapStockByRef);}
else
{var ajaxRequest=new ajaxObject(sURL);ajaxRequest.callback=function(responseText)
{mapStockByRef=responseText.parseJSON();updateStockDisplay(mapStockByRef);}
var sParams="ACTION=GETSECTIONSTOCK&SID="+sSID;if(sShopID)
{sParams+='&SHOP='+sShopID;}
ajaxRequest.update(sParams,"GET");}}
function updateStockDisplay(mapStockByRef)
{var arrStockElems=getStockNodes();for(var nIndex=0;nIndex<arrStockElems.length;nIndex++)
{var aRef=arrStockElems[nIndex].id.split("_");var sProdRef=aRef[aRef.length-1];var sIDStart=arrStockElems[nIndex].id.substring(0,arrStockElems[nIndex].id.length-sProdRef.length-1);if(mapStockByRef[sProdRef]!=null)
{if(sIDStart=='StockLevel')
{arrStockElems[nIndex].innerHTML=mapStockByRef[sProdRef];}
if(sIDStart=='EnableIfOutOfStock')
{if(mapStockByRef[sProdRef]<=0)
{arrStockElems[nIndex].style.visibility="visible";arrStockElems[nIndex].style.display="inline";}
else
{arrStockElems[nIndex].style.visibility="hidden";arrStockElems[nIndex].style.display="none";}}
if(sIDStart=='RemoveIfOutOfStock')
{if(mapStockByRef[sProdRef]<=0)
{arrStockElems[nIndex].innerHTML="";}}
if(sIDStart=='EnableIfInStock')
{if(mapStockByRef[sProdRef]>0)
{arrStockElems[nIndex].style.visibility="visible";arrStockElems[nIndex].style.display="inline";}
else
{arrStockElems[nIndex].style.visibility="hidden";arrStockElems[nIndex].style.display="none";}}
if(sIDStart=='RemoveIfInStock')
{if(mapStockByRef[sProdRef]>0)
{arrStockElems[nIndex].innerHTML="";}}
if(sIDStart=='EnableIfStockOk')
{arrStockElems[nIndex].style.visibility="visible";arrStockElems[nIndex].style.display="inline";}}}}
function AttachEvent(obj,eventName,eventHandler)
{if(obj)
{if(eventName.substring(0,2)=="on")
{eventName=eventName.substring(2,eventName.length);}
if(obj.addEventListener)
{obj.addEventListener(eventName,eventHandler,false);}
else if(obj.attachEvent)
{obj.attachEvent("on"+eventName,eventHandler);}}}
function ValidateCartNameDetails()
{var elemDiv=document.getElementById("idRowCartNamePassword");if(!elemDiv)
{return true;}
if(elemDiv.style.display=="none")
{elemDiv.style.display="";return(false);}
var elemInput=document.getElementById("idCartName");if(elemInput.value=='')
{alert('Username must be filled in');return false;}
elemInput=document.getElementById("idCartPassword");if(elemInput.value=='')
{alert('Password must be filled in');return false;}
return true;}
function DeliveryCountryChanged()
{CountryChanged('Delivery');}
function InvoiceCountryChanged()
{CountryChanged('Invoice');}
function CountryChanged(sLocationType)
{var cmbCountry=document.getElementById('lst'+sLocationType+'Country');if(!cmbCountry)
{return;}
SetCountryTextFieldDisplay(sLocationType,'');var cmbState=document.getElementById('lst'+sLocationType+'Region');if(!cmbState||!cmbState.options)
{return;}
var editState=document.getElementById('id'+sLocationType+'RegionEdit');var sStateName=editState?editState.value:'';var sCurrentState=cmbState.value;cmbState.options.length=1;if(cmbCountry.value=="UndefinedRegion")
{cmbState.style.display="none";if(editState)
{editState.style.display="";}
return;}
var chkSeparateShip=document.getElementById("idSEPARATESHIP");var bSeparateShip=chkSeparateShip&&chkSeparateShip.checked;var mapCountries=(sLocationType=='Delivery')?g_mapDeliveryCountryStateMap:g_mapInvoiceCountryStateMap;var arrOptions=mapCountries[cmbCountry.value];if(!arrOptions&&sLocationType=='Invoice'&&!bSeparateShip&&g_mapDeliveryCountryStateMap[cmbCountry.value])
{arrOptions=g_mapDeliveryCountryStateMap[cmbCountry.value];}
if(!arrOptions)
{cmbState.style.display="none";if(editState)
{editState.style.display="";}
return;}
cmbState.style.display="";if(editState)
{editState.style.display="none";}
var bFound=false;for(var i=0;i<arrOptions.length;i+=2)
{var oOption=document.createElement("OPTION");oOption.text=arrOptions[i+1];oOption.value=arrOptions[i];if(oOption.value==sCurrentState||oOption.text==sStateName)
{bFound=true;sCurrentState=oOption.value;oOption.selected=true;}
cmbState.options.add(oOption);}
if(bFound)
{cmbState.value=sCurrentState;}}
function SetCountryTextFieldDisplay(sLocationType,sDisplay)
{var sTextID=(sLocationType=='Delivery')?'idDELIVERCOUNTRYText':'idINVOICECOUNTRYText';var elemCountryText=document.getElementById(sTextID);if(elemCountryText)
{var cmbCountry=document.getElementById('lst'+sLocationType+'Country');elemCountryText.style.display=(cmbCountry&&cmbCountry.value=='---')?sDisplay:'none';}}
function SetDeliveryAddressVisibility()
{if(document.getElementById("idInvoiceRule")||document.getElementById("idDeliveryRule"))
{SetAccountAddressVisibility();return;}
SetInvoiceCountries();var chkSeparateShip=document.getElementById("idSEPARATESHIP");var sDisplay="none";if(chkSeparateShip.checked)
{sDisplay="";}
var cellSeparateShip=document.getElementById("idSeparateShipCell");if(document.getElementById("idDeliverHeader"))
{if(cellSeparateShip)
{cellSeparateShip.colSpan=sDisplay?1:2;}}
SetTableCellsDisplay("idBothAddressesTable","DeliverField",sDisplay);var chkResidential=document.getElementById("idINVOICERESIDENTIAL");if(chkResidential)
{chkResidential.style.display=(chkSeparateShip.checked)?'none':'';}
InvoiceCountryChanged();}
function SetAccountAddressVisibility()
{var sDisplay="";var bNewInvoiceAddress=IsElementChecked("idINVOICEADDRESSSELECT_0");var bNewDeliverAddress=IsElementChecked("idDELIVERADDRESSSELECT_0");if(!bNewInvoiceAddress&&!bNewDeliverAddress)
{sDisplay="none";}
var tblTarget=document.getElementById("idBothAddressesTable");if(!tblTarget)
{return;}
for(var nRow=0;nRow<tblTarget.rows.length;nRow++)
{var elemRow=tblTarget.rows[nRow];if(elemRow.className!="ShowAlways")
{elemRow.style.display=sDisplay;}}
if(sDisplay=='none')
{return;}
sDisplay=bNewInvoiceAddress?"":"none";SetTableCellsChildDisplay("idBothAddressesTable","InvoiceField",sDisplay);if(sDisplay!='none')
{InvoiceCountryChanged();}
sDisplay="none";if(bNewDeliverAddress)
{if(!bNewInvoiceAddress||IsElementChecked("idSEPARATESHIP"))
{sDisplay="";}}
SetTableCellsChildDisplay("idBothAddressesTable","DeliverField",sDisplay);if(sDisplay!='none')
{DeliveryCountryChanged();}
var rowSeparateShip=document.getElementById("idSeparateShipRow");if(rowSeparateShip)
{rowSeparateShip.style.display=bNewInvoiceAddress&&bNewDeliverAddress?'':'none';}}
function IsElementChecked(sID)
{var elemCheck=document.getElementById(sID);if(elemCheck&&elemCheck.checked)
{return true;}
return false;}
function SetTableCellsDisplay(sTableID,sClassName,sDisplay)
{var tblTarget=document.getElementById(sTableID);if(!tblTarget)
{return;}
for(var nRow in tblTarget.rows)
{var elemRow=tblTarget.rows[nRow];for(var nCell in elemRow.cells)
{var elemCell=elemRow.cells[nCell];if(elemCell.className&&elemCell.className==sClassName)
{elemCell.style.display=sDisplay;}}}}
function SetTableCellsChildDisplay(sTableID,sClassName,sDisplay)
{var tblTarget=document.getElementById(sTableID);if(!tblTarget)
{return;}
for(var nRow=0;nRow<tblTarget.rows.length;nRow++)
{var elemRow=tblTarget.rows[nRow];if(elemRow.className!='ShowAlways')
{for(var nCell=0;nCell<elemRow.cells.length;nCell++)
{var elemCell=elemRow.cells[nCell];if(elemCell.className&&elemCell.className==sClassName)
{for(var i=0;i<elemCell.childNodes.length;i++)
{var elemChild=elemCell.childNodes[i];if(elemChild.style&&elemChild.id.indexOf('pcaDiv')!=0)
{elemCell.childNodes[i].style.display=sDisplay;}}}}}}}
function SetShoppingCartVisibility()
{var elemShowHide=document.getElementById("idShowHide");if(!elemShowHide)
{return;}
var spanShoppingCart=document.getElementById("idShoppingCartGrid");if(!spanShoppingCart)
{return;}
var elemCartHeadingTotal=document.getElementById("idCartHeadingTotal");var elemCartChangeCell=document.getElementById("idCartChangeCell");if(spanShoppingCart.style.display=="none")
{spanShoppingCart.style.display="";elemShowHide.innerHTML='hide';elemCartHeadingTotal.style.display='none';if(elemCartChangeCell)
{document.getElementById("idCartChangeCell").style.display='';}}
else
{spanShoppingCart.style.display="none";elemShowHide.innerHTML='show';elemCartHeadingTotal.style.display='';if(elemCartChangeCell)
{document.getElementById("idCartChangeCell").style.display='none';}}}
function SetCreditCardFieldsVisibility()
{var nPaymentMethod=GetPaymentMethod();var sDisplay="none";if(nPaymentMethod=="10005")
{sDisplay="";}
SetTableRowsDisplay("idPaymentMethodTable","CreditCardField",sDisplay);}
function SetTableRowsDisplay(sTableID,sClassName,sDisplay)
{var tblTarget=document.getElementById(sTableID);if(!tblTarget)
{return;}
for(var nRow in tblTarget.rows)
{var elemRow=tblTarget.rows[nRow];if(elemRow.className&&elemRow.className==sClassName)
{elemRow.style.display=sDisplay;}}}
function CheckForm(elemBtn)
{var elemForm=elemBtn.parentElement?elemBtn.parentElement:elemBtn.parentNode;while(elemForm&&elemForm.tagName!="FORM")
{elemForm=elemForm.parentElement?elemForm.parentElement:elemForm.parentNode;}
if(!elemForm)
{return true;}
var bAccountCustomer=(document.getElementsByName('INVOICEADDRESSSELECT').length>0);var bSkipInvoice=false;if(bAccountCustomer)
{bSkipInvoice=!IsElementChecked("idINVOICEADDRESSSELECT_0");}
var chkSeparateShip=document.getElementById('idSEPARATESHIP');var bSkipDeliver=false;if(bAccountCustomer)
{bSkipDeliver=!IsElementChecked("idDELIVERADDRESSSELECT_0");}
if(!bSkipDeliver)
{bSkipDeliver=(chkSeparateShip&&!chkSeparateShip.checked);}
if(bSkipInvoice&&bSkipDeliver)
{return true;}
var arrDescendants=GetAllElements(elemForm);for(var i=0;i<arrDescendants.length;i++)
{var elemThis=arrDescendants[i];if((elemThis.id=='idINVOICEEMAIL_CONFIRM'&&!bSkipInvoice)||(elemThis.id=='idDELIVEREMAIL_CONFIRM'&&!bSkipDeliver))
{var elemEmail=document.getElementById(elemThis.id.replace(/_CONFIRM$/,''));if(elemEmail.style.display!='none'&&elemEmail.value!=elemThis.value)
{var sMsg=GetLabelText(elemThis)+"\n\n";sMsg+="'"+elemThis.value+"' does not match '"+elemEmail.value+"'";alert(sMsg);elemThis.focus();return false;}}}
if(bSkipInvoice&&!bSkipDeliver)
{chkSeparateShip.checked=true;}
return true;}
function GetAllElements(elemParent)
{if(elemParent.all)
{return elemParent.all;}
else if(elemParent.getElementsByTagName)
{return elemParent.getElementsByTagName('*');}}
var g_sConfirmOrderInitText='';function SubmitPSPForm()
{var sSendingOrder="Saving your order";var elemConfirmOrder=document.getElementById("idBtnConfirm");if(elemConfirmOrder.value==sSendingOrder)
{if(confirm("Are you sure")==false)
{return false;}}
else
{g_sConfirmOrderInitText=elemConfirmOrder.value;}
elemConfirmOrder.value=sSendingOrder;var nPaymentMethod=GetPaymentMethod();if(nPaymentMethod==-1)
{return true;}
if(nPaymentMethod>=10000)
{return true;}
GetPSPFormAndSubmit(nPaymentMethod);return false;}
function GetPaymentMethod()
{var cmbPaymentMethod=document.getElementById("idPAYMENTMETHOD");if(cmbPaymentMethod)
{return cmbPaymentMethod.value;}
var collPaymentMethods=document.getElementsByName("PAYMENTMETHOD");if(!collPaymentMethods)
{return-1;}
if(collPaymentMethods.length==1)
{return collPaymentMethods[0].value;}
for(var i=0;i<collPaymentMethods.length;i++)
{if(collPaymentMethods[i].checked)
{return collPaymentMethods[i].value;}}
return-1;}
function GetPSPFormAndSubmit(nPaymentMethod)
{var ajaxRequest=new ajaxObject(document.location.href.split('?')[0]);ajaxRequest.callback=function(responseText)
{if(responseText.substring(0,6)=="Error:")
{alert(responseText);var elemConfirmOrder=document.getElementById("idBtnConfirm");if(elemConfirmOrder)
{elemConfirmOrder.value=g_sConfirmOrderInitText;}
return;}
var elemSpanPSPForm=document.getElementById("idSpanPSPForm");if(!elemSpanPSPForm)
{return;}
elemSpanPSPForm.innerHTML=responseText;var elemPSPForm=document.getElementById("idPSPForm");if(!elemPSPForm)
{return;}
elemPSPForm.submit();}
var sParams="ACTION=GETPSPFORM&PAYMENTMETHOD="+nPaymentMethod;var elemPONumber=document.getElementsByName('PAYMENTPONO');if(elemPONumber.length)
{sParams+='&PAYMENTPONO='+escape(elemPONumber[0].value);}
var elemPayUserDef=document.getElementsByName('PAYMENTUSERDEFINED');if(elemPayUserDef.length)
{sParams+='&PAYMENTUSERDEFINED='+escape(elemPayUserDef[0].value);}
ajaxRequest.update(sParams,"GET");}
function SFDropDownMenu(sID)
{var collElems=document.getElementById(sID).getElementsByTagName("LI");for(var i=0;i<collElems.length;i++)
{collElems[i].onmouseover=function()
{this.className+=" sfhover";}
collElems[i].onmouseout=function()
{this.className=this.className.replace(new RegExp(" sfhover\\b"),"");}}}
function ShowHideHelp(elemSource,sDisplay)
{var elemHelp=document.getElementById(elemSource.id+'help');if(!elemHelp)
{return;}
elemHelp.style.display=sDisplay;}
function ShowHideHelpDiv(elemSource,sDisplay)
{var elemHelp=document.getElementById(elemSource.id+'help');if(!elemHelp)
{return;}
var elemHelpElem=document.getElementById('idCheckoutHelp');if(!elemHelpElem)
{return;}
var sText=elemHelp.innerHTML;var elemLabel=document.getElementById(elemSource.id+'label');if(elemLabel&&elemLabel.className=='actrequired')
{sText+=' This is a required field.';}
elemHelpElem.innerHTML=sDisplay==''?sText:'';}
function GetLabelText(elemSource)
{var elemLabel=document.getElementById(elemSource.id+'label');if(!elemLabel)
{elemLabel=document.getElementById(elemSource.id.replace(/DELIVER/,'INVOICE')+'label');}
if(elemLabel)
{var sLabel=elemLabel.innerHTML;sLabel.replace(/(\n|\t)/,'');return sLabel;}
return'';}
function SetFocusToID(sID)
{var elemFocus=document.getElementById(sID);if(!elemFocus)
{return;}
if(elemFocus.style.display!='none')
elemFocus.focus();}
var g_sInvoiceCountryCode='';function SetInvoiceCountries()
{var cmbCountry=document.getElementById('lstInvoiceCountry');if(!cmbCountry||!cmbCountry.options)
{return;}
var editCountry=document.getElementById('idINVOICECOUNTRYText');var chkSeparateShip=document.getElementById('idSEPARATESHIP');var bSeparateShip=(chkSeparateShip&&chkSeparateShip.checked)?true:false;var sCurrentCountryCode=cmbCountry.value?cmbCountry.value:g_sInvoiceCountryCode;var sCurrentCountryText=((sCurrentCountryCode==''||sCurrentCountryCode=='---')&&editCountry)?editCountry.value:'';cmbCountry.options.length=1;var sFoundCode='';var sFoundNameCode='';for(var i in g_arrCountries)
{var arrCountry=g_arrCountries[i];var bAdd=true;if(g_bInvoiceLocationRestrictive)
{if(!bSeparateShip&&g_bDeliveryLocationRestrictive)
{bAdd=arrCountry[2]&&arrCountry[3];}
else
{bAdd=arrCountry[2];}}
else if(g_bDeliveryLocationRestrictive&&!bSeparateShip)
{bAdd=arrCountry[3];}
else
{bAdd=arrCountry[2]||arrCountry[3];}
if(bAdd)
{var oOption=document.createElement("OPTION");oOption.value=arrCountry[0];oOption.text=arrCountry[1];if(sCurrentCountryCode&&oOption.value==sCurrentCountryCode)
{sFoundCode=oOption.value;}
if(sCurrentCountryCode!='---'&&oOption.text==sCurrentCountryText)
{sFoundNameCode=oOption.value;}
cmbCountry.options.add(oOption);}}
if(sFoundCode)
{cmbCountry.value=sFoundCode;}
if(sFoundNameCode)
{cmbCountry.value=sFoundNameCode;}
if(cmbCountry.value)
{g_sInvoiceCountryCode=cmbCountry.value;}}
function StateDropdownChanged(cmbState)
{var idEdit=(cmbState.id.indexOf('Invoice')!=-1)?'idInvoiceRegionEdit':'idDeliveryRegionEdit';var editState=document.getElementById(idEdit);if(!editState||cmbState.value=='UndefinedRegion')
{return;}
var nIndex=cmbState.selectedIndex;editState.value=cmbState.options[nIndex].text;}
function LoadXMLDoc(sURL,bReturnDoc)
{if(window.XMLHttpRequest)
{xhttp=new XMLHttpRequest();}
else
{xhttp=new ActiveXObject("Microsoft.XMLHTTP");}
xhttp.open("GET",sURL,false);xhttp.send(null);if(bReturnDoc)
{return xhttp.responseXML;}
else
{return xhttp.responseText;}}
function DOMDocFromXML(sXML)
{var docDOM=null;if(window.ActiveXObject)
{docDOM=new ActiveXObject("Microsoft.XMLDOM");docDOM.async="false";docDOM.loadXML(sXML);}
else if(window.DOMParser)
{var oParser=new DOMParser();docDOM=oParser.parseFromString(sXML,"text/xml");}
return docDOM;}
function DisplayFeefoFeedback(nLimit,sSiteURL,sCGIURL,sLogon,sProduct,sShopID)
{var sParams=escape("?logon="+sLogon);var sNode="FeefoFeedback";if(sProduct!="")
{sParams+=escape("&vendorref="+sProduct);sNode+="_"+sProduct;}
sParams+=escape("&limit="+nLimit);sParams+=escape("&mozillahack=true");var sFeefoURL=sCGIURL+"?ACTION=FEEFOXML&FEEFOPARAM="+sParams;if(sShopID)
{sFeefoURL+="&SHOP="+escape(sShopID);}
var xml=LoadXMLDoc(sFeefoURL,true);if(xml==null||xml.xml=="")
{return;}
var sXslXML=LoadXMLDoc(sSiteURL+"feedback.xsl",false);var reFiles=/(feefo\.css|plus\.gif|minus\.gif)/ig;sXslXML=sXslXML.replace(reFiles,sSiteURL+"$1");var docXSL=DOMDocFromXML(sXslXML);if(window.ActiveXObject)
{ex=xml.transformNode(docXSL);document.getElementById(sNode).innerHTML=ex;}
else if(document.implementation&&document.implementation.createDocument)
{xsltProcessor=new XSLTProcessor();xsltProcessor.importStylesheet(docXSL);resultDocument=xsltProcessor.transformToFragment(xml,document);document.getElementById(sNode).appendChild(resultDocument);}}
