
<!--
//************************************************************************************************************



 	// The following two variables establish the tax rate and the state in which you charge tax.


var taxrate = 0.07; //Tax rate for your state, must be in decimal form (eg. 8.750 becomes 0.0875)
var taxstate = "Indiana";	//The state you collect tax in (Your home state)
var business = "Barclay Blocks";
var tableheadcolor = "#F3F2FF"; //Table Header and Footer Color
var tablebodycolor = "#FFF2F5"; //Body Color
var tablefontcolor = "#800080"; //Font Color
var vbasketTransaction = 1; // go to the basket after each transaction
var shipdis = .75; //shipping discount
var shipmode=0;  //this resets to 1 if the shipment is overseas or uses Flat rate calculations
var shipbump=0;  //this is to bump up shipping prices under some cirtcumstances, items causing a bump are items such as free scrap

/* 	if the group is 3,4 or 5 - there is no flat rate shipping as the boxes are too big and noflat=1;
	if the group is 0,3 or 5 - the amounts are cumulated in itemtotalzero which is not discounted.
	if the group is 1 or 4 - the amounts are cumulated in itemtotalone which is discounted. */





/* These functions control the hover buttons on the index pages.*/

function FP_preloadImgs() {//v1.0
 var d=document,a=arguments; if(!d.FP_imgs) d.FP_imgs=new Array();
 for(var i=0; i<a.length; i++) { d.FP_imgs[i]=new Image; d.FP_imgs[i].src=a[i]; }
}

function FP_swapImg() {//v1.0
 var doc=document,args=arguments,elm,n; doc.$imgSwaps=new Array(); for(n=2; n<args.length;
 n+=2) { elm=FP_getObjectByID(args[n]); if(elm) { doc.$imgSwaps[doc.$imgSwaps.length]=elm;
 elm.$src=elm.src; elm.src=args[n+1]; } }
}

function FP_getObjectByID(id,o) {//v1.0
 var c,el,els,f,m,n; if(!o)o=document; if(o.getElementById) el=o.getElementById(id);
 else if(o.layers) c=o.layers; else if(o.all) el=o.all[id]; if(el) return el;
 if(o.id==id || o.name==id) return o; if(o.childNodes) c=o.childNodes; if(c)
 for(n=0; n<c.length; n++) { el=FP_getObjectByID(id,c[n]); if(el) return el; }
 f=o.forms; if(f) for(n=0; n<f.length; n++) { els=f[n].elements;
 for(m=0; m<els.length; m++){ el=FP_getObjectByID(id,els[n]); if(el) return el; } }
 return null;
}




 /*This function sets up the shopping cart cookie and the customer identification number.  The parameter "page" is the page
	on which the customer entered the site for the first time.  */
	

	
function bdentget(page){
	 
	
	var CookieName = "vshoppingcart";

    var cookieFound = false;
    var start = 0;
    var end = 0;
        var cookieString = document.cookie;
    var i = 0;
	while (i <= cookieString.length) {
      start = i;
      end = start + CookieName.length;
      if (cookieString.substring(start,end) == CookieName) {
         cookieFound = true;
        break;
       }
       i++;
     }
     
      if (cookieFound == false){     
      	document.cookie = "vshoppingcart=.";
      	/*var sPath = window.location.pathname;
	 	var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
	 	alert(sPage);   
	 	window.location="http://www.barclaywoods.com";*/
 	
     	}
	

	var CookieName = "CustID";
    var cookieFound = false;
    var start = 0;
    var end = 0;
    var cookieString = document.cookie;
    var i = 0;
	while (i <= cookieString.length) {
      start = i;
      end = start + CookieName.length;
      if (cookieString.substring(start,end) == CookieName) {
         cookieFound = true;
        break;
       }
       i++;
    }
     
     if (cookieFound == false){
     function setCookie2(name, value, path) {  	
       document.cookie = name + "=" + page + escape(value) + ";expires=Monday,06-Apr-2015 05:00:00 GMT";
         ((path) ? "; path=" + path : "");
		
		}
		
	var theDate = new Date();
	setCookie2("CustID", theDate.getTime(), "/");
	}
	}




// alterError - fixes a rounding bug
function alterError(xvalue) {
		xvalue=xvalue+.0008;
		if (xvalue<=0.99) {
			newDollars = '0';
		} else {
			newDollars = parseInt(xvalue);
		}
		newCents = parseInt((xvalue - newDollars)* 100);
		if (eval(newCents) <= 9) newCents='0'+newCents;
		newString = newDollars + '.' + newCents;
		return (newString);
	}

// End alterError *********************************************




// buyItem is called from every product page each time an item is purchased and the "buy" button
// is pressed.  This function gets the cookie, and adds the new item to it.  The product page
// passes the item name, the item price in dollars and cents, the item wieght in ounces and
// decimals, a group identifier if there are groups of items, and the number of each item
// purchased.  All of this info must be set up initially on the product pages.

// buyItem - adds an item to the shopping basket
function buyItem(newItem, newPrice, newWeight, newGroup, newQuantity) {
     var CookieName = "vshoppingcart";
     var cookieFound = false;
     var start = 0;
     var end = 0;
     var cookieString = document.cookie;
     var i = 0;
     while (i <= cookieString.length) {
       start = i;
       end = start + CookieName.length;
       if (cookieString.substring(start,end) == CookieName) {
         cookieFound = true;
        break;
       }
       i++;
     }
     if (cookieFound) {
       start = end + 1;
       end = document.cookie.indexOf(";",start);
       if (end < start)
         end = document.cookie.length;
       document.cookie.substring(start,end);
      }
	document.cookie="vshoppingcart="+document.cookie.substring(start, end)	+"["+newItem+"|"+newPrice+"|"+newWeight+"|"+newGroup+"|"+newQuantity+"];";
	window.location.href=document.location;

	if (vbasketTransaction){
	window.location.href='vbasket.htm';
	}
	}
	
	
	//*******************************************************************************
	
	
function zipzone(p){
var zipthree=p;
var zipCodeToZoneArray =
new Array("004-005 005", "006-007 228","008-008 999", "009-009 225", "010-089 005","090-099 999", "100-129 005",
    "130-132 004", "133-135 005", "136-179 004", "180-181 005", "182-182 004", "183-183 005", "184-188 004", 
    "189-194 005", "195-196 004", "197-199 005", "200-217 004", "218-219 005", "220-232 004", "233-237 005", 
    "238-277 004", "278-279 005", "280-282 004", "283-285 005", "286-289 004", "290-292 005", "293-293 004", 
    "294-295 005", "296-297 004", "298-299 005", "300-303 004", "304-304 005", "305-307 004", "308-310 005", 
    "311-311 004", "312-329 005", "330-334 006", "335-338 005", "339-339 006", "340-340 999", "341-341 006", 
    "342-347 005", "348-348 009", "349-349 006", "350-359 004", "360-361 005", "362-362 004", "363-369 005", "370-386 004", 
    "387-387 005", "388-389 004", "390-396 005", "397-397 004", "398-398 005", "399-399 004", "400-406 003", 
    "407-409 004", "410-410 003", "411-422 004", "423-424 003", "425-426 004", "427-438 003", "439-439 004", 
    "440-443 003", "444-447 004", "448-459 003", "460-469 002", "470-472 003", "473-473 002", "474-478 003", 
    "479-479 002", "480-487 003", "488-495 002", "496-499 003", "500-505 004", "506-507 003", "508-516 004","517-517 010", 
    "520-528 003", "530-537 002", "538-538 003", "539-539 002", "540-540 004", "541-547 003", "548-548 004","518-518 011",
    "549-549 003", "550-558 004", "559-559 003", "560-566 004", "567-567 005", "570-574 004", "575-577 005","519-519 012",
    "580-581 004", "582-588 005", "590-591 006", "592-593 005", "594-599 006", "600-611 002", "612-612 003", 
    "613-613 002", "614-614 003", "615-619 002", "620-635 003", "636-675 004", "676-679 005", "680-689 004", 
    "690-714 005","700-714 005", "716-716 004", "717-718 005", "719-729 004", "730-739 005", "740-744 004", 
    "745-748 005", "749-749 004", "750-778 005", "779-785 006", "786-787 005", "788-788 006", "789-796 005", 
    "797-799 006", "800-810 005", "811-816 006", "820-820 005", "821-821 006", "822-822 005", "823-825 006", 
    "826-828 005", "829-834 006", "835-838 007", "840-847 006", "850-854 007", "855-855 006", "856-858 007", 
    "859-860 006", "863-864 007", "865-880 006", "881-881 005", "882-883 006", "884-884 005", "885-885 006", 
    "889-930 007", "931-931 008", "932-933 007", "934-934 008", "935-938 007", "939-941 008", "942-942 007", 
    "943-955 008", "956-961 007","962-966 999","967-968 228","969-969 999", "970-986 007", "988-994 007", 
    "995-999 226"); 



//this goes through the array and finds the correct range that
//the zip code fits into - then sets the value of the zoneText field
//to the correct zone
  zipCode=zipthree;
  var curRangeStart, curRangeEnd, zone1;
  for (var i = 0; i < zipCodeToZoneArray.length; i++) {
    curRangeStart = parseFloat(zipCodeToZoneArray[i].substring(0, 3));
    curRangeEnd   = parseFloat(zipCodeToZoneArray[i].substring(4, 7));
    if (zipCode >= curRangeStart && zipCode <= curRangeEnd) {
    zone1 = parseFloat(zipCodeToZoneArray[i].substring(8, 11));
    return zone1;
    }
  	}
	}

	//End of zoning function
	



// showItems is not implemented on our shopping cart.  If implemented, it allows one
// to display the running total of the number of items and the total amount spent in a
// display bar at the bottom of any page that calls it.

// showItems() - displays shoppingcart contents in a drop down select array
//function showItems() {
	//var CookieName = "vshoppingcart";
     //var cookieFound = false;
     //var start = 0;
     //var end = 0;
     //var cookieString = document.cookie;
     //var i = 0;
     //while (i <= cookieString.length) {
       //start = i;
       //end = start + CookieName.length;
       //if (cookieString.substring(start,end) == CookieName) {
        // cookieFound = true;
        //break;
       //}
       //i++;
     //}
     //if (cookieFound) {
       //start = end + 1;
       //end = document.cookie.indexOf(";",start);
       //if (end < start)
         //end = document.cookie.length;
       //document.cookie.substring(start,end);
      //}
      //fulllist = document.cookie.substring(start, end);
		
		//noflat=0;
		
		//subtotal = 0;
		//subtotalzero = 0;
		//subtotalone =  0;
		//howmany = 0;
		//document.writeln('<form><table border="0" cellspacing="0" cellpadding="0"><tr><td><select><option>Click For ShoppingCart Contents</option>');
		//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;
				//itemtotalzero = 0;
				//itemtotalone = 0;
				//itemweight = 0;
				//howmany = howmany + 1;
				//itemtotal = (eval(theprice*thequantity));
				
				//if ((thegroup==1)||(thegroup==4)) {
					//noflat=1;
				//}
				
				//if ((thegroup==0)||(thegroup==3)){
					//itemtotalzero = (eval(theprice*thequantity))
				//}
				//if ((thegroup==1)||(thegroup==4)) {
					//itemtotalone = (eval(theprice*thequantity))
				//}
				//itemweight = (eval(theweight*thequantity));
				//temptotal = itemtotal * 100;
				//temptotalzero = itemtotalzero * 100;
				//temptotalone = itemtotalone * 100
				//tempweight = itemweight * 100;
				//subtotal = subtotal + itemtotal;
				//subtotalzero = subtotalzero + itemtotalzero;
				//subtotalone = subtotalone + itemtotalone;
				//subweight = subweight + itemweight;
				//itemlist=itemlist+1;
				//document.write('<option>'+thequantity+' -   '+theitem+'</option>');
			//} 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) theweight = fulllist.substring(itemstart, i);
				//if (thisitem==4) thegroup = fulllist.substring(itemstart, i);
				//if (thisitem==5) theoption = fulllist.substring(itemstart, i);
				//thisitem++;
				//itemstart=i+1
				//}
				//}
		//document.writeln('</select><br><center><font size="1" color="#000000" face="Arial, Helvetica, sans-serif">');
		//document.writeln('&nbsp;'+ howmany +'&nbsp;Item(s)&nbsp;&nbsp;Sub Total: $'+ alterError(subtotal) +'</font></center></td></tr></table></form>');
			    //}


// End ShowItems ****************************************************************************************************




// gettax gets the zip code of the recipient and determines whether the customer is a resident of Indiana.

function gettax() {
     var CookieName1 = "zipstate";
     var cookieFound = false;
     var start = 0;
     var end = 0;
     var cookieString = document.cookie;
     var i = 0;
     while (i <= cookieString.length) {
      start = i;
      end = start + CookieName1.length;
      if (cookieString.substring(start,end) == CookieName1) {
         cookieFound = true;
        break;
       }
       i++;
     }
     if (cookieFound) {
       start = end + 1;
       end = document.cookie.indexOf(";",start);
       if (end < start)end = document.cookie.length;
       fulllist=document.cookie.substring(start,end);
       recipzip=document.cookie.substring(start+1,end-9);
       buyerstate=document.cookie.substring(start+7,end-5);
       pickup=document.cookie.substring(start+11,end-1);

     }
     
     
     }




// showbuy is the biggy.  It has been heavily modified for our web site.
// It calculates the total price, it allows discounts by category.  It calculates
// tax, total weight or the order, shipping according to UPS zone and shipping
// for canada and Europe.  It displays these in a table on the vbuyX page and it
// passes these amounts and values to a database or e-mail program.  We have
// annotated this section more heavily/



//Show vbuy.htm contents
function showvbuy() {
     var CookieName = "vshoppingcart";
     var cookieFound = false;
     var start = 0;
     var end = 0;
     var cookieString = document.cookie;
     var i = 0;



//****************************************************************

// Tax function.  Here a "confirm" prompt is used to discover whether the customer is from Indiana.
	gettax();
	var noshipping=0;
	var taxcharge = "0";
	//var taxcheck = confirm('State Sales Tax Question: Are You A Resident Of ' + taxstate+'? Press "Ok" For Yes. Otherwise Press "Cancel" For No.');
	if (pickup=="yes"){
	noshipping=1;
	buyerstate="yes";
	}
	if (buyerstate=="yes") taxcharge = taxrate;
	

// This is a temporary end to the tax rate gathering.

//****************************************************************

// Here, a check is made for the existence of the cookie and start and end points for reading it
// are determined.  Then, the cookie is read and the order is assembled.
	var CookieName = "vshoppingcart";
	i=0;
	while (i <= cookieString.length) {
      start = i;
      end = start + CookieName.length;
      if (cookieString.substring(start,end) == CookieName) {
         cookieFound = true;
        break;
       }
       i++;
     }
     if (cookieFound) {
       start = end + 1;
       end = document.cookie.indexOf(";",start);
       if (end < start)
         end = document.cookie.length;
       document.cookie.substring(start,end);
     }

	var ItemsOrdered = document.cookie.substring(start,end);
		fulllist = document.cookie.substring(start, end);
		var totprice = 0;
		var totpricezero = 0;
		var totpriceone = 0;
		var totweight = 0;
		var totpricenoship = 0;
        var theweight=0;

// Here, the headings of the table are written

		document.writeln('<table id="center4" cellpadding="2" class="style79">');
		document.writeln('<tr><td class="style133"><strong>Item</strong></td>');
		document.writeln('<td class="style133"><strong>Quantity</strong></td><td class="style133"><strong>Cost Each</strong></td><td class="style133"><strong>Sub Total</strong></td></tr>');

						

// Next, the cart cycles through the cookie calculating the price of each item ordered
// times the number of that item ordered.  It accumulates an item total, and item totals
// for each of the two catagories we currently employ. It also sums these weights and amounts
// as well as summing the total weight.  Each item is printed in a table.
		itemlist = 0;
		numberofitems = 0;
		noflat=0;
		for (var i = 0; i<= fulllist.length; i++) {
			if (fulllist.substring(i,i+1) == '[') {
				thisitem = 1;
				itemstart = i+1;
			} else if (fulllist.substring(i,i+1) == ']') {
				itemend = i;
				thequantity = fulllist.substring(itemstart, itemend);
				itemtotal = 0;
				itemtotalzero = 0;
				itemtotalone = 0;
				itemweight = 0;
				itemtotal = (eval(theprice*thequantity));
				if ((thegroup==3)||(thegroup==4)||(thegroup==5))noflat=1;
				if(thegroup==6) shipbump=1;
				if ((thegroup==0)||(thegroup==3)||(thegroup==5)||(thegroup==6))itemtotalzero = (eval(theprice*thequantity));
				if ((thegroup==1)||(thegroup==4))itemtotalone = (eval(theprice*thequantity));
				itemweight = (eval(theweight*thequantity));
				totprice = totprice + itemtotal;
				totpricezero = totpricezero + itemtotalzero;
				totpriceone = totpriceone + itemtotalone;
				totweight = totweight + itemweight;
				itemlist = itemlist + 1;
				numberofitems = (numberofitems + parseInt(thequantity,10));
				document.write('<tr><td class="style132">'+theitem+'</td>');
				document.writeln('<td class="style132">'+thequantity+'</td><td class="style132">'+theprice+'</td><td class="style132">'+alterError(itemtotal)+'</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) theweight = fulllist.substring(itemstart, i);
				if (thisitem==4) thegroup = fulllist.substring(itemstart, i);
				if (thisitem==5) theoption = fulllist.substring(itemstart, i);
				thisitem++;
				itemstart=i+1;
       }}

// Calculate Discounts.  Here, quantity discounts rates at different
// levels of purchase are calculated.  These discounts proceed smoothly
// from one level to the next in order to avoid a price hiccup at the
// transition where, for example, 99 items cost more than 100
// items because the discount applies to the latter but not the former.
// In our case, we provide these discounts only to catagory 2 of our
// items.

		level = 0;
		pricediscountone = 0;
		beforeprice=0;
		afterprice=0;
		if (totprice<50)level = 0;
		if (totprice>=50&&totprice<150)level = 1;
		if (totprice>=150&&totprice<250)level = 2;
		if (totprice>=250&&totprice<500)level = 3;
		if (totprice>=500&&totprice<1000)level = 4;
		if (totprice>=1000&&totprice<2000)level = 5;
		if (totprice>=2000)level = 6;
		// remember that this calcualtion appears in two places and has to be changed both places. See lines around line 775
		if (level==0) discount = 0;
		if (level==1) discount = (.05+(.05*((totprice-50)/100)));
		if (level==2) discount = (.10+(.05*((totprice-150)/100)));
		if (level==3) discount = (.15+(.05*((totprice-250)/250)));
		if (level==4) discount = (.20+(.05*((totprice-500)/500)));
		if (level==5) discount = (.25+(.05*((totprice-1000)/1000)));
		if (level==6) discount = .30;
		
		pricediscountone = totpriceone*discount;
		

//********************end of calculating discounts



//********************calculating final prices

		beforeprice=totprice;
		totpriceone = totprice - pricediscountone;
		totprice = totprice-pricediscountone;
		afterprice = totprice

//**********end calculating final prices





// ******************calculate & print Tax.  This is obvious

		var subtax=0;
		subtax = totprice *taxcharge;
		totprice = totprice + subtax;
		
		document.writeln('<tr><td colspan="3" class="style132">Original Price</td><td  class="style132">'+alterError(beforeprice)+'</td></tr>');
		document.writeln('<tr><td colspan="3" class="style132">(Open Stock Discount)</td><td class="style132">'+alterError(pricediscountone)+'</td></tr>');
		document.writeln('<tr><td colspan="3" class="style132">Discount Price</td><td class="style132">'+alterError(afterprice)+'</td></tr>');
		document.writeln('<tr><td colspan="3" class="style132">Sales Tax('+taxstate+')</td><td  class="style132">'+alterError(subtax)+'</td></tr>');
// **************************end calculating tax




//theirzip function

   	// Here, the shopping cart prompts for a five digit zip code or the
	// terms "can" "CAN, "eur" or "EUR", "PAC" 0r "pac."  The numbers provided are checked with a variety of
	// tests and then truncated to three digits for a zone check
     		var zipthree = recipzip;
    		var accept=false;
		if(zipthree.length==5)accept=true;
		for(j=0;j<5;j++){
			if(zipthree.charAt(j)<"0") accept=false;
			if(zipthree.charAt(j)>"9") accept=false;
			}
		if (zipthree<=0||zipthree>=99999) accept=false;
		if (zipthree>0||zipthree<99999){
			zipthree=zipthree/100;
			zipthree=Math.floor(zipthree);
			}

		if(zipthree == 517||zipthree == 518||zipthree  ==519||zipthree  ==518||zipthree  ==518||zipthree  ==568				||zipthree  ==569||zipthree  ==578||zipthree  ==579||zipthree ==589)accept=false;
		if (zipthree  ==694||zipthree  ==695||zipthree  ==696||zipthree  ==697||zipthree  ==698||zipthree  ==699)				accept=false;
		if(zipthree  ==715) accept = false;
		if(zipthree  ==817||zipthree  ==819||zipthree  ==839||zipthree  ==848||zipthree  ==849||zipthree  ==861				||zipthree  ==862||zipthree  ==886||zipthree  ==887||zipthree ==888) accept=false;
		
		if((zipthree=="MEX")||(zipthree=="mex")||(zipthree=="CAN")||(zipthree=="can")||(zipthree=="ESA")||(zipthree=="esa")||(zipthree=="PAC")||(zipthree=="pac"))accept=true;

		if(accept==false) window.location="vbuy2.htm";
		//if(accept==true) index=10;



	  if((zipthree=="CAN")||(zipthree=="can"))zipthree=348;
	  if((zipthree=="ESA")||(zipthree=="esa"))zipthree=517;
	  if((zipthree=="PAC")||(zipthree=="pac"))zipthree=518;
	  if((zipthree=="MEX")||(zipthree=="mex"))zipthree=519;

//************************************************************************************




//this array contains strings that can be broken down
//into zip code ranges and their corresponding zone

zone1 = zipzone(zipthree);
zone=zone1;

//********************* end of zone setting

// From the zone, a zone charge is assigned.  This is dollars per pound that it costs to send
// to this zip code.  UPS charges a fixed amount per box, plus a charge based on weight.  This
// has to be fine tuned empirically but is approximately correct as of 9/1/06 for UPS from
// NWI.  The zones for Hawaii, Alaska, Canada, and Europe are based on Priority mail and air post.

	zonechg=.746;
	boxprice =8.00;
	
if (zone==2) zonechg=.32;
if (zone==3) zonechg=.35;
if (zone==4) zonechg=.38;
if (zone==5) zonechg=.41;
if (zone==6) zonechg=.45;
if (zone==7) zonechg=.48;
if (zone==8) zonechg=.51;

//if (zone==2) zonechg=.213;
//if (zone==3) zonechg=.267;
//if (zone==4) zonechg=.299;
//if (zone==5) zonechg=.373;
//if (zone==6) zonechg=.48;
//if (zone==7) zonechg=.618;
//if (zone==8) zonechg=.746;


if (zone==9) {zonechg=1.5; boxprice=18.50;shipmode=1;} 	//***Canada

if (zone==10){zonechg=3.45; boxprice=23.50;shipmode=1;}	//***Europe, Africa

if (zone==11){zonechg=3.80; boxprice=23.50;shipmode=1;}	//***Pacific Basin

if (zone==12){zonechg=3.22;shipmode=1;}	//***Mexico and Central America

if (zone==999){zonechg=1.75;shipmode=1;}	//***Hawaii

if (zone==226){zonechg=1.75;shipmode=1;}	//***Alaska

if (zone==228){zonechg=1.75;shipmode=1;}	//***Puerto Rico

if (zone==225){zonechg=1.75;shipmode=1;}	//***USVI

// ***************************** end of zonecharge








//*************** start of shipping section.  This can be done in various ways.  For us, there are abrupt
// increments when an order calls for additional boxes.  A box of blocks weighs about 40 pounds, so we
// add this increment every 40 lbs of total weight.  We also set some specific prices that call for special
// treatment.  In particular, we set the shipping charge to $4.05 for items that can be gotten
// into a Priority Mail fixed price envelope (except when it goes to Europe or Canada).

	onealph=0;
	alphcart=0;
	
	
	boxes = Math.round((totweight/40)+.5);
	shippingcharge = (totweight*zonechg)+(boxprice*boxes);
	if((zone!=9)&&(zone!=10)&&(zone!=11)&&(zone!=12)){
	if ((totprice>15.94&&totprice<15.96)||(totprice>16.89&&totprice<16.91)) shippingcharge = 5.95;
	if (totprice<.01) shippingcharge = 0;
	if (boxes<2) shippingcharge=shippingcharge +1;
	if (totweight<.75)shippingcharge=6.50;
	if (totprice<.01) shippingcharge = 0;
	if (totweight<.01) shippingcharge = 0;
	}
	
	
	if(noflat==0){
	
	if(((zone==226)||(zone==228)||(zone==999))&&(totweight>16))shippingcharge=((2*boxes*16.95)); //big piles
	if(((zone==226)||(zone==228)||(zone==999))&&(totweight>12&&totweight<=16))shippingcharge=16.95; //small orders
	if(((zone==226)||(zone==228)||(zone==999))&&(totweight<=12))shippingcharge=12.95; //small orders
	if(((zone==226)||(zone==228)||(zone==999))&&(totweight==22.0025))shippingcharge=16.95; //toddler kit with book
	if(((zone==226)||(zone==228)||(zone==999))&&(totweight==20.0025))shippingcharge=16.95; //toddler kit
	

    if((zone==10||zone==11)&&(totweight>16))shippingcharge=((2*boxes*53.95)); //big piles
	if(((zone==10||zone==11))&&(totweight>12&&totweight<=16))shippingcharge=53.95; //small orders
	if(((zone==10||zone==11))&&(totweight<=12))shippingcharge=42.95; //small orders
	if(((zone==10||zone==11))&&(totweight==22.0025))shippingcharge=53.95; //toddler kit with book
	if(((zone==10||zone==11))&&(totweight==20.0025))shippingcharge=53.95; //toddler kit

	
	
	if((zone==9)||(zone==12)&&(totweight>16))shippingcharge=((2*boxes*33.95)); //big piles
	if(((zone==9)||(zone==12))&&(totweight>12&&totweight<=16))shippingcharge=33.95; //small orders
	if(((zone==9)||(zone==12))&&(totweight<=12))shippingcharge=27.95; //small orders
	if(((zone==9)||(zone==12))&&(totweight==22.0025))shippingcharge=33.95; //toddler kit with book
	if(((zone==9)||(zone==12))&&(totweight==20.0025))shippingcharge=33.95; //toddler kit
	

		
	}
	

	if(noflat==1){
	if(((zone==226)||(zone==228)||(zone==999)))shippingcharge=(15.00+(totweight*1.5)); //Priority Mail
	
	if(zone==9)  shippingcharge=(26+(totweight*1.58)); // Canada
	
	if(zone==12) shippingcharge=(28+(totweight*3.50)); //Mexico

    if(zone==10) shippingcharge=(40+(2.63*totweight)); //Europe, S.America, & Africa
    
    if(zone==11) shippingcharge=(40+(3.38*totweight)); //asia & Australia
	

	}
	if (shipmode==1) shipdis=1;
	if(shippingcharge<150) shippingcharge=shippingcharge*shipdis;  //applies the current shipping discount
	if(noshipping==1)shippingcharge=4.95+((boxes-1)*2.49);	
	if(shipbump==1) shippingcharge=shippingcharge+(3.00*boxes);
	if((shippingcharge>=0)&&(shippingcharge<4.95))shippingcharge=4.95;
	totpricenoship=totprice;
	totprice=totprice+shippingcharge;
	itemprice=totprice-shippingcharge+subtax;	
	


//***************** end of shipping section

// Here we obtain the customer ID cookie (a separate cookie based on the
// exact time). This cookie distinguishes one customer from another and allows
// us to identify the various pieces of the order later.

// Get Transaction ID Cookie

	function getCookie(name) {  //"name" is a reserved word
     	var cookie = " " + document.cookie;  // "cookie" is a reserved name
      var search = " " + name + "=";
     	var setStr = null;
      var offset = 0;
     	var end = 0;
     	if (cookie.length > 0) {
      offset = cookie.indexOf(search);
	if (offset != -1) {
   	offset += search.length;
   	end = cookie.indexOf(";", offset);
   		if (end == -1) {
   		end = cookie.length;
		}
		setStr = unescape(cookie.substring(offset, end));
		}
		}
		return(setStr);
		}
		var ID="";
		ID = getCookie("TransID");
		ID2=ID;
// Get Transaction ID Cookie - End

//Get customer ID
		var IC="";
		IC = getCookie("CustID");
		IC2=IC;
//end get customer ID - end
		
	
	

shipweight=Math.round((totweight)+.5);

// Here the table is written for the customer
shipword = "Shipping";
if(noshipping==1)shipword="Box and handling";

		
        document.writeln('<tr><td colspan="3" class="style132">' + shipword +'(about  ' +shipweight+ '    lbs.)</td><td  class="style132">'+alterError(shippingcharge)+'</td></tr>');
		
		document.writeln('<tr class="style133"><td  colspan="3" class="style134"><strong>Total:</strong></td><td class="style133" align="right">$'+alterError(totprice)+'</td></tr>');
// end writing the table for customers


		

//begin posting the order to e-mail.  Here, the order is sent to us by e-mail using formmail.
// also, the "continue" button is drawn at the bottom of the table

		document.write('<form action="http://www.barclaywoods.com/FormMail.aspx" method="post">');
		//document.write('<input type=hidden name="emailto" value="orders@">');
		//document.write('<input type=hidden name="emailfrom" value="mBAC@barclaywoods.com">');
		//document.write('<input type=hidden name="emailsubject" value="form submit">');
		//document.write('<input type=hidden name="emailconfirm" value="http://www.barclaywoods.com/vbuyX.htm">');
		document.write('<input type=hidden name="RedirectTo" value="http://www.barclaywoods.com/vbuyX1.htm">');
		document.write('<input type="hidden" name="business" value="' + business + '">');
		document.write('<input type="hidden" name="item_name" value="' + fulllist + '">');
		document.write('<input type="hidden" name="item_number" value="' + ID + '">');
		document.write('<input type="hidden" name="cust_number" value="' + IC + '">');		
		document.write('<input type="hidden" name="Original Price" value="' + alterError(beforeprice) + '">');
		document.write('<input type="hidden" name="(Open Stock Discount)" value="' + alterError(pricediscountone) + '">');		
		document.write('<input type="hidden" name="Discount Price" value="' + alterError(afterprice) + '">');
		document.write('<input type="hidden" name="Sales Tax" value="' + alterError(subtax) + '">');
		document.write('<input type="hidden" name="Shipping" value="' + alterError(shippingcharge) + '">');
		document.write('<input type="hidden" name="Total Cost" value="' + alterError(totprice) + '">');
		document.writeln('</table><br />OrderId = ' + ID +'<br /><br />');
		//document.writeln('Zone = ' + zone +'<p>');
		//document.writeln('Zonechg = ' + zonechg +'<p>');
		//document.writeln('Total price = ' + totprice +'<p>');
		//document.writeln('Tax Charge = ' + taxcharge +'<p>');
		//document.writeln('Tax Rate = ' + taxrate +'<p>');
		//document.writeln('Price check = ' + cktotalprice +'<p>');
		document.writeln('<input type="image" name=submit_order src="bttnsbanners/continue.jpg"><p>');
		document.writeln('</form>');
		}




// Show basket contents.  Here, the items are printed sorted by categories,
// the discount is shown for those categories that warrant them, and buttons are
// provide to delete items from the cart, clear the whole cart, or alter the number
// of each item.  In order to write the items sorted by category, this function cycles
// through the routine as many times as there are categories.

// Here the table headings are written as a form along with the necessary links and calls
// to change the item quantities.



//Show vbuy.htm contents

//showvbuy2 is for vbuy4 and PayPal
function showvbuy2() {
     var CookieName = "vshoppingcart";
     var cookieFound = false;
     var start = 0;
     var end = 0;
     var cookieString = document.cookie;
     var i = 0;



//****************************************************************

// Tax function.  Here a "confirm" prompt is used to discover whether the customer is from Indiana.
	gettax();
	var noshipping=0;
	var taxcharge = "0";
	//var taxcheck = confirm('State Sales Tax Question: Are You A Resident Of ' + taxstate+'? Press "Ok" For Yes. Otherwise Press "Cancel" For No.');
	if (pickup=="yes"){
	noshipping=1;
	buyerstate="yes";
	}
	if (buyerstate=="yes") taxcharge = taxrate;
	

// This is a temporary end to the tax rate gathering.

//****************************************************************

// Here, a check is made for the existence of the cookie and start and end points for reading it
// are determined.  Then, the cookie is read and the order is assembled.
	var CookieName = "vshoppingcart";
	i=0;
	while (i <= cookieString.length) {
      start = i;
      end = start + CookieName.length;
      if (cookieString.substring(start,end) == CookieName) {
         cookieFound = true;
        break;
       }
       i++;
     }
     if (cookieFound) {
       start = end + 1;
       end = document.cookie.indexOf(";",start);
       if (end < start)
         end = document.cookie.length;
       document.cookie.substring(start,end);
     }

	var ItemsOrdered = document.cookie.substring(start,end);
		fulllist = document.cookie.substring(start, end);
		var totprice = 0;
		var totpricezero = 0;
		var totpriceone = 0;
		var totweight = 0;
		var totpricenoship = 0;
        var theweight=0;

// Here, the headings of the table are written

		document.writeln('<table id="center4" cellpadding="2" class="style79">');
		document.writeln('<tr><td class="style133"><strong>Item</strong></td>');
		document.writeln('<td class="style133"><strong>Quantity</strong></td><td class="style133"><strong>Cost Each</strong></td><td class="style133"><strong>Sub Total</strong></td></tr>');

		
// Next, the cart cycles through the cookie calculating the price of each item ordered
// times the number of that item ordered.  It accumulates an item total, and item totals
// for each of the two catagories we currently employ. It also sums these weights and amounts
// as well as summing the total weight.  Each item is printed in a table.
		itemlist = 0;
		numberofitems = 0;
		noflat=0;
		for (var i = 0; i<= fulllist.length; i++) {
			if (fulllist.substring(i,i+1) == '[') {
				thisitem = 1;
				itemstart = i+1;
			} else if (fulllist.substring(i,i+1) == ']') {
				itemend = i;
				thequantity = fulllist.substring(itemstart, itemend);
				itemtotal = 0;
				itemtotalzero = 0;
				itemtotalone = 0;
				itemweight = 0;
				itemtotal = (eval(theprice*thequantity));
				if ((thegroup==3)||(thegroup==4)||(thegroup==5))noflat=1;
				if(thegroup==6) shipbump=1;
				if ((thegroup==0)||(thegroup==3)||(thegroup==5)||(thegroup==6))itemtotalzero = (eval(theprice*thequantity));
				if ((thegroup==1)||(thegroup==4))itemtotalone = (eval(theprice*thequantity));
				itemweight = (eval(theweight*thequantity));
				totprice = totprice + itemtotal;
				totpricezero = totpricezero + itemtotalzero;
				totpriceone = totpriceone + itemtotalone;
				totweight = totweight + itemweight;
				itemlist = itemlist + 1;
				numberofitems = (numberofitems + parseInt(thequantity,10));
				document.write('<tr><td class="style132">'+theitem+'</td>');
				document.writeln('<td class="style132">'+thequantity+'</td><td class="style132">'+theprice+'</td><td class="style132">'+alterError(itemtotal)+'</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) theweight = fulllist.substring(itemstart, i);
				if (thisitem==4) thegroup = fulllist.substring(itemstart, i);
				if (thisitem==5) theoption = fulllist.substring(itemstart, i);
				thisitem++;
				itemstart=i+1;
       }}

// Calculate Discounts.  Here, quantity discounts rates at different
// levels of purchase are calculated.  These discounts proceed smoothly
// from one level to the next in order to avoid a price hiccup at the
// transition where, for example, 99 items cost more than 100
// items because the discount applies to the latter but not the former.
// In our case, we provide these discounts only to catagory 2 of our
// items.

		level = 0;
		pricediscountone = 0;
		beforeprice=0;
		afterprice=0;
		if (totprice<50)level = 0;
		if (totprice>=50&&totprice<150)level = 1;
		if (totprice>=150&&totprice<250)level = 2;
		if (totprice>=250&&totprice<500)level = 3;
		if (totprice>=500&&totprice<1000)level = 4;
		if (totprice>=1000&&totprice<2000)level = 5;
		if (totprice>=2000)level = 6;
		// remember that this calcualtion appears in two places and has to be changed both places. See lines around line 775
		if (level==0) discount = 0;
		if (level==1) discount = (.05+(.05*((totprice-50)/100)));
		if (level==2) discount = (.10+(.05*((totprice-150)/100)));
		if (level==3) discount = (.15+(.05*((totprice-250)/250)));
		if (level==4) discount = (.20+(.05*((totprice-500)/500)));
		if (level==5) discount = (.25+(.05*((totprice-1000)/1000)));
		if (level==6) discount = .30;
		
		pricediscountone = totpriceone*discount;
		

//********************end of calculating discounts



//********************calculating final prices

		beforeprice=totprice;
		totpriceone = totprice - pricediscountone;
		totprice = totprice-pricediscountone;
		afterprice = totprice

//**********end calculating final prices





// ******************calculate & print Tax.  This is obvious

		var subtax=0;
		subtax = totprice *taxcharge;
		totprice = totprice + subtax;
		
	document.writeln('<tr><td colspan="3" class="style132">Original Price</td><td  class="style132">'+alterError(beforeprice)+'</td></tr>');
		document.writeln('<tr><td colspan="3" class="style132">(Open Stock Discount)</td><td class="style132">'+alterError(pricediscountone)+'</td></tr>');
		document.writeln('<tr><td colspan="3" class="style132">Discount Price</td><td class="style132">'+alterError(afterprice)+'</td></tr>');
		document.writeln('<tr><td colspan="3" class="style132">Sales Tax('+taxstate+')</td><td  class="style132">'+alterError(subtax)+'</td></tr>');
// **************************end calculating tax

//theirzip function

   	// Here, the shopping cart prompts for a five digit zip code or the
	// terms "can" "CAN, "eur" or "EUR", "PAC" 0r "pac."  The numbers provided are checked with a variety of
	// tests and then truncated to three digits for a zone check
     		var zipthree = recipzip;
    		var accept=false;
		if(zipthree.length==5)accept=true;
		for(j=0;j<5;j++){
			if(zipthree.charAt(j)<"0") accept=false;
			if(zipthree.charAt(j)>"9") accept=false;
			}
		if (zipthree<=0||zipthree>=99999) accept=false;
		if (zipthree>0||zipthree<99999){
			zipthree=zipthree/100;
			zipthree=Math.floor(zipthree);
			}

		if(zipthree == 517||zipthree == 518||zipthree  ==519||zipthree  ==518||zipthree  ==518||zipthree  ==568				||zipthree  ==569||zipthree  ==578||zipthree  ==579||zipthree ==589)accept=false;
		if (zipthree  ==694||zipthree  ==695||zipthree  ==696||zipthree  ==697||zipthree  ==698||zipthree  ==699)				accept=false;
		if(zipthree  ==715) accept = false;
		if(zipthree  ==817||zipthree  ==819||zipthree  ==839||zipthree  ==848||zipthree  ==849||zipthree  ==861				||zipthree  ==862||zipthree  ==886||zipthree  ==887||zipthree ==888) accept=false;
		
		if((zipthree=="MEX")||(zipthree=="mex")||(zipthree=="CAN")||(zipthree=="can")||(zipthree=="ESA")||(zipthree=="esa")||(zipthree=="PAC")||(zipthree=="pac"))accept=true;

		if(accept==false) window.location="vbuy2.htm";
		//if(accept==true) index=10;



	  if((zipthree=="CAN")||(zipthree=="can"))zipthree=348;
	  if((zipthree=="ESA")||(zipthree=="esa"))zipthree=517;
	  if((zipthree=="PAC")||(zipthree=="pac"))zipthree=518;
	  if((zipthree=="MEX")||(zipthree=="mex"))zipthree=519;
	  

zone1 = zipzone(zipthree);
zone=zone1;



//********************* end of zone setting

// From the zone, a zone charge is assigned.  This is dollars per pound that it costs to send
// to this zip code.  UPS charges a fixed amount per box, plus a charge based on weight.  This
// has to be fine tuned empirically but is approximately correct as of 9/1/06 for UPS from
// NWI.  The zones for Hawaii, Alaska, Canada, and Europe are based on Priority mail and air post.

	zonechg=.746;
	boxprice =8.00;
	
if (zone==2) zonechg=.32;
if (zone==3) zonechg=.35;
if (zone==4) zonechg=.38;
if (zone==5) zonechg=.41;
if (zone==6) zonechg=.45;
if (zone==7) zonechg=.48;
if (zone==8) zonechg=.51;

//if (zone==2) zonechg=.213;
//if (zone==3) zonechg=.267;
//if (zone==4) zonechg=.299;
//if (zone==5) zonechg=.373;
//if (zone==6) zonechg=.48;
//if (zone==7) zonechg=.618;
//if (zone==8) zonechg=.746;

if (zone==9) {zonechg=1.5; boxprice=18.50;shipmode=1;} 	//***Canada

if (zone==10){zonechg=3.45; boxprice=23.50;shipmode=1;}	//***Europe, Africa

if (zone==11){zonechg=3.80; boxprice=23.50;shipmode=1;}	//***Pacific Basin

if (zone==12){zonechg=3.22;shipmode=1;}	//***Mexico and Central America

if (zone==999){zonechg=1.75;shipmode=1;}	//***Hawaii

if (zone==226){zonechg=1.75;shipmode=1;}	//***Alaska

if (zone==228){zonechg=1.75;shipmode=1;}	//***Puerto Rico

if (zone==225){zonechg=1.75;shipmode=1;}	//***USVI

// ***************************** end of zonecharge








//*************** start of shipping section.  This can be done in various ways.  For us, there are abrupt
// increments when an order calls for additional boxes.  A box of blocks weighs about 40 pounds, so we
// add this increment every 40 lbs of total weight.  We also set some specific prices that call for special
// treatment.  In particular, we set the shipping charge to $4.05 for items that can be gotten
// into a Priority Mail fixed price envelope (except when it goes to Europe or Canada).

	onealph=0;
	alphcart=0;
	//if((totweight==4.037)||(totweight==2.037)) onealph=1;	
	//if(totweight==7.037) alphcart=1;	
	//if((totweight==8.074)||(totweight==4.074)) onealph=2;	
	//if(totweight==14.074) alphcart=2;	
	
	boxes = Math.round((totweight/40)+.5);
	shippingcharge = (totweight*zonechg)+(boxprice*boxes);
	if((zone!=9)&&(zone!=10)&&(zone!=11)&&(zone!=12)){
	if ((totprice>15.94&&totprice<15.96)||(totprice>16.89&&totprice<16.91)) shippingcharge = 5.95;
	if (totprice<.01) shippingcharge = 0;
	if (boxes<2) shippingcharge=shippingcharge +1;
	if (totweight<.75)shippingcharge=6.50;
	if (totprice<.01) shippingcharge = 0;
	if (totweight<.01) shippingcharge = 0;
	}
	
	
	if(noflat==0){
	
	if(((zone==226)||(zone==228)||(zone==999))&&(totweight>16))shippingcharge=((2*boxes*16.95)); //big piles
	if(((zone==226)||(zone==228)||(zone==999))&&(totweight>12&&totweight<=16))shippingcharge=16.95; //small orders
	if(((zone==226)||(zone==228)||(zone==999))&&(totweight<=12))shippingcharge=12.95; //small orders
	if(((zone==226)||(zone==228)||(zone==999))&&(totweight==22.0025))shippingcharge=16.95; //toddler kit with book
	if(((zone==226)||(zone==228)||(zone==999))&&(totweight==20.0025))shippingcharge=16.95; //toddler kit
	

    if((zone==10||zone==11)&&(totweight>16))shippingcharge=((2*boxes*53.95)); //big piles
	if(((zone==10||zone==11))&&(totweight>12&&totweight<=16))shippingcharge=53.95; //small orders
	if(((zone==10||zone==11))&&(totweight<=12))shippingcharge=42.95; //small orders
	if(((zone==10||zone==11))&&(totweight==22.0025))shippingcharge=53.95; //toddler kit with book
	if(((zone==10||zone==11))&&(totweight==20.0025))shippingcharge=53.95; //toddler kit

	
	
	if((zone==9)||(zone==12)&&(totweight>16))shippingcharge=((2*boxes*33.95)); //big piles
	if(((zone==9)||(zone==12))&&(totweight>12&&totweight<=16))shippingcharge=33.95; //small orders
	if(((zone==9)||(zone==12))&&(totweight<=12))shippingcharge=27.95; //small orders
	if(((zone==9)||(zone==12))&&(totweight==22.0025))shippingcharge=33.95; //toddler kit with book
	if(((zone==9)||(zone==12))&&(totweight==20.0025))shippingcharge=33.95; //toddler kit
	

		
	}
	

	if(noflat==1){
	if(((zone==226)||(zone==228)||(zone==999)))shippingcharge=(15.00+(totweight*1.5)); //Priority Mail
	
	if(zone==9)  shippingcharge=(26+(totweight*1.58)); // Canada
	
	if(zone==12) shippingcharge=(28+(totweight*3.50)); //Mexico

    if(zone==10) shippingcharge=(40+(2.63*totweight)); //Europe, S.America, & Africa
    
    if(zone==11) shippingcharge=(40+(3.38*totweight)); //asia & Australia
	

	}
	if (shipmode==1) shipdis=1;
	if(shippingcharge<150) shippingcharge=shippingcharge*shipdis;  //applies the current shipping discount
	if(noshipping==1)shippingcharge=4.95+((boxes-1)*2.49);	
	if(shipbump==1) shippingcharge=shippingcharge+(3.00*boxes);
	if((shippingcharge>=0)&&(shippingcharge<4.95))shippingcharge=4.95;
	totpricenoship=totprice;
	totprice=totprice+shippingcharge;
	itemprice=totprice-shippingcharge+subtax;

//***************** end of shipping section

// Here we obtain the customer ID cookie (a separate cookie based on the
// exact time). This cookie distinguishes one customer from another and allows
// us to identify the various pieces of the order later.

// Get Transaction ID Cookie

	function getCookie(name) {  //"name" is a reserved word
     	var cookie = " " + document.cookie;  // "cookie" is a reserved name
      var search = " " + name + "=";
     	var setStr = null;
      var offset = 0;
     	var end = 0;
     	if (cookie.length > 0) {
      offset = cookie.indexOf(search);
	if (offset != -1) {
   	offset += search.length;
   	end = cookie.indexOf(";", offset);
   		if (end == -1) {
   		end = cookie.length;
		}
		setStr = unescape(cookie.substring(offset, end));
		}
		}
		return(setStr);
		}
		var ID="";
		ID = getCookie("TransID");
		ID2=ID;
// Get Transaction ID Cookie - End

//Get customer ID
		var IC="";
		IC = getCookie("CustID");
		IC2=IC;
//end get customer ID - end
		
	
	

shipweight=Math.round((totweight)+.5);
shipword = "Shipping";
if(noshipping==1)shipword="Box and handling";



// Here the table is written for the customer

	  document.writeln('<tr><td colspan="3" class="style132">' + shipword +'(about  ' +shipweight+ '    lbs.)</td><td  class="style132">'+alterError(shippingcharge)+'</td></tr>');
		
		document.writeln('<tr class="style133"><td  colspan="3" class="style134"><strong>Total:</strong></td><td class="style133" align="right">$'+alterError(totprice)+'</td></tr>');
// end writing the table for customers


// This is a temporary end to the tax rate gathering.


// This section is for testing and implementing PayPal using a form
// For testing purposes, the mail to is activated and the PayPal sections commented out

		//document.write('<form action="mailto:alexandergalvin@earthlink.net" method="post">');
		
		
		document.write('<form action="https://www.paypal.com/us/cgi-bin/webscr" method="post">');
		document.write('<input type=hidden name="cmd" value="_xclick">');
		document.write('<input type=hidden name="business" value="alexandergalvin@earthlink.net">');
		document.write('<input type=hidden name="item_number" value="' + ID + '">');
		document.write('<input type=hidden name="item_name" value="Miscellaneous Blocks">');
		document.write('<input type=hidden name="currency_code" value="USD">');
		document.write('<input type=hidden name="amount" value="'+ alterError(afterprice) + '">');	
		document.write('<input type="hidden" name="tax" value="' + alterError(subtax) + '">');	
		document.write('<input type="hidden" name="shipping" value="' + alterError(shippingcharge) + '">');
		document.write('<input type="hidden" name="no_shipping" value="1">');
		document.write('<input type="hidden" name="return" value="http://www.barclaywoods.com/thanks.htm">');		
		document.write('<input type="hidden" name="cancel_return" value="http://www.barclaywoods.com/nothanks.htm">');
		
		
		//document.writeln('<input type="submit" value="Submit" name="B1">');
				
		document.writeln('</table><br/>OrderId = ' + ID +'<br/><br />');
		document.write('<input type="image" src="bttnsbanners/PayPay.gif" name="submit" alt="Make payments with PayPal!"><br />');
		document.writeln('</form>');
		}



function showvbuy3() {
     var CookieName = "vshoppingcart";
     var cookieFound = false;
     var start = 0;
     var end = 0;
     var cookieString = document.cookie;
     var i = 0;



//****************************************************************

// Tax function.  Here a "confirm" prompt is used to discover whether the customer is from Indiana.
	gettax();
	var noshipping=0;
	var taxcharge = "0";
	//var taxcheck = confirm('State Sales Tax Question: Are You A Resident Of ' + taxstate+'? Press "Ok" For Yes. Otherwise Press "Cancel" For No.');
	if (pickup=="yes"){
	noshipping=1;
	buyerstate="yes";
	}
	if (buyerstate=="yes") taxcharge = taxrate;
	

// This is a temporary end to the tax rate gathering.

//****************************************************************

// Here, a check is made for the existence of the cookie and start and end points for reading it
// are determined.  Then, the cookie is read and the order is assembled.
	var CookieName = "vshoppingcart";
	i=0;
	while (i <= cookieString.length) {
      start = i;
      end = start + CookieName.length;
      if (cookieString.substring(start,end) == CookieName) {
         cookieFound = true;
        break;
       }
       i++;
     }
     if (cookieFound) {
       start = end + 1;
       end = document.cookie.indexOf(";",start);
       if (end < start)
         end = document.cookie.length;
       document.cookie.substring(start,end);
     }

	var ItemsOrdered = document.cookie.substring(start,end);
		fulllist = document.cookie.substring(start, end);
		var totprice = 0;
		var totpricezero = 0;
		var totpriceone = 0;
		var totweight = 0;
		var totpricenoship = 0;
        var theweight=0;

// Here, the headings of the table are written

		document.writeln('<table id="center4" cellpadding="2" class="style79">');
		document.writeln('<tr><td class="style133"><strong>Item</strong></td>');
		document.writeln('<td class="style133"><strong>Quantity</strong></td><td class="style133"><strong>Cost Each</strong></td><td class="style133"><strong>Sub Total</strong></td></tr>');

		
// Next, the cart cycles through the cookie calculating the price of each item ordered
// times the number of that item ordered.  It accumulates an item total, and item totals
// for each of the two catagories we currently employ. It also sums these weights and amounts
// as well as summing the total weight.  Each item is printed in a table.
		itemlist = 0;
		numberofitems = 0;
		noflat=0;
		for (var i = 0; i<= fulllist.length; i++) {
			if (fulllist.substring(i,i+1) == '[') {
				thisitem = 1;
				itemstart = i+1;
			} else if (fulllist.substring(i,i+1) == ']') {
				itemend = i;
				thequantity = fulllist.substring(itemstart, itemend);
				itemtotal = 0;
				itemtotalzero = 0;
				itemtotalone = 0;
				itemweight = 0;
				itemtotal = (eval(theprice*thequantity));
				if ((thegroup==3)||(thegroup==4)||(thegroup==5))noflat=1;
				if(thegroup==6) shipbump=1;
				if ((thegroup==0)||(thegroup==3)||(thegroup==5)||(thegroup==6))itemtotalzero = (eval(theprice*thequantity));
				if ((thegroup==1)||(thegroup==4))itemtotalone = (eval(theprice*thequantity));
				itemweight = (eval(theweight*thequantity));
				totprice = totprice + itemtotal;
				totpricezero = totpricezero + itemtotalzero;
				totpriceone = totpriceone + itemtotalone;
				totweight = totweight + itemweight;
				itemlist = itemlist + 1;
				numberofitems = (numberofitems + parseInt(thequantity,10));
			document.write('<tr><td class="style132">'+theitem+'</td>');
				document.writeln('<td class="style132">'+thequantity+'</td><td class="style132">'+theprice+'</td><td class="style132">'+alterError(itemtotal)+'</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) theweight = fulllist.substring(itemstart, i);
				if (thisitem==4) thegroup = fulllist.substring(itemstart, i);
				if (thisitem==5) theoption = fulllist.substring(itemstart, i);
				thisitem++;
				itemstart=i+1;
       }}

// Calculate Discounts.  Here, quantity discounts rates at different
// levels of purchase are calculated.  These discounts proceed smoothly
// from one level to the next in order to avoid a price hiccup at the
// transition where, for example, 99 items cost more than 100
// items because the discount applies to the latter but not the former.
// In our case, we provide these discounts only to catagory 2 of our
// items.

		level = 0;
		pricediscountone = 0;
		beforeprice=0;
		afterprice=0;
		if (totprice<50)level = 0;
		if (totprice>=50&&totprice<150)level = 1;
		if (totprice>=150&&totprice<250)level = 2;
		if (totprice>=250&&totprice<500)level = 3;
		if (totprice>=500&&totprice<1000)level = 4;
		if (totprice>=1000&&totprice<2000)level = 5;
		if (totprice>=2000)level = 6;
		// remember that this calcualtion appears in two places and has to be changed both places. See lines around line 775
		if (level==0) discount = 0;
		if (level==1) discount = (.05+(.05*((totprice-50)/100)));
		if (level==2) discount = (.10+(.05*((totprice-150)/100)));
		if (level==3) discount = (.15+(.05*((totprice-250)/250)));
		if (level==4) discount = (.20+(.05*((totprice-500)/500)));
		if (level==5) discount = (.25+(.05*((totprice-1000)/1000)));
		if (level==6) discount = .30;
		
		pricediscountone = totpriceone*discount;


//********************end of calculating discounts



//********************calculating final prices

		beforeprice=totprice;
		totpriceone = totprice - pricediscountone;
		totprice = totprice-pricediscountone;
		afterprice = totprice

//**********end calculating final prices





// ******************calculate & print Tax.  This is obvious

		var subtax=0;
		subtax = totprice *taxcharge;
		totprice = totprice + subtax;
		
	document.writeln('<tr><td colspan="3" class="style132">Original Price</td><td  class="style132">'+alterError(beforeprice)+'</td></tr>');
		document.writeln('<tr><td colspan="3" class="style132">(Open Stock Discount)</td><td class="style132">'+alterError(pricediscountone)+'</td></tr>');
		document.writeln('<tr><td colspan="3" class="style132">Discount Price</td><td class="style132">'+alterError(afterprice)+'</td></tr>');
		document.writeln('<tr><td colspan="3" class="style132">Sales Tax('+taxstate+')</td><td  class="style132">'+alterError(subtax)+'</td></tr>');
// **************************end calculating tax

//theirzip function

   	// Here, the shopping cart prompts for a five digit zip code or the
	// terms "can" "CAN, "eur" or "EUR", "PAC" 0r "pac."  The numbers provided are checked with a variety of
	// tests and then truncated to three digits for a zone check
     		var zipthree = recipzip;
    		var accept=false;
		if(zipthree.length==5)accept=true;
		for(j=0;j<5;j++){
			if(zipthree.charAt(j)<"0") accept=false;
			if(zipthree.charAt(j)>"9") accept=false;
			}
		if (zipthree<=0||zipthree>=99999) accept=false;
		if (zipthree>0||zipthree<99999){
			zipthree=zipthree/100;
			zipthree=Math.floor(zipthree);
			}

		if(zipthree == 517||zipthree == 518||zipthree  ==519||zipthree  ==518||zipthree  ==518||zipthree  ==568				||zipthree  ==569||zipthree  ==578||zipthree  ==579||zipthree ==589)accept=false;
		if (zipthree  ==694||zipthree  ==695||zipthree  ==696||zipthree  ==697||zipthree  ==698||zipthree  ==699)				accept=false;
		if(zipthree  ==715) accept = false;
		if(zipthree  ==817||zipthree  ==819||zipthree  ==839||zipthree  ==848||zipthree  ==849||zipthree  ==861				||zipthree  ==862||zipthree  ==886||zipthree  ==887||zipthree ==888) accept=false;
		
		if((zipthree=="MEX")||(zipthree=="mex")||(zipthree=="CAN")||(zipthree=="can")||(zipthree=="ESA")||(zipthree=="esa")||(zipthree=="PAC")||(zipthree=="pac"))accept=true;

		if(accept==false) window.location="vbuy2.htm";
		//if(accept==true) index=10;



	  if((zipthree=="CAN")||(zipthree=="can"))zipthree=348;
	  if((zipthree=="ESA")||(zipthree=="esa"))zipthree=517;
	  if((zipthree=="PAC")||(zipthree=="pac"))zipthree=518;
	  if((zipthree=="MEX")||(zipthree=="mex"))zipthree=519;

//************************************************************************************




//this array contains strings that can be broken down
//into zip code ranges and their corresponding zone

zone1 = zipzone(zipthree);
zone=zone1;

//********************* end of zone setting

// From the zone, a zone charge is assigned.  This is dollars per pound that it costs to send
// to this zip code.  UPS charges a fixed amount per box, plus a charge based on weight.  This
// has to be fine tuned empirically but is approximately correct as of 9/1/06 for UPS from
// NWI.  The zones for Hawaii, Alaska, Canada, and Europe are based on Priority mail and air post.

	zonechg=.746;
	boxprice =8.00;
	
if (zone==2) zonechg=.32;
if (zone==3) zonechg=.35;
if (zone==4) zonechg=.38;
if (zone==5) zonechg=.41;
if (zone==6) zonechg=.45;
if (zone==7) zonechg=.48;
if (zone==8) zonechg=.51;

//if (zone==2) zonechg=.213;
//if (zone==3) zonechg=.267;
//if (zone==4) zonechg=.299;
//if (zone==5) zonechg=.373;
//if (zone==6) zonechg=.48;
//if (zone==7) zonechg=.618;
//if (zone==8) zonechg=.746;


if (zone==9) {zonechg=1.5; boxprice=18.50;shipmode=1;} 	//***Canada

if (zone==10){zonechg=3.45; boxprice=23.50;shipmode=1;}	//***Europe, Africa

if (zone==11){zonechg=3.80; boxprice=23.50;shipmode=1;}	//***Pacific Basin

if (zone==12){zonechg=3.22;shipmode=1;}	//***Mexico and Central America

if (zone==999){zonechg=1.75;shipmode=1;}	//***Hawaii

if (zone==226){zonechg=1.75;shipmode=1;}	//***Alaska

if (zone==228){zonechg=1.75;shipmode=1;}	//***Puerto Rico

if (zone==225){zonechg=1.75;shipmode=1;}	//***USVI

// ***************************** end of zonecharge








//*************** start of shipping section.  This can be done in various ways.  For us, there are abrupt
// increments when an order calls for additional boxes.  A box of blocks weighs about 40 pounds, so we
// add this increment every 40 lbs of total weight.  We also set some specific prices that call for special
// treatment.  In particular, we set the shipping charge to $4.05 for items that can be gotten
// into a Priority Mail fixed price envelope (except when it goes to Europe or Canada).

	onealph=0;
	alphcart=0;
	
	
	boxes = Math.round((totweight/40)+.5);
	shippingcharge = (totweight*zonechg)+(boxprice*boxes);
	if((zone!=9)&&(zone!=10)&&(zone!=11)&&(zone!=12)){
	if ((totprice>15.94&&totprice<15.96)||(totprice>16.89&&totprice<16.91)) shippingcharge = 5.95;
	if (totprice<.01) shippingcharge = 0;
	if (boxes<2) shippingcharge=shippingcharge +1;
	if (totweight<.75)shippingcharge=6.50;
	if (totprice<.01) shippingcharge = 0;
	if (totweight<.01) shippingcharge = 0;
	}
	
	
	if(noflat==0){
	
	if(((zone==226)||(zone==228)||(zone==999))&&(totweight>16))shippingcharge=((2*boxes*16.95)); //big piles
	if(((zone==226)||(zone==228)||(zone==999))&&(totweight>12&&totweight<=16))shippingcharge=16.95; //small orders
	if(((zone==226)||(zone==228)||(zone==999))&&(totweight<=12))shippingcharge=12.95; //small orders
	if(((zone==226)||(zone==228)||(zone==999))&&(totweight==22.0025))shippingcharge=16.95; //toddler kit with book
	if(((zone==226)||(zone==228)||(zone==999))&&(totweight==20.0025))shippingcharge=16.95; //toddler kit
	

    if((zone==10||zone==11)&&(totweight>16))shippingcharge=((2*boxes*53.95)); //big piles
	if(((zone==10||zone==11))&&(totweight>12&&totweight<=16))shippingcharge=53.95; //small orders
	if(((zone==10||zone==11))&&(totweight<=12))shippingcharge=42.95; //small orders
	if(((zone==10||zone==11))&&(totweight==22.0025))shippingcharge=53.95; //toddler kit with book
	if(((zone==10||zone==11))&&(totweight==20.0025))shippingcharge=53.95; //toddler kit

	
	
	if((zone==9)||(zone==12)&&(totweight>16))shippingcharge=((2*boxes*33.95)); //big piles
	if(((zone==9)||(zone==12))&&(totweight>12&&totweight<=16))shippingcharge=33.95; //small orders
	if(((zone==9)||(zone==12))&&(totweight<=12))shippingcharge=27.95; //small orders
	if(((zone==9)||(zone==12))&&(totweight==22.0025))shippingcharge=33.95; //toddler kit with book
	if(((zone==9)||(zone==12))&&(totweight==20.0025))shippingcharge=33.95; //toddler kit
	

		
	}
	

	if(noflat==1){
	if(((zone==226)||(zone==228)||(zone==999)))shippingcharge=(15.00+(totweight*1.5)); //Priority Mail
	
	if(zone==9)  shippingcharge=(26+(totweight*1.58)); // Canada
	
	if(zone==12) shippingcharge=(28+(totweight*3.50)); //Mexico

    if(zone==10) shippingcharge=(40+(2.63*totweight)); //Europe, S.America, & Africa
    
    if(zone==11) shippingcharge=(40+(3.38*totweight)); //asia & Australia
	

	}
	if (shipmode==1) shipdis=1;
	if(shippingcharge<150) shippingcharge=shippingcharge*shipdis; //applies the current shipping discount
	if(noshipping==1)shippingcharge=4.95+((boxes-1)*2.49);
	if(shipbump==1) shippingcharge=shippingcharge+(3.00*boxes);
	if((shippingcharge>=0)&&(shippingcharge<4.95))shippingcharge=4.95;
	totpricenoship=totprice;
	totprice=totprice+shippingcharge;
	itemprice=totprice-shippingcharge+subtax;

//***************** end of shipping section

// Here we obtain the customer ID cookie (a separate cookie based on the
// exact time). This cookie distinguishes one customer from another and allows
// us to identify the various pieces of the order later.

// Get Transaction ID Cookie

	function getCookie(name) {  //"name" is a reserved word
     	var cookie = " " + document.cookie;  // "cookie" is a reserved name
      var search = " " + name + "=";
     	var setStr = null;
      var offset = 0;
     	var end = 0;
     	if (cookie.length > 0) {
      offset = cookie.indexOf(search);
	if (offset != -1) {
   	offset += search.length;
   	end = cookie.indexOf(";", offset);
   		if (end == -1) {
   		end = cookie.length;
		}
		setStr = unescape(cookie.substring(offset, end));
		}
		}
		return(setStr);
		}
		var ID="";
		ID = getCookie("TransID");
		ID2=ID;
// Get Transaction ID Cookie - End

//Get customer ID
		var IC="";
		IC = getCookie("CustID");
		IC2=IC;
//end get customer ID - end
		
	
	

shipweight=Math.round((totweight)+.5);

// Here the table is written for the customer
shipword = "Shipping";
if(noshipping==1)shipword="Box and handling";

		
       document.writeln('<tr><td colspan="3" class="style132">' + shipword +'(about  ' +shipweight+ '    lbs.)</td><td  class="style132">'+alterError(shippingcharge)+'</td></tr>');
		
		document.writeln('<tr class="style133"><td  colspan="3" class="style134"><strong>Total:<strong></td><td class="style133" align="right">$'+alterError(totprice)+'</td></tr>');
// end writing the table for customers

		document.writeln('</table><br />OrderId = ' + ID +'<br /><br/>');

		document.write('<a href="home.htm"><img  src="bttnsbanners/home.jpg" width="110" height="20" alt="Return Home" class="style36"/></a><br/><br />');
		
		}







// Show basket contents.  Here, the items are printed sorted by categories,
// the discount is shown for those categories that warrant them, and buttons are
// provide to delete items from the cart, clear the whole cart, or alter the number
// of each item.  In order to write the items sorted by category, this function cycles
// through the routine as many times as there are categories.

// Here the table headings are written as a form along with the necessary links and calls
// to change the item quantities.



function showvbasket() {
		document.writeln('<form name="updateform">');
		document.writeln('<input type="button" name="clear" value="Clear Entire ShoppingCart" onclick="clearBasket()"/><br /><br />');
		document.writeln('<table id="center5" cellpadding="2" class="style79">');
		document.writeln('<tr><td class="style133"><strong>Item</strong></td><td class="style133"><strong>Quantity</strong></td><td class="style133"><strong>Cost Each</strong></td>');
		document.writeln('<td class="style133"><strong>Sub Total </strong></td><td class="style133"><strong>Delete Item</strong></td></tr>');

// Here the form has been created and awaits writing from the cookie


var j=1;
while (j<=2){
	var CookieName = "vshoppingcart";
     var cookieFound = false;
     var start = 0;
     var end = 0;
     var cookieString = document.cookie;
     var i = 0;
     while (i <= cookieString.length) {
       start = i;
       end = start + CookieName.length;
       if (cookieString.substring(start,end) == CookieName) {
         cookieFound = true;
        break;
       }
       i++;
     }
     if (cookieFound) {
       start = end + 1;
       end = document.cookie.indexOf(";",start);
       if (end < start)
         end = document.cookie.length;
       document.cookie.substring(start,end);
     }
		fulllist = document.cookie.substring(start, end);
		var totprice = 0;
		var totpricezero = 0;
		var totpriceone = 0;
		var totweight = 0;
		var itemlist = 0;
		var theweight=0
		var noflat=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;
				itemtotalzero = 0;
				itemtotalone = 0;
				itemweight = 0;			
				itemtotal = (eval(theprice*thequantity));
				if(thegroup==6)shipbump=1;
				  if ((thegroup==3)||(thegroup==4)||(thegroup==5))noflat=1; //3 is cart,4 is openstock 22", 5 is bigger kits
			      if ((thegroup==0)||(thegroup==3||thegroup==5)||(thegroup==6)){
					itemtotalzero = (eval(theprice*thequantity));
				}
				if ((thegroup==1)||(thegroup==4)){
					itemtotalone = (eval(theprice*thequantity));
				}
				itemweight = (eval(theweight*thequantity));

				totprice = totprice + itemtotal;
				totpricezero = totpricezero + itemtotalzero;
				totpriceone = totpriceone + itemtotalone;
				totweight = totweight + itemweight;
				itemlist=itemlist+1;
				if (((thegroup==0)||(thegroup==3)||(thegroup==5)||(thegroup==6))&&(j==1)){
				document.write('<tr><td class="style132">'+theitem+'</td>');
				document.write('<td  class="style180" style="height:48px"><input type="text" name="quant'+itemlist+'" value="'+thequantity+'" size="3"/><br/><a href="javascript:amendItem('+itemlist+',document.updateform.quant'+itemlist+'.value)"><img alt="update" height="14" src="bttnsbanners/buttonAC.jpg" width="44" class="style36" /></a></td>');
				document.write('<td  class="style132">'+theprice+'</td><td  class="style132">'+alterError(itemtotal)+'</td><td class="style180"><a href="javascript:removeItem('+itemlist+')" class="style36"><img alt="delete item" height="14" src="bttnsbanners/buttonB1.jpg" width="69" class="style36" /></a></td></tr>');
				
				}
				if (((thegroup==1)||(thegroup==4))&&(j==2)){
				document.write('<tr><td class="style132">'+theitem+'</td>');
				document.write('<td  class="style139" style="height:48px"><input type="text" name="quant'+itemlist+'" value="'+thequantity+'" size="3"/><br/><a href="javascript:amendItem('+itemlist+',document.updateform.quant'+itemlist+'.value)"><img alt="update" height="14" src="bttnsbanners/buttonAC.jpg" width="44" class="style36" /></a></td>');
				document.write('<td  class="style132">'+theprice+'</td><td  class="style132">'+alterError(itemtotal)+'</td><td class="style139"><a href="javascript:removeItem('+itemlist+')" class="style36"><img alt="delete item" height="14" src="bttnsbanners/buttonB1.jpg" width="69" class="style36" /></a></td></tr>');
				
				}
				
			} else if (fulllist.substring(i,i+1) == '|') {
				var thegroup = "0";
				if (thisitem==1) theitem = fulllist.substring(itemstart, i);
				if (thisitem==2) theprice = fulllist.substring(itemstart, i);
				if (thisitem==3) theweight = fulllist.substring(itemstart, i);
				if (thisitem==4) thegroup = fulllist.substring(itemstart, i);
				thisitem++;
				itemstart=i+1;
			}
		}
		j=j+1;
}

		document.writeln('<tr><td colspan="3"  class="style132">Block Kits and Craft Parts</td><td  class="style132" >'+alterError(totpricezero)+'</td><td class="style132"></td></tr>');
		document.writeln('<tr><td colspan="3"  class="style132">Open Stock</td><td   class="style132">'+alterError(totpriceone)+'</td><td class="style132"></td></tr>');

		
			

			






	// *************************Calculate Discounts
		level = 0;
		pricediscountone = 0;
		beforeprice=0;
		afterprice=0;
		if (totprice<50)level = 0;
		if (totprice>=50&&totprice<150)level = 1;
		if (totprice>=150&&totprice<250)level = 2;
		if (totprice>=250&&totprice<500)level = 3;
		if (totprice>=500&&totprice<1000)level = 4;
		if (totprice>=1000&&totprice<2000)level = 5;
		if (totprice>=2000)level = 6;
		// remember that this calcualtion appears in two places and has to be changed both places. See lines around line 775
		if (level==0) discount = 0;
		if (level==1) discount = (.05+(.05*((totprice-50)/100)));
		if (level==2) discount = (.10+(.05*((totprice-150)/100)));
		if (level==3) discount = (.15+(.05*((totprice-250)/250)));
		if (level==4) discount = (.20+(.05*((totprice-500)/500)));
		if (level==5) discount = (.25+(.05*((totprice-1000)/1000)));
		if (level==6) discount = .30;
		
		pricediscountone = totpriceone*discount;
		totprice = totprice-pricediscountone;

	//********************end of calculating discounts
	
		document.writeln('<tr><td colspan="3"  class="style132">(Open Stock Discount)</td><td   class="style132">'+alterError(pricediscountone)+'</td><td class="style132"></td></tr>');
		document.writeln('<tr><td colspan="3"  class="style132"><strong>Total:</strong></td><td   class="style134">'+alterError(totprice)+'</td><td   class="style133"></td></tr>');
		document.writeln('</table></form>');
		document.writeln('');
				
		}



// amend quantity of vbasket.htm  This routine is called from the shopping basket and revises the
// contents of the basket.

function amendItem(itemno, newquant) {
		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=itemlist+1;
				if (itemlist != itemno) {
					newItemList = newItemList+'['+fulllist.substring(fullstart, itemend)+']';
				} else {
					newItemList = newItemList + '['+theitem+'|'+theprice+'|'+theweight+'|'+thegroup+'|'+newquant+']';
				}
			} else if (fulllist.substring(i,i+1) == '|') {
				var thegroup = "0";
				if (thisitem==1) theitem = fulllist.substring(itemstart, i);
				if (thisitem==2) theprice = fulllist.substring(itemstart, i);
				if (thisitem==3) theweight = fulllist.substring(itemstart, i);
				if (thisitem==4) thegroup = fulllist.substring(itemstart, i);
				if (thisitem==5) theoption = fulllist.substring(itemstart, i);
				thisitem++;
				itemstart=i+1;

		}

		index = document.cookie.indexOf("vshoppingcart");
		document.cookie="vshoppingcart="+newItemList+";";
		self.location = "vbasket.htm";
		}

	}

//Remove item from vbasket.htm.  This subroutine removes an item at a time from the shopping basket.
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("vshoppingcart");
		document.cookie="vshoppingcart="+newItemList+"; ";
		self.location = "vbasket.htm";
		}



// clearBasket() - removes all items from the basket
function clearBasket() {
		if (confirm('Are you sure you want to ERASE everything in your ShoppingCart?')) {
			index = document.cookie.indexOf("vshoppingcart");
			document.cookie="vshoppingcart=.";
			self.location = "vbasket.htm";
		}
		}




