
function settime()
{

	document.basketform.TimeStamp.value=new Date().valueOf();
}



function goBuy() {
        ilist='';
        index=document.cookie.indexOf('GCW');
        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);
            }
        }
        if (ilist > ""){
        ilist=changeSpaces(ilist);
        top.location='/buy.php?items='+ilist;
        }
         if (ilist == ""){
        alert ("Your shopping basket is empty. Please add a product to your basket first")
        }
    }

    function changeSpaces(tstring) {
        nstring='';
        for (var i=0; i <= tstring.length; i++) {
            if (tstring.charAt(i)==' ') { nstring=nstring+'^';
            } else { nstring=nstring+tstring.charAt(i); }
        }
        return nstring;
    }



function checkAdvanced(adv) {
     newAdv='';advlist=0;
    for (var j=0;j<=adv.length;j++) {
            if (adv.substring(j,j+1) == '{') {
            thisadv=1;
            advstart=j+1;
        } else if (adv.substring(j,j+1) == '}') {
            advend=j;
            advPrice2=adv.substring(advstart,advend);
            advlist++; applicable=true;
            if (applicable==true) {
                newAdv = newAdv+ '{'+advFrom+'~'+advTo+'~'+advPrice+'~'+advPrice2+'}'
            }
        } else if (adv.substring(j,j+1)=='~') {
            if (thisadv== 1) advFrom=adv.substring(advstart,j);
            if (thisadv== 2) advTo=adv.substring(advstart,j);
            if (thisadv== 3) advPrice=adv.substring(advstart,j);
            if (thisadv== 4) advPrice2=adv.substring(advstart,j);
            thisadv++;advstart=j+1;
        }
    }
    if (newAdv=='') newAdv='none';
    return newAdv;
}


   



 function showBasket() {
     currency=1;
     index=document.cookie.indexOf('GCW');
     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;
     document.writeln('<table width="500" border=0 cellpadding=2 cellspacing=0>');
     document.writeln('<tr>');
     document.writeln('<td  bgcolor=#EAEAEA ><font color=#000000 face="Arial" size=2>Product Name</font></td>');
     document.writeln('<td  bgcolor=#EAEAEA align=right><font color=#000000 face="Arial" size=2>Price</font></td>');
     document.writeln('<td bgcolor=#EAEAEA align=right><font color=#000000 face="Arial" size=2>Quantity</font></td><td  bgcolor=#EAEAEA align=right><font color=#000000 face="Arial" size=2>Total Cost</font></td><td  bgcolor=#EAEAEA align=right><font color=#000000 face="Arial" size=2>Action</font></td>');
     document.writeln('</tr>');
     itemlist=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;
             if (theAP!='none') {
             if (currency==1) { tempprice=getAdvanced(theAP,1,thequantity); if (tempprice>0) theprice=tempprice; }
             if (currency==2) { tempprice=getAdvanced(theAP,2,thequantity); if (tempprice>0) theprice2=tempprice; }
             }
             itemtotal=(eval(theprice*thequantity));
             temptotal=itemtotal*100;
             totprice=totprice+itemtotal;
             itemlist=itemlist+1;
         document.writeln('<tr><td  ><font color=#000000 face="Arial" size=2>'+theitem+'</font></td>');
     document.writeln('<td   align=right><font color=#000000 face="Arial" size=2>'+presentValue(eval(theprice))+'</font></td>');
     document.writeln('<td   align=right><font color=#000000 face="Arial" size=2><input type=text name="quant'+itemlist+'" value='+thequantity+' size=3></font></td>');
     document.writeln('<td   align=right><font color=#000000 face="Arial" size=2>'+presentValue(itemtotal)+'</font></td>');
     document.writeln('<td   align=right><font color=#000000 face="Arial" size=2><input type=button name="remove'+itemlist+'" value="Remove" onClick="removeItem('+itemlist+');"></font></td></tr>');
             } else if (fulllist.substring(i,i+1)=='|') {
                 if (thisitem==1) theitem=fulllist.substring(itemstart,i);
                 if (thisitem== 2) theprice=fulllist.substring(itemstart,i);
                 if (thisitem== 3) thetaxable=fulllist.substring(itemstart,i);
                 if (thisitem== 4) theweight=fulllist.substring(itemstart,i);
                     if (thisitem== 5) theAP=fulllist.substring(itemstart,i);
               thisitem++; itemstart=i+1;
             }
         }
     document.writeln('<tr><td colspan=3  ><font color=#000000 face="Arial" size=2>Total Goods</font></td>');
     document.writeln('<td   align=right><font color=#000000 face="Arial" size=2>'+presentValue(totprice)+'</font></td>');
     document.writeln('<td   align=right><font color=#000000 face="Arial" size=2>&nbsp;</font></td>');
     document.writeln('</tr>');
     document.writeln('</table><br>');
     document.writeln('<input type=button name=clear value="Clear Basket" onClick="clearBasket();">');
     document.writeln('<input type=button name=update value="Update" onClick="updateBasket();">');
}



function ShowOrder() {
     currency=1;
     index=document.cookie.indexOf('GCW');
     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;
	 
 //    document.writeln('<table width="500" border=0 cellpadding=2 cellspacing=0>');
 //    document.writeln('<tr>');
  //   document.writeln('<td  bgcolor=#EAEAEA ><font color=#000000 face="Arial" size=2>Product Name</font></td>');
//     document.writeln('<td  bgcolor=#EAEAEA align=right><font color=#000000 face="Arial" size=2>Price</font></td>');
//     document.writeln('<td bgcolor=#EAEAEA align=right><font color=#000000 face="Arial" size=2>Quantity</font></td><td  bgcolor=#EAEAEA align=right><font color=#000000 face="Arial" size=2>Total Cost</font></td><td  bgcolor=#EAEAEA align=right><font color=#000000 face="Arial" size=2>Action</font></td>');
//     document.writeln('</tr>');


     itemlist=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;
             if (theAP!='none') {
             if (currency==1) { tempprice=getAdvanced(theAP,1,thequantity); if (tempprice>0) theprice=tempprice; }
             if (currency==2) { tempprice=getAdvanced(theAP,2,thequantity); if (tempprice>0) theprice2=tempprice; }
             }
             itemtotal=(eval(theprice*thequantity));
             temptotal=itemtotal*100;
             totprice=totprice+itemtotal;
             itemlist=itemlist+1;

             } else if (fulllist.substring(i,i+1)=='|') {
                 if (thisitem==1) theitem=fulllist.substring(itemstart,i);
                 if (thisitem== 2) theprice=fulllist.substring(itemstart,i);
                 if (thisitem== 3) thetaxable=fulllist.substring(itemstart,i);
                 if (thisitem== 4) theweight=fulllist.substring(itemstart,i);
                     if (thisitem== 5) theAP=fulllist.substring(itemstart,i);
               thisitem++; itemstart=i+1;
             }
         }
//     document.writeln('<tr><td colspan=3  ><font color=#000000 face="Arial" size=2>Total Goods</font></td>');
//     document.writeln('<td   align=right><font color=#000000 face="Arial" size=2>'+presentValue(totprice)+'</font></td>');
//     document.writeln('<td   align=right><font color=#000000 face="Arial" size=2>&nbsp;</font></td>');
//     document.writeln('</tr>');
//     document.writeln('</table><br>');
//     document.writeln('<input type=button name=clear value="Clear Basket" onClick="clearBasket();">');
//     document.writeln('<input type=button name=update value="Update" onClick="updateBasket();">');
     document.writeln('<table width=125  border=1 cellpadding=2 cellspacing=0 bordercolor=#C4C4FF class=border><tr>');
document.writeln('<td height=60 bgcolor=#F2F2F2><p align=center class=order > <span class=order2 >Your Basket</span>');
document.writeln('<br> No Items: '+itemlist+'<br> Order Value: '+presentValue(totprice)+'</p></td></tr></table><span class=fill>.</span>');
				 


}





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 = document.cookie.indexOf('GCW');
        document.cookie='GCW='+newItemList+'; path=/; expires=Friday, 31-Dec-2020 08:00:00 GMT';
        self.location = '/mybasket/';
    }


    function clearBasket() {
        if (confirm('Are you sure you wish to clear the basket?')) {
            index=document.cookie.indexOf('GCW');
            document.cookie='GCW=.' +'; path=/';
            self.location='/mybasket/';
        }
    }
    function changeCurrency(num) {
         index=document.cookie.indexOf('TheCurrency');
         document.cookie='TheCurrency='+num+';  path=/; expires=Friday, 31-Dec-2020 08:00:00 GMT';
         self.location='/mybasket/';
    }

    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['quant'+itemlist].value;
                newItemList=newItemList+'['+partList+'|'+thiselement+']'
            } else if(fulllist.substring(i,i+1)=='|') {
                partList=fulllist.substring(itemstart,i);
            }
        }
        index=document.cookie.indexOf('GCW');
        document.cookie='GCW='+newItemList+'; path=/; expires=Friday, 31-Dec-2020 08:00:00 GMT';
        self.location='/mybasket/';
    }


function getAdvanced(adv,curr,qty) {
     newAdv='';advlist=0;applicable=true;advnewprice=0;
    for (var j=0;j<=adv.length;j++) {
            if (adv.substring(j,j+1) == '{') {
            thisadv=1;
            advstart=j+1;
        } else if (adv.substring(j,j+1) == '}') {
            advend=j;
            advPrice2=adv.substring(advstart,advend);
            advlist++; applicable=true;
            if (applicable==true) {
             if (eval(advFrom) > 0 && eval(advFrom) > eval(qty)) applicable=false;
             if (eval(advTo) > 0 && eval(advTo) < eval(qty)) applicable=false;
             if (curr==1 && applicable==true) advnewprice=advPrice;
             if (curr==2 && applicable==true) advnewprice=advPrice2;
            }
        } else if (adv.substring(j,j+1)=='~') {
            if (thisadv== 1) advFrom=adv.substring(advstart,j);
            if (thisadv== 2) advTo=adv.substring(advstart,j);
            if (thisadv== 3) advPrice=adv.substring(advstart,j);
            if (thisadv== 4) advPrice2=adv.substring(advstart,j);
            thisadv++;advstart=j+1;
        }
    }
     return advnewprice;
}


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 buyItem(newItem,newPrice,newTaxable,newWeight,newAP,newQuantity) {
        if(newQuantity<=0) {
            rc = alert('The quantity entered is incorrect');
        } else {
            if (confirm('Add '+newQuantity+' x '+newItem+' to Basket ')) {
                 if (newAP!='none') {
                     newAP=checkAdvanced(newAP);
                 }
                index=document.cookie.indexOf('GCW');
                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 ) {
                             amended=true;
                             tempquantity=eval(thequantity)+eval(newQuantity);
                             newItemList=newItemList+'['+theItem+'|'+thePrice+'|'+theTaxable+'|'+theWeight+'|'+newAP+'|'+tempquantity+']';
                         } else {
                             newItemList=newItemList+'['+theItem+'|'+thePrice+'|'+theTaxable+'|'+theWeight+'|'+theAP+'|'+thequantity+']';
                         }
                     } else if (fulllist.substring(i,i+1)=='|') {
                         if (thisitem==1) theItem=fulllist.substring(itemstart,i);
                         if (thisitem== 2) thePrice=fulllist.substring(itemstart,i);
                         if (thisitem== 3) theTaxable=fulllist.substring(itemstart,i);
                         if (thisitem== 4) theWeight=fulllist.substring(itemstart,i);
                         if (thisitem== 5) theAP=fulllist.substring(itemstart,i);
                         thisitem++;itemstart=i+1;
                     }
                 }
                 if (amended==false) {
                     newItemList=newItemList+'['+newItem+'|'+newPrice+'|'+newTaxable+'|'+newWeight+'|'+newAP+'|'+newQuantity+']'; }
                 index = document.cookie.indexOf('GCW');
                 document.cookie='GCW='+newItemList+'; path=/; expires=Friday, 31-Dec-2020 08:00:00 GMT';
            }
        }
	
    }


function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function CheckoutBasket() {
	notax = ""; 
     currency=1; 
     index=self.location.href.indexOf('items'); 
     countbegin=(self.location.href.indexOf('=',index)+1); 
     countend=self.location.href.length; 
 fulllist=self.location.href.substring(countbegin,countend); 
//fulllist="gcw-items";
     fulllist=replaceSpaces(fulllist); 
     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;totalforshipping=0; 
     document.writeln('<table border=0 cellspacing=0 cellpadding=2 width="535">');
     document.writeln('<tr>'); 
     document.writeln('<td bgcolor=#EAEAEA><font color=#000000 face="Arial" size=2>Product Name</font></td>');
     document.writeln('<td bgcolor=#EAEAEA align=right><font color=#000000 face="Arial" size=2>Price</font></td>');
     document.writeln('<td bgcolor=#EAEAEA align=right><font color=#000000 face="Arial" size=2>Quantity</font></td><td bgcolor=#EAEAEA align=right><font color=#000000 face="Arial" size=2>Total Cost</font></td>');
     document.writeln('</tr>'); 

     itemlist=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; 
             if (currency==2) theprice=theprice2; 

             if (theAP!='none') { 
     tempprice=getAdvanced(theAP,currency,thequantity); if (tempprice>0) theprice=tempprice; } 
             itemtotal=(eval(theprice*thequantity)); 

             temptotal=itemtotal*100; 
             totprice=totprice+itemtotal; 
             if (thetaxable == 0) taxablestandard = taxablestandard + itemtotal; 
             if (thetaxable == 1) taxablesecond = taxablesecond + itemtotal; 
             totalforshipping = totalforshipping + eval(theweight * thequantity); 
             itemlist=itemlist+1; 
newname=replacequote(theitem);

         document.writeln('<tr><td bgcolor=#FFFFFF><font color=#000000 face="Arial" size=2>'+theitem+'</font></td>');
     document.writeln('<input type=hidden name="'+'Name'+itemlist+'" value="'+newname+'"><input type=hidden name="'+'Quantity'+itemlist+'" value="'+thequantity+'"><input type=hidden name="'+'Weight'+itemlist+'" value="'+theweight+'">'); 

     document.writeln('<td bgcolor=#FFFFFF align=right><font color=#000000 face="Arial" size=2>'+presentValue(eval(theprice))+'</font></td><input type=hidden name="'+'Price'+itemlist+'" value="'+presentValue(eval(theprice))+'">');
     document.writeln('<td bgcolor=#FFFFFF align=right><font color=#000000 face="Arial" size=2>'+thequantity+'</font></td>');
	
     document.writeln('<td bgcolor=#FFFFFF align=right><font color=#000000 face="Arial" size=2>'+presentValue(itemtotal)+'</font></td><input type=hidden name="'+'Item Total'+itemlist+'" value="'+presentValue(eval(itemtotal))+'">');
     document.writeln('</tr>'); 

             } else if (fulllist.substring(i,i+1)=='|') { 
                 if (thisitem==1) theitem=fulllist.substring(itemstart,i); 
                 if (thisitem== 2) theprice=fulllist.substring(itemstart,i); 
                 if (thisitem== 3) thetaxable=fulllist.substring(itemstart,i); 
                 if (thisitem== 4) theweight=fulllist.substring(itemstart,i); 
                     if (thisitem== 5) theAP=fulllist.substring(itemstart,i); 
               thisitem++; itemstart=i+1; 
             } 
         } 

if ( totprice > 750) {document.writeln('<tr><td><font color=#000000 face="Arial" size=2>Free DVD Player</td><td>&nbsp;</td><td>&nbsp;</td><td bgcolor=#FFFFFF align=right><font color=#000000 face="Arial" size=2>0.00</td></tr>');}

     document.writeln('<tr><td colspan=3 bgcolor=#FFFFFF><div align="right"><font color=#000000 face="Arial" size=2>Total Goods</font></div></td>');
  
   if (currency==1) { document.writeln('<td bgcolor=#FFFFFF align=right><font color=#000000 face="Arial" size=2><input type=hidden name="TaxTotal" value="'+presentValue(totprice)+'"> '+presentValue(totprice)+'</font></td>');}
     if (currency==2) { document.writeln('<td bgcolor=#FFFFFF align=right><font color=#000000 face="Arial" size=2><input type=hidden name="TaxTotal" value="'+presentValue2(totprice)+'"> '+presentValue2(totprice)+'</font></td>');}
     document.writeln('</tr>'); 

document.writeln('<INPUT type="hidden" name="discount"  value="">')

     document.writeln('<tr><td colspan=3 bgcolor=#FFFFFF><div align="right"><font color=#000000 face="Arial" size=2>Delivery</font></div></td>');
     document.writeln('<td bgcolor=#FFFFFF align=right><font color=#000000 face="Arial" size=2><input type=text size=8 name=showshipping value="2.00" disabled ><input type=hidden name="ShippingTotal"></font></td>');
     document.writeln('</tr>'); 


document.writeln('<tr><td colspan=3 bgcolor=#FFFFFF><font color=#000000 face="Arial" size=2></font></td>');

      document.writeln('<td bgcolor=#FFFFFF align=right><font color=#000000 face="Arial" size=2><input type=hidden name="Total"><input type=hidden size=8 name=showtax value=""></font></td>');

notax = "true";

     
 
     document.writeln('</tr>'); 
     document.writeln('<tr><td colspan=3 bgcolor=#FFFFFF><div align="right"><font color=#000000 face="Arial" size=2>Order Total</font></div></td>');
     document.writeln('<td bgcolor=#FFFFFF align=right><font color=#000000 face="Arial" size=2><input type=hidden name="ordertotal"><input type=text size=8 name=showtotal value="" disabled></font></td>');
     document.writeln('</tr>'); 
     document.writeln('</table><br>'); 

recalculateTax();
recalculateShipping(); 
} 


 function recalculateTax() {

        foundloc = false;
        tottax = 0.00;
	if ( notax == ""){

 tottax = (taxablestandard - cltdiscount) *(17.5/100);
            tottax = tottax+ taxablesecond*(0/100);
            foundloc = true;


       if (taxfield.toLowerCase() == 'united kingdom (bfpo)') {
            tottax = (taxablestandard - cltdiscount) *(17.5/100);
            tottax = tottax+ taxablesecond*(0/100);
            foundloc = true;
        }

       if (taxfield.toLowerCase() == 'united kingdom (northern ireland)') {
            tottax = (taxablestandard - cltdiscount)*(17.5/100);
            tottax = tottax+ taxablesecond*(0/100);
            foundloc = true;
        }
	if (taxfield.toLowerCase() == 'united kingdom (non mainland)') {
            tottax = (taxablestandard - cltdiscount)*(17.5/100);
            tottax = tottax+ taxablesecond*(0/100);
            foundloc = true;
        }

        if (taxfield.toLowerCase() == 'united kingdom') {
            tottax = (taxablestandard - cltdiscount)*(17.5/100);
            tottax = tottax+ taxablesecond*(0/100);
            foundloc = true;
        }
	if (taxfield.toLowerCase() == 'belgium') {
            tottax = (taxablestandard - cltdiscount)*(17.5/100);
            tottax = tottax+ taxablesecond*(0/100);
            foundloc = true;
        }
	if (taxfield.toLowerCase() == 'austria') {
            tottax = (taxablestandard - cltdiscount)*(17.5/100);
            tottax = tottax+ taxablesecond*(0/100);
            foundloc = true;
        }
if (taxfield.toLowerCase() == 'denmark') {
            tottax = (taxablestandard - cltdiscount)*(17.5/100);
            tottax = tottax+ taxablesecond*(0/100);
            foundloc = true;
        }
if (taxfield.toLowerCase() == 'finland') {
            tottax = (taxablestandard - cltdiscount)*(17.5/100);
            tottax = tottax+ taxablesecond*(0/100);
            foundloc = true;
        }
if (taxfield.toLowerCase() == 'france') {
            tottax = (taxablestandard - cltdiscount)*(17.5/100);
            tottax = tottax+ taxablesecond*(0/100);
            foundloc = true;
        }
if (taxfield.toLowerCase() == 'germany') {
            tottax = (taxablestandard - cltdiscount)*(17.5/100);
            tottax = tottax+ taxablesecond*(0/100);
            foundloc = true;
        }
if (taxfield.toLowerCase() == 'greece') {
            tottax = (taxablestandard - cltdiscount)*(17.5/100);
            tottax = tottax+ taxablesecond*(0/100);
            foundloc = true;
        }
if (taxfield.toLowerCase() == 'ireland') {
            tottax = (taxablestandard - cltdiscount)*(17.5/100);
            tottax = tottax+ taxablesecond*(0/100);
            foundloc = true;
        }
if (taxfield.toLowerCase() == 'italy') {
            tottax = (taxablestandard - cltdiscount)*(17.5/100);
            tottax = tottax+ taxablesecond*(0/100);
            foundloc = true;
        }
if (taxfield.toLowerCase() == 'luxembourg') {
            tottax = (taxablestandard - cltdiscount)*(17.5/100);
            tottax = tottax+ taxablesecond*(0/100);
            foundloc = true;
        }
if (taxfield.toLowerCase() == 'netherlands') {
            tottax = (taxablestandard - cltdiscount)*(17.5/100);
            tottax = tottax+ taxablesecond*(0/100);
            foundloc = true;
        }
if (taxfield.toLowerCase() == 'portugal') {
            tottax = (taxablestandard - cltdiscount)*(17.5/100);
            tottax = tottax+ taxablesecond*(0/100);
            foundloc = true;
        }
if (taxfield.toLowerCase() == 'spain') {
            tottax = (taxablestandard - cltdiscount)*(17.5/100);
            tottax = tottax+ taxablesecond*(0/100);
            foundloc = true;
        }
if (taxfield.toLowerCase() == 'sweden') {
            tottax = (taxablestandard - cltdiscount)*(17.5/100);
            tottax = tottax+ taxablesecond*(0/100);
            foundloc = true;
        }

}
         if (currency==1) {
        document.basketform.showtax.value = presentValue(tottax)
        document.basketform.Total.value = presentValue(tottax)
        document.basketform.showtotal.value = presentValue(tottax+totprice+shippingtotal)
        document.basketform.ordertotal.value = presentValue(tottax+totprice+shippingtotal)
    }
     if (currency==2) {
        document.basketform.showtax.value = presentValue2(tottax)
        document.basketform.Total.value = presentValue2(tottax)
        document.basketform.showtotal.value = presentValue2(tottax+totprice+shippingtotal)
        document.basketform.ordertotal.value = presentValue2(tottax+totprice+shippingtotal)
    }
    }



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);
    }

    numFields=0;
    function addFiller(curnum) {
        newnum=parseInt(curnum);
        if (newnum<10) return '00'+newnum;
        if (newnum<100) return '0'+newnum;
        return newnum;
    }

    function nextField() {
        numFields++;
        return addFiller(numFields)+'-';
    }


function recalculateShipping() {

shippingtotal = 0.00;

   if (totprice > 15.00) {
	shippingtotal= 0.00;
	}


document.basketform.showshipping.value = presentValue(shippingtotal); 
        document.basketform.ShippingTotal.value = presentValue(shippingtotal);
        


	recalculateTax();

}   


 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); 
    } 
 
    numFields=0; 
    function addFiller(curnum) { 
        newnum=parseInt(curnum); 
        if (newnum<10) return '00'+newnum; 
        if (newnum<100) return '0'+newnum; 
        return newnum; 
    } 
 
    function nextField() { 
        numFields++; 
        return addFiller(numFields)+'-'; 
    } 


function getAdvanced(adv,curr,qty) { 
     newAdv='';advlist=0;applicable=true;advnewprice=0; 
    for (var j=0;j<=adv.length;j++) { 
            if (adv.substring(j,j+1) == '{') { 
            thisadv=1; 
            advstart=j+1; 
        } else if (adv.substring(j,j+1) == '}') { 
            advend=j; 
            advPrice2=adv.substring(advstart,advend); 
            advlist++; applicable=true; 
            if (applicable==true) { 
             if (eval(advFrom) > 0 && eval(advFrom) > eval(qty)) applicable=false; 
             if (eval(advTo) > 0 && eval(advTo) < eval(qty)) applicable=false; 
             if (curr==1 && applicable==true) advnewprice=advPrice; 
             if (curr==2 && applicable==true) advnewprice=advPrice2; 
            } 
        } else if (adv.substring(j,j+1)=='~') { 
            if (thisadv== 1) advFrom=adv.substring(advstart,j); 
            if (thisadv== 2) advTo=adv.substring(advstart,j); 
            if (thisadv== 3) advPrice=adv.substring(advstart,j); 
            if (thisadv== 4) advPrice2=adv.substring(advstart,j); 
            thisadv++;advstart=j+1; 
        } 
    } 
     return advnewprice; 
} 
 taxfield='';taxfield2='';shippingfile='';primaryfield='';secondaryfield='' 
 primaryfield=''; 
 taxfield=''; 
 taxfield2=''; 

 function changeCurrency(num) { 
         index=document.cookie.indexOf('TheCurrency'); 
         document.cookie='TheCurrency='+num+'; path=/ ;xpires=Friday, 31-Dec-2020 08:00:00 GMT';
         self.location='basket2.htm'; 
   
}



function replaceSpaces(tstring) { 
        nstring=''; 
        for(var i=0;i<=tstring.length;i++) { 
            if (tstring.charAt(i)=='^') { nstring=nstring+' '; 
            } else { nstring=nstring+tstring.charAt(i); } 
        } 
        return nstring; 
    } 

     function replacequote(tstring) { 
        nstring=''; 
        for(var i=0;i<=tstring.length;i++) { 
            if (tstring.charAt(i)=='"') { nstring=nstring+'<q>'; 
            } else { nstring=nstring+tstring.charAt(i); } 
        } 
        return nstring; 
    } 


function checkform2(which) {
var pass=true;

if (document.basketform.delivery.value =="notselected"){
	alert("Please Select Delivery");
    return false;
	}
return true;
}

function checkform(which) {
var pass=true;

if (document.basketform.delivery.value =="notselected"){
	alert("Please Select Delivery");
    return false;
	}

if (document.images) {


for (i=0;i<which.length;i++) {
var tempobj=which.elements[i];
if (tempobj.name =="firstname") {
if (((tempobj.type=="text"||tempobj.type=="textarea")&&
tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&
tempobj.selectedIndex==0)) {
pass=false;
alert("Please enter your name");
return false;
break;
}}}

for (i=0;i<which.length;i++) {
var tempobj=which.elements[i];
if (tempobj.name =="lastname") {
if (((tempobj.type=="text"||tempobj.type=="textarea")&&
tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&
tempobj.selectedIndex==0)) {
pass=false;
alert("Please enter your name");
return false;
break;
}}}

for (i=0;i<which.length;i++) {
var tempobj=which.elements[i];
if (tempobj.name =="caddress") {
if (((tempobj.type=="text"||tempobj.type=="textarea")&&
tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&
tempobj.selectedIndex==0)) {
pass=false;
alert("Please Address");
return false;
break;
}}}


for (i=0;i<which.length;i++) {
var tempobj=which.elements[i];
if (tempobj.name =="ccity") {
if (((tempobj.type=="text"||tempobj.type=="textarea")&&
tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&
tempobj.selectedIndex==0)) {
pass=false;
alert("Please Enter City");
return false;
break;
}}}

for (i=0;i<which.length;i++) {
var tempobj=which.elements[i];
if (tempobj.name =="ccounty") {
if (((tempobj.type=="text"||tempobj.type=="textarea")&&
tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&
tempobj.selectedIndex==0)) {
pass=false;
alert("Please enter your Card expiry year");
return false;
break;
}}}
for (i=0;i<which.length;i++) {
var tempobj=which.elements[i];
if (tempobj.name =="cpostcode") {
if (((tempobj.type=="text"||tempobj.type=="textarea")&&
tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&
tempobj.selectedIndex==0)) {
pass=false;
alert("Please enter your postcode");
return false;
break;
}}}

for (i=0;i<which.length;i++) {
var tempobj=which.elements[i];
if (tempobj.name =="email") {
if (((tempobj.type=="text"||tempobj.type=="textarea")&&
tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&
tempobj.selectedIndex==0)) {
pass=false;
alert("Please enter your email address");
return false;
break;
}}}



for (i=0;i<which.length;i++) {
var tempobj=which.elements[i];
if (tempobj.name =="telephone") {
if (((tempobj.type=="text"||tempobj.type=="textarea")&&
tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&
tempobj.selectedIndex==0)) {
pass=false;
alert("Please enter your telephone number");
return false;
break;
}}}

for (i=0;i<which.length;i++) {
var tempobj=which.elements[i];
if (tempobj.name =="daddress") {
if (((tempobj.type=="text"||tempobj.type=="textarea")&&
tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&
tempobj.selectedIndex==0)) {
pass=false;
alert("Please enter your delivery address");
return false;
break;
}}}

for (i=0;i<which.length;i++) {
var tempobj=which.elements[i];
if (tempobj.name =="dcity") {
if (((tempobj.type=="text"||tempobj.type=="textarea")&&
tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&
tempobj.selectedIndex==0)) {
pass=false;
alert("Please enter your delivery town");
return false;
break;
}}}


for (i=0;i<which.length;i++) {
var tempobj=which.elements[i];
if (tempobj.name =="dcounty") {
if (((tempobj.type=="text"||tempobj.type=="textarea")&&
tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&
tempobj.selectedIndex==0)) {
pass=false;
alert("Please enter your delivery county");
return false;
break;
}}}

for (i=0;i<which.length;i++) {
var tempobj=which.elements[i];
if (tempobj.name =="dpostcode") {
if (((tempobj.type=="text"||tempobj.type=="textarea")&&
tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&
tempobj.selectedIndex==0)) {
pass=false;
alert("Please enter your delivery county");
return false;
break;
}}}
}

if (document.basketform.email.value.indexOf('@') < 0 && document.basketform.email.value.indexOf('.') < 0)
{
alert("Please a valid email address");
return false;
}

return true;
}



function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function recalculateOrder()
{
	
	if (document.basketform.delivery.value =="firstclass"){shippingtotal=2.95;}
	if (document.basketform.delivery.value =="special"){shippingtotal=8.50;}
	if (document.basketform.delivery.value =="nextday"){shippingtotal=10.50;}
    if (shippingtotal==0){shippingtotal=2.95;}
        document.basketform.showshipping.value = presentValue(shippingtotal); 
        document.basketform.ShippingTotal.value = presentValue(shippingtotal);
		
        recalculateTax();	
}

function closemenu()
{
}

