function AddProduct(product_id)
{
	document.getElementById("product_id").value = product_id;
	document.getElementById("product_quantity").value = 1;
	
}

function AddProductFromDetail(product_id)
{
	document.getElementById("product_id").value = product_id;
	
}

function SubmitCart()
{
	document.cart_add.submit();
}


function CheckSearch()
{
	if (document.getElementById("search").value=="" || document.getElementById("search").value=='Search')
	{
		document.getElementById("search").value = "";
		document.getElementById("search").focus();
		return false;
	} else
	{
		return true;
	}
	
}


function CheckAdd()
{
	var atts = document.getElementsByName("attributes[]");
	var err = "no";
	if ( document.getElementsByName("attributes") )
	{
		for (x=0;x<atts.length;x++)
		{
			if ( atts[x].value=="" )
				err = "yes";
		}
		
		if (err=="yes")
		{
			alert("You have left one or more product options blank");
			return false;
		} else 
		{
			return true;
		}
		
	} else 
	{
		return true;
	}
}

function CartHeader(q)
{
	var cart_header = document.getElementById("cart_header_content");
	var plural = "";
	
	if (cart_header)
	{
		if (q>0)
		{
			if (q>1) plural = "s";
			cart_header.innerHTML = '<a href="/cart.php" style="color: #000;">'+q+' item'+plural+' in your cart</a> <img src="/global/images/saed_icon_cart.gif" border="0" width="23" height="17"  alt="" align="absmiddle"  />';
		} else 
		{
			cart_header.innerHTML = '<a href="/products.php" style="color: #000;">Your cart is empty</a> <img src="/global/images/saed_icon_cart.gif" border="0" width="23" height="17"  alt="" align="absmiddle"  />';
		}
	}
}

function ManSort(val,cid)
{
		window.location.href = "/accessories_listings.php?category_id="+cid+"&man_id="+val;
	
}