
	function OnCalculateCost( nValue, nDivId )
	{
		var sCost = nCost * nValue;
		eval("document.all.divTotalCost" + nDivId + ".innerHTML = \"$\" + sCost" );
		//Now calculate the total cost
		//first get the values of all the divs:
		OnCalculateTotal();
		//Set the cookie now
		DeleteCookie( 'divTotalCost' + nDivId );
		SetCookie( 'divTotalCost' + nDivId, sCost );
		//alert("document.cookie = \ + "=" + sCost + ";expires=1/05/05\""  );
	}   
	
	function OnCalculateTotal()
	{
		var nTotalValue = 0;
		var aCosts = new Array(
								document.all.divTotalCost1.innerHTML,
								document.all.divTotalCost2.innerHTML,
								document.all.divTotalCost3.innerHTML,
								document.all.divTotalCost4.innerHTML
								)
		for ( var i = 0; i < aCosts.length; i++ )
		{
			var nCost = parseInt( aCosts[i].replace("$",""), 10);
			nTotalValue += nCost;
		}
		document.all.divTotalValue.innerHTML = "$" + nTotalValue;
	}
	
	function SetCookie( name, value )
	{
	 	document.cookie =	name + "=" + escape(value) +
							"; expires=" + "12/31/2010";
		
	}
	
	function GetCookie(name)
	{
	    var dc = document.cookie;
	    var prefix = name + "=";
	    var begin = dc.indexOf("; " + prefix);
	    if (begin == -1)
	    {
	        begin = dc.indexOf(prefix);
	        if (begin != 0) return null;
	    }
	    else
	    {
	        begin += 2;
	    }
	    var end = document.cookie.indexOf(";", begin);
	    if (end == -1)
	    {
	        end = dc.length;
	    }
	    return unescape(dc.substring(begin + prefix.length, end));
	}
	
	function DeleteCookie( sName )
	{
    	if ( GetCookie( sName ) )
	    {
    	    document.cookie = sName + "=" +
           	 "; expires=Thu, 01-Jan-70 00:00:01 GMT";
	    }
	}
