// Gets the value of the cookie
// name - name of the cookie
// returns a string with the value of the specified cookie or null if the cookie does not exists
function getCookie(name){
	var cname = name + "=";
	var dc = document.cookie;
	if (dc.length > 0) {
		begin = dc.indexOf(cname);
		if (begin != -1) {
			begin += cname.length;
			end = dc.indexOf(";", begin);
			if (end == -1) end = dc.length;
				return unescape(dc.substring(begin, end));
		}
	}
	return null;
}


// Set a cookie
// name - name of the  cookie
// value - value of the cookie
// [expires] - expiring date of the cookie (initially, end of the sesion)
// [path] - path where the cookie is valid (initially, path of the documents that calls the function)
// [domain] - domain where the cookie is valid (initially, domain where the documents calls the function)
// [secure] - boolean indicating where the transmission of the cookie requieres a secure connection
function setCookie(name, value, expires, path, domain, secure) {
	document.cookie = name + "=" + escape(value) + 
	((expires == null) ? "" : "; expires=" + expires.toGMTString()) +
	((path == null) ? "" : "; path=" + path) +
	((domain == null) ? "" : "; domain=" + domain) +
	((secure == null) ? "" : "; secure");
}


// Deletes a cookie
// name - name of the cookie
// [path] - path of the cookie (must be the same path especified when creating the cookie))
// [domain] - domain of the cookie (must be the same domain especified when creating the cookie)
function delCookie (name,path,domain) {
	if (getCookie(name)) {
		document.cookie = name + "=" +
		((path == null) ? "" : "; path=" + path) +
		((domain == null) ? "" : "; domain=" + domain) +
		"; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}