<!--
//*****************************************************
//Start- This Is For Your Shipping Charge	
       
var base1 = 3.59;
var base2 = 9.25;
var base3 = 3.50;
var base4 = 13.25;
// How much for shipping PER ORDER? This could also be a handling charge. If you do not want a per order charge, enter 0.00. There MUST be a ; after the number! 

var peritem1 = 0.00;
var peritem2 = 0.00;
var peritem3 = 0.00;
var peritem4 = 0.00;
// How much for shipping PER ITEM? This is a flat rate for each item purchased. This is in addition to any shipping included in the html for each 'buy' button.

var rate1 = 0.19;
var rate2 = 1.55;
var rate3 = 1.36;
var rate4 = 1.50;
 // This is the rate applied per lb or kg for each item. Set this to 1.00 if you want to enter dollar amounts rather than weights for each item.
var freeshipping = 9999; // When is shipping free? If never, put in a very large number.
//end- Shipping Charge	

//Start- Simple Tax Functions
var taxrate = 0.0825; //Tax rate for your state, must be in decimal form (eg. 8.750 becomes 0.0875)
var taxstate = "California";	//The state you collect tax in (Your home state)
//end- Tax Functions	

// Start-Merchant Data
var business = "031017";
var emailaddress = "info@abaip.com";
//End- Merchant Data
//CSS Table colors.  This allows you to set the table  
//colors and font colors displayed on vbuy.htm and 
//vbasket.htm.  Define these in your CSS file.
//checkouthead = Table Header and Footer 
//checkoutbody =  Table Body    

//End- Table colors
//Set the expiration time for cookie
var expireDays=14
var expireDate=new Date()
expireDate.setDate(expireDate.getDate()+expireDays)
//Start- Go to vbasket.htm after product is added to shoppingcart
// 1 is for yes. 0 is for no.
var vbasketTransaction = 0;
//end- Go to vbasket.htm	
// ****************************************************************** 
// Unique Registration Number 1kU892loQQuyw1983-kk
//
// vShoppingCart(tm) ver 5.6 AU (c) 1999-2002 All rights reserved.
// This is a licensed and copyrighted work. It is NOT 'Shareware' or
// 'Freeware'.  This page and its software may not be copied,
// dissassembled or reverse engineered. Use of this software
// assumes your argeement to all license terms and condtions.
//
// http://www.vShoppingCart.com
//
// For more information contact: info@vshoppingCart.com 
//
// Name: vShoppingCart.js
//
// Everything above this line can not be removed.
//****************************************************************** 

// alterError - fixes a rounding bug
function alterError(value) {
		if (value<=0.99) {
			newDollars = '0';
		} else {
			newDollars = parseInt(value);
		}
		newCents = parseInt((value+.0008 - newDollars)* 100);
		if (eval(newCents) <= 9) newCents='0'+newCents;
		newString = newDollars + '.' + newCents;
		return (newString);
	}

// buyItem - adds an item to the shopping basket
function buyItem(newItem, newPrice, newShipping, 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+"|"+newShipping+"|"+newQuantity+"]"; 
	window.location.href=document.location;
}

// showItems() - displays shopping cart item count
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);
		subtotal = 0;
		howmany = 0;
		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;
				howmany = (howmany+parseInt(thequantity));
				itemtotal = (eval(theprice*thequantity));
				temptotal = itemtotal * 100;
				subtotal = subtotal + itemtotal;
				itemlist=itemlist+1;
			} else if (fulllist.substring(i,i+1) == '|') {
				if (thisitem==1) theitem = fulllist.substring(itemstart, i);
				if (thisitem==2) theprice = fulllist.substring(itemstart, i);
				if (thisitem==3) theoption = fulllist.substring(itemstart, i);
				thisitem++;
				itemstart=i+1
				}
				}
		document.writeln('<A href="vbasket.html">Your cart has '+howmany +'&nbsp;item(s)</A><BR><a href="vbasket.html"><button type="button">View / Checkout</button></a>');
    }
	
//Show vbasket.html contents	
function showvbasket(tax) {
	var CookieName = "vShoppingCart";
	var cookieFound = false;
	var start = 0;
	var end = 0;
	var cookieString = document.cookie;
	var base = 0;
	var i = 0;
	var subtax=0;
	var totship1 = 0;
	var totship2 = 0;
	var totship3 = 0;
	var totship4 = 0;

// FOR eProcessing Network -start
	document.writeln('<INPUT TYPE=HIDDEN NAME="ePNAccount" VALUE="031017">');
// FOR eProcessing Network -end

     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);
		totprice = 0;
		totshipping= 0;
		totpricenoship = 0;
		document.writeln('<TABLE Border="1" CELLSPACING="1" CELLPADDING="3" WIDTH="100%" >');
		document.writeln('<TR class="checkouthead"><TD>Item<TD>Quantity<TD>Cost Each<TD>Sub Total<TD>Delete Item');
		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;
			itemtotal = (eval(theprice*thequantity));
			if (theitem.indexOf('Case') + theitem.indexOf('referral') > 0) {
			  ship1 = 0;
			} else {
			  ship1 = (eval(thequantity*(theshipping*rate1+peritem1)));
			  base = base1;}
			totprice = totprice + itemtotal;
			ship2 = (eval(thequantity*(theshipping*rate2+peritem2)));
			ship3 = (eval(thequantity*(theshipping*rate3+peritem3)));
			ship4 = (eval(thequantity*(theshipping*rate4+peritem4)));
			totship1 = totship1 + ship1;
			totship2 = totship2 + ship2;
			totship3 = totship3 + ship3;
			totship4 = totship4 + ship4;
			itemlist=itemlist+1;
			document.write('<TR class="checkoutbody"><TD>'+theitem+' ');
			if (theitem.indexOf('referral') > 0) document.write('<br><A href="referinfo.html">what is this?</A>');

// FOR eProcessing Network -start
			document.writeln('<INPUT TYPE=HIDDEN NAME="ItemQty" VALUE="'+thequantity+'">');
			document.writeln('<INPUT TYPE=HIDDEN NAME="ItemDesc" VALUE="'+theitem+'" >');
			document.writeln('<INPUT TYPE=HIDDEN NAME="ItemCost" VALUE="'+theprice+'">');
// FOR eProcessing Network -end
			document.write('</TD>');
			document.write('<TD ALIGN=RIGHT><INPUT TYPE=TEXT NAME="quant'+itemlist+'" VALUE="'+thequantity+'" SIZE=5 ONCHANGE="amendItem('+itemlist+',document.updateform.quant'+itemlist+'.value)"><BR><A HREF="javascript:amendItem('+itemlist+',document.updateform.quant'+itemlist+'.value)"><font size=-1>Update subtotal</A></font>');
			document.write('<TD ALIGN=RIGHT>'+theprice+'</TD><TD ALIGN=RIGHT><B>'+alterError(itemtotal)+'</B></TD><TD ALIGN="CENTER"><FONT SIZE=1><a href="javascript:removeItem('+itemlist+')"><IMG SRC="images/delete_item.gif" BORDER=0></A></FONT></TD></TR>');
		} else if (fulllist.substring(i,i+1) == '|') {
			if (thisitem==1) theitem = fulllist.substring(itemstart, i);
			if (thisitem==2) theprice = fulllist.substring(itemstart, i);
			if (thisitem==3) theshipping = fulllist.substring(itemstart, i);
			thisitem++;
			itemstart=i+1;
		}
		}

		subtax = totprice * taxrate + .005;

		if (totprice > freeshipping) totship1 = 0;
		else totship1 = base + totship1;	 
				totship2 = base2 + totship2;
				totship3 = base3 + totship3;
				totship4 = base4 + totship4;


		document.writeln('<TR class="checkouthead"><TD COLSPAN="3">Sub Total<TD ALIGN="RIGHT">'+alterError(totprice)+'<TD ALIGN="CENTER"><INPUT TYPE="button" NAME="clear" VALUE="clear all" ONCLICK="clearBasket()">');
		document.writeln('</TABLE>');
		document.writeln('<p>');

		document.writeln('<b>Tax Rate</b> (shipping to):<table border=0>');
		document.writeln('<tr><td><INPUT type="radio"  name="ApplyTax" value="on"> California &nbsp <td> $' + alterError(subtax));
		document.writeln('<tr><td><INPUT type="radio" name="ApplyTax" value="off"> Anywhere Else &nbsp <td> $0.00</table>');
		document.writeln('<INPUT TYPE=HIDDEN NAME="TaxRate" VALUE=".0825">');

		document.writeln('<p>');
		document.writeln('<b>Shipping Method:</b><table border="1" width="100%" cellspacing="1">');
		document.writeln('<tr class="checkoutbody"><td><input type="radio" name="Shipping" checked="yes" value="' + alterError(totship1) + ';Ground"><td><b>FedEx Ground</b><br> (1-7 business days)<br><i>continental US only, no PO boxes.</i><td> $' + alterError(totship1));
//		document.writeln('<tr><td><input type="radio" name="Shipping" value="' + alterError(totship2) + ';2-Day Air"><td><b>FedEx 2 Day Air</b><br> (2 business days) Order by 5 p.m. ET for same day processing<br><i>continental US only, no PO boxes.</i><td> $' + alterError(totship2));
//		document.writeln('<tr><td><input type="radio" name="Shipping" value="' + alterError(totship3) + ';USPS Priority Mail"><td><b>USPS Priority Mail</b><br> (1-4 working days)<br><i>all US addresses including PO Box, AK, HI, FPO and APO.</i><td> $' + alterError(totship3));
//		document.writeln('<tr><td><input type="radio" name="Shipping" value="' + alterError(totship4) + ';Airmail to Canada"><td>CANADA via Air Mail<br><i>international delivery via Canada Post in 2-3 weeks.</i><td> $' + alterError(totship4));
		document.writeln('</table>');
		document.writeln('<INPUT TYPE="HIDDEN" NAME="ShippingPrompt" VALUE="Yes">');
		document.writeln('<INPUT TYPE="HIDDEN" NAME="URL" VALUE="http://www.abaip.com/index.html">');
		document.writeln('<INPUT TYPE="HIDDEN" NAME="LogoURL" VALUE="http://www.abaip.com/images/header1.jpg">');
		document.writeln('<INPUT TYPE="HIDDEN" NAME="PaymentFormHeader" VALUE=""');
		document.writeln('<INPUT TYPE="HIDDEN" NAME="EMailHeader" VALUE="Thank you for choosing ABAIP! We appreciate your business. This is an automatic email confirming that our website received your order, not a shipping confirmation. We do our best to ship orders within one business day of receipt. We will deliver another email confirming shipping information at the end of the business day that your order actually ships (with tracking information if applicable). If you have any questions about this order or need to make a correction, send email to info@abiap.com.">');
		document.writeln('<INPUT TYPE="HIDDEN" NAME="BackgroundColor" VALUE="#fdf6e6">');
		document.writeln('<INPUT TYPE="HIDDEN" NAME="TextColor" VALUE="#000000">');
	}


//adjust quantity of vbasket.html
function amendItem(itemno, newquant) {
		newItemList = "";
		itemlist = 0;
		for (var i = 0; i <= fulllist.length; i++) {
			if (fulllist.substring(i,i+1) == '[') {
				thisitem = 1;
				itemstart = i+1;
				fullstart = i+1;
			} else if (fulllist.substring(i,i+1) == ']') {
				itemend = i;
				itemlist=itemlist+1;
				if (itemlist != itemno) {
					newItemList = newItemList+'['+fulllist.substring(fullstart, itemend)+']';
				} else {
					newItemList = newItemList + '['+theitem+'|'+theprice+"|"+theshipping+'|'+newquant+']';
				}
			} 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) theshipping = fulllist.substring(itemstart, i);
				thisitem++;
				itemstart=i+1;
			}
		}
		index = document.cookie.indexOf("vShoppingCart");
		document.cookie="vShoppingCart="+newItemList;
		self.location = "vbasket.html";
		}
	
	
//Remove item from vbasket.html	
function removeItem(itemno) {
		newItemList = "";
		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.html";
		}

// 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.html";
		}
		}


// reset() - removes all items from the basket, return to home no warning message
function reset() {
		index = document.cookie.indexOf("vShoppingCart");
		document.cookie="vShoppingCart=";
		}

// require at least one radio button be selected
function TaxValidate(theForm)
{
	if ((document.updateform.ApplyTax[0].checked == false) && (document.updateform.ApplyTax[1].checked == false))
	{
		alert("Please select your tax rate.");
		return false;
	}
  
}

//-->
