var compareList;
function updateCompareList(productID, includeProduct)
{
	if (!compareList)
	{
		compareList = getCookie("compareProductList");
	}
	
	if (!compareList)
	{
		compareList = "";
	}
	
	var productArray = compareList.split(",");

	if (includeProduct)
	{
		var alreadyIncluded = false;
		for (var i = 0; i < productArray.length; i++)
		{
			if (productArray[i] == productID)
			{
				alreadyIncluded = true;
				break;
			}
		}
		
		if (!alreadyIncluded)
		{
			productArray[productArray.length] = productID
		}
	}
	else
	{
		for (var i = 0; i < productArray.length; i++)
		{
			if (productArray[i] == productID)
			{
				delete productArray[i];
				i--;
			}
		}
	}
	
	compareList = "";
	for (var i = 0; i < productArray.length; i++)
	{
		if(productArray[i])
		{
			compareList += "" + productArray[i];
			if (i < productArray.length - 1)
			{
				compareList += ",";
			}
		}
	}
	setCookie("compareProductList", compareList, null, "/");
}

function submitCompare()
{
	if (!compareList)
	{
		compareList = getCookie("compareProductList");
	}
	
	if (!compareList)
	{
		compareList = "";
	}
	
	var compareForm = document.getElementById("compareForm");
	compareForm.compareProductList.value = compareList;
	
	return true;
}
