<!-- hide script from old browsers
//
// Define some global variables
//
var destination='UK';
var destination='Overseas';
var title='';
var firstName='';
var surName='';
var address1='';
var address2='';
var address3='';
var town='';
var postCode='';
var country='';
var telephone='';
var fax='';
var email='';
var paymentMethod='';
var cardType='';
var cardNumber='';
var expiryMonth='';
var expiryYear='';
var issue='';
var cardHolder='';
var PMSelected=['','','','','','','','','','',]
var discount;
var discountm;
var postage;
var surcharge;
var surchargem;
var totalWeight=0;


function ReadInfo() {
//
// Read the DinsdaleInfo cookie and set the form variables
//
  var fulllist, itemlist;
  var itemstart, thisitem, itemend;
  fulllist=getmycookielist('DinsdaleInfo');
//JK  alert('fulllist='+fulllist);
  itemlist=0;
  PMSelected[0] = '';
  PMSelected[1] = '';
  PMSelected[2] = '';
  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;
        destination=fulllist.substring(itemstart,itemend);
        itemlist=itemlist+1;
    } else if (fulllist.substring(i,i+1)=='|') {
            if (thisitem == 1) title=fulllist.substring(itemstart,i);
            if (thisitem == 2) firstName=fulllist.substring(itemstart,i);
            if (thisitem == 3) surName=fulllist.substring(itemstart,i);
            if (thisitem == 4) address1=fulllist.substring(itemstart,i);
            if (thisitem == 5) address2=fulllist.substring(itemstart,i);
            if (thisitem == 6) address3=fulllist.substring(itemstart,i);
            if (thisitem == 7) town=fulllist.substring(itemstart,i);
            if (thisitem == 8) postCode=fulllist.substring(itemstart,i);
            if (thisitem == 9) country=fulllist.substring(itemstart,i);
            if (thisitem ==10) email=fulllist.substring(itemstart,i);
            if (thisitem ==11) telephone=fulllist.substring(itemstart,i);
            if (thisitem ==12) fax=fulllist.substring(itemstart,i);
            if (thisitem ==13) paymentMethod=fulllist.substring(itemstart,i);
            thisitem++; itemstart=i+1;
    }
  }
  PMSelected[paymentMethod] = 'selected'
}


function writeInfo() {
//
// Write the DinsdaleInfo cookie
//
 var information;
//jk  var expDate = new Date ();
 if ( acceptsCookies() == false ) {
    return;
 }
 readForm();
 information = '[' + title + '|' + firstName + '|' + surName + '|' + address1 + '|' + address2 + '|' + address3 + '|' + town + '|' + postCode + '|' + country + '|' + email + '|' + telephone + '|' + fax + '|' + paymentMethod + '|' + cardType + '|' + cardNumber + '|' + expiryMonth + '|' + expiryYear + '|' + issue + '|' + cardHolder + '|' + destination + ']';
//jk  expDate.setTime( expDate.getTime() + (182 * 24 * 60 * 60 * 1000) ); 
//jk alert('writeInfo: DinsdaleInfo='+information);
 document.cookie='DinsdaleInfo='+information+'; path=/';

}

function addressChange() {
//
// The Address button has been clicked
//
	var last;
	if (document.basketform.address[0].checked) destination='UK';
	if (document.basketform.address[1].checked) destination='Overseas';
	writeInfo();
	// Refresh the screen
	self.location = self.location;
}

function showOrderForm() {
 // Show the order form as html
 // This is the form a user can print out and fill in by hand.
 document.writeln('<P>Postage and Packing Charges for Posted to UK Destinates');
 document.writeln('<br>&nbsp;&nbsp;£1.50 on orders up to £10');
 document.writeln('<br>&nbsp;&nbsp;£2.50 on orders between £10 and £20');
 document.writeln('<br>&nbsp;&nbsp;£4.00 on orders between £20 and £40');
 document.writeln('<br>&nbsp;&nbsp;£5.50 on orders between £40 and £60');
 document.writeln('<br>&nbsp;&nbsp;£6.50 on orders over £60');
 document.writeln('<P>Postage and Packing Charges for non-UK Destinations' );
 document.writeln('<br>&nbsp;&nbsp;£2.50 on orders up to £40');
 document.writeln('<br>&nbsp;&nbsp;£4.50 on orders between £40 and £70');
 document.writeln('<br>&nbsp;&nbsp;£6.00 on orders between £70 and £100');
 document.writeln('<br>&nbsp;&nbsp;£7.50 on orders over £100');
 document.writeln('<P>On goods totalling less than £10 there is an additional £1 handling charge.</P> ');
 document.writeln('<P></P> ');
 document.writeln('<table width=100% border=1 cellpadding=2 cellspacing=0>');
 document.writeln('<tr>');
 document.writeln('<td width=30% bgcolor=white><font color=black size=2>Product Name</font></td>');
 document.writeln('<td width=10% bgcolor=white><font color=black size=2>Code</font></td>');
 document.writeln('<td width=10% bgcolor=white><font color=black size=2>Details</font></td>');
 document.writeln('<td width=10% bgcolor=white align=right><font color=black size=2>Price</font></td>');
 document.writeln('<td bgcolor=white align=right><font color=black size=2>Quantity</font></td>');
 document.writeln('<td bgcolor=white align=right><font color=black size=2>Total Cost</font></td>');
 document.writeln('<td bgcolor=white align=right><font color=black size=2>&nbsp;</font></td>');
 document.writeln('</tr>');
 for (count=0; count < 8; count++) {
  document.writeln('<tr><td bgcolor=white><font color=black size=2>&nbsp</font></td>');
  document.writeln('<td bgcolor=white><font color=black size=2>&nbsp</font></td>');
  document.writeln('<td bgcolor=white><font color=black size=2>&nbsp</font></td>');
  document.writeln('<td bgcolor=white align=right><font color=black size=2>&nbsp</font></td>');
  document.writeln('<td bgcolor=white align=right><font color=black size=2>&nbsp</font></td>');
  document.writeln('<td bgcolor=white align=right><font color=black size=2>&nbsp</font></td>');
  document.writeln('<td bgcolor=white align=right><font color=black size=2>&nbsp</font></td></tr>');
 }
 document.writeln('<tr><td colspan=5 bgcolor=white><font color=black size=3><b>Total Goods</b></font></td>');
 document.writeln('<td bgcolor=white align=right><font color=black size=3><b>&nbsp</b></font></td>');
 document.writeln('<td bgcolor=white align=right><font color=black size=3><b>&nbsp;</b></font></td>');

 document.writeln('<tr><td colspan=5 bgcolor=white><font color=black size=3><b>Discounts</b></font></td>');
 document.writeln('<td bgcolor=white align=right><font color=red size=3><b>&nbsp</b></font></td>');
 document.writeln('<td bgcolor=white align=right><font color=black size=3><b>&nbsp;</b></font></td>');

 document.writeln('<tr><td colspan=5 bgcolor=white><font color=black size=3><b>Postage</b></font></td>');
 document.writeln('<td bgcolor=white align=right><font color=red size=3><b>&nbsp</b></font></td>');
 document.writeln('<td bgcolor=white align=right><font color=black size=3><b>&nbsp;</b></font></td>');

 document.writeln('<tr><td colspan=5 bgcolor=white><font color=black size=3><b>Order Total</b></font></td>');
 document.writeln('<td bgcolor=white align=right><font color=black size=3><b>&nbsp</b></font></td>');
 document.writeln('<td bgcolor=white align=right><font color=black size=3><b>&nbsp;</b></font></td>');
 document.writeln('</tr>');
 document.writeln('</table><br>');
}

function requestPostageInformation() {
 // Adds the html for the postage information
 ReadInfo();
 document.writeln('<P>Please select the final address for calculation of the postage.<br>');
 document.writeln('<INPUT TYPE=radio name=address onClick="addressChange()" VALUE="UK">For the UK <BR> ');
 document.writeln('<INPUT TYPE=radio name=address onClick="addressChange()" VALUE="Overseas">For outside the UK <BR> ');
 if (destination == 'UK' )       document.basketform.address[0].checked = true;
 if (destination == 'Overseas' ) document.basketform.address[1].checked = true;
 document.writeln('<P></P> ')
}

function showBasket(action) {
 // Shows the contents of the shopping basket
 var fulllist, totprice, itemlist;
 var itemstart, thisitem, itemend, thequantity, itemtotal;
 var theitem, theprice, thetaxable, theweight, field1, thecolour;
 var ordertotal;
 totprice=0;ordertotal=0;
 // document.writeln('<form name=basketform>');
 requestPostageInformation();
 document.writeln('<table width=100% border=1 cellpadding=2 cellspacing=0>');
 document.writeln('<tr>');
 document.writeln('<td width=30% bgcolor=white><font color=black size=2>Product Name</font></td>');
 document.writeln('<td width=10% bgcolor=white><font color=black size=2>Code</font></td>');
 document.writeln('<td width=10% bgcolor=white><font color=black size=2>Details</font></td>');
 document.writeln('<td width=10% bgcolor=white align=right><font color=black size=2>Price</font></td>');
 document.writeln('<td bgcolor=white align=right><font color=black size=2>Quantity</font></td>');
 document.writeln('<td bgcolor=white align=right><font color=black size=2>Total Cost</font></td>');
 if ( action=='noaction' ) {
   document.writeln('<td bgcolor=white align=right><font color=black size=2>&nbsp;</font></td>');
 } else {
   document.writeln('<td bgcolor=white align=right><font color=black size=2>Action</font></td>');
 }
 document.writeln('</tr>');
 fulllist=getmycookielist('DinsdaleBasket');
 itemlist=0;
 totalWeight=0;
 for (var i=0; i<=fulllist.length;i++) {
    if (fulllist.substring(i,i+1)=='[') {
        itemstart=i+1;	// This is the beginning of a record
        thisitem=1;
    } else if (fulllist.substring(i,i+1)==']') {
        itemend=i;      // This is the end of a record
        thequantity=fulllist.substring(itemstart,itemend);
        if ( (eval(1*thequantity)) < 0 ) thequantity='0';
        itemtotal=0;
        itemtotal=(eval(theprice*thequantity));
        totprice=totprice+itemtotal;
        itemlist=itemlist+1;
        document.writeln('<tr><td bgcolor=white><font color=black size=2>'+theitem+'</font></td>');
        document.writeln('<td bgcolor=white><font color=black size=2>'+field1+'</font></td>');
        document.writeln('<td bgcolor=white><font color=black size=2>'+thecolour+'&nbsp</font></td>');
        document.writeln('<td bgcolor=white align=right><font color=black size=2>'+presentValue(eval(theprice))+'</font></td>');
        if ( action=='noaction' ) {
          document.writeln('<td bgcolor=white align=right><font color=black size=2>'+thequantity+'</font></td>');
        } else {
          document.writeln('<td bgcolor=white align=right><font color=black size=2><input type=text onchange="updateBasket()" name="quant'+itemlist+'" value='+thequantity+' size=3></font></td>');
        }
        document.writeln('<td bgcolor=white align=right><font color=black size=2>'+presentValue(itemtotal)+'</font></td>');
        if ( action=='noaction' ) {
          document.writeln('<td bgcolor=white align=right><font color=black size=2>&nbsp;</font></td></tr>');
        } else {
          document.writeln('<td bgcolor=white align=right><font color=black size=2><a href="javascript:removeItem('+itemlist+');">Remove</a></font></td></tr>');
        }
    } else if (fulllist.substring(i,i+1)=='|') {
        // Process the contents of a record, thisitem holds the index inside the record
        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) field1=fulllist.substring(itemstart,i);
        if (thisitem== 6) thecolour=fulllist.substring(itemstart,i);
        thisitem++; itemstart=i+1;
	totalWeight=totalWeight+theweight;
    }
 }  // end of for loop around items
 calculatePostage(totprice);
 calculateDiscount(totprice);
 ordertotal = totprice + postage - discount + surcharge;
 document.writeln('<tr><td colspan=5 bgcolor=white><font color=black size=3><b>Total Goods</b></font></td>');
 document.writeln('<td bgcolor=white align=right><font color=black size=3><b>'+presentValue(totprice)+'</b></font></td>');
 document.writeln('<td bgcolor=white align=right><font color=black size=3><b>&nbsp;</b></font></td>');
 if ( surcharge > 0 ) {
  document.writeln('<tr><td colspan=5 bgcolor=white><font color=red size=3><b>'+surchargem+'</b></font></td>');
  document.writeln('<td bgcolor=white align=right><font color=black size=3><b>'+presentValue(surcharge)+'</b></font></td>');
  document.writeln('<td bgcolor=white align=right><font color=black size=3><b>&nbsp;</b></font></td>');
 }
// document.writeln('<tr><td colspan=5 bgcolor=white><font color=black size=3><b>'+discountm+'</b></font></td>');
// document.writeln('<td bgcolor=white align=right><font color=red size=3><b>'+presentValue(discount)+'</b></font></td>');
// document.writeln('<td bgcolor=white align=right><font color=black size=3><b>&nbsp;</b></font></td>');
 document.writeln('<tr><td colspan=5 bgcolor=white><font color=black size=3><b>'+postagem+'</b></font></td>');
 document.writeln('<td bgcolor=white align=right><font color=black size=3><b>'+presentValue(postage)+'</b></font></td>');
 document.writeln('<td bgcolor=white align=right><font color=black size=3><b>&nbsp;</b></font></td>');
 document.writeln('<tr><td colspan=5 bgcolor=white><font color=black size=3><b>Order Total</b></font></td>');
 document.writeln('<td bgcolor=white align=right><font color=black size=3><b>'+presentValue(ordertotal)+'</b></font></td>');
 document.writeln('<td bgcolor=white align=right><font color=black size=3><b>&nbsp;</b></font></td>');
 document.writeln('</tr>');
 document.writeln('</table><br>');
//  document.writeln('</form>');
}


function buygoods(noaction) {
 if ( acceptsCookies() == false ) {
   document.writeln('<P>Your web browser does not accept cookies and our shopping cart uses them');
   document.writeln('If you wish to use the shopping cart then you must enable cookies on your');
   document.writeln('web browser.  There are some more details about the way we use cookies');
   document.writeln('in our terms and conditions page.</P>');
   showOrderForm();
 } else {
   showBasket(noaction);
 }
   document.writeln('<TABLE width="100%" border="0">');
   document.writeln('<TR><TD>');
   document.writeln('<P align="left"><FONT color="black">Please complete the form below, then print and post it to us</FONT></P>');
   document.writeln('</TD></TR> </TABLE> ');
   showForm('noaction');
   return
}


function paypal() {
 var fulllist, totprice, itemlist;
 var itemstart, thisitem, itemend, thequantity, itemtotal;
 var theitem, theprice, thetaxable, theweight, field1, thecolour;
 var ordertotal;
 var temp, temp1;
 totprice=0;ordertotal=0;
 ReadInfo();
 fulllist=getmycookielist('DinsdaleBasket');
 max = fulllist.length+10;
 document.writeln('<BR>');
// document.writeln('<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">');
 document.writeln('<form action="https://www.paypal.com/cgi-bin/webscr" method="post">');
 document.writeln('<input type="hidden" name ="cmd"           value="_cart">');
 document.writeln('<input type="hidden" name ="upload"        value="1">');
 document.writeln('<input type="hidden" name ="business"      value="admin@dinsdaleembroideries.co.uk">');
// document.writeln('<input type="hidden" name ="business"      value="seller_1230670151_biz@kendrick.me.uk">');
 
 document.writeln('<input type="hidden" name ="currency_code" value="GBP">');
 document.writeln('<input type="hidden" name ="return" value="http://www.dinsdaleembroideries.com/shoppingcart/thankyou.html">');
 document.writeln('<input type="hidden" name ="cancel_return" value="http://www.dinsdaleembroideries.com/shoppingcart/cancel_return.html">');
 document.writeln('<input type="hidden" name ="shopping_url" value="http://www.dinsdaleembroideries.com/index.html">');
 document.writeln('<input type="hidden" name ="img_url" value="http://www.dinsdaleembroideries.com/logo.gif">');
 // document.writeln('<input type="hidden" name ="page_style" value="page_style_name">');
 itemlist=0;
 totalWeight=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;
        itemlist=itemlist+1;
        thequantity=fulllist.substring(itemstart,itemend);
        if ( (eval(1*thequantity)) < 0 ) thequantity='0';
        itemtotal=0;
        itemtotal=(eval(theprice*thequantity));
        totprice=totprice+itemtotal;
	lfield1 = field1.length;
	ltheitem = theitem.length;
	lthecolour = thecolour.length;
	if (thecolour == '' ) {
         temp=field1;
	 ltemp=lfield1;
	} else {
         temp=field1+'('+thecolour+')';
	 ltemp=lfield1+2+lthecolour;
	}
	if ( ltheitem+1+ltemp > 127 ) {
		ltheitem = 126 - ltemp;
	}
	temp2=theitem.substring(0,ltheitem)+'-'+temp
        document.writeln('<input type="hidden" name ="item_name_'+itemlist+'"   value="'+temp2+'">');
        document.writeln('<input type="hidden" name ="amount_'+itemlist+'"   value="'+theprice+'">');
        document.writeln('<input type="hidden" name ="quantity_'+itemlist+'"   value="'+thequantity+'">');
        thisitem++; itemstart=i+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) field1=fulllist.substring(itemstart,i);
        if (thisitem== 6) thecolour=fulllist.substring(itemstart,i);
        thisitem++; itemstart=i+1;
	totalWeight=totalWeight+theweight;
    }
 }
 calculatePostage(totprice);
 calculateDiscount(totprice);
 if ( surcharge != 0 ) {
  itemlist=itemlist+1;
  document.writeln('<input type="hidden" name="item_name_'+itemlist+'" value="'+surchargem+'">');
  document.writeln('<input type="hidden" name="quantity_'+itemlist+'"  value="1">');
  document.writeln('<input type="hidden" name="amount_'+itemlist+'" value="'+surcharge+'">');
 }
 itemlist=itemlist+1
 document.writeln('<input type="hidden" name="item_name_'+itemlist+'" value="'+postagem+'">');
 document.writeln('<input type="hidden" name="quantity_'+itemlist+'"  value="1">');
 document.writeln('<input type="hidden" name="amount_'+itemlist+'" value="'+postage+'">');
 if ( discount != 0 ) {
  itemlist=itemlist+1;
  document.writeln('<input type="hidden" name="item_name_'+itemlist+'" value="'+discountm+'">');
  document.writeln('<input type="hidden" name="quantity_'+itemlist+'"  value="1">');
  document.writeln('<input type="hidden" name="amount_'+itemlist+'" value="'+discount+'">');
 }
 document.writeln('<input type="submit" value="Purchase goods over the internet">');
 document.writeln('</form>');
 return
}

function worldpay() {
 var fulllist, totprice, itemlist;
 var itemstart, thisitem, itemend, thequantity, itemtotal;
 var theitem, theprice, thetaxable, theweight, field1, thecolour;
 var ordertotal;
 var temp, temp1;
 totprice=0;ordertotal=0;
 ReadInfo();
 fulllist=getmycookielist('DinsdaleBasket');
 max = fulllist.length+10;
 document.writeln('<BR>');
 document.writeln('<form action="https://secure.worldpay.com/payments/select" method = post>');
 document.writeln('<input type="hidden" name ="store" value="dinsdale">');
 document.writeln('<input type="hidden" name ="cname" value="GBP">');
 document.writeln('<input type="hidden" name ="max"   value="'+max+'">');
 itemlist=0;
 totalWeight=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;
        itemlist=itemlist+1;
        thequantity=fulllist.substring(itemstart,itemend);
        if ( (eval(1*thequantity)) < 0 ) thequantity='0';
        itemtotal=0;
        itemtotal=(eval(theprice*thequantity));
        totprice=totprice+itemtotal;
	if (thecolour == '' ) {
         temp=field1;
	} else {
         temp=field1+'('+thecolour+')';
	}
	temp2=theitem+'-'+temp
        document.writeln('<input type="hidden" name ="code'+itemlist+'"   value="'+temp+'">');
        document.writeln('<input type="hidden" name ="desc'+itemlist+'"   value="'+temp2+'">');
        document.writeln('<input type="hidden" name ="cur'+itemlist+'"   value="GBP">');
        document.writeln('<input type="hidden" name ="cost'+itemlist+'"   value="'+theprice+'">');
        document.writeln('<input type="hidden" name ="qty'+itemlist+'"   value="'+thequantity+'">');
        thisitem++; itemstart=i+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) field1=fulllist.substring(itemstart,i);
        if (thisitem== 6) thecolour=fulllist.substring(itemstart,i);
        thisitem++; itemstart=i+1;
	totalWeight=totalWeight+theweight;
    }
 }
 calculatePostage(totprice);
 calculateDiscount(totprice);
 if ( surcharge != 0 ) {
  itemlist=itemlist+1;
  document.writeln('<input type="hidden" name="code'+itemlist+'" value="Surcharge">');
  document.writeln('<input type="hidden" name="desc'+itemlist+'" value="'+surchargem+'">');
  document.writeln('<input type="hidden" name="cur'+itemlist+'"  value="GBP">');
  document.writeln('<input type="hidden" name="qty'+itemlist+'"  value="1">');
  document.writeln('<input type="hidden" name="cost'+itemlist+'" value="'+surcharge+'">');
 }
 itemlist=itemlist+1
 document.writeln('<input type="hidden" name="code'+itemlist+'" value="~WP_PNP">');
 document.writeln('<input type="hidden" name="desc'+itemlist+'" value="'+postagem+'">');
 document.writeln('<input type="hidden" name="cur'+itemlist+'"  value="GBP">');
 document.writeln('<input type="hidden" name="qty'+itemlist+'"  value="1">');
 document.writeln('<input type="hidden" name="cost'+itemlist+'" value="'+postage+'">');
 if ( discount != 0 ) {
  itemlist=itemlist+1;
  document.writeln('<input type="hidden" name="code'+itemlist+'" value="~WP_DISCA">');
  document.writeln('<input type="hidden" name="desc'+itemlist+'" value="'+discountm+'">');
  document.writeln('<input type="hidden" name="cur'+itemlist+'"  value="GBP">');
  document.writeln('<input type="hidden" name="qty'+itemlist+'"  value="1">');
  document.writeln('<input type="hidden" name="cost'+itemlist+'" value="'+discount+'">');
 }
 document.writeln('<input type="submit" value="Purchase goods over the internet">');
 document.writeln('</form>');
 return
}


function shoppingcart(action) {
 if ( acceptsCookies() == false ) {
   document.writeln('<P>Your web browser does not accept cookies and our shopping cart uses them');
   document.writeln('If you wish to use the shopping cart then you must enable cookies on your');
   document.writeln('web browser.  There are some more details about the way we use cookies');
   document.writeln('in our terms and conditions page.</P>');
   return
 }
 showBasket(action);
 addButtons();
 return;
}

function addButtons() {
 document.writeln('<input type=button name=empty value="Empty  Basket" onClick="clearBasket()"> &nbsp; &nbsp;');
 document.writeln('<input type=button name=empty value="Update Basket" onClick="updateBasket()">');
}

function removeItem(itemno) {
    var newItemList, itemlist, fulllist, itemstart, itemend, theitem;
    newItemList=null;
    itemlist=0;
    fulllist=getmycookielist('DinsdaleBasket');
    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)+']';
            }
        }
    }
    writeDinsdaleBasket(newItemList);
    self.location = 'shoppingcart.html';
}

function clearBasket() {
    var index;
    if (confirm('Are you sure you wish to clear the shopping basket?')) {
	writeDinsdaleBasket('.;');
        self.location='shoppingcart.html';
    }
}

function updateBasket() {
    var newItemList, itemlist, fulllist;
    var thisitem, itemstart, fullstart, itemend, thiselement, partList, index;
    newItemList='';
    itemlist=0;
    ilast=1;
    fulllist = getmycookielist('DinsdaleBasket');
//jk    alert(fulllist);
    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++;
            obj1=document.basketform.elements['quant'+itemlist];
//jk	    alert(obj1);
	    type = typeof obj1;
	    if ( type != 'undefined') {
             thiselement=document.basketform.elements['quant'+itemlist].value;
	    } else {
             thiselement=fulllist.substring(ilast,itemend);
	    }
            newItemList=newItemList+'['+partList+'|'+thiselement+']'
//jk            alert('itemlist='+itemlist+'  thiselement='+thiselement+'  partList='+partList);
        } else if(fulllist.substring(i,i+1)=='|') {
            partList=fulllist.substring(itemstart,i);
	    ilast = i+1;
        }
    }
    index=document.cookie.indexOf('DinsdaleBasket');
    writeDinsdaleBasket(newItemList);
    self.location='shoppingcart.html';
}

function showForm() {
 var fullist;
 ReadInfo();
 document.writeln('<TABLE border="0">');
 document.writeln('<TR><TD><B>Customer Details<B></B></B></TD>');
 document.writeln('<TD></TD></TR>');
 document.writeln('<TR><TD width=25% valign=bottom><FONT>Title</FONT></td>');
 document.writeln('<TD width=75% valign=bottom><input type="text" name="MyTitle" onchange=writeInfo() size="5" value="'+title+'"></TD></TR>');
 document.writeln('<TR><TD width=25% valign=bottom><FONT>First Name</FONT></TD>');
 document.writeln('<TD width=75% valign=bottom> <INPUT name="FirstName" onchange=writeInfo() size="40" value="'+firstName+'"> </TD> </TR>');
 document.writeln('<TR> <TD width=25% valign=bottom><FONT>Surname</FONT>; </TD>');
 document.writeln('<TD width=75% valign=bottom> <INPUT name="SurName" onchange=writeInfo() size="40" value="'+surName+'"> </TD> </TR>');
 document.writeln('<TR> <TD width=25% valign=bottom><FONT>Address</FONT>; </TD>');
 document.writeln('<TD width=75% valign=bottom> <INPUT name="Address1" onchange=writeInfo() size="40" value="'+address1+'"> </TD> </TR>');
 document.writeln('<TR> <TD width=25% valign=bottom> </TD>');
 document.writeln('<TD width=75% valign=bottom> <INPUT name="Address2" onchange=writeInfo() size="40" value="'+address2+'"> </TD> </TR>');
 document.writeln('<TR> <TD width=25% valign=bottom> </TD>');
 document.writeln('<TD width=75% valign=bottom> <INPUT name="Address3" onchange=writeInfo() size="40" value="'+address3+'"> </TD> </TR>');
 document.writeln('<TR> <TD width=25% valign=bottom><FONT>Town/City</FONT> </TD>');
 document.writeln('<TD width=75% valign=bottom> <INPUT name="Town" onchange=writeInfo() size="40" value="'+town+'"> </TD> </TR>');
 document.writeln('<TR> <TD width=25% valign=bottom><FONT>Post Code</FONT> </TD>');
 document.writeln('<TD width=75% valign=bottom> <INPUT name="PostCode" onchange=writeInfo() size=15 value="'+postCode+'"> </TD> </TR>');
 document.writeln('<TR> <TD width=25% valign=bottom><FONT>Country</FONT> </TD>');
 document.writeln('<TD width=75% valign=bottom> <INPUT name="Country" onchange=writeInfo() size="40" value="'+country+'"> </TD> </TR>');
 document.writeln('<TR> <TD width=25% valign=bottom><FONT>Email address</FONT> </TD>');
 document.writeln('<TD width=75% valign=bottom> <INPUT name="Email" onchange=writeInfo() size="40" value="'+email+'"> </TD> </TR>');
 document.writeln('<TR> <TD width=25% valign=bottom><FONT>Telephone</FONT> </TD>');
 document.writeln('<TD width=75% valign=bottom> <INPUT name="Telephone" onchange=writeInfo() size="40" value="'+telephone+'"> </TD> </TR>');
 document.writeln('<TR> <TD width=25% valign=bottom>Fax </TD>');
 document.writeln('<TD width=75% valign=bottom> <INPUT name="Fax" onchange=writeInfo() size="40" value="'+fax+'"> </TD> </TR>');
//jk document.writeln('<TR> <TD width=25% valign=bottom>Payment Method </TD>');
//jk  document.writeln('<TD width=75% valign=bottom> <SELECT name="PaymentMethod" onchange=writeInfo()>');
//jk  document.writeln('<OPTION '+PMSelected[0]+'>Choose you payment method...'); 
//jk  document.writeln('<OPTION '+PMSelected[1]+'>UK Sterling Cheque');
//jk  document.writeln('<OPTION '+PMSelected[2]+'>Credit or charge card</OPTION>');
//jk  document.writeln('</SELECT> </TR>');
//jk  document.writeln('<TR> <TD colspan="2"> <P><B>For credit and charge card payments, please provide the information below.</B></P> </TD> </TR>');
//jk  document.writeln('<TR> <TD width=25% valign=bottom>Card Type <TD width=75% valign=bottom>');
//jk  document.writeln('<SELECT name="CardType" >');
//jk  document.writeln('<OPTION>Select your card... ');
//jk  document.writeln('<OPTION>Visa');
//jk  document.writeln('<OPTION>Mastercard');
//jk  document.writeln('<OPTION>Switch');
//jk  document.writeln('<OPTION>Solo');
//jk  document.writeln('<OPTION>Visa Electron</OPTION>');
//jk  document.writeln('</SELECT></TR>');
//jk  document.writeln('<TR> <TD width=25% valign=bottom>Card Number</TD>');
//jk  document.writeln('<TD width=75% valign=bottom> <INPUT name="CardNumber" size="40"> </TD> </TR>');
//jk  document.writeln('<TR> <TD width=25% valign=bottom>Expiry Date</TD>');
//jk  document.writeln('<TD width=75% valign=bottom> <SELECT name="ExpiryMonth">');
//jk  document.writeln('<OPTION>Select the month... ');
//jk  document.writeln('<OPTION>01');
//jk  document.writeln('<OPTION>02');
//jk  document.writeln('<OPTION>03');
//jk  document.writeln('<OPTION>04');
//jk  document.writeln('<OPTION>05');
//jk  document.writeln('<OPTION>06');
//jk  document.writeln('<OPTION>07');
//jk  document.writeln('<OPTION>08');
//jk  document.writeln('<OPTION>09');
//jk  document.writeln('<OPTION>10');
//jk  document.writeln('<OPTION>11');
//jk  document.writeln('<OPTION>12</OPTION>');
//jk  document.writeln('</SELECT>');
//jk  document.writeln('<SELECT name="ExpiryYear">');
//jk  document.writeln('<OPTION>Select the year... ');
//jk  document.writeln('<OPTION>2000');
//jk  document.writeln('<OPTION>2001');
//jk  document.writeln('<OPTION>2002');
//jk  document.writeln('<OPTION>2003');
//jk  document.writeln('<OPTION>2004');
//jk  document.writeln('<OPTION>2005');
//jk  document.writeln('<OPTION>2006');
//jk  document.writeln('<OPTION>2007');
//jk  document.writeln('<OPTION>2008');
//jk  document.writeln('<OPTION>2009');
//jk  document.writeln('<OPTION>2010</OPTION>');
//jk  document.writeln('</SELECT>');
//jk  document.writeln('<TR> <TD width=25% valign=bottom>Issue Number or Date</TD>');
//jk  document.writeln('<TD width=75% valign=bottom> <INPUT name="IssueNumber" size="10"> </TD> </TR>');
//jk  document.writeln('<TR> <TD width=25% valign=bottom>Name of Card Holder</TD>');
//jk  document.writeln('<TD width=75% valign=bottom> <INPUT name="NameOnCard" size="40"> </TD> </TR>');
//jk  document.writeln('<TR> <TD width=25% valign=bottom><HR></TD>');
//jk  document.writeln('<TD width=75% valign=bottom><HR></TD> </TR>');
//jk  document.writeln('</TABLE>');
}

function readForm() {
//
// Read the form and set the variables
//
 type = typeof document.basketform.MyTitle;
 if ( type != 'undefined') {
  title = document.basketform.MyTitle.value;
  firstName = document.basketform.FirstName.value;
  surName = document.basketform.SurName.value;
  address1 = document.basketform.Address1.value;
  address2 = document.basketform.Address2.value;
  address3 = document.basketform.Address3.value;
  town = document.basketform.Town.value;
  postCode = document.basketform.PostCode.value;
  country = document.basketform.Country.value;
  email = document.basketform.Email.value;
  telephone = document.basketform.Telephone.value;
  fax = document.basketform.Fax.value;
  paymentMethod = document.basketform.PaymentMethod.selectedIndex;
  cardType = document.basketform.CardType.selectedIndex;
//jk  cardNumber = document.basketform.CardNumber.value;
  cardNumber='';
  expiryMonth = document.basketform.ExpiryMonth.selectedIndex;
  expiryYear = document.basketform.ExpiryYear.selectedIndex;
  issue = document.basketform.IssueNumber.value;
  cardHolder = document.basketform.NameOnCard.value;
 }
}

function calculatePostage(totprice) {
 if ( destination == 'Overseas' ) {
	postage = 13.00;
	postagem = 'Overseas postage on orders over £100';
	if ( totprice <= 40 ) {
		postage = 5.00;
		postagem = 'Overseas postage on orders up to £40';
	} else if ( totprice <= 70 ) {
		postage = 7.00;
		postagem = 'Overseas postage on orders up to £70';
	} else if ( totprice <= 100 ) {
		postage = 9.00;
		postagem = 'Overseas postage on orders up to £100';
	}
 } else {
	postage = 6.50;
	postagem = 'UK postage on orders over £60';
	if ( totprice <= 10 ) {
		postage = 1.50;
		postagem = 'UK postage on orders up to £10';
	} else if ( totprice <= 20 ) {
		postage = 2.50;
		postagem = 'UK postage on orders up to £20';
	} else if ( totprice <= 40 ) {
		postage = 4.00;
		postagem = 'UK postage on orders up to £40';
	} else if ( totprice <= 60 ) {
		postage = 5.50;
		postagem = 'UK postage on orders up to £60';
	}
 }
 if ( totprice <= 0 ) {
   postagem = 'Postage';
   postage = 0.0;
 }
 return;
}

function calculateDiscount(totprice) {
// discountm = 'Discounts are available for orders over £50';
 discountm = '';
 discount=0;
 surcharge = 0;
 if ( totprice > 0 && totprice < 10 ) {
 	surcharge = 1.0;
	surchargem = "A surcharge is payable on orders under £10"
 }
// if ( totprice > 100 ) {
//	discount = totprice * 0.05;
//	discountm = 'Discount of 5% for orders over £100';
// } else if ( totprice > 50 ) {
//	discount = totprice * 0.03;
//	discountm = 'Discount of 3% for orders over £50';
// } else if ( totprice > 0 && totprice < 10 ) {
// 	surcharge = 1.0;
//	surchargem = "A surcharge is payable on orders under £10"
// }
}
// end hiding script from old browsers>
