var disc_trap=0;
var disc_cook=0;
var discount_cook=getCookie("Discount");
if(discount_cook!=null&&discount_cook!=""){
disc_cook=1;
// EXTRACT DISCOUNT DATA
var discount_cook_sub=discount_cook;
var cbeg=0;
var cend=0;
var citem="";
for(var z=0;z<=2;z++){
cfin=discount_cook_sub.length;
cend=discount_cook_sub.indexOf('&');
citem=discount_cook_sub.substring(cbeg,cend);
		cend++;
		discount_cook_sub=discount_cook_sub.substring(cend,cfin);
if(z==0){
disc_code=citem;
}else if(z==1){
disc_amount=citem;
}else{
disc_mess=citem;
}
}
if(disc_amount==0){
disc_cook=0;
disc_trap=1;
}
}
primplus=0;
lim1=0;
t1=0;
t2=0;
thistotal=0;
spcost=new Array(12);
for(i=0;i<=11;i++){
spcost[i]=10000;
}
mailshipping=new Array(9);
mailshipping[0]=0;
mailshipping[1]=70;
mailshipping[2]=5.00;
mailshipping[3]=70;
mailshipping[4]=129.00;
mailshipping[5]=9.00;
mailshipping[6]=129.01;
mailshipping[7]=10000;
mailshipping[8]=13.00;
totalforshipping=0;
totalformailshipping=0;
prim_0="";
prim_1="";
prim_2="";
prim_3="";
prim_4="";
prim_5="";
prim_6="";
prim_7="";
prim_8="";
prim_9="";
prim_10="";
prim_11="";
prim_n="";
shippingmethod='';
deldate='';
primaryfield=getCookie("ShipDest");
/////////////////////////////IF DESTINATION COUNTRY CHOSEN
if(primaryfield!=null&&primaryfield!=""){
//COUNTRY NAME
prim_5=primaryfield.split("|")[5];
//SMALL PACKET
prim_0=primaryfield.split("|")[0];
//SPEC DELIV
prim_1=primaryfield.split("|")[1];
//FIRST CLASS
prim_2=primaryfield.split("|")[2];
//CITYPACK
prim_3=primaryfield.split("|")[3];
//CITYPARCEL
prim_4=primaryfield.split("|")[4];
//CITYINTEXP
prim_6=primaryfield.split("|")[6];
//CITYINTVAL
prim_7=primaryfield.split("|")[7];
//TARGET EUROBAG
prim_8=primaryfield.split("|")[8];
//DHL EURO ROAD
prim_9=primaryfield.split("|")[9];
//TARGET
prim_10=primaryfield.split("|")[10];
//CITYINTEXP TOWNS
prim_11=primaryfield.split("|")[11];
}
/////////////////////////////END IF DESTINATION COUNTRY CHOSEN
shippingmethod=getCookie("ShipBy");
shippingdest=primaryfield;
if(prim_3==1||prim_3==2){
	if(shippingmethod!=null && shippingmethod!='Normal (7-9 working days)' && shippingmethod!='Fast (4-6 working days)' && shippingmethod!='Super Fast (2-3 working days)' && shippingmethod!='Collect From Office'){
		shippingmethod='';
}
}
if(prim_0==0||prim_0==1||prim_0==2||prim_2==9){shippingmethod='International (5-7 working days)'}
secondaryfield='';
shippingtotal=0.00;
totprice=0;
totpricevat=0;
var line1="Select Country For Delivery:<\/td><td align=right colspan=\"3\"><select name=\"e_Country\" class=\"whatshipping\" onChange=\"primaryfield=document.purchasesform.e_Country.options[document.purchasesform.e_Country.selectedIndex].value;shippingOptions()\;\">";
var line2="";
for(i=0;i<=342;i++){
cname=d_c[i].split("|")[5];
line2=line2+'<option value=\"'+d_c[i]+'\">'+cname;
}

// OFFER DELIVERY
//offeron="yes"; // offer on or off
//offdate=new Date(2008,11,23); // offer delivery date (yyyy,mm-1,dd)
//offdname="December 23rd"; // name of date by which delivery is guaranteed
//endname="3pm December 19th"; // name of time and date of last ordering
//endoffdate=new Date(2008,11,19); // last ordering day for offer (yyyy,mm-1,dd)
//endofftime=15; // last ordering time eg 14=2pm
offeron="yes";
offdate=new Date(2011,11,23);
offdname="December 23rd";
endname="Midnight December 20th";
endoffdate=new Date(2011,11,20);
endofftime=24;
endoffdate1=endoffdate.getTime()+endofftime*60*60*1000;

// create holiday array
hlcount=5;
hol=new Array(6); 
hol[0] = new Date ( 2011, 11, 26 );
// 26 Dec 2011
hol[1] = new Date ( 2011, 11, 27 );
// 27 Dec 2011
hol[2] = new Date ( 2012, 0, 2 );
// 2 Jan 2012
hol[3] = new Date ( 2012, 3, 6 );
// 6 Apr 2012
hol[4] = new Date ( 2012, 3, 9 );
// 9 Apr 2012
hol[5] = new Date ( 2012, 4, 7 );
// 7 May 2012

// LOOK FOR FOLLOWING MARKERS
/////////////////////////////////
//WEB PROG	top.location.href='https://secure.hammocks.co.uk/process-web.htm?items='+ilist;
//OFFICE PROG	top.location='http://localhost/MailOrderProgram/secure/process-web.htm?items='+ilist;
///////////////////////////////////
var DelDay=0;
var Fromwhere=getCookie("Referrer");
var Frompage=getCookie("EntryPage");
endlist=0;
//*******************************************************************
function hist_fun(){
self.location="hammocks.htm";
}
//*******************************************************************
function fmvalidation(thisform){
if(totprice==0){
alert("Your Basket Is Currently Empty");
return true;
}
if(shippingdest==null){
alert("Please Select Shipping Destination");
document.purchasesform.e_Country.focus();
return true;
}
if(shippingdest.indexOf('United Kingdom')!=-1){
if(shippingmethod==''||shippingmethod==null){
alert("Please Select Shipping Method");
document.purchasesform.e_ShipMethod.focus();
return true;
}
}
if(shippingdest.indexOf('---')!=-1){
alert("Please Select Country For Delivery");
document.purchasesform.e_Country.focus();
return true;
}
if(document.purchasesform.showshipping.value.indexOf('n/a')!=-1){
alert("Unfortunately we are unable to process this order due to courier\n restrictions on size and weight for shipments to "+prim_5+".");
return true;
}
goBuy();
}
//*******************************************************************
function dayconvert(dayno){
if(dayno==1){dayname="Monday"}
if(dayno==0){dayname="Sunday"}
if(dayno==2){dayname="Tuesday"}
if(dayno==3){dayname="Wednesday"}
if(dayno==4){dayname="Thursday"}
if(dayno==5){dayname="Friday"}
if(dayno==6){dayname="Saturday"}
return(dayname);
}
//*******************************************************************
function monthconvert(monthno){
if(monthno==0){monthname="January"}
if(monthno==1){monthname="February"}
if(monthno==2){monthname="March"}
if(monthno==3){monthname="April"}
if(monthno==4){monthname="May"}
if(monthno==5){monthname="June"}
if(monthno==6){monthname="July"}
if(monthno==7){monthname="August"}
if(monthno==8){monthname="September"}
if(monthno==9){monthname="October"}
if(monthno==10){monthname="November"}
if(monthno==11){monthname="December"}
return(monthname);
}
//*******************************************************************
function deliverydate(nodays){
//USE nodays TO SET DATE FOR VARIABLE deldate
var adddays=0;
var now=new Date();
var deldt=now;
var nowhours=now.getHours();
	if(nowhours>=17){
		deldt=new Date(now.getTime() + 1 * 24 * 60 * 60 * 1000);
	}
	deldt=checkday(deldt);
	for (var daycount=1; daycount <=nodays;daycount++) {
		deldt=new Date(deldt.getTime() + 1 * 24 * 60 * 60 * 1000);
		deldt=checkday(deldt);
	}
////////////////////////////////////
if(offeron=="yes"){
if(shippingdest.indexOf('United Kingdom')!=-1){
offdate1=offdate.getTime();
calcdel=deldt.getTime();
nowtime=now.getTime();
if(nowtime<endoffdate1){
if(calcdel>=offdate1){
deldt=offdate;
}
}
}
}
////////////////////////////////////
var delday=deldt.getDay();
dayname=dayconvert(delday);
var deldaydate=deldt.getDate();
var deldaymonth=deldt.getMonth();
monthname=monthconvert(deldaymonth);
var deldayyear=deldt.getFullYear();
	DelDay=deldaydate + " " + monthname + " " +  deldayyear;
	deldate=dayname + " " + monthname + " " + deldaydate;
	return (deldate);
}
//*******************************************************************
function checkday(dr){
var drday=dr.getDay();
var drdate=dr.getDate();
var drmonth=dr.getMonth();
var dryear=dr.getYear();
var xa=0;
for(var xl=0;xl<=hlcount;xl++){
holDate=hol[xl].getDate();
holMonth=hol[xl].getMonth();
holYear=hol[xl].getYear();
if(holYear==dryear&&holMonth==drmonth&&holDate==drdate){
xa=xa+1;
}
}
if(xa>0||drday==0||drday==6){
		dr=new Date(dr.getTime() + 1 * 24 * 60 * 60 * 1000);
		dr=checkday(dr);
}
return(dr);
}
//*******************************************************************
function recalculateShipping(){
if(prim_5.indexOf('---')!=-1){
document.purchasesform.shipint.value="Please Select Country For Delivery.";
document.purchasesform.deldate.value="Please Select Country For Delivery.";
document.purchasesform.showshipping.value="n\/a";
document.purchasesform.ShippingTotal.value="n\/a";
document.purchasesform.e_Country.focus();
}else{
nopacks=1;
///// ROYAL MAIL SMALL PACKET
if(maxweight<=2000){
if(prim_0==0||prim_0==1||prim_0==2){
nopacks=1;
if(totalforshipping>2000){
				if(maxweight<=2000){
					//round up no packets;
					temp1=totalforshipping/2000;			
					nopacks=Math.round(temp1);
					if(nopacks < temp1){
nopacks++;
}
packweight=totalforshipping/nopacks;
}else{
nopacks=0;
}
}else{
packweight=totalforshipping;
}
if(nopacks>0){
for(var i=0;i<=2;i++){
spzonename=sp_rates[i].split("|")[0];
var g320=sp_rates[i].split("|")[1];
					var add20=sp_rates[i].split("|")[2];
					g320=parseFloat(g320);
					add20=parseFloat(add20);
					if(prim_0 == spzonename){
						//round up weight to 20g;
						temp1=packweight/20;			
						temp2=Math.round(temp1);
						if(temp2 < temp1){
							temp2=temp2+1;
						}
						spcost[0]=g320+((temp2*20)-320)*add20/20;
						//// price goes up by penny in world zones at 1980g
if(prim_0==1||prim_0==2){
if(packweight>1980){
spcost[0]=spcost[0]+0.01;
}
}
}
}
}
}
spcost[0]=nopacks*spcost[0];
nopacks=1;
		// ADD VAT
spcost[0]=1.175*spcost[0];
}
///// ROYAL MAIL SPECIAL DELIVERY
if(prim_1==1){
if(maxweight<=10000){
found=0;
for(j=0;j<=9;j++){
z=j+1;
lim1=j+"2000";
lim1=parseFloat(lim1);
lim2=j+"4000";
lim2=parseFloat(lim2);
lim3=z+"0000";
lim3=parseFloat(lim3);
if(totalforshipping<=lim1){
					nopacks=z;// 1 at 2kg j at 10kg
spcost[1]=j*parseFloat(sd_rates[4].split("|")[2]);
spcost[1]=spcost[1]+parseFloat(sd_rates[3].split("|")[2]);
found=1;
}else if(totalforshipping<=lim2){
if(maxweight<=2000){
						nopacks=z+1;// 2 at 2kg j at 10kg
spcost[1]=j*parseFloat(sd_rates[4].split("|")[2]);
spcost[1]=spcost[1]+2*parseFloat(sd_rates[3].split("|")[2]);
found=1;
}else{
						nopacks=z; // z at 10kg
						spcost[1]=nopacks*parseFloat(sd_rates[4].split("|")[2]);
found=1;
}
}else if(totalforshipping<=lim3){
					nopacks=z; // z at 10kg
spcost[1]=nopacks*parseFloat(sd_rates[4].split("|")[2]);
found=1;
}else{
continue;
}
if(found==1){
break;
}
}
}
spcost[1]=1.175*spcost[1];
}
///// ROYAL MAIL FIRST CLASS
if(prim_2==1||prim_2==9){
		//if maxweight<=1000 do two packs
tmp1=totalforshipping-maxweight;
if(totalforshipping>1250&&maxweight<=1000&&tmp1<=1250){
tot1=totalforshipping-maxweight;
sptot1=0;
sptot2=0;
for(var i=1;i<=6;i++){
fc1=parseFloat(fc_rates[i].split("|")[0]);
fc2=parseFloat(fc_rates[i].split("|")[1]);
fccost=parseFloat(fc_rates[i].split("|")[2]);
if(tot1>=fc1&&tot1<=fc2){
sptot1=fccost;
}
if(maxweight>=fc1&&maxweight<=fc2){
sptot2=fccost;
}
}
spcost[2]=sptot1+sptot2;
}else{

for(var i=0;i<=6;i++){
fc1=parseFloat(fc_rates[i].split("|")[0]);
fc2=parseFloat(fc_rates[i].split("|")[1]);
fccost=parseFloat(fc_rates[i].split("|")[2]);
if(i==0){
					g250= fccost;
					add250=fc2;
}else if(totalforshipping>=fc1&&totalforshipping<=fc2){
spcost[2]=fccost;
break;
}else{
					//round up weight
temp1=Math.round(totalforshipping/g250);
if(temp1*g250<totalforshipping){
temp1++;
}
spcost[2]=fccost+(temp1-5)*add250;
}
}
}
spcost[2]=0.7+spcost[2];
spcost[2]=1.175*spcost[2];
}
///// CITYLINK CITYPACK
if(prim_3==1||prim_3==2){
if(totalforshipping<=5000){
cp1=parseFloat(cp_rates[0].split("|")[2]);
cpsurch=parseFloat(cp_rates[1].split("|")[2]);
			if(prim_3==1){
				spcost[3]=cp1;
}else{
spcost[3]=cp1+cpsurch;
}
			//FUEL SUR
spcost[3]=spcost[3]*1.026;
if(prim_2==1||prim_2==2){
spcost[3]=spcost[3]*1.175;
}
}
}
///// FLAT RATES
if(prim_3==1||prim_3==2){
if(totalforshipping<=5000){
			if(prim_3==1){
				spcost[3]=5;
}else{
spcost[3]=5+15;
}
}
}
///// CITYLINK PARCEL
if(prim_4==1||prim_4==2){
maxkg1=parseFloat(cpp_rates[1].split("|")[2]);
maxkg2=parseFloat(cpp_rates[2].split("|")[2]);
addkg=parseFloat(cpp_rates[0].split("|")[3]);
suroff=parseFloat(cpp_rates[3].split("|")[3]);
surkg=parseFloat(cpp_rates[4].split("|")[3]);
surweight=parseFloat(cpp_rates[4].split("|")[2]);
if(totalforshipping<=maxkg1){
spcost[4]=parseFloat(cpp_rates[1].split("|")[3]);
}else if(totalforshipping<=maxkg2){
spcost[4]=parseFloat(cpp_rates[2].split("|")[3]);
}else{
totship=1000*Math.round(totalforshipping/1000);
			if(totship<totalforshipping){
				totship=totship+1000;
}
totship=totship-maxkg2;
spcost[4]=parseFloat(cpp_rates[2].split("|")[3])+(totship*addkg/1000);
}
if(prim_4==2){
spcost[4]=spcost[4]+suroff;
}
		if(totalforshipping>surweight){
			spcost[4]=spcost[4]+surkg;
		}
		//FUEL SUR
		spcost[4]=spcost[4]*1.026;
		//ADD VAT
		spcost[4]=spcost[4]*1.175;
	}


///// FLAT RATES
if(prim_4==1||prim_4==2){
if(totalforshipping<=8000){
spcost[4]=5;
}else if(totalforshipping<=15000){
spcost[4]=9;
}else if(totalforshipping<=39000){
spcost[4]=13;
}else if(totalforshipping<=76000){
spcost[4]=24;
}
if(prim_4==2){
spcost[4]=spcost[4]+15;
}
}
///// CITYLINK INT VAL
astrix=0;
if(maxweight<=30000){
if(prim_7.indexOf("*")!=-1){
astrix=1;
prim_7=parseFloat(prim_7.substring(0,(prim_7.length-1)));
}
if(prim_7<=9&&prim_7>=1){
for(var i=0;i<=8;i++){
val1=parseFloat(clintval[i].split("|")[0]);
val2=parseFloat(clintval[i].split("|")[1]);
val3=parseFloat(clintval[i].split("|")[2]);
if(prim_7==val1){
if(totalforshipping<=10000){
spcost[6]=val2;
}else{
						//round up weight to next 1000g
tot=Math.round(totalforshipping/1000);
if((tot*1000)<totalforshipping){
tot++;
}
tot=tot-10;
spcost[6]=val2+(tot*val3);
}
}
}
			//FUEL SUR
			spcost[6]=spcost[6]*1.026;
			//ADD VAT
			spcost[6]=spcost[6]*1.175;
		}
	}
///// TARGET EUROBAG
if(maxweight<=5000){
		// No good for chairs
if(fulllist.indexOf('Chair')==-1){
			// split into 5kg bags
if(prim_8==1){
nobags=Math.round(totalforshipping/5000);
if((nobags*5000)<totalforshipping){
nobags++;
}
				spcost[7]=nobags*tg_eur;
				//ADD VAT
				spcost[7]=spcost[7]*1.175;
}
}else{
spcost[7]=1001;
}
}
///// CHANNEL ISLANDS CONDOR
	if (prim_5.indexOf('Guernsey')!=-1 || prim_5.indexOf('Jersey')!=-1 || prim_5.indexOf('Channel Islands')!=-1){
		if(totalforshipping<38000){
			// To PORTSMOUTH THEN WITH CONDOR
			spcost[10]=13+36.90;
		}
	}

///// FASTLANE
if(totalforshipping>2000){
if(prim_6<=9&&prim_6>=1){
totalforshipping1=totalforshipping;
			if(fulllist.indexOf('Mariposa')!=-1){
				vol=168*80*15/4;
				if(totalforshipping<vol){
totalforshipping1=vol;
}
}
for(var i=0;i<=32;i++){
w1=1000*parseFloat(fastlane[i].split("|")[0]);
if(totalforshipping1<=w1){
spcost[5]=parseFloat(fastlane[i].split("|")[prim_6]);
break;
}
}
spcost[5]=spcost[5]*1.175;
if(spcost[5]>=300){
spcost[5]=10000;
}
}
}
///// END OPTIONS
thistotal=10000;
for(i=0;i<=10;i++){
		if(spcost[i]<=thistotal){
			thistotal=spcost[i];
}
}
if(shippingmethod=='Normal (7-9 working days)'){
		thistotal=thistotal;
		days=9;
}else if(shippingmethod=='Fast (4-6 working days)'){
days=6;
if(thistotal!=0){
thistotal=thistotal+2;
}
}else if(shippingmethod=='Super Fast (2-3 working days)'){
days=3;
if(thistotal!=0){
thistotal=thistotal+4;
		}

	} else if (shippingmethod == 'Collect From Office') {
		days=1;	
		if (thistotal != 0){
			thistotal=0;
		}
	}
if(shippingmethod=='International (5-7 working days)'){
days=7;
}
shippingtotal=thistotal;
if(thistotal+totprice>=0){
setCookie('Howmuch',presentValue(thistotal+totprice));
}else{
setCookie('Howmuch',presentValue(0.00));
}
if(shippingmethod!=null&&shippingmethod!=''&&shippingdest!=""){
if(thistotal==10000){
document.purchasesform.shipint.value="Sorry - no service available.";
document.purchasesform.deldate.value="No service available.";
document.purchasesform.showshipping.value="n\/a";
document.purchasesform.ShippingTotal.value="n\/a";
}else{
document.purchasesform.deldate.value=deliverydate(days);
document.purchasesform.showshipping.value=presentValue(thistotal);
document.purchasesform.ShippingTotal.value=presentValue(thistotal);
}
if(document.purchasesform.CreditTotal){
if(-thistotal-totprice<=0){
document.purchasesform.CreditTotal.value=presentValue(0.00);
}else{
document.purchasesform.CreditTotal.value=presentValue(-thistotal-totprice);
}
}
if(thistotal==10000){
document.purchasesform.showordertotal.value="n\/a";
document.purchasesform.Total.value="n\/a";
}else{
if(thistotal+totprice>=0){
document.purchasesform.showordertotal.value=presentValue(thistotal+totprice);
document.purchasesform.Total.value=presentValue(thistotal+totprice);
}else{
document.purchasesform.showordertotal.value=presentValue(0.00);
document.purchasesform.Total.value=presentValue(0.00);
}
}
}
}
}
//*******************************************************************
function shippingOptions(){
setCookie('ShipDest',primaryfield);
setCookie('ShipBy',shippingmethod);
self.location='purchases.htm';
}
//*******************************************************************
function presentValue(value){
if(value>=0){
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);
}else{
if(value>=-0.9999){
newPounds='0';
}else{
newPounds=parseInt(value);
}
dec='1';
for(var i=1;i<=2;i++){
dec=dec+'0';
}
newPence=-Math.round((value+.000008-newPounds)*(eval(dec)));
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 goBuy(){
setCookie("BeenHere",1);
ilist='';
index=document.cookie.indexOf('Purchases');
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);
}
}
Goods=document.purchasesform.GoodsTotal.value;
Shipping=document.purchasesform.showshipping.value;
Shipping=Shipping.substring(1,Shipping.length);
Howmuch=eval(Shipping)+eval(Goods);
DeliverBy=DelDay;
if(document.purchasesform.CreditTotal){
CreditTotal=document.purchasesform.CreditTotal.value;
CreditTotal=CreditTotal.substring(1,CreditTotal.length);
}else{
CreditTotal=0.00;
}
ShipType=shippingmethod;
if(disc_cook==1){
ilist=ilist+'['+disc_mess+'|'+-disc_tot+'|0|0|purchases.htm|1]';
}
if(prim_2!=1&&prim_2!=2){
ilist=ilist+'[VAT Exemption Credit for '+prim_5+'|'+-totpricevat+'|0|0|purchases.htm|1]';
}
dest=prim_5;
if(dest.indexOf("United Kingdom")!=-1){
dest=dest.replace(/United Kingdom/,"UK");
}
username="NONE";
ilist=ilist+'!TotalGoods~'+Goods+'~Shipping~'+Shipping+'~GrandTotal~'+Howmuch+'~Referrer~'+Fromwhere+'~Entrypage~'+Frompage+'~User~'+username+'~ShipBy~'+ShipType+'~'+dest+'~'+DeliverBy+'~CreditTotal~'+CreditTotal+'@';
ilist=changeSpaces(ilist);

ilist=removebr(ilist);

top.location="https://www.hammocks.co.uk/process.html?items="+ilist;
//	top.location="process.html?items="+ilist;
}
//*******************************************************************
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 removebr(tstring) {
        nstring='';
	nstring=tstring.replace(/<br>/ig,"");
        return nstring;
    }
//****************************************
function showPurchases(){
document.writeln('<table border="0" class="p14">');
index=document.cookie.indexOf('ThePurchases');
countbegin=(document.cookie.indexOf('=',index)+1);
countend=document.cookie.indexOf(';',index);
if(countend==-1){
countend=document.cookie.length;
}
fulllist=document.cookie.substring(countbegin,countend);
maxweight=0;
totprice=0;
document.writeln('<form name="purchasesform">');
itemlist=0;
thisitem=0;
free_bag=0;
wrp=0;
wrp_banned=-1;
card_chosen=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;
			itemtotal=(eval(theprice*thequantity));
			temptotal=itemtotal*100;
			totprice=totprice+itemtotal;
setCookie('Howmuch',presentValue(totprice));
itemlist=itemlist+1;
totalforshipping=totalforshipping+(eval(thequantity)*eval(theweight));
if(theprice>=0){
if(itemlist==1){
document.writeln('<tr><td colspan="5">&nbsp;<\/td><\/tr>');
document.writeln('<tr><td align=left><b><u>Article<\/u><\/b><\/td><td align=right><b><u>Qty<\/u><\/b><\/td><td align=right><b><u>Price<\/u><\/b><\/td><td align=right><b><u>Total<\/u><\/b><\/td><td>&nbsp;<\/td><\/tr>');
}
// if(field1.indexOf('Gift Wrapping With')!=-1||field1.indexOf('Free Jute Hammock Bag')!=-1){

				if(field1.indexOf('Gift Wrapping With')!=-1 || field1.indexOf('Free Jute Hammock Bag')!=-1){
					document.writeln('<tr><td nowrap>'+field1+'<\/td><td align=right><INPUT TYPE=TEXT class="purch1" NAME="quant'+itemlist+'" VALUE="'+thequantity+'" readonly="readonly"><\/td><td align=right nowrap>&nbsp;'+presentValue(eval(theprice))+'<\/td><td align=right nowrap>&nbsp;'+presentValue(itemtotal)+'<\/td><td align="right"><img src="http:\/\/www.garden-hammocks.co.uk\/images\/remove.gif" border="0" width="121" height="22" onClick="removeItem('+itemlist+');" \/><\/td><\/tr>');
				}else if(field1.indexOf('Gift Wrapping')!=-1){
					document.writeln('<tr><td nowrap><a href="'+theurl+'">'+field1+'<\/td><td align=right><INPUT TYPE="hidden" class="purch1" NAME="quant'+itemlist+'" VALUE="'+thequantity+'"><\/td><td align=right nowrap>&nbsp;'+presentValue(eval(theprice))+'<\/td><td align=right nowrap>&nbsp;'+presentValue(itemtotal)+'<\/td><td align="right"><img src="http:\/\/www.garden-hammocks.co.uk\/images\/remove.gif" border="0" width="121" height="22" onClick="removeItem('+itemlist+');" \/><\/td><\/tr>');
				}else if(field1.indexOf('Salamander')!=-1 || field1.indexOf('Frog')!=-1){
					document.writeln('<tr><td nowrap><a href="'+theurl+'">'+field1+'<\/td><td align=right><INPUT TYPE=TEXT class="purch1" NAME="quant'+itemlist+'" VALUE="'+thequantity+'" readonly="readonly"><\/td><td align=right nowrap>&nbsp;'+presentValue(eval(theprice))+'<\/td><td align=right nowrap>&nbsp;'+presentValue(itemtotal)+'<\/td><td align="right"><img src="http:\/\/www.garden-hammocks.co.uk\/images\/remove.gif" border="0" width="121" height="22" onClick="removeItem('+itemlist+');" \/><\/td><\/tr>');
				}else if(field1.indexOf('Tile Selection')!=-1){
					document.writeln('<tr><td><a href="'+theurl+'">'+field1+'<\/td><td align=right><INPUT TYPE=TEXT class="purch1" NAME="quant'+itemlist+'" VALUE="'+thequantity+'"><\/td><td align=right nowrap>&nbsp;'+presentValue(eval(theprice))+'<\/td><td align=right nowrap>&nbsp;'+presentValue(itemtotal)+'<\/td><td align="right"><img src="http:\/\/www.garden-hammocks.co.uk\/images\/remove.gif" border="0" width="121" height="22" onClick="removeItem('+itemlist+');" \/><\/td><\/tr>');
				}else {
					document.writeln('<tr><td nowrap><a href="'+theurl+'">'+field1+'<\/td><td align=right><INPUT TYPE=TEXT class="purch1" NAME="quant'+itemlist+'" VALUE="'+thequantity+'"><\/td><td align=right nowrap>&nbsp;'+presentValue(eval(theprice))+'<\/td><td align=right nowrap>&nbsp;'+presentValue(itemtotal)+'<\/td><td align="right"><img src="http:\/\/www.garden-hammocks.co.uk\/images\/remove.gif" border="0" width="121" height="22" onClick="removeItem('+itemlist+');" \/><\/td><\/tr>');
				}

}else{
if(itemlist==1){
document.writeln('<tr><td colspan="5"><br><\/td><\/tr>');
document.writeln('<tr><td align=left><b><u>Article<\/u><\/b><\/td><td align=right><b><u>Qty<\/u><\/b><\/td><td align=right><b><u>Price<\/u><\/b><\/td><td align=right><b><u>Total<\/u><\/b><\/td><td>&nbsp;<\/td><\/tr>');
}
if(field1.indexOf('Gift Wrapping With')!=-1||field1.indexOf('Free Jute Hammock Bag')!=-1){
document.writeln('<tr><td nowrap>'+field1+'<\/td><td align=right><INPUT TYPE=hidden NAME="quant'+itemlist+'" VALUE="'+thequantity+'" SIZE=3 READONLY><\/td><td align=right nowrap>&nbsp;'+presentValue(eval(theprice))+'<\/td><td align=right nowrap>&nbsp;'+presentValue(itemtotal)+'<\/td><td align="right"><img src="http:\/\/www.garden-hammocks.co.uk\/images\/remove.gif" border="0" width="121" height="22" onClick="removeItem('+itemlist+');" \/><\/td><\/tr>');
}else if(field1.indexOf('Gift Wrapping')==-1){
document.writeln('<tr><td nowrap>'+field1+'<\/td><td align=right><INPUT TYPE=TEXT class="purch1" NAME="quant'+itemlist+'" VALUE="'+thequantity+'" READONLY><\/td><td align=right nowrap>&nbsp;'+presentValue(eval(theprice))+'<\/td><td align=right nowrap>&nbsp;'+presentValue(itemtotal)+'<\/td><td align="right"><img src="http:\/\/www.garden-hammocks.co.uk\/images\/remove.gif" border="0" width="121" height="22" onClick="removeItem('+itemlist+');" \/><\/td><\/tr>');
}
}
}else if(fulllist.substring(i,i+1)=='|'){
if(thisitem==1){
field1=fulllist.substring(itemstart,i);
for(var wrp_i=0;wrp_i<=no_wrp_ban;wrp_i++){
if(field1.indexOf(wrp_ban[wrp_i])!=-1){
wrp_banned=wrp_i;
}
}
if(field1.indexOf('Gift Wrapping')!=-1){
wrp++;
if(field1.indexOf('Gift Wrapping With')!=-1){
card_chosen++;
}
}
if(field1.indexOf('Free Jute Hammock Bag')!=-1){
free_bag++;
}
}
if(thisitem==2)theprice=fulllist.substring(itemstart,i);
if(thisitem==3)field4=fulllist.substring(itemstart,i);
if(thisitem==4){
theweight=fulllist.substring(itemstart,i);
noweight=Math.floor(theweight);
if(noweight>maxweight){
maxweight=noweight;
}
}
if(thisitem==5)theurl=fulllist.substring(itemstart,i);
thisitem++;
itemstart=i+1;
}
}
if(wrp==0){
if(itemlist!=0){
document.writeln('<tr><td colspan=2>Normal Wrapping<\/td><td align=right>&nbsp;£0.00<\/td><td align=right>&nbsp;£0.00<\/td><td align="right"><img src="http:\/\/www.garden-hammocks.co.uk\/images\/wrap.gif" border="0" width="121" height="22" onClick="wrapit(\'Gift Wrapping\',2.75,0,0, \'purchases.htm\',1)\;self.location=\'purchases.htm\'\;\" \/><\/td><\/tr>');
document.writeln('<tr><td colspan=5><HR><\/td><\/tr>');
}
}else{
if(card_chosen==0){
document.writeln('<tr><td colspan=5><font color="#870101">Please Select Gift Card:<\/font><br>&nbsp;<a href=# onClick="choose_card(\'Pausa De La Guerra\');"><img src="http:\/\/www.garden-hammocks.co.uk\/images\/rev-card-5.jpg" height="75" alt="Pausa De La Guerra" \/><\/a>&nbsp\;<a href=# onClick="choose_card(\'Nino Soldado\');"><img src="http:\/\/www.garden-hammocks.co.uk\/images\/rev-card-1.jpg" height="75" alt="Nino Soldado" \/><\/a>&nbsp\;<a href=# onClick="choose_card(\'Jefes Zapatistas\');"><img src="http:\/\/www.garden-hammocks.co.uk\/images\/rev-card-2.jpg" height="75" alt="Jefes Zapatistas" \/><\/a>&nbsp\;<a href=# onClick="choose_card(\'Tren De Libertad\');"><img src="http:\/\/www.garden-hammocks.co.uk\/images\/rev-card-3.jpg" width="75" alt="Tren De Libertad" \/><\/a>&nbsp\;<a href=# onClick="choose_card(\'Viva La Revolucion\');"><img src="http:\/\/www.garden-hammocks.co.uk\/images\/rev-card-4.jpg" width="75" alt="Viva La Revolucion" \/><\/a><\/td><\/tr>');
document.writeln('<tr><td colspan=5><font color="#870101"><i>You will be asked to enter a message for your card at the checkout<\/i><\/font><\/td><\/tr>');
document.writeln('<tr><td colspan=5><HR><\/td><\/tr>');
}
}
if(itemlist!=0){
if(wrp==0||(wrp!=0&&card_chosen!=0)){
if(disc_cook==1){
document.writeln('<tr><td colspan=3><b>Cost Of Purchases<\/b><\/td><td align=right>&nbsp;'+presentValue(totprice)+'<\/td><td>&nbsp\;<\/td><\/tr>');
disc_tot=disc_amount*totprice;
disc_tot=Math.round(disc_tot*Math.pow(10,2))/Math.pow(10,2);
totprice=totprice-disc_tot;
document.writeln('<tr><td colspan=3><font color=red>'+disc_mess+'<\/font><\/td><td align=right><font color=red>&nbsp;- '+presentValue(disc_tot)+'<\/font><\/td><td>&nbsp\;<\/td><\/tr>');
}
if(prim_2!=1&&prim_2!=2){
if(shippingdest!=null&&shippingdest!=""&&prim_5.indexOf('---')==-1){
if(disc_cook==0){
document.writeln('<tr><td colspan=3><b>Cost Of Purchases<\/b><\/td><td align=right>&nbsp;'+presentValue(totprice)+'<\/td><td>&nbsp\;<\/td><\/tr>');
}
totpricevat=totprice-(totprice/1.2);
totpricevat=Math.round(totpricevat*Math.pow(10,2))/Math.pow(10,2);
totprice=totprice-totpricevat;
document.writeln('<tr><td colspan=3><font color=red>VAT Exemption Credit for '+prim_5+'<\/font><\/td><td align=right><font color=red>&nbsp;- '+presentValue(totpricevat)+'<\/font><\/td><td>&nbsp\;<\/td><\/tr>');
totpricecon=totprice.toString();
if(totpricecon.indexOf(".")==-1){
totpricecon=totpricecon+".00";
}else if(totpricecon.length-totpricecon.indexOf(".")==2){
totpricecon=totpricecon+"0";
}else if(totpricecon.length-totpricecon.indexOf(".")>3){
totpricecon=totpricecon.substring(0,totpricecon.indexOf(".")+3);
}
document.writeln('<tr><td colspan=3><b>Total Cost Of Purchases<\/b><\/td><td align=right><a href="convertgrand1.htm?'+totpricecon+'" target="linkwindow"  onclick="window.open(this.href,this.target,\'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=600,height=380\')\; return false\;"><img src="http:\/\/www.garden-hammocks.co.uk\/images\/converter.gif" width="15" height="15" border="0" alt="Currency Converter" \/><\/a>&nbsp;'+presentValue(totprice)+'<\/td><td>&nbsp\;<\/td><\/tr>');
document.writeln('<tr><td colspan=5>&nbsp;<\/td><\/tr>');
}else{
totpricecon=totprice.toString();
if(totpricecon.indexOf(".")==-1){
totpricecon=totpricecon+".00";
}else if(totpricecon.length-totpricecon.indexOf(".")==2){
totpricecon=totpricecon+"0";
}else if(totpricecon.length-totpricecon.indexOf(".")>3){
totpricecon=totpricecon.substring(0,totpricecon.indexOf(".")+3);
}
document.writeln('<tr><td colspan=3><b>Total Cost Of Purchases<\/b><\/td><td align=right><a href="convertgrand1.htm?'+totpricecon+'" target="linkwindow"  onclick="window.open(this.href,this.target,\'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=600,height=380\')\; return false\;"><img src="http:\/\/www.garden-hammocks.co.uk\/images\/converter.gif" width="15" height="15" border="0" alt="Currency Converter" \/><\/a>&nbsp;'+presentValue(totprice)+'<\/td><td>&nbsp\;<\/td><\/tr>');
document.writeln('<tr><td colspan=5>&nbsp;<\/td><\/tr>');
}
}else{
totpricecon=totprice.toString();
if(totpricecon.indexOf(".")==-1){
totpricecon=totpricecon+".00";
}else if(totpricecon.length-totpricecon.indexOf(".")==2){
totpricecon=totpricecon+"0";
}else if(totpricecon.length-totpricecon.indexOf(".")>3){
totpricecon=totpricecon.substring(0,totpricecon.indexOf(".")+3);
}
document.writeln('<tr><td colspan=3><b>Total Cost Of Purchases<\/b><\/td><td align=right><a href="convertgrand1.htm?'+totpricecon+'" target="linkwindow"  onclick="window.open(this.href,this.target,\'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=600,height=380\')\; return false\;"><img src="http:\/\/www.garden-hammocks.co.uk\/images\/converter.gif" width="15" height="15" border="0" alt="Currency Converter" \/><\/a>&nbsp;'+presentValue(totprice)+'<\/td><td>&nbsp\;<\/td><\/tr>');
document.writeln('<tr><td colspan=5>&nbsp;<\/td><\/tr>');
}
document.writeln('<tr><td colspan=5><input type=hidden name="GoodsTotal" value="'+totprice+'" size=35><\/td><\/tr>');
if(shippingdest==null||shippingdest==""){
document.writeln('<tr><td colspan=2>'+line1+'<option value="" selected>Select Country'+line2+'<\/select><\/td><\/tr>');
document.writeln('<tr><td colspan=5>&nbsp;<\/td><\/tr>');
document.purchasesform.e_Country.focus();
}else if(prim_3==1||prim_3==2){
document.writeln('<tr><td colspan=2>'+line1+'<option value='+primaryfield+'>'+prim_5+line2+'<\/select><\/td><\/tr>');
document.writeln('<tr><td colspan=5>&nbsp;<\/td><\/tr>');
if(shippingmethod==null||shippingmethod==""){
document.writeln('<tr><td colspan=2 nowrap>Select Shipping Method to display shipping rate:<\/td><td align=right colspan="3"><select name="e_ShipMethod" class="whatshipping" onChange="shippingmethod=document.purchasesform.e_ShipMethod.options[document.purchasesform.e_ShipMethod.selectedIndex].text;shippingOptions();"><option value="" selected>Select Shipping Method<option>Normal (7-9 working days)<option>Fast (4-6 working days)<option>Super Fast (2-3 working days)<\/select><\/td><\/tr>');
document.writeln('<tr><td colspan=5>&nbsp;<\/td><\/tr>');
document.purchasesform.e_ShipMethod.focus();
}else if(shippingmethod=='Super Fast (2-3 working days)'){
document.writeln('<tr><td colspan=2 nowrap>Select Shipping Method to display shipping rate:<\/td><td align=right colspan="3"><select name="e_ShipMethod" class="whatshipping" onChange="shippingmethod=document.purchasesform.e_ShipMethod.options[document.purchasesform.e_ShipMethod.selectedIndex].text;recalculateShipping();"><option>Super Fast (2-3 working days)<option>Normal (7-9 working days)<option>Fast (4-6 working days)<\/select><\/td><\/tr>');
document.writeln('<tr><td colspan=5>&nbsp;<\/td><\/tr>');
}else if(shippingmethod=='Fast (4-6 working days)'){
document.writeln('<tr><td colspan=2 nowrap>Select Shipping Method to display shipping rate:<\/td><td align=right colspan="3"><select name="e_ShipMethod" class="whatshipping" onChange="shippingmethod=document.purchasesform.e_ShipMethod.options[document.purchasesform.e_ShipMethod.selectedIndex].text;recalculateShipping();"><option>Fast (4-6 working days)<option>Super Fast (2-3 working days)<option>Normal (7-9 working days)<\/select><\/td><\/tr>');
document.writeln('<tr><td colspan=5>&nbsp;<\/td><\/tr>');
				} else if(shippingmethod=='Collect From Office'){
					document.writeln('<tr><td colspan=2 nowrap>Select Shipping Method to display shipping rate:<\/td><td align=right colspan="3"><select name="e_ShipMethod" class="whatshipping" onChange="shippingmethod=document.purchasesform.e_ShipMethod.options[document.purchasesform.e_ShipMethod.selectedIndex].text;recalculateShipping();"><option>Collect From Office<option>Fast (4-6 working days)<option>Super Fast (2-3 working days)<option>Normal (7-9 working days)<\/select><\/td><\/tr>');          
					document.writeln('<tr><td colspan=5>&nbsp;<\/td><\/tr>');
}else{
document.writeln('<tr><td colspan=2 nowrap>Select Shipping Method to display shipping rate:<\/td><td align=right colspan="3"><select name="e_ShipMethod" class="whatshipping" onChange="shippingmethod=document.purchasesform.e_ShipMethod.options[document.purchasesform.e_ShipMethod.selectedIndex].text;recalculateShipping();"><option>Normal (7-9 working days)<option>Fast (4-6 working days)<option>Super Fast (2-3 working days)<\/select><\/td><\/tr>');
document.writeln('<tr><td colspan=5>&nbsp;<\/td><\/tr>');
}
}else{
document.writeln('<tr><td colspan=2>'+line1+'<option value='+primaryfield+'>'+prim_5+line2+'<\/select><\/td><\/tr>');
document.writeln('<tr><td colspan=5>&nbsp;<\/td><\/tr>');
document.writeln('<tr><td colspan=2 nowrap>Your goods will be shipped by:<\/td><td align=right colspan="3"><input type=text name="shipint" class="whatshipping" value="'+shippingmethod+'" size=36 READONLY><\/td><\/tr>');
document.writeln('<tr><td colspan=5>&nbsp;<\/td><\/tr>');
}
// IF NOT FIRST TIME
if(shippingdest!=null&&shippingdest!=""&&shippingmethod!=null&&shippingmethod!=""){
document.writeln('<tr><td colspan=5><input type=hidden name="ShippingTotal" value="'+presentValue(0.00)+'" size=35><\/td><\/tr>');
document.writeln('<tr><td colspan=2 nowrap>With this method your order should arrive by >>>><\/td>');
document.writeln('<td colspan=3 align=right>&nbsp;&nbsp;&nbsp;<input type=text name="deldate" class="whatshipping" value="" size=24 READONLY><\/td><\/tr>');
				document.writeln('<tr><td colspan=5>&nbsp;<\/td><\/tr>');
				document.writeln('<tr><td colspan=3 nowrap>The Shipping Charge for your order will be >>>><\/td>');
document.writeln('<td colspan=2 align=right>&nbsp;&nbsp;&nbsp;<input type=text name="showshipping" class="purch" value="'+presentValue(0.00)+'" READONLY><\/td><\/tr>');
document.writeln('<tr><td colspan=5>&nbsp;<\/td><\/tr>');
if(totprice>=0){
document.writeln('<tr><td colspan=3 nowrap><b>The Grand Total (in UK Pounds Sterling) will be >>>><\/b><\/td><td colspan=2 align=right><a href="convertgrand.htm" target="linkwindow"  onclick="window.open(this.href,this.target,\'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=600,height=380\')\; return false\;"><img src="http:\/\/www.garden-hammocks.co.uk\/images\/converter.gif" width="15" height="15" border="0" alt="Currency Converter" \/><\/a>&nbsp\;<input type=text name="showordertotal" class="purch" value="'+presentValue(totprice)+'" READONLY><\/td><\/tr>');
document.writeln('<tr><td colspan=5><BR><input type=hidden name="Total" value="'+document.purchasesform.showordertotal.value+'" size=35><\/td><td><\/td><\/tr>');
}else{
document.writeln('<tr><td colspan=3 nowrap><b>The Grand Total (in UK Pounds Sterling) will be >>>><\/b><\/td><td colspan=2 align=right><a href="#" onClick="convert();"><img src="http:\/\/www.garden-hammocks.co.uk\/images\/converter.gif" width="15" height="15" border="0" alt="Currency Converter" \/><\/a>&nbsp\;<input type=text name="showordertotal" class="purch" value="'+presentValue(0.00)+'" READONLY><\/td><\/tr>');
document.writeln('<tr><td colspan=5><BR><input type=hidden name="Total" value="'+presentValue(0.00)+'" size=35><\/td><td><\/td><\/tr>');
}
}else{
document.writeln('<tr><td colspan=5>&nbsp\;<\/td><\/tr>');
}
// END IF NOT FIRST TIME
document.writeln('<tr><td colspan=5><font color=red>'+p_message+'<\/font><\/td><\/tr>');
document.writeln('<tr><td colspan=3 nowrap><img src="http:\/\/www.garden-hammocks.co.uk\/images\/return_shop.gif" border="0" width="121" height="22" onClick="hist_fun();" \/>');
document.writeln('<img src="http:\/\/www.garden-hammocks.co.uk\/images\/update.gif" border="0" width="121" height="22" onClick="updatePurchases();" \/>');
document.writeln('<img src="http:\/\/www.garden-hammocks.co.uk\/images\/clear.gif" border="0" width="121" height="22" onClick="clearPurchases();" \/><\/td>');
document.writeln('<td colspan=2 align="right"><input type="button" class="checkit" name="checkout" onclick="fmvalidation(purchasesform);"><\/td><\/tr>');
document.writeln('<tr><td colspan=2><img src="http:\/\/www.garden-hammocks.co.uk\/images\/space.gif" border="0" height="10" width="10" \/><\/td><td width="70"><img src="http:\/\/www.garden-hammocks.co.uk\/images\/space.gif" width="70" border="0" height="10" \/><\/td><td width="70"><img src="http:\/\/www.garden-hammocks.co.uk\/images\/space.gif" width="70" border="0" height="10" \/><\/td><td width="70"><img src="http:\/\/www.garden-hammocks.co.uk\/images\/space.gif" width="70" border="0" height="10" \/><\/td><\/tr>');
			if (totprice>=0) {
				document.writeln('<tr><td colspan=5 height=50><HR><\/td><\/tr>');
document.writeln('<tr><td colspan=3 nowrap class="p13"><i>If you have a Discount Code, enter it here and click "apply code".<\/td><td><input type="text" name="disc_code" class="whatshipping" size="15" maxlength="40" value=""><\/td><td><img src="http:\/\/www.garden-hammocks.co.uk\/images\/apply_code.gif" border="0" width="121" height="22" align="right" valign="bottom" onClick="discgo();" \/><\/td><\/tr>');
document.writeln('<tr><td colspan=5>&nbsp;<\/td><\/tr>');
}else{
totpriceneg=0-totprice;
document.writeln('<tr><td colspan=5><HR><\/td><\/tr>');
document.writeln('<tr><td colspan=5 align=center><i>You are currently in credit to the tune of &nbsp\; <input type=text name="CreditTotal" value="'+presentValue(totpriceneg)+'" size=6 READONLY>. If you proceed with this basket we will email you with a credit which can be redeemed on our site in the future.<\/i><\/b><br>&nbsp\;<\/td><\/tr>');
document.writeln('<tr><td colspan=5><HR><\/td><\/tr>');
document.writeln('<tr><td colspan=3 nowrap class="p13"><i>If you have a Discount Code, enter it here and click "apply code".<\/td><td><input type="text" name="disc_code" class="whatshipping" size="15" maxlength="40" value=""><\/td><td><img src="http:\/\/www.garden-hammocks.co.uk\/images\/apply_code.gif" border="0" width="121" height="22" align="right" valign="bottom" onClick="discgo();" \/><\/td><\/tr>');
document.writeln('<tr><td colspan=5>&nbsp;<\/td><\/tr>');
}
}else{
document.writeln('<input type=hidden name="deldate" value="">');
document.writeln('<input type=hidden name="showshipping" value="">');
document.writeln('<input type=hidden name="ShippingTotal" value="">');
document.writeln('<input type=hidden name="showordertotal" value="">');
document.writeln('<input type=hidden name="Total" value="">');
}
}else{
document.writeln('<input type=hidden name="deldate" value="">');
document.writeln('<input type=hidden name="showshipping" value="">');
document.writeln('<input type=hidden name="ShippingTotal" value="">');
document.writeln('<input type=hidden name="showordertotal" value="">');
document.writeln('<input type=hidden name="Total" value="">');
document.write('<tr><td colspan=5 height=50>Your basket is currently empty<\/td><\/tr>');
document.writeln('<tr><td colspan=5 align=right nowrap><img src="http:\/\/www.garden-hammocks.co.uk\/images\/return_shop.gif" border="0" width="121" height="22" onClick="hist_fun();" \/><\/td><\/tr>');
document.writeln('<tr><td colspan=5>&nbsp;<\/td><\/tr>');
}
if(itemlist!=0){
if(shippingdest!=null){
document.writeln('<tr><td align=left colspan="5" class="p13"><I>Currency shown is UK Pounds Sterling. Click on the <a href="#" onClick="convert();"><img src="http:\/\/www.garden-hammocks.co.uk\/images\/converter.gif" width="15" height="15" border="0" alt="Currency Converter" \/><\/a> symbol to convert to different currency<\/I><\/td><\/tr>');
document.writeln('<TR><TD colspan=5>&nbsp;<\/TD><\/TR>');
document.writeln('<tr><td align=left colspan="5" class="p13"><I>Please note: Delivery date shown above is a target only and not guaranteed.<\/I><\/td><\/tr>');
document.writeln('<TR><TD colspan=5>&nbsp;<\/TD><\/TR>');
}
}
document.writeln('<tr><td align=left colspan="5" class="p13"><I>If you have selected items and nothing appears in your basket your browser may not be accepting cookies. Please reset your browser and continue.<\/I><\/td><\/tr>');
document.writeln('<TR><TD colspan=5>&nbsp;<\/TD><\/TR>');
document.writeln('<TR><TD valign="top" colspan=5 class="p13"><I>If for any reason you are unable to order via our website please contact us by telephone on:<\/I><\/td><\/tr>');
document.writeln('<TR><TD colspan=5>&nbsp;<\/TD><\/TR>');
document.writeln('<TR><TD valign="top" colspan=5 class="p14"><center>+44 (0)117 942 5353<\/center><\/TD><\/TR>');
document.writeln('<TR><TD colspan=5>&nbsp;<\/TD><\/TR>');
document.writeln('<\/form>');
document.writeln('<\/table>');
if(shippingdest!=null){
recalculateShipping();
if(shippingmethod!=null&&shippingmethod!=""){
document.purchasesform.checkout.focus();
}
}
}
//*******************************************************************
function removeItem(itemno){
ittot=0;
newItemList=null;
itemlist=0;
thisitem=0;
substart=1;
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)=='|'){
			if (thisitem==2) theprice = fulllist.substring(substart,i);
			thisitem++;
			substart=i+1;
}else if(fulllist.substring(i,i+1)==']'){
itemend=i;
thequantity=fulllist.substring(substart,i);
theitem=fulllist.substring(itemstart,itemend);
itemlist=itemlist+1;
if(itemlist!=itemno){
// keep track of goods total
				newItemList = newItemList+'['+fulllist.substring(itemstart,itemend)+']';
				ittemp=eval('thequantity*theprice');
				ittot=ittot+ittemp;
}
}
}
// if Free Jute Hammock Bag in basket and basket is less than 65 remove it and notify
// if totprice - removed item price < 65 remove Jute
if(ittot<65&&free_bag!=0){
fulllist=newItemList;
newItemList=null;
thisitem=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);
if(theitem.indexOf('Free Jute Hammock Bag')==-1){
newItemList=newItemList+'['+fulllist.substring(itemstart,itemend)+']';
}else{
itemlist=itemlist-1;
}
}
}
// if now got only 1 item and it is Gift Wrapping set cookie to zero
}
if(itemlist==2&&newItemList.indexOf('Gift Wrapping')!=-1){
document.cookie='ThePurchases=.';
}else{
document.cookie='ThePurchases='+newItemList+'; expires='+expireDate.toGMTString();
}
self.location='purchases.htm';
}
//*******************************************************************
function discgo(){
// pass to discount.cgi
self.location="http://www.hammocks.co.uk/cgi-bin/discount.cgi?code="+document.purchasesform.disc_code.value;
// self.location="http://localhost/cgi-bin/MailOrderProgram/discount.cgi?code="+document.purchasesform.disc_code.value;
}
//*******************************************************************
function clearPurchases(){
if(confirm('Are you sure?')){
index=document.cookie.indexOf('ThePurchases');
document.cookie='ThePurchases=.';
self.location='purchases.htm';
}
}
//*******************************************************************
function updatePurchases(){
newItemList=null;
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='quant'+itemlist;
			newItemList=newItemList+'['+field1+'|'+field2+'|'+field3+'|'+field4+'|'+field5+'|'+document.purchasesform.elements[thiselement].value+']';
}else if(fulllist.substring(i,i+1)=='|'){
if(thisitem==1)field1=fulllist.substring(itemstart,i);
if(thisitem==2)field2=fulllist.substring(itemstart,i);
if(thisitem==3)field3=fulllist.substring(itemstart,i);
if(thisitem==4)field4=fulllist.substring(itemstart,i);
if(thisitem==5)field5=fulllist.substring(itemstart,i);
thisitem++;
itemstart=i+1;
}
}
index=document.cookie.indexOf('ThePurchases');
document.cookie='ThePurchases='+newItemList+'; expires='+expireDate.toGMTString();
self.location='purchases.htm';
}
