var fSubTotal=0;var fVolDiscount=0;var fDelivery=0;var fFinalCost=0;var iNumProducts=0;var strBasketCookieName="DW_basketcookie";var strCustomerCookieName="DW_customercookie";var strEstOrdCookieName="DW_estordcookie";var strPayMethod="nil";var strOrderRef=null;var bCopyCustFields=false,bSendEstimate=false,bSendOrder=false;var strStartTable='<table align="center" cellpadding="1" cellspacing="0" width="700"><tr class="norm_font">';var strEndTable='</tr></table>';var strNormRow='<tr class="norm_font" height="20">';var str200Wide='<td class="tbl_col" rowspan="1" colspan="2" width="200" align="right">';var str100WideGBP='<td class="tbl_col" rowspan="1" colspan="1" width="100" align="right">GBP ';var strCustomerInput=new Array();var strPartNo=new Array(),strDescription=new Array(),fProductPrice=new Array(),iQuantity=new Array();var fDiscountValue=new Array(0.05,0.075,0.1);function fnNextPage(strPageName,form){if(strPageName=="customer_info.html"){if(strPayMethod=="nil"){alert("You must choose a payment method");return;}
var strBasketCookie=fnMakeBasketCookie();fnWriteCookie(strBasketCookieName,strBasketCookie);}
if(strPageName=="final_order.html"){if(!fnCheckForm(form)){return false;}
var strCustomerCookie=fnMakeCustomerCookie();fnWriteCookie(strCustomerCookieName,strCustomerCookie);}
window.open(strPageName,'_top');}
function fnPreviousPage(strPageName){if(strPageName=="shopping_basket.html"){var strCustomerCookie=fnMakeCustomerCookie();fnWriteCookie(strCustomerCookieName,strCustomerCookie);}
window.open(strPageName,'_top');}
function fnQuitShopping(){var strMessage="                Quit Shopping\n\n"+"Are you sure that you want to quit shopping\n"+"and empty your shopping basket ?";var bQuitShopping=confirm(strMessage);if(bQuitShopping){document.cookie=strBasketCookieName+"=; expires=Thu, 01-Jan-70 00:00:01 GMT";document.cookie=strCustomerCookieName+"=; expires=Thu, 01-Jan-70 00:00:01 GMT";document.cookie=strEstOrdCookieName+"=; expires=Thu, 01-Jan-70 00:00:01 GMT";window.open('products.html','_top');}
else{return;}}
function fnMakeBasketCookie(){var strBasketCookie=strPayMethod+"||";for(n=0;n<iQuantity.length;n++){if(iQuantity[n]!=0){strBasketCookie+=(strPartNo[n]+"/"+iQuantity[n]+"/|"+fProductPrice[n]+"||");}}
strBasketCookie+="~";return strBasketCookie;}
function fnParseBasketCookie(strBasketCookie){var iStartPos=0;var iSlashPos=0;var iDoublePipePos=strBasketCookie.indexOf("||",iStartPos);strPayMethod=strBasketCookie.substring(iStartPos,iDoublePipePos);iStartPos=iDoublePipePos+2;iDoublePipePos=strBasketCookie.indexOf("||",iStartPos);for(n=0;iDoublePipePos!=-1;n++){strTempCookie=strBasketCookie.substring(iStartPos,iDoublePipePos);iSlashPos=strTempCookie.indexOf("/",0);strPartNo[n]=strTempCookie.substring(0,iSlashPos);strDescription[n]="";strDescription[n]+=(strPartNo[n].indexOf("76")>-1)?"76cm, ":(strPartNo[n].indexOf("57")>-1)?"57cm, ":(strPartNo[n].indexOf("38")>-1)?"38cm, ":(strPartNo[n].indexOf("B")>-1)?"Bracket":'';strDescription[n]+=(strPartNo[n].indexOf("8S")>-1)?"8 spokes, ":(strPartNo[n].indexOf("10S")>-1)?"10 spokes, ":(strPartNo[n].indexOf("12S")>-1)?"12 spokes, ":'';strDescription[n]+=(strPartNo[n].indexOf("RT")>-1)?"rubber tyre, ":(strPartNo[n].indexOf("ST")>-1)?"steel tyre, ":'';strDescription[n]+=(strPartNo[n].indexOf("U")>-1)?"untreated":(strPartNo[n].indexOf("T")>-1)?"treated":'';iStartPos=iSlashPos+1;iSlashPos=strTempCookie.indexOf("/|",0);iQuantity[n]=parseFloat(strTempCookie.substring(iStartPos,iSlashPos));fProductPrice[n]=parseInt(strTempCookie.substring(iSlashPos+2,iDoublePipePos));iStartPos=iDoublePipePos+2;iDoublePipePos=strBasketCookie.indexOf("||",iStartPos);}}
function fnWriteCookie(strName,strValue,dateExpires,strPath,strDomain,bSecure){var strCookie=strName+"="+escape(strValue)+((dateExpires)?"; expires="+dateExpires.toGMTString():"")+((strPath)?"; path="+strPath:"")+((strDomain)?"; domain="+strDomain:"")+((bSecure)?"; secure":"");if((strName+"="+escape(strValue)).length<=3800){document.cookie=strCookie;}
else{confirm("Your shopping basket is becoming overloaded.\n"+"Please remove an item and try again.\n\n"+"Complete your purchase and return with\n"+"an empty basket to start shopping again.");}}
function fnGetCookie(strCookieName){var strPrefix=strCookieName+"=";var iStartIndex=document.cookie.indexOf(strPrefix);if(iStartIndex==-1){return null;}
var iEndIndex=document.cookie.indexOf("~",iStartIndex+strPrefix.length)
if(iEndIndex==-1){iEndIndex=document.cookie.length;}
return unescape(document.cookie.substring(iStartIndex+strPrefix.length,iEndIndex));}
function fnGetCurrency(fValue){var fGBPounds=Math.floor(fValue);var strTemp=new String(fValue);var iDecimalAt=(strTemp.indexOf(".",0)!=-1)?strTemp.indexOf(".",0):0;var strPence=""+Math.round(fValue*100);strPence=strPence.substring(strPence.length-2,strPence.length);fGBPounds+=((strTemp.charAt(iDecimalAt+2)=="9")&&(strPence=="00"))?1:0;if(strPence=="0"){strPence="00";}
return(fGBPounds+"."+strPence);}
function fnCheckForm(form){var bPass=true;var strTempObj="";var strInputName="";var strFieldOrigin="";if(document.images){for(i=0;i<form.length;i++){strTempObj=form.elements[i];strInputName=(strTempObj.name.indexOf("required")>-1)?"required":"deliver";if(strTempObj.name.substring(0,strInputName.length)==strInputName){if(((strTempObj.type=="text"||strTempObj.type=="textarea")&&strTempObj.value=='')||(strTempObj.type.toString().charAt(0)=="s"&&strTempObj.selectedIndex==0)){bPass=false;break;}
if((strTempObj.name=="required_email")&&((strTempObj.value.indexOf("@")==-1)||(strTempObj.value.indexOf(".")==-1))){alert("Your address appears incorrect.\n\n"+"Please check you have an '@' character\n"+"and a '.' character.\n");strTempObj.focus();return false;}}}}
if(!bPass){strFieldName=strTempObj.name.substring(strInputName.length+1,strTempObj.length).toUpperCase();strFieldOrigin=(strTempObj.name.indexOf("required")>-1)?"customer":"delivery";alert("The "+strFieldOrigin+" "+strFieldName+" field has not been completed.");strTempObj.focus();return false;}
else{return true;}}
function fnShowMessage(){if(document.URL.indexOf("?")!=-1){var iEqualsPos=document.URL.indexOf("=");var iMessageValue=parseInt(document.URL.substring(iEqualsPos+1,document.URL.length));if(iMessageValue==1){var strMessage="Your message has been sent to Decorative Wheels.";}
else if(iMessageValue==2){var strMessage="Your order details have been sent to Decorative Wheels,\nand copied to your email address.";}
else if(iMessageValue==3){var strMessage="Your estimate details have been sent to Decorative Wheels,\nand copied to your email address.";}
else if(iMessageValue==4){var strMessage="Your payment has been accepted.\nThank you for placing your order with Decorative Wheels.";}
else if(iMessageValue==5){var strMessage="Your order payment has been cancelled.";}
alert(strMessage);}
return;}