function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function setCookie(name, value) {
	if(name != '')
	{
		content = getCookie(name);
		position = content.indexOf(value);
		if(position>-1)
		{
			head = content.substring(0,position-1);
			tail = content.substring(position+1,content.length);
			cut = tail.indexOf("|");
			if(cut<0)
				cut = content.length;
			tail = content.substring(position+cut+1,content.length);
			content = head + tail;
		}
	   	document.cookie = name + '=' + '|' + value + content;
	}
}

function getCookie(name) {
	if(name == '')
		return('');
	name_index = document.cookie.indexOf(name + '=');
	
	if(name_index == -1)
		return('');

	cookie_value =  document.cookie.substr(name_index + name.length + 1,document.cookie.length);
    //All cookie name-value pairs end with a semi-colon, except the last one.
	end_of_cookie = cookie_value.indexOf(';');
	
	if(end_of_cookie != -1)
		cookie_value = cookie_value.substr(0, end_of_cookie);
	//Restores all the blank spaces.
	space = cookie_value.indexOf('+');

	while(space != -1)
	{ 
		cookie_value = cookie_value.substr(0, space) + ' ' + 
		cookie_value.substr(space + 1, cookie_value.length);
		space = cookie_value.indexOf('+');
	}
	
	return(cookie_value);
}

function showCookie(name,maxrecords) {
	var content = getCookie(name);
	content = content.substring(1,content.length);
	while (maxrecords>0 && content.indexOf('|')>-1)
	{
		ini = content.indexOf('name=');
		end = content.indexOf('|');
		product = content.substring(ini+5,end);
		prodid = product.substring(0,product.indexOf('@'));
		product = product.substring(product.indexOf('@')+1,end);		
		document.write("<li><a href='shopexd.asp?id=" + prodid + "'>" + product + "</a></li>");
		content = content.substring(end+1,content.length);
		maxrecords--;
	}
}