// JavaScript Document


var products=null;

// set some once run variables for the date
var date = new Date();
		date.setTime(date.getTime()+(1*24*60*60*1000));
		var expires = "; expires="+date.toGMTString()+"; path=/";

function read_cookie (crumb)
{
	// Set skips to 0 if parameter was omitted:

	var single_cookie = new Array();
	// Get cookie string and separate into individual cookie phrases:
	var cookie_string = "" + document . cookie;
	var cookie_array = cookie_string . split ("; ");
	
	// Scan for desired cookie:
	for (var i = 0; i < cookie_array . length; ++ i)
	{
		single_cookie = cookie_array [i] . split ("=");
		if (single_cookie . length != 2)
			continue;
		var name  = unescape (single_cookie [0]);
		var value = unescape (single_cookie [1]);

		if(name==crumb) // allow for reuse of code
		{
		
		var count=(value.split('i')).length;
		
		
		if(count<=1) document.getElementById('floatLayer').innerHTML=count+" item";
		else document.getElementById('floatLayer').innerHTML=count+" items";
		
		
		return single_cookie;
		
		}
	}
	

	// Cookie was not found:
	return null;
}

function add2Cart(row, button)
{
//if(products.getCurrentRow()["status"]!="sold")
//{
//alert(row);
if(document.add2cart.value=="quickCart") 
		{
		parent.document.location.replace("/cart.html"); 
		return null;
		}



	var single_cookie=read_cookie("JasmineCart");
		
		if(single_cookie !=null){
		
		var name  = unescape (single_cookie [0]);
		var value = unescape (single_cookie [1]);
		
			if(name=="JasmineCart") // update cookie
					{
						value=value + row;
						document.cookie=name+"="+value+expires;
					//	document.all.item('checkit').value=value;
					
					
					
					}
					
					// make a new cookie if none found
					

}
		else	{
			document.cookie="JasmineCart="+row+expires;
					if(navigator.appVersion.length > 30){		
			 document.all.item('floatLayer').innerHTML="1 item";
					}
					else
					{
						document.getElementById('floatLayer').innerHTML="1 item";
					}
			}
			
//alert(single_cookie);


if(document.add2cart.value=="Add2Cart") document.add2cart.value="quickCart";

if(button=="quickcart") parent.document.location.replace("/cart.html");

//}
}

function whatImage(action,button)
{

var mode=document.add2cart.value;

//if(products.getCurrentRow()["status"]!="sold")
	//	{
			if(button == "add2cart")
			{

if(action=='over' && mode=="Add2Cart") document.add2cart.src="/images/buynowup_02.jpg";
if(action=='out' && mode=="Add2Cart") document.add2cart.src="/images/buynowhover_02.jpg";

if(action=='over' && mode=="quickCart") document.add2cart.src="/images/viewcarthover_02.jpg";
if(action=='out' && mode=="quickCart") document.add2cart.src="/images/viewcartup_02.jpg";

			}
			
			if(button == "quikcart")
			{
			
if(action=='over') document.quikcart.src="/images/buynowup_01.jpg";
if(action=='out')  document.quikcart.src="/images/buynowhover_01.jpg";
			
			}

//alert(mode+ " " + action);
//}
}


