
/*******************************************************************
Name : WrCookie
Arguments: name - Name of the cookie, value - Value for that name, 
				  days - Days for which cookie is valid 
Description: Generic function for creating cookies
*******************************************************************/
function WrCookie(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=/"; 
	
}

/***********************************************************************
Name : RdCookie
Arguments: name - Name of the cookie 
Description: Generic function for reading cookies value by their names
************************************************************************/
function RdCookie(name)
{
	var allcookies = window.document.cookie;
	if (allcookies == "") 
	{
		//alert("No Cookie found for document");
		return ;
	}
	var start = allcookies.indexOf(name + "=");
	if (start == -1) 
	{	
		//alert("Cookie not found");
		return ;
	}
	start += name.length + 1;

	var end = allcookies.indexOf(";", start);
	if (end == -1)
		end = allcookies.length;
	var cookieval = allcookies.substring(start, end);
	return cookieval;
}

