var secureLoc = "https://secure.thecitysecret.com/altberg/";var bsktName = "abBasket";//var secureLoc = "http://127.0.0.1/";var emptyBasket = false;var contextVal = "";// Set values for style formattingvar bgCol1 = '#FFFFFF';var bgCol2 = '#666633';var bgCol3 = '#999966';function clearOutBasket(){  if(emptyBasket){    deleteBasket();    emptyBasket = false;  }}function goBuy() {        ilist='';        index=eval("document.cookie.indexOf('"+bsktName+"')");        countbegin=(document.cookie.indexOf('=', index)+1);        countend=document.cookie.indexOf(';',index);        if(countend==-1) { countend=document.cookie.length; }        fulllist=document.cookie.substring(countbegin,countend);        for(var i=0; i<fulllist.length;i++) {            if(fulllist.substring(i,i+1)=='[') {                itemstart=i;            } else if (fulllist.substring(i,i+1)==']') {                itemend=i+1;                ilist=ilist+fulllist.substring(itemstart,itemend);            }        }		var o = document.cookie.indexOf('orig');		var orig = "ab";		if(o!=-1){		  var origStart = document.cookie.indexOf('=',o)+1;		  var origEnd = document.cookie.indexOf(';',o);		  if(origEnd==-1){                  	origEnd = document.cookie.length;		  }		  orig = document.cookie.substring(origStart, origEnd);		}		ilist=changeSpaces(ilist);		var pathVal = contextVal + "/servlet/com.thecitysecret.afs.CheckLogin?secure=yes&sdest="+secureLoc +"buy.php&items="+ilist;        var nWin = window.open(pathVal,'newWin','left=20, top=20, width=800,height=950,status=1,menubar=1,resize=1,scrollbars=1');		nWin.focus();}function checkBasket(){    var col	var index = eval("document.cookie.indexOf('"+bsktName+"')");    var totprice=0.00;    var itemlist=0;    if(index!=-1){  	  countbegin=(document.cookie.indexOf('=',index)+1);      countend=document.cookie.indexOf(';',index);      if (countend==-1) {	 	countend=document.cookie.length;	  }      fulllist=document.cookie.substring(countbegin,countend);      for (var i=0; i<=fulllist.length;i++) {         if (fulllist.substring(i,i+1)=='[') {             itemstart=i+1;             thisitem=1;         } else if (fulllist.substring(i,i+1)==']') {             itemend=i;             thequantity=fulllist.substring(itemstart,itemend);             itemtotal=(eval(theprice*thequantity));             temptotal=itemtotal*100;             totprice += itemtotal;             itemlist=itemlist+1;          } else if (fulllist.substring(i,i+1)=='|') {                 if (thisitem== 1) theitem=fulllist.substring(itemstart,i);				 if (thisitem== 2) theProdId=fulllist.substring(itemstart,i);                 if (thisitem== 3) theprice=fulllist.substring(itemstart,i);                 if (thisitem== 4) theSize=fulllist.substring(itemstart,i);                 if (thisitem== 5) theweight=fulllist.substring(itemstart,i);               	 thisitem++; itemstart=i+1;          }      }    }    var bsktObj = document.getElementById("bskt"); 	var bsktStyle = eval("bsktObj"+styleObj);    var prcChk = parseFloat(totprice);	var imOb = document.images["basket"];    var htmlStr = "";    if(prcChk>0){      imOb.src = contextVal + "/Web/images/shopping-full.gif";   	  var bsktTxt = bsktObj.innerHTML;  	  var tempStr = "";      var amount = new Number(Math.round(prcChk*100)/100);      var stringamt = amount.toFixed(2);	    	  var num = stringamt.split('.');    	if(num[1].length==1){	 			num[1]+="0";	 			stringamt=num[0]+"."+num[1];	    }		  htmlStr += "&pound;"+(stringamt); 	}		var amountObj = document.getElementById("chkAmount"); 	amountObj.innerHTML = htmlStr;}function buyItem(newItem,newId,newPrice,newCat,formName,newCurr,row) {  // newItem - Item Name  // newId - Item id  // newPrice - Item price  // newSize - Item size  // newCat - Either A==Accessories or B==boots  // newAP - Not required???  // new Quantity - Item Qty - usually 1.  // new Currency - Currency value // Need to add a bit to check that size has been entered var formObj = eval("document."+coll+formName); var newSize = ""; var newQuantity = ""; var newColour = ""; var sizeMsg = ""; var qtyMsg = ""; if(undef!=typeof(formObj)){ 	//var sizeValue = formObj.size.value;    newSize = formObj.size.value;	sizeMsg =  ' Size '+newSize;	//var qtyValue = formObj.qty.value;	newQuantity = formObj.qty.value;	// Colour not always present	if(eval(formObj.colour)!=null){	  newColour = formObj.colour.value;	  newItem+=" - Colour("+newColour+")";	}	qtyMsg = newQuantity + ' x '; }else{ 	newSize = "1"; 	newQuantity = "1"; }  var indSize = newSize.length; var indQty = newQuantity.length; var rc = true;   if(indSize==0 || indQty==0){   		var msg = "You are about to enter something to your basket without entering a size and/or quantity.";   		msg = msg + "\n Are you sure you want to do this?";		rc = confirm(msg);	      }   if(rc){   	  orderComplete = false;	  if (newItem.indexOf("\'")||newItem.indexOf("\"")){      	newItem = newItem.replace(/[\|]/g,"\'");        newItem = newItem.replace(/~/g,"\"");      }	  var addConfirm = confirm('Add '+newQuantity+' x '+newItem+sizeMsg+ ' to your basket? ');      if (addConfirm) {      	index=eval("document.cookie.indexOf('"+bsktName+"')");        countbegin=(document.cookie.indexOf('=',index)+1);        countend=document.cookie.indexOf(';',index);        if(countend==-1) { 			countend=document.cookie.length;		}        fulllist = document.cookie.substring(countbegin,countend);        amended = false;        newItemList=''; itemlist=0;        for (var i=0;i<=fulllist.length;i++) {		        	if (fulllist.substring(i,i+1) == '[') {            	thisitem=1;                itemstart=i+1;                fullstart=i+1;            } else if (fulllist.substring(i,i+1) == ']') {            	itemend=i;                thequantity=fulllist.substring(itemstart,itemend);                 itemlist++;                if (theItem==newItem && theSize==newSize) {                	amended=true;                    tempquantity=eval(thequantity)+eval(newQuantity);    				// removed newAP from list                    newItemList=newItemList+'['+theItem+'|'+theProdId+'|'+thePrice+'|'+theSize+'|'+theCat+'|'+theCurr+'|'+tempquantity+']';                } else {				  	// removed newAP from list	                   newItemList=newItemList+'['+theItem+'|'+theProdId+'|'+thePrice+'|'+theSize+'|'+theCat+'|'+theCurr+'|'+thequantity+']';                }            } else if (fulllist.substring(i,i+1)=='|') {					                	if (thisitem== 1){					theItem=fulllist.substring(itemstart,i);					}			 	if (thisitem== 2){				 	theProdId=fulllist.substring(itemstart,i);				}                if (thisitem== 3){				 	thePrice=fulllist.substring(itemstart,i);				}                if (thisitem== 4){				    theSize=fulllist.substring(itemstart,i);				}                if (thisitem== 5){				    theCat=fulllist.substring(itemstart,i);				}				if (thisitem== 6){				    theCurr=fulllist.substring(itemstart,i);				}                thisitem++;				itemstart=i+1;            }        }        if (amended==false) {			// removed newAP from list        	newItemList=newItemList+'['+newItem+'|'+newId+'|'+newPrice+'|'+newSize+'|'+newCat+'|'+newCurr+'|'+newQuantity+']';        }			    index = eval("document.cookie.indexOf('"+bsktName+"')");        document.cookie=bsktName +"="+newItemList+"; expires=Friday, 31-Dec-2010 08:00:00 GMT; path=/";        window.document.location.reload();	}  }}function presentValue(value) {        if(value<=0.9999) {            newPounds='0';        } else {            newPounds=parseInt(value);        }        dec='1';        for (var i=1; i<=2;i++) {            dec=dec+'0';        }        if (value>0) {            newPence=Math.round((value+.000008 - newPounds)*(eval(dec)));        } else {            newPence=0;        }        compstring='9';        for (var i=1; i <=2-1;i++) {            if (eval(newPence) <= eval(compstring)) newPence='0'+newPence;            compstring=compstring+'9';        }        if (2>0) {            newString = newPounds + '.' + newPence + '';        } else {            newString = newPounds + '';        }        return (newString);} function showBasket(postcode) {          currency=1;     index=eval("document.cookie.indexOf('"+bsktName+"')");     countbegin=(document.cookie.indexOf('=',index)+1);     countend=document.cookie.indexOf(';',index);     if (countend==-1) {	 	countend=document.cookie.length;	 }     fulllist=document.cookie.substring(countbegin,countend);	 totprice=0;totprice2=0;shippingtotal=0;shippingtotal2=0;taxtotalone=0;taxtotalone2=0;taxtotaltwo=0;taxtotaltwo2=0;ordertotal=0;ordertotal2=0;	 taxablestandard=0;taxablesecond=0;taxable=0;theCat=0;	 // Need to create a table of cat & quantity to generate the postage.	 // Rules are as follows.....	 // Cat B , <= 5 items - charged ?7.10	 // Cat A, if No cat B items charged at ?2.50	 	 // Cat B > 5 items, FREE	 // Customers with postcodes, IV,HS,KA27, KA28, KW,PA20 - PA49,PA60 - 78, PH17 - 26, PH30-44,PH49-50,BT, ZE, IM, TR21-25	 // are charged GBP11.50 and GBP5.00 respectively.	 //      document.writeln('<br><table border=0 bgcolor=\"#FFFFFF\" width=750px cellspacing=0 cellpadding=0>');     document.writeln('<tr><td align=center><form name="basketform">');     document.writeln('<table border=0 bgcolor=\"#FFFFFF\" cellspacing=0 cellpadding=0>');     document.writeln('<tr><td align=center>');     document.writeln('<table border=\"1\" bordercolorlight=\"#FFFFFF\" bordercolordark=\"#FFFFFF\" width=750>');     document.writeln('<tr bgcolor='+bgCol2+'>');	 document.writeln('<td align=center><font size=2 face="Tahoma, Arial" color=#FFFFFF>Product</font></td>');     document.writeln('<td align=center><font size=2 face="Tahoma, Arial"   color="#FFFFFF">Cost Each</font></td>');     document.writeln('<td align=center><font size=2 face="Tahoma, Arial" color="#FFFFFF">Size</font></td>');     document.writeln('<td align=center><font size=2 face="Tahoma, Arial" color="#FFFFFF">Qty</font></td>');	 document.writeln('<td align=center><font size=2 face="Tahoma, Arial" color="#FFFFFF">Total Cost</font></td>');	 document.writeln('<td align=center><font size=2 face="Tahoma, Arial" color="#FFFFFF">Action</font></td></tr>');     itemlist=0;     var catArray = new Array(0);     var qtyArray = new Array(0);     var aCount = 0;      for (var i=0; i<=fulllist.length;i++) {         if (fulllist.substring(i,i+1)=='[') {             itemstart=i+1;             thisitem=1;         } else if (fulllist.substring(i,i+1)==']') {             itemend=i;             thequantity=fulllist.substring(itemstart,itemend);             itemtotal=0;             itemtotal2=0;             itemtotal=(eval(theprice*thequantity));             temptotal=itemtotal*100;             totprice=totprice+itemtotal; 			 catArray[aCount]=theCat; 			 qtyArray[aCount]=thequantity; 			 aCount++;             itemlist=itemlist+1;        	 document.writeln('<tr bgColor='+bgCol3+'>');			 document.writeln('<td><font size=2 face=arial color="#000051">'+theitem+'</font></td>');     	   	 document.writeln('<td align=right><font color=#000000 face="Tahoma, Arial" size=2>'+presentValue(eval(theprice))+'</font></td>');		 	 document.writeln('<td align=right><font color=#000000 face="Tahoma, Arial" size=2>'+theSize+'</font></td>');     	 	 document.writeln('<td align=center><font color=#000000 face="Tahoma, Arial" size=2><input type=text name="Quantity'+itemlist+'" value="'+thequantity+'" size=2></font></td>');     	 	 document.writeln('<td align=right><font color=#000000 face="Tahoma, Arial" size=2>'+presentValue(itemtotal)+'</font>');    	 	 document.writeln('<td class=boottitle><a href="javascript:removeItem('+itemlist+');">Remove</a></td></tr>');         } else if (fulllist.substring(i,i+1)=='|') {         	 if (thisitem== 1){			 	theitem=fulllist.substring(itemstart,i);			 }		 	 if (thisitem== 2){			    theProdId=fulllist.substring(itemstart,i);			 }             if (thisitem== 3){			    theprice=fulllist.substring(itemstart,i);			 }			 if (thisitem== 4){			    theSize=fulllist.substring(itemstart,i);			 }             if (thisitem== 5){			    theCat=fulllist.substring(itemstart,i);				}			 			if (thisitem== 6){			    theCurr=fulllist.substring(itemstart,i);			}             thisitem++;              itemstart=i+1;          }     }     document.writeln('<tr bgcolor=#A8B986><td colspan=4 align="right"><font color=#000000 face="Tahoma, Arial" size=2><b>Total Goods</b></font></td>');     document.writeln('<td  align=right><font color=#000000 face="Tahoma, Arial" size=2><b>'+presentValue(totprice)+'</b></font></td>');     document.writeln('<td  align=right><font color=#000000 face="arial" size=3>&nbsp;</font>');	 document.writeln('</tr>');     document.writeln('<tr bgcolor=#A8B986><td colspan=4 align=right><font color=#000000 face="arial" size=2>Shipping Total&nbsp;</font></td>');     document.writeln('<td bgcolor=#A8B986 align=right><font color=#000000 face="arial" size=2><input type=text size=8 name="showshipping" value="" READONLY  style="text-align:right"><input type=hidden name="Shipping_Total"><input type=hidden name=NumItems value="'+itemlist+'"></font></td><td>&nbsp;</td>');     document.writeln('</tr>');     document.writeln('<tr bgcolor=#A8B986><td colspan=4 align=right><font color=#000000 face="arial" size=2><b>Order Total</b></font></td>');     document.writeln('<td bgcolor=#A8B986 align=right><font color=#000000 face="Times New Roman" size=2><input type=hidden name="Order_Total"><input type=text size=8 name=showtotal value="" READONLY  style="text-align:right"></font>');     document.writeln('</td></tr></table>');     document.writeln('</td></tr></table>');     document.writeln('<table class=boottitle valign=top width=550><tr>');     document.writeln('<td><a href="index.jsp">Continue shopping</a></td>');     document.writeln('<td><a href="javascript:clearBasket();">Clear Basket</a></td>');     document.writeln('<td><a href="javascript:updateBasket();">Update Basket</a></td>');	 document.writeln('<td><a href="javascript:goBuy();"><img src="'+contextVal+'/Web/images/checkOut.gif" border=0 alt="Check Out" width=25px>&nbsp;&nbsp;Check Out</a></td></tr>');	 document.writeln('</table>');     document.writeln('</form>');     recalculateShipping(catArray,qtyArray,postcode);}function removeItem(itemno) {        newItemList=null;        itemlist=0;        for(var i=0;i<=fulllist.length;i++) {            if (fulllist.substring(i,i+1)=='[') {                itemstart=i+1;            } else if (fulllist.substring(i,i+1)==']') {                itemend=i;                theitem = fulllist.substring(itemstart,itemend);                itemlist=itemlist+1;                if(itemlist != itemno) {                    newItemList = newItemList+'['+fulllist.substring(itemstart,itemend)+']';                }            }        }        index = eval("document.cookie.indexOf('"+bsktName+"')");        document.cookie=bsktName+"="+newItemList+"; expires=Friday, 31-Dec-2010 08:00:00 GMT; path=/";        self.location = contextVal+'/Web/basket.jsp';		window.document.location.reload();}function clearBasket() {        if (confirm('Are you sure you wish to clear the basket?')) {            this.document.cookie=bsktName+'= ; expires=Friday, 31-Dec-2010 08:00:00 GMT; path=/';            self.location= contextVal+'/Web/Basket.jsp';        }}function updateBasket() {        newItemList='';        itemlist=0;		for(var i=0;i<=fulllist.length; i++) {            if(fulllist.substring(i,i+1)=='[') {                thisitem=1;                itemstart=i+1;                fullstart=i+1;            } else if(fulllist.substring(i,i+1)==']') {                itemend=i;itemlist++;                thiselement=document.basketform.elements['Quantity'+itemlist].value;                newItemList=newItemList+'['+partList+'|'+thiselement+']'            } else if(fulllist.substring(i,i+1)=='|') {                partList=fulllist.substring(itemstart,i);            }        }        index=eval("document.cookie.indexOf('"+bsktName+"')");        document.cookie=bsktName+'='+newItemList+'; expires=Friday, 31-Dec-2010 08:00:00 GMT; path=/';        self.location= contextVal+'/Web/basket.jsp';		window.document.location.reload();    }function changeSpaces(tstring) {        nstring='';        for (var i=0; i <= tstring.length; i++) {            if (tstring.charAt(i)==' ') {			   nstring=nstring+'^';            } else if(tstring.charAt(i)=='&'){            	nstring=nstring+'^and^';            }else {			   nstring=nstring+tstring.charAt(i);			}        }        return nstring;}    function recalculateShipping(catArray,qtyArray,postcode) { 	   var tempshipping = "0.00";	   var outlying = false; 	   var bQty = 0;	   var aQty = 0;	   for(var i=0;i<catArray.length;i++){	      if(catArray[i]=="B"||catArray[i]=="b"){	        bQty+=qtyArray[i];	      } else {	        aQty++;	      }	   }	   var outly = ["IV","HS","KA27","KA28","KW","PA20","PA21","PA22","PA23","PA24","PA25","PA26","PA27","PA28","PA29","PA30","PA31","PA32","PA33","PA34","PA35","PA36","PA37","PA38","PA39","PA40","PA41","PA42","PA43","PA44","PA45","PA46","PA47","PA48","PA49","PA60","PA61","PA62","PA63","PA64","PA65","PA66","PA67","PA68","PA69","PA70","PA71","PA72","PA73","PA74","PA75","PA76","PA77","PA78","PH17","PH18","PH19","PH20","PH21","PH22","PH23","PH24","PH25","PH26","PH30","PH31","PH32","PH33","PH34","PH35","PH36","PH37","PH38","PH39","PH40","PH41","PH42","PH43","PH44","PH49","PH50","BT","ZE","IM","TR21","TR22","TR23","TR24","TR25"];	   var pcparts = postcode.split(" ");	   for(var p=0;p<outly.length;p++){	      if(outly[p].length==2){	          var twodigit = pcparts[0].substring(0,2);	          if(twodigit==outly[p]){	            outlying=true;	          }	      } else {	      	if(outly[p]==pcparts[0]){	        	outlying = true;	      	}	      }	   }	   // default price if any items present	   if(catArray.length>0){		   if(outlying){		   	 tempshipping="11.90";		   } else {		     tempshipping="7.10";		   }	   }	   // If only ordering accessories then charge the accessories prices	   if(bQty==0&&aQty>0){	     if(outlying){	     	tempshipping = "5.00";	     } else {	     	tempshipping = "2.50";	     }	   }	   // more than 5 boots are free!	   if(bQty>5){	     tempshipping = "0.00";	   } 		numericship=eval(tempshipping);		// Now format the number for the text fields...		if(tempshipping>0){		    num = tempshipping.split('.');			if(num[1].length==1){		 			num[1]+="0";		 			tempshipping=num[0]+"."+num[1];		    }		}		if(tempshipping=="0.00"&&catArray.length>0){		  tempshipping="FREE";		}	    document.basketform.showshipping.value = tempshipping;        document.basketform.Shipping_Total.value = tempshipping;	    document.basketform.showtotal.value = presentValue(numericship+totprice);        document.basketform.Order_Total.value = presentValue(numericship+totprice);    } function checkRegForm(){  var errNo = 0;  var errMsg = "Please complete the following details to complete your registration \n\n";  if(document.custForm.fName.value.length==0){    errNo = 1;    errMsg = "Name \n"  }   if(document.custForm.sName.value.length==0){    errNo = 1;    errMsg = "Surame \n"  }   if(document.custForm.emailAddr.value.length==0){    errNo = 1;    errMsg = "Email Address \n"  }  if(document.custForm.tel.value.length==0){    errNo = 1;    errMsg = "Contact telephone number \n"  }  if(document.custForm.notifyEmail.checked){  	document.custForm.notifyEmail.value = "1";  } else {    document.custForm.notifyEmail.value = "0";  }  if(errNo>0){    alert(errMsg);     return false;  } else {	return true;  }}function emptyBasket(){ window.opener.emptyBasket = true; window.opener.clearOutBasket(); window.opener.parent.location.reload(); this.close();}