
	var listids = ',';
	function AddToCompare(checkbox, productid)
	{
	
		if (checkbox.checked )			
		{		
			var pos = listids.indexOf("," +productid + ",");
			if (pos < 0) 
			{
				if ( GetCompareItems().length >= 4)
				{
					alert('Chọn 2-4 sản phẩm để so sánh');
					checkbox.checked = false;
				}
				else listids += productid + ',';
			}
		}
		else
		{
			var pos = listids.indexOf("," +productid + ",");
			if (pos >= 0) listids = listids.replace("," +productid + ",",",");
		}
	}	
	function GetCompareItems()
	{
		if (listids == ",") temp = "";
		else temp = listids.substring(1,listids.length-1);			
		retval = temp.split(",");		
		return retval;
	}
	function Compare()
	{				
	    
		arr = GetCompareItems();	
		if (arr.length < 2)
		{
			alert('Chọn 2-4 sản phẩm để so sánh');
			return;
		}
		compareurl = "/Default.aspx?page=compare&param=";
		for ( i = 0 ; i < arr.length; i ++)
			compareurl += arr[i] + ',';
		compareurl = compareurl.substring(0,compareurl.length - 1);	
		window.location = compareurl;
	}