<!--
//1202 Test Version*******************************************************************************************
//************************************************************************************************************
//************************************************************************************************************
//************************************************************************************************************
//************************************************************************************************************

      //*****************************************************
      //*****************************************************
      //Start- This Is For Your Shipping Charge	
       

var shipping = 0; // How much for shipping PER ITEM?  There MUST be a ; after the number!

var freeshipping = 0; // When is shipping free? If never, put in a very large number. There MUST be a ; after the number!


       //end- Shipping Charge	
       //*****************************************************
	   //*****************************************************



 	  //*****************************************************
      //*****************************************************
      //Start- Simple Tax Functions
	       

var taxrate = 0; //Tax rate for your state, must be in decimal form (eg. 8.750 becomes 0.0875)

var taxstate = "Texas";	//The state you collect tax in (Your home state)


       //end- Tax Functions	
       //*****************************************************
	   //*****************************************************




       //*****************************************************
	   //*****************************************************
	   //Start- This Is For Your Authorize.net Merchant Login Data
	   //Enter in your supplied Authorize.net Login between the
	   //quotes"testdriver" replace "testdriver"
	   //with your login name


//var business = "";

//var loginid = "thelordmag";

		//Enter in your email address to recieve a recipt 

var emailaddress =  "david.crank@pdq.net";




      //End- Merchant Login Data
	  //*****************************************************
	  //*****************************************************


	  
	  //*****************************************************
	  //*****************************************************
      //Start- Return To A Thank You Page On Your Website
	  //Enter in a URL back to your website that your customer
	  //will press after an order (eg: a thank you page).  
	  //Replace "http://www.YOURWEBSITE.com" with your URL.
		

var returnURL = "http://www.unlessthelordmagazine.com/Back%20Iss%20and%20Subs/thankyou.htm";


      //End- Thank You Page
	  //*****************************************************
	  //*****************************************************
      
	  
	  //*****************************************************
	  //*****************************************************
      //Start- This is the complete location (URL) to vbuy2.htm
	  //on your server.  Include the vbuy2.htm in the URL.
	  //Example you site URL is http://someplace.com 
	  //vbus2.htm is in the root folder the URL would be http://someplace.com/vbuy2.htm
		

var TovBuy2 = "http://www.unlessthelordmagazine.com/Back%20Iss%20and%20Subs/vbuy2.htm";

      //End- Thank You Page
	  //*****************************************************
	  //*****************************************************


	  
	  //*****************************************************
	  //*****************************************************
      //Start- Table colors.  This allows you to set the table  
	  //colors and font colors displayed on vbuy.htm and 
	  //vbasket.htm.  You can change the to reflect the colors
	  //you want on your website.

      
 var tableheadcolor = "#336699"; //Table Header and Footer Color
 var tablebodycolor = "#CCCCCC"; //Body Color    
 var tablefontcolor = "#FFFFFF"; //Font Color
 
 
      //End- Table colors
	  //*****************************************************
	  //*****************************************************
       
      //*****************************************************
      //*****************************************************
      //Start- Go to vbasket.htm after product is added to shoppingcart
      // 1 is for yes. 0 is for no.


var vbasketTransaction = 1;


       //end- Go to vbasket.htm	
       //*****************************************************
	   //*****************************************************
       
       
       
//************************************************************************************************************
//************************************************************************************************************
//************************************************************************************************************
//************************************************************************************************************
//************************************************************************************************************



	// ****************************************************************** 
	// Unique Registration Number 1kU892loQQuyw1983-kk
	//
	// vShoppingCart(tm) ver 5.0-nq relay AU (c) 1999-2001 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: vShoppingCar.js
	//
	// Everything above this line can not be removed.
	//
	//
	// NO NEED TO CHANGE ANYTHING HERE. DO NOT EDIT THIS PAGE IN A
	// WYSIWYG HTML EDITOR. USE A TEXT EDITOR. 
	//****************************************************************** 

   
      
      // No need to change anything below this line.
      //*****************************************************
      

// 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, 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+"|"+newQuantity+"]; expires=Friday, 31-Dec-2010 08:00:00 GMT";
	window.location.href=document.location;
	
	if (vbasketTransaction){
	window.location.href='vbasket.htm';
	}
	
	
	}



	
// 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);
		subtotal = 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;
				howmany = howmany + 1;
				itemtotal = (eval(theprice*thequantity));
				temptotal = itemtotal * 100;
				subtotal = subtotal + itemtotal;
				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) 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>');
			    }




	

//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
		var taxcharge = "0";
		var taxcheck = "Cancel"

		//DISABLE SALES TAX STATE QUESTION "cancel" for following expression
	//confirm('State Sales Tax Question: Are You A Resident Of ' + taxstate+'? Press "Ok" For Yes. Otherwise Press "Cancel" For No.');
	
	//if (taxcheck) {
	//	taxcharge = taxrate;
	//	} 
     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);
		totprice = 0;
		totpricenoship = 0;
		document.writeln('<TABLE CELLSPACING=1 CELLPADDING=3 BGCOLOR="' + tablebodycolor + '">');
		document.writeln('<TR bgcolor=' + tableheadcolor + '><TD><b><font size=3 color=' + tablefontcolor + '>Item</FONT></B></TD>');
		document.writeln('<TD><B><FONT SIZE=3 COLOR=' + tablefontcolor + '>Quantity</FONT></B></TD><TD><B><FONT SIZE=3 COLOR=' + tablefontcolor + '>Cost Each</FONT></B></TD><TD><B><FONT SIZE=3 COLOR=' + tablefontcolor + ' >Sub Total</FONT></B></TD></TR>');
		itemlist = 0;
		numberofitems = 0;
var BIQ=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;
				itemtotal = (eval(theprice*thequantity));
				temptotal = itemtotal * 100;
				totprice = totprice + itemtotal;
Price= (eval(theprice));
if (Price ==5.00)
{Quantity= (eval(thequantity));
BIQ = BIQ + Quantity;}

				itemlist = itemlist + 1;
				numberofitems = (numberofitems + parseInt(thequantity,10));
				document.write('<TR><TD>'+theitem+'</TD>');
				document.writeln('<TD ALIGN=RIGHT>'+thequantity+'</TD><TD ALIGN=RIGHT>'+theprice+'</TD><TD ALIGN=RIGHT>'+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);
				thisitem++;
				itemstart=i+1;
       }}
		// Print Tax       
		// var subtax=0;
		// subtax = totprice * taxcharge;
		// totprice = totprice + subtax;
		// document.writeln('<TR><TD COLSPAN=3><B>Tax</B> ('+taxstate+')</TD><TD ALIGN=RIGHT>'+alterError(subtax)+'</TD></TR>');
		 // end
	  // if (totprice > freeshipping) shippingcharge = 0;
	   // else shippingcharge = shipping * numberofitems;
	  // if (totprice<1) shippingcharge = 0;
	   //totpricenoship = totprice
       // totprice = totprice + shippingcharge;
       
              
		// Get CustID Cookie
		function getCookie(name) {
     	var cookie = " " + document.cookie;
      	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("CustID");
		// Get CustID Cookie - End
		//document.writeln('<TR><TD COLSPAN=3><B>Shipping</B></TD><TD ALIGN=RIGHT>'+alterError(shippingcharge)+'</TD></TR>');

var sets= parseInt(BIQ/3);
if (sets>=1)
{discountString = sets + '.00'; document.writeln('<TR><TD COLSPAN=3><B>Back Issues Discount</B></TD> <TD ALIGN=RIGHT> - $'+discountString+'</TD></TR>');
totprice = totprice - sets}

		document.writeln('<TR><TD BGCOLOR=' + tableheadcolor + ' COLSPAN=3><FONT COLOR=' + tablefontcolor + '><B>Total To Be Charged</B></FONT></TD><TD BGCOLOR=' + tableheadcolor + ' ALIGN=RIGHT><FONT COLOR=' + tablefontcolor + '><B>$'+alterError(totprice)+'</B></FONT></TD></TR>');


//FORM POSTING
	
//document.writeln('<!--#INCLUDE FILE="simlib.asp"-->');
//document.writeln('<!--#INCLUDE FILE="simdata.asp"-->');

var sequence = ID;

document.writeln('<FORM ACTION="https://secure.authorize.net/gateway/transact.dll" METHOD=POST target="_top"><% ret = InsertFP (loginid, txnkey, amount, sequence) %>');

document.writeln('<INPUT TYPE="hidden" NAME="x_Login" VALUE="' + loginid + '">');

document.writeln('<INPUT TYPE="hidden" NAME="x_Receipt_Link_URL"  VALUE="' + returnURL + '">');

document.writeln('<INPUT TYPE="hidden" NAME="x_Receipt_Link_Method" VALUE=Link><INPUT TYPE="hidden" NAME="x_Receipt_Link_Text" VALUE=Continue>');

document.write('<INPUT TYPE="hidden" NAME="x_Show_Form" VALUE="PAYMENT_FORM">');

document.writeln('<INPUT TYPE="hidden" NAME="x_Cust_ID" VALUE=' + ID + '>');

document.writeln('<INPUT TYPE="hidden" NAME="x_Invoice_Num" VALUE=' + ID + '>');

document.writeln('<INPUT TYPE="hidden" NAME="x_Amount" VALUE="'+alterError(totprice)+'">');

document.writeln('</TABLE><INPUT TYPE="hidden" NAME="x_Description" VALUE="'+fulllist+'">');

document.write('<FONT SIZE=1><I>Your Customer Id=' + ID +'</I></FONT><BR>');

document.writeln('<INPUT TYPE="hidden" NAME="x_test_request" VALUE="FALSE">');

document.writeln('<P><INPUT TYPE="SUBMIT" NAME=Submit VALUE="  Proceed To Secure Payment System  "></TD></TR></CENTER></TABLE><CENTER><BR>');

document.writeln('<INPUT TYPE=IMAGE NAME=submit_order SRC="images/CreditCards.gif" WIDTH=150 HEIGHT=38 ALIGN=BOTTOM><P>');
		
document.writeln('<INPUT TYPE="image" NAME="submit_order" SRC="images/vShoppingCart-50.gif" WIDTH=170 HEIGHT=32 ALIGN=BOTTOM>');

document.writeln('</CENTER></FORM>');
		
			}
	
	
	
	
//Show vbasket.htm contents	
function showvbasket() {
	 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);
		totprice = 0;
		document.writeln('<FORM NAME="updateform">');
		document.writeln('<INPUT TYPE="button" NAME="clear" VALUE="Clear Entire ShoppingCart" ONCLICK="clearBasket()"><P>');
		document.writeln('<TABLE CELLSPACING=1 CELLPADDING=3 BGCOLOR="' + tablebodycolor + '">');
		document.writeln('<TR bgcolor=' + tableheadcolor + '><TD><b><font size=3 color=' + tablefontcolor + '>Item</FONT></B></TD><TD><B><FONT SIZE=3 COLOR=' + tablefontcolor + '>Quantity</FONT></B></TD><TD><B><FONT SIZE=3 COLOR=' + tablefontcolor + '>Cost Each</FONT></B></TD>');
		document.writeln('<TD><B><FONT SIZE=3 COLOR=' + tablefontcolor + '>Sub Total </FONT></B><TD><B><FONT SIZE=3 COLOR=' + tablefontcolor + '>Delete Item</FONT></B></TD></TR>');
		itemlist = 0;
var BIQ=0
		for (var i = 0; i <= fulllist.length; i++) 
			{if (fulllist.substring(i,i+1) == '[') 
				{itemstart = i+1;
				thisitem = 1;}
			 else if (fulllist.substring(i,i+1) == ']') 
				{itemend = i;
				thequantity = fulllist.substring(itemstart, itemend);
				itemtotal = 0;
				itemtotal = (eval(theprice*thequantity));
				temptotal = itemtotal * 100;
				totprice = totprice + itemtotal;
Price= (eval(theprice));
if (Price ==5.00)
{Quantity= (eval(thequantity));
BIQ = BIQ + Quantity;}
				itemlist=itemlist+1;
				document.write('<TR><TD>'+theitem+'</TD>');
				document.write('<TD ALIGN=RIGHT><INPUT TYPE=TEXT NAME="quant'+itemlist+'" VALUE="'+thequantity+'" SIZE=5><BR><FONT SIZE=1 COLOR=' + tablefontcolor + '><A HREF="javascript:amendItem ('+itemlist+',document.updateform.quant'+itemlist+'.value)"><FONT SIZE="1" FACE="Arial, Helvetica, sans-serif">Change This Quantity</A></FONT></TD>');
				document.write('<TD ALIGN=RIGHT>$'+theprice+'</TD><TD ALIGN=RIGHT><B>$'+alterError(itemtotal)+'</B></TD><TD><FONT SIZE=1><a href="javascript:removeItem('+itemlist+')"<CENTER><IMG SRC="images/delete_item.gif" BORDER=0></CENTER></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);
				thisitem++;
				itemstart=i+1;}
					}


var sets= parseInt(BIQ/3);
if (sets>=1)
{discountString = sets + '.00'; document.writeln('<TR><TD COLSPAN=3><B>Back Issues Discount</B></TD> <TD ALIGN=RIGHT> - $'+discountString+'</TD></TR>');
totprice = totprice - sets}


		document.writeln('<TR><TD COLSPAN=3 BGCOLOR=' + tableheadcolor + '><FONT COLOR=' + tablefontcolor + '><B>Total</B></FONT></TD><TD BGCOLOR=' + tableheadcolor + ' ALIGN=RIGHT><FONT COLOR=' + tablefontcolor + '><B>$'+alterError(totprice)+'</B></FONT></TD><TD  BGCOLOR=' + tableheadcolor + '></TD></TR>');
		document.writeln('</TABLE></FORM>');
		document.writeln('');
	}
	
//TEST SECTION =================================================
//Determine renwal category & reduced cost	

// document.writeln('<FORM><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0><TR><TD><select><option>Click For ShoppingCart Contents</OPTION>');
// Print Tax       
	//	var subtax=0;
	//	subtax = totprice * taxcharge;
	//	 totprice = totprice + subtax;
		// document.writeln('<TR><TD COLSPAN=3><B>Tax</B> ('+taxstate+')</TD><TD ALIGN=RIGHT>'+alterError(subtax)+'</TD></TR>');
	//	 end
	  // if (totprice > freeshipping) shippingcharge = 0;
	  // else shippingcharge = shipping * numberofitems;
	   // if (totprice<1) shippingcharge = 0;
	   // totpricenoship = totprice
       // totprice = totprice + shippingcharge;
//-alterError(sets) var discounts= 'sets' + .00;
//itemtotal = (eval(theprice*thequantity));
//newString = newDollars + '.' + newCents;
//TEST SECTION END ===============================================


//function renewalcategory(R1)
//{var Ren_Cat='R'
//If (Ren_Cat =='E')
//      {s='22.00'; t='13.00'};
//If (Ren_Cat=='R')
//      {s='23.00'; t='13.00'};
//If (Ren_Cat=='L')
//      {s='24.00'; t='14.00'};}


	
//adjust quantity of vbasket.htm
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+'|'+newquant+']';
				}
			} else if (fulllist.substring(i,i+1) == '|') {
				if (thisitem==1) theitem = fulllist.substring(itemstart, i);
				if (thisitem==2) theprice = fulllist.substring(itemstart, i);
				thisitem++;
				itemstart=i+1;
			}
		}
	
		index = document.cookie.indexOf("vShoppingCart");
		document.cookie="vShoppingCart="+newItemList+"; expires=Friday, 31-Dec-2010 08:00:00 GMT";
		self.location = "vbasket.htm";
		}
	
	
//Remove item from vbasket.htm	
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+"; expires=Friday, 31-Dec-2010 08:00:00 GMT";
		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";
			
		}}


//-->
