<!--//hide
/***********************************************************************************/
if (window!= top)
	{
	top.location.href=location.href
	}


// alterError - fixes a rounding bug in Netscape 2
	function alterError(value)
	{
		newPounds = parseInt(value);
		newPence = parseInt((value+.0008 - parseInt(value))* 100);
		if (eval(newPence) <= 9) newPence=newPence+'0';
		newString = newPounds + '.' + newPence;
		return (newString);
	}
// showItems () - creates a table of items in the basket and
	// creates the start of a form which sets information for
	// basket items.
	/* used in buy.asp */
	
	function showItems()
	{
		//alert(document.cookie);
		index = document.cookie.indexOf("TheBasket");
		countbegin = (document.cookie.indexOf("=", index) + 1);
       	countend = document.cookie.indexOf(";", index);
		//alert(countend);
       	if (countend == -1)
		{
           	countend = document.cookie.length;
       	}
		fulllist = document.cookie.substring(countbegin, countend);
		totprice = 0;
		document.writeln('<FORM action="orderProcess.asp" method="get" name="checkout">');
		//document.writeln('<FORM action="No-cc.asp" method="get" name="checkout">');
		document.writeln('<TABLE BORDER bordercolor=#000000 COLS=4  cellpadding=5 cellspacing=0 width=98%>');
		document.writeln('<TR><TD class=white bgcolor=#CF1F26><b class=white>Item</b></TD><TD  class=white bgcolor=#CF1F26><b class=white>Qty</b></TD><TD  class=black bgcolor=#CF1F26><b class=white>Price</b></TD><td  class=black bgcolor=#CF1F26><b class=white>Total</b><TD  class=black bgcolor=#CF1F26><b class=white>Action</b></TD></TR>');
		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;
				thequantity = fulllist.substring(itemstart, itemend);
				itemtotal = 0;
				itemtotal = (eval(theprice*thequantity));
				temptotal = itemtotal * 100;
				totprice = totprice + itemtotal;
				itemlist=itemlist+1;
				theprice = (eval(theprice));
				document.writeln('<tr><td  class=black bgcolor=#F1BBBD>'+theitem+'</td><td align=right  class=black bgcolor=#F1BBBD>'+thequantity+'</td><td align=right  class=black bgcolor=#F1BBBD>$'+theprice+'</td><td align=right  class=black bgcolor=#F1BBBD>$'+alterError(itemtotal)+'</td><td  class=black bgcolor=#F1BBBD><a href="javascript:removeItem('+itemlist+')" STYLE=color:#000000;text-decoration:none;font: 9pt Arial, Helvetica;font-weight: bold; color:#000000>Remove</a></td></tr>');
				document.writeln('<input name=item'+itemlist+'  type=hidden value="'+theitem+' ">');
				document.writeln('<input name=itemQyt'+itemlist+'  type=hidden value="'+thequantity+'">');
				document.writeln('<input name=itemPrice'+itemlist+'  type=hidden value=" '+theprice+'">');
				
			} else if (fulllist.substring(i,i+1) == ',') {
				theitem = fulllist.substring(itemstart, i);
				itemstart = i+1;
			} else if (fulllist.substring(i,i+1) == '#') {
				theprice = fulllist.substring(itemstart, i);
				itemstart = i+1;
			}
		}
			document.writeln('<input type=hidden name=count value='+itemlist+'>');
			document.writeln('<tr><td colspan=3  class=black bgcolor=#CF1F26><b class=white>Sub Total</b></td><td align=right  class=black bgcolor=#F1BBBD>$'+alterError(totprice)+'</td><td bgcolor=#F1BBBD>&nbsp;</td></tr>');
			document.writeln('<INPUT TYPE="hidden" NAME="Total" VALUE="'+alterError(totprice)+'" SIZE="40">');
			document.writeln('</TABLE>');
	}
	
	// showItems1 () - creates a table of items in the basket and
	// creates the start of a form which sets information for
	// basket items.
	function showItems1()
	{
		index = document.cookie.indexOf("TheBasket");
		countbegin = (document.cookie.indexOf("=", index) + 1);
       	countend = document.cookie.indexOf(";", index);
       	if (countend == -1)
		{
           	countend = document.cookie.length;
       	}
		fulllist = document.cookie.substring(countbegin, countend);
		totprice = 0;
		document.writeln('<TABLE BORDER=0 COLS=3 width="95%" align=center cellpadding=5 cellspacing=0>');
		document.writeln('<TR><TD class=small><b class=white>Item</b></TD><TD class=small><b class=white>Qty</b></TD><td class=small><b class=white>Cost</b></TD></TR>');
		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;
				thequantity = fulllist.substring(itemstart, itemend);
				itemtotal = 0;
				itemtotal = (eval(theprice*thequantity));
				temptotal = itemtotal * 100;
				totprice = totprice + itemtotal;
				itemlist=itemlist+1;
				theprice = (eval(theprice));
				document.writeln('<tr><td class=small>'+theitem+'<input name=item type=hidden value="'+thequantity+' '+theitem+' '+theprice+'"></td><td align=right class=small>'+thequantity+'</td><td align=right class=small>$'+alterError(itemtotal)+'</td></tr>');
			} else if (fulllist.substring(i,i+1) == ',') {
				theitem = fulllist.substring(itemstart, i);
				itemstart = i+1;
			} else if (fulllist.substring(i,i+1) == '#') {
				theprice = fulllist.substring(itemstart, i);
				itemstart = i+1;
			}
		}
		document.writeln('<tr><td colspan=2 class=small><b class=white>Sub Total</b></td><td align=right class=small>$'+alterError(totprice)+'</td><td></td></tr>');
		document.writeln('<INPUT TYPE="hidden" NAME="Total" VALUE="'+alterError(totprice)+'" SIZE="40">');
		document.writeln('</tr><tr><td colspan=3 valign=top align=center><b class=white><a href=bbasket.asp><img src="images/edit.jpg" alt="VEIW / EDIT CART" border="0" width="58" height="12"></a>&nbsp;&nbsp;<A href=buy.asp><img src="images/checkout.jpg" alt="CHECK OUT / BUY ITEMS" border="0" width="58" height="12"></a></td></tr></TABLE>');		
	}
/******************************************************************************************/


// for the basket page.
	// showItems() - displays shopping basket in a table
	function showBasket() {
		index = document.cookie.indexOf("TheBasket");
		countbegin = (document.cookie.indexOf("=", index) + 1);
        	countend = document.cookie.indexOf(";", index);
        	if (countend == -1)
			{
            	countend = document.cookie.length;
        	}
		fulllist = document.cookie.substring(countbegin, countend);
		totprice = 0;
		document.writeln('<center><TABLE BORDER=1 bordercolor=#000000 cellpadding=5 cellspacing=0 WIDTH=95% ALIGN=CENTER>');
		document.writeln('<TR><TD  class=black  bgcolor=#CF1F26><b class=white>Item</b></TD><TD class=black bgcolor=#CF1F26><b class=white>Quantity</b></TD><TD class=black bgcolor=#CF1F26><b class=white>Cost Each</b></TD><td class=black bgcolor=#CF1F26><b class=white>Total Cost</b><TD class=black bgcolor=#CF1F26><b class=white>Action</b></TD></TR>');
		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;
				thequantity = fulllist.substring(itemstart, itemend);
				itemtotal = 0;
				itemtotal = (eval(theprice*thequantity));
				temptotal = itemtotal * 100;
				totprice = totprice + itemtotal;
				itemlist=itemlist+1;
				document.writeln('<tr><td class=black  bgcolor=#F1BBBD>'+theitem+'</td><td align=right class=black bgcolor=#F1BBBD><input type="text" size="5" name="' + theitem+ '_Qty" Value="' + thequantity + '"></td><td align=right class=black bgcolor=#F1BBBD>$'+theprice+'</td><td align=right class=black bgcolor=#F1BBBD>$'+alterError(itemtotal)+'</td><td class=black bgcolor=#F1BBBD><a href="javascript:removeItem('+itemlist+')" class=blue2 >remove</a></td></tr>');
			} else if (fulllist.substring(i,i+1) == ',') {
				theitem = fulllist.substring(itemstart, i);
				itemstart = i+1;
			} else if (fulllist.substring(i,i+1) == '#') {
				theprice = fulllist.substring(itemstart, i);
				itemstart = i+1;
			}
		}

		document.writeln('<tr><td colspan=3 class=black bgcolor=#CF1F26><b class=white>Sub Total</b></td><td align=right class=black bgcolor=#F1BBBD>$'+alterError(totprice)+'</td><td class=black bgcolor=#F1BBBD></td></tr>');
		document.writeln('</TABLE></CENTER>');
	}



// for the basket page.
	// showItems() - displays shopping basket in a table
	function OLD_showBasket() {
		index = document.cookie.indexOf("TheBasket");
		countbegin = (document.cookie.indexOf("=", index) + 1);
        	countend = document.cookie.indexOf(";", index);
        	if (countend == -1)
			{
            	countend = document.cookie.length;
        	}
		fulllist = document.cookie.substring(countbegin, countend);
		totprice = 0;
		document.writeln('<center><TABLE BORDER=1 bordercolor=#000000 cellpadding=5 cellspacing=0 WIDTH=95% ALIGN=CENTER>');
		document.writeln('<TR><TD  class=black  bgcolor=#CF1F26><b class=white>Item</b></TD><TD class=black bgcolor=#CF1F26><b class=white>Quantity</b></TD><TD class=black bgcolor=#CF1F26><b class=white>Cost Each</b></TD><td class=black bgcolor=#CF1F26><b class=white>Total Cost</b><TD class=black bgcolor=#CF1F26><b class=white>Action</b></TD></TR>');
		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;
				thequantity = fulllist.substring(itemstart, itemend);
				itemtotal = 0;
				itemtotal = (eval(theprice*thequantity));
				temptotal = itemtotal * 100;
				totprice = totprice + itemtotal;
				itemlist=itemlist+1;
				document.writeln('<tr><td class=black  bgcolor=#F1BBBD>'+theitem+'</td><td align=right class=black bgcolor=#F1BBBD>'+thequantity+'</td><td align=right class=black bgcolor=#F1BBBD>$'+theprice+'</td><td align=right class=black bgcolor=#F1BBBD>$'+alterError(itemtotal)+'</td><td class=black bgcolor=#F1BBBD><a href="javascript:removeItem('+itemlist+')" class=blue2 >remove</a></td></tr>');
			} else if (fulllist.substring(i,i+1) == ',') {
				theitem = fulllist.substring(itemstart, i);
				itemstart = i+1;
			} else if (fulllist.substring(i,i+1) == '#') {
				theprice = fulllist.substring(itemstart, i);
				itemstart = i+1;
			}
		}

		document.writeln('<tr><td colspan=3 class=black bgcolor=#CF1F26><b class=white>Sub Total</b></td><td align=right class=black bgcolor=#F1BBBD>$'+alterError(totprice)+'</td><td class=black bgcolor=#F1BBBD></td></tr>');
		document.writeln('</TABLE></CENTER>');
	}
/*********************************************************************************/
// showReceipt() is a function that will return and display
// Items purchased, Cost Per Unit, Total Cost, Tax, and Processing Fee.
	function showReceipt() {
		index = document.cookie.indexOf("TheBasket");
		countbegin = (document.cookie.indexOf("=", index) + 1);
        	countend = document.cookie.indexOf(";", index);
        	if (countend == -1)
			{
            	countend = document.cookie.length;
        	}
		fulllist = document.cookie.substring(countbegin, countend);
		totprice = 0;
		document.writeln('<center><TABLE BORDER=1 cellpadding=5 cellspacing=0 WIDTH=95% ALIGN=CENTER>');
		document.writeln('<TR><TD class=black><b class=white>Item</b></TD><TD class=black><b class=white>Quantity</b></TD><TD class=black><b class=white>Cost Each</b></TD><td class=black><b class=white>Total Cost</b></TR>');
		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;
				thequantity = fulllist.substring(itemstart, itemend);
				itemtotal = 0;
				itemtotal = (eval(theprice*thequantity));
				temptotal = itemtotal * 100;
				totprice = totprice + itemtotal;
				itemlist=itemlist+1;
				document.writeln('<tr><td class=black>'+theitem+'</td><td align=right class=black>'+thequantity+'</td><td align=right class=black>$'+theprice+'</td><td align=right class=black>$'+alterError(itemtotal)+'</td></tr>');
			} else if (fulllist.substring(i,i+1) == ',') {
				theitem = fulllist.substring(itemstart, i);
				itemstart = i+1;
			} else if (fulllist.substring(i,i+1) == '#') {
				theprice = fulllist.substring(itemstart, i);
				itemstart = i+1;
			}
		}

		document.writeln('<tr><td colspan=3 class=black><b class=white>Sub Total</b></td><td align=right class=black>$'+alterError(totprice)+'</td></tr>');
		document.writeln('</TABLE></CENTER>');
	}

	function updateBasket()
	{
		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);
				x = "document.getElementById['" + theitem + "_Qty'].value";
				alert(x);
				//alert(eval(x));
				alert(theitem);
				itemlist=itemlist+1;
				if (itemlist != itemno)
				{
					newItemList = newItemList+'['+fulllist.substring(itemstart, itemend)+']';
				}
			}
		}
		index = document.cookie.indexOf("TheBasket");
		document.cookie="TheBasket="+newItemList;
		location = "cart.asp";
	}

	
	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("TheBasket");
		document.cookie="TheBasket="+newItemList;
		location = "cart.asp";
	}

	// clearBasket() - removes all items from the basket
	function clearBasket(prompt) {
		if (prompt == true && confirm('Are you sure you wish to clear the basket')) {
			index = document.cookie.indexOf("TheBasket");
			document.cookie="TheBasket=.";
			location = "cart.asp";
		}else if (prompt == false)
		{
			index = document.cookie.indexOf("TheBasket");
			document.cookie="TheBasket=.";
		}
	}

	// clearBasket() - removes all items from the basket
	function clearBasket1() {
		{
			index = document.cookie.indexOf("TheBasket");
			document.cookie="TheBasket=.";
		}
	}

/******************************************************************************************/
// was in cart.inc.txt
// buyItem - adds an item to the shooping basket
	function buyItem(newItem, newPrice, newQuantity)
	{
		if (newQuantity <= 0)
		{
			rc = alert('The quantity entered is incorrect');
			return false;
		}
		var a = true;
		// confirm('Add '+newQuantity+' x '+newItem+' to basket')
		if (a == true)
		{
			index = document.cookie.indexOf("TheBasket");
			countbegin = (document.cookie.indexOf("=", index) + 1);
        	countend = document.cookie.indexOf(";", index);
	        if (countend == -1)
			{
        	    countend = document.cookie.length;
        	}
	        document.cookie="TheBasket="+document.cookie.substring(countbegin, countend)+"["+newItem+","+newPrice+"#"+newQuantity+"]";
		}
		return false;
	}

	// resetShoppingBasket - resets to shopping basket to empty
	function resetShoppingBasket() {
		index = document.cookie.indexOf("TheBasket");
		document.cookie="TheBasket=.";
	}
/********************************************************************************************/

function checkoutfields (form)
	{
	  return  (
			   checkIfEmpty (form.elements["x_last_name"]) &&
			   checkIfEmpty (form.elements["x_first_name"]) &&
			   checkIfEmpty (form.elements["x_address"]) &&
			   checkIfEmpty (form.elements["x_city"]) &&
			   checkZIPCode (form.elements["x_zip"],false) &&
			   checkUSPhone (form.elements["x_phone"],false) &&
			   checkEmail (form.elements["x_email"],false) 
			  )
	}
function warnInvalid (theField, s)
{   theField.focus()
    theField.select()
    alert(s)
    return false
}
function isFloat (s)
{   var i;
    var seenDecimalPoint = false;
    if ((s == null) || (s.length == 0)) 
        return false;
 //      if (isFloat.arguments.length == 1) return false;
 //      else return (isFloat.arguments[1] == true);
    if (s == ".") return false;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);

        if ((c == ".") && !seenDecimalPoint) seenDecimalPoint = true;
        else if (!((c >= "0") && (c <= "9"))) return false;
    }
    // All characters are numbers.
    return true;
}
// POP UP
		function winOpen(filename,widthParam,heightParam) 
		{
			msg=window.open(filename,"_blank","location=no,toolbar=no,width=" + widthParam + ",height=" + heightParam + ",directories=no,status=no,scrollbars=yes,resize=yes,menubar=no,screenx=1,screeny=1");
		}

		
// This sends to the recipt page and add the INfo to the DB
	function InsertItems()
	{
		index = document.cookie.indexOf("TheBasket");
		countbegin = (document.cookie.indexOf("=", index) + 1);
       	countend = document.cookie.indexOf(";", index);
       	if (countend == -1)
		{
           	countend = document.cookie.length;
       	}
		fulllist = document.cookie.substring(countbegin, countend);
		totprice = 0;
		document.writeln('<FORM action="SRtest.asp" method="get" name="checkout">');
		document.writeln('<TABLE BORDER COLS=4 width="95%" align=center cellpadding=5 cellspacing=0>');
		document.writeln('<TR><TD ><b class=white>Item</b></TD><TD ><b class=white>Quantity</b></TD><TD ><b class=white>Cost Each</b></TD><td ><b class=white>Total Cost</b><TD ><b class=white>Action</b></TD></TR>');
		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;
				thequantity = fulllist.substring(itemstart, itemend);
				itemtotal = 0;
				itemtotal = (eval(theprice*thequantity));
				temptotal = itemtotal * 100;
				totprice = totprice + itemtotal;
				itemlist=itemlist+1;
				theprice = (eval(theprice));
				document.writeln('<tr><td>'+theitem+'<input name=item type=hidden value="'+thequantity+' '+theitem+' '+theprice+'" ></td><td align=right>'+thequantity+'</td><td align=right>$'+theprice+'</td><td align=right>$'+alterError(itemtotal)+'</td><td><a href="javascript:removeItem('+itemlist+')" STYLE=color:#F2C871;text-decoration:none;font: 9pt Verdana, Arial, Helvetica;font-weight: bold; color:#F2C871>Remove</a></td></tr>');
				document.writeln('<input name=item'+itemlist+' type=hidden value="'+theitem+' ">');
				document.writeln('<input name=itemQyt'+itemlist+' type=hidden value="'+thequantity+' ">');
				document.writeln('<input name=itemPrice'+itemlist+' type=hidden value=" '+theprice+'">');		
			} else if (fulllist.substring(i,i+1) == ',') {
				theitem = fulllist.substring(itemstart, i);
				itemstart = i+1;
			} else if (fulllist.substring(i,i+1) == '#') {
				theprice = fulllist.substring(itemstart, i);
				itemstart = i+1;
			}
		}
			document.writeln('<input name=count type=hidden value="'+itemList+'">');		
			document.writeln('<tr><td colspan=3 ><b class=white>Sub Total</b></td><td align=right>$'+alterError(totprice)+'</td><td></td></tr>');
			document.writeln('<INPUT TYPE="hidden" NAME="Total" VALUE="'+alterError(totprice)+'" SIZE="40">');
			document.writeln('</TABLE>');
	}
	
/*******************************************************************************************/
function checkData(whichForm)
{
	//Company;
	if (document.forms[whichForm].elements['Company'].value.length==0)
	{
		alert("Please enter your Company Name.");
		document.forms[whichForm].elements['Company'].focus();
		document.forms[whichForm].elements['Company'].select();
		return false;
	}
	//First Name;
	if (document.forms[whichForm].elements['First Name'].value.length==0)
	{
		alert("Please enter your First Name.");
		document.forms[whichForm].elements['First Name'].focus();
		document.forms[whichForm].elements['First Name'].select();
		return false;
	}
	//Last Name;
	if (document.forms[whichForm].elements['Last Name'].value.length==0)
	{
		alert("Please enter your Last Name.");
		document.forms[whichForm].elements['Last Name'].focus();
		document.forms[whichForm].elements['Last Name'].select();
		return false;
	}
	//Password;
	if (document.forms[whichForm].elements['Password'].value.length==0)
	{
		alert("Please enter a Password.");
		document.forms[whichForm].elements['Password'].focus();
		document.forms[whichForm].elements['Password'].select();
		return false;
	}
	//Email;
	if (document.forms[whichForm].elements['Email'].value.length==0)
	{
		alert("Please enter an email address.");
		document.forms[whichForm].elements['Email'].focus();
		document.forms[whichForm].elements['Email'].select();
		return false;
	}
	if (document.forms[whichForm].elements['Email'].value.length>0)
	{
		i=document.forms[whichForm].elements['Email'].value.indexOf("@");
		j=document.forms[whichForm].elements['Email'].value.indexOf(".",i);
		k=document.forms[whichForm].elements['Email'].value.indexOf(",");
		kk=document.forms[whichForm].elements['Email'].value.indexOf(" ");
		jj=document.forms[whichForm].elements['Email'].value.lastIndexOf(".")+1;
		len=document.forms[whichForm].elements['Email'].value.length;

		if ((i>0) && (j>(1+1)) && (k==-1) && (kk==-1) && (len-jj >=2) && (len-jj<=3))
		{
			return true;
		} else {
			alert("Please enter a valid email address.\n" +
			document.forms[whichForm].elements['Email'].value + " is invalid.");
			document.forms[whichForm].elements['Email'].focus();
			document.forms[whichForm].elements['Email'].select();
			return false;
		}
	}
}
//-->