// JavaScript Document

<!--

var ItemName = new Array(16);
var ItemDescription = new Array(16);
var ItemPrice = new Array(16);

ItemName[0] = 			"Custom card";
ItemDescription[0] = 	getDescription(0);
ItemPrice[0] = 			1;


ItemName[1] = 			"10-piece box";
ItemDescription[1] = 	"10-piece box";
ItemPrice[1] = 			14;

ItemName[2] = 			"16-piece box";
ItemDescription[2] = 	"16-piece box";
ItemPrice[2] = 			30;

ItemName[3] = 			"20-piece box";
ItemDescription[3] =	"20-piece box";
ItemPrice[3] = 			28;

ItemName[4] = 			"Hazelnut Delight";
ItemDescription[4] =	"Hazelnut Delight";
ItemPrice[4] = 			8;

ItemName[5] = 			"Peanut Supreme";
ItemDescription[5] =	"Peanut Supreme";
ItemPrice[5] = 			8;

ItemName[6] = 			"Dark Velvet";
ItemDescription[6] =	"Dark Velvet";
ItemPrice[6] = 			14;

ItemName[7] = 			"Bourbon Milk";
ItemDescription[7] =	"Bourbon Milk";
ItemPrice[7] = 			14;

ItemName[8] = 			"Grand Marnier Truffles";
ItemDescription[8] =	"Grand Marnier Truffles";
ItemPrice[8] = 			15;

ItemName[9] = 			"Caramel Truffles";
ItemDescription[9] =	"Caramel Truffles";
ItemPrice[9] = 			15;

ItemName[10] = 			"Dark Chocolate Truffles";
ItemDescription[10] =	"Dark Chocolate Truffles";
ItemPrice[10] = 		15;

ItemName[11] = 			"Milk Chocolate Almonds";
ItemDescription[11] =	"Milk Chocolate Almonds";
ItemPrice[11] = 		18;

ItemName[12] = 			"Dark Chocolate Almonds";
ItemDescription[12] =	"Dark Chocolate Almonds";
ItemPrice[12] = 		18;

ItemName[13] = 			"Dark Chocolate 64% with caramelized cocoa nibs";
ItemDescription[13] =	"Dark Chocolate 64% with caramelized cocoa nibs";
ItemPrice[13] = 		4.50;

ItemName[14] = 			"Milk Chocolate with coffee bits and almond crunch";
ItemDescription[14] =	"Milk Chocolate with coffee bits and almond crunch";
ItemPrice[14] = 		4.50;

ItemName[15] = 			"White Chocolate raspberries, vanilla and pistachios";
ItemDescription[15] =	"White Chocolate raspberries, vanilla and pistachios";
ItemPrice[15] = 		4.50;

function setCookie(c_name,value,add)
{
	var new_value = value ;
	if (add == 'add') new_value = parseInt(value) + parseInt(getCookie(c_name));
	var exdate=new Date();
	document.cookie=c_name+ "=" +escape(new_value) ;
}

function getCookie(c_name)
{
	if (document.cookie.length>0)
  	{
  		c_start=document.cookie.indexOf(c_name + "=");
  		if (c_start!=-1)
    	{ 
	    	c_start=c_start + c_name.length+1; 
    		c_end=document.cookie.indexOf(";",c_start);
    		if (c_end==-1) c_end=document.cookie.length;
			return unescape(document.cookie.substring(c_start,c_end));
    	} 
  	}

	return 0;
}



function IsNumeric(obj)
{
	obj.value = obj.value.replace(/[^0-9]/g,'');
	setCookie(obj.name,obj.value,'set');
}

function IsNumericOne(obj)
{
	obj.value = obj.value.replace(/[^0-9]/g,'');
	if (parseInt(obj.value) > 1) obj.value = 1;
	setCookie(obj.name,obj.value,'set');
}


function setDescription(obj, itemnumber)
{
	document.cookie="shopping-cart.items.item-" + itemnumber + ".item-description"+ "=" +escape(obj.value) ;
	ItemDescription[itemnumber] = getDescription(itemnumber);
}
function getDescription(itemnumber)
{
	var c_name = "shopping-cart.items.item-" + itemnumber + ".item-description";
	
	if (document.cookie.length>0)
  	{
		
  		c_start=document.cookie.indexOf(c_name + "=");
  		if (c_start!=-1)
    	{ 	
	    	c_start=c_start + c_name.length+1; 
    		c_end=document.cookie.indexOf(";",c_start);
    		if (c_end==-1) c_end=document.cookie.length;
			return unescape(document.cookie.substring(c_start,c_end));
    	} 
  	}

	return "";
}


function ShowShoppingCart()
{

	var table = "";
	table = table +"          	<table width='100%' cellspacing='0' cellpadding='0' bgcolor='#FFE6C2' border='0'>";
    table = table +"              <tr>";
    table = table +"                <td colspan='4' ><p><br><span class='style1'>Shopping Cart</span></p></td>";
    table = table +"              </tr>";
	table = table +"			  <tr valign='top'>";
    table = table +"                <td height='20' colspan='4' valign='middle' ><img src='images/brown_sp.jpg' alt='' width='454' height='1'></td>";
    table = table +"              </tr>";
    table = table +"         	  <tr >";
    table = table +"              	<td width='70' id='table_format'>Qty.</td>";
    table = table +"              	<td width='244'>Item Description</td>";
    table = table +"              	<td width='70' id='table_format'>Price $</td>";
    table = table +"             	<td width='70' id='table_format'>Total $ </td>";
    table = table +"              </tr>";
    table = table +"              <tr valign='top'>";
    table = table +"                <td height='20' colspan='4' valign='middle' ><img src='images/brown_sp.jpg' alt='' width='454' height='1'></td>";
    table = table +"              </tr>";
     

	var str = "";
	var table_end = "";
	var total = 0;
	
	str = str + ShowCustomCard(0);
	total = parseFloat(total) + parseFloat(GetTotalForItem(0));

	for (i=1;i<ItemName.length;i++){
		str = str + ShowShoppingItem(i);
		total = parseFloat(total) + parseFloat(GetTotalForItem(i));
		
	}
	
	
	table_end = table_end +"               <tr valign='top'>";
    table_end = table_end +"                 <td height='20' colspan='4' valign='middle' ><img src='images/brown_sp.jpg' alt='' width='454' height='1'></td>";
    table_end = table_end +"               </tr>";
    table_end = table_end +"               <tr>";
    table_end = table_end +"               	<td id='table_format'>Total</td>";
    table_end = table_end +"               	<td>&nbsp;</td>";
    table_end = table_end +"               	<td id='table_format'>&nbsp;</td>";
    table_end = table_end +"               	<td id='table_format'>$"+total+"</td>";
    table_end = table_end +"               </tr>";
    table_end = table_end +"               <tr valign='top'>";
    table_end = table_end +"                 <td height='20' colspan='4' valign='middle' ><img src='images/brown_sp.jpg' alt='' width='454' height='1'></td>";
    table_end = table_end +"               </tr>";
 	table_end = table_end +"</table>";

	document.all.cart1.innerHTML =table + str + table_end;
	EnableCheckout();
}
function GetTotalForItem(itemnumber)
{
	if (getCookie("shopping-cart.items.item-"+itemnumber+".quantity")>0){
		return parseFloat(ItemPrice[itemnumber])*parseInt(getCookie("shopping-cart.items.item-"+itemnumber+".quantity"));
	}
	return 0;
}

function EnableCheckout()
{

	var total = 0;
	
	total = parseFloat(total) + parseFloat(GetTotalForItem(0));
	for (i=1;i<ItemName.length;i++){
		total = parseFloat(total) + parseFloat(GetTotalForItem(i));
	}
	if (document.all.i_agree.checked == true && total>0 ){
		document.all.checkout_button.style.visibility  = "visible";	
	}else{
		document.all.checkout_button.style.visibility = "hidden";	
	}
	
}

function ShowShoppingItem(itemnumber,description,name,unit_price)
{
	var str = "";
	if (getCookie("shopping-cart.items.item-"+itemnumber+".quantity")>0){
	
		str = str + "<input type='hidden' name='shopping-cart.items.item-" + itemnumber + ".item-description' value='"+ItemDescription[itemnumber]+"'/>";
		str = str + "<input type='hidden' name='shopping-cart.items.item-" + itemnumber + ".item-name' value='"+ItemName[itemnumber]+"'/>";
		str = str + "<input type='hidden' name='shopping-cart.items.item-" + itemnumber + ".unit-price' value='"+ItemPrice[itemnumber]+"'/>";

		str = str + "		<tr >";
        str = str + "         	<td width='70' id='table_format'><input size='3' maxlength='3' name='shopping-cart.items.item-" + itemnumber + ".quantity' value='" +getCookie("shopping-cart.items.item-"+itemnumber+".quantity")+ "' onkeyup='IsNumeric(this)'/></td>";
        str = str + "          	<td width='244'>" +ItemName[itemnumber]+ "</td>";
        str = str + "          	<td width='70' id='table_format'>$"+ItemPrice[itemnumber]+"</td>";
        str = str + "          	<td width='70' id='table_format'>$"+parseFloat(ItemPrice[itemnumber])*parseInt(getCookie("shopping-cart.items.item-"+itemnumber+".quantity")) +"</td>";
        str = str + "       </tr>";
	
	}
	return str;
}


function ShowCustomCard(itemnumber)
{
	var str = "";
	if (getCookie("shopping-cart.items.item-"+itemnumber+".quantity")>0){
		str = str + "<input type='hidden' name='shopping-cart.items.item-" + itemnumber + ".item-name' value='"+ItemName[itemnumber]+"'/>";
		str = str + "<input type='hidden' name='shopping-cart.items.item-" + itemnumber + ".unit-price' value='"+ItemPrice[itemnumber]+"'/>";
		str = str + "		<tr >";
        str = str + "         	<td width='70' id='table_format'><input size='3' maxlength='3' name='shopping-cart.items.item-" + itemnumber + ".quantity' value='" +getCookie("shopping-cart.items.item-"+itemnumber+".quantity")+ "' onkeyup='IsNumericOne(this)'/></td>";
        str = str + "          	<td width='244'><textarea rows=3 cols='20' onClick='if(getDescription(0)==\"\")this.value=\"\"' maxlength='100' onkeyup='setDescription(this,0)' name='shopping-cart.items.item-" + itemnumber + ".item-description' >"
		
		if (ItemDescription[itemnumber] == ""){
			str = str + "Please type you custom message here.";
		}else
		{
			str = str  + ItemDescription[itemnumber];	
		}
		
		str = str + "</textarea></td>";
        str = str + "          	<td width='70' id='table_format'>$"+ItemPrice[itemnumber]+"</td>";
        str = str + "          	<td width='70' id='table_format'>$"+parseFloat(ItemPrice[itemnumber])*1 +"</td>";
        str = str + "       </tr>";
	

	}
	return str;
}
-->