function setCookie(name, value, expires, path, domain, secure) {
	var curCookie = name + "=" + escape(value) +
			((expires) ? "; expires=" + expires.toGMTString() : "") +
			((path) ? "; path=" + path : "") +
			((domain) ? "; domain=" + domain : "") +
			((secure) ? "; secure" : "");
	document.cookie = curCookie;
}

function getCookie(name) {
	var prefix = name + "=";
	var cookieStartIndex = document.cookie.indexOf(prefix);
	if (cookieStartIndex == -1)
			return null
	var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length);
	if (cookieEndIndex == -1)
			cookieEndIndex = document.cookie.length;
	return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex));
}

function deleteCookie(name, path, domain) {
	if (getCookie(name)) {
		 document.cookie = name + "=" + 
		 ((path) ? "; path=" + path : "") +
		 ((domain) ? "; domain=" + domain : "") +
		 "; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}

function addProductToCompare( itemId ) {
	var s = getCookie("compare_products");
	if( (","+s+",").indexOf(","+itemId+",")<0 )
	{
		if( s==null ) s = itemId;
		else s = s + "," + itemId;
		setCookie("compare_products",s,void 0,"/",void 0);
	}
}

function removeProductFromCompare( itemId ) {
	var s = getCookie("compare_products");
	s = ","+s+",";
	s = s.replace(","+itemId+",",",");
	s = s.replace(/^,|,$/g,"");
	setCookie("compare_products",s,void 0,"/",void 0);
}

function clearProductsCompare() {
	setCookie("compare_products","",void 0,"/",void 0);
}
