// sets a cookie using the given arguments
function setCookie(name, value) { 
	var exp = new Date(); //set new date object 
	exp.setTime(exp.getTime() + (1000 * 60 * 60 * 24 * 365)); //set it a year ahead
	
	document.cookie = name + "=" + escape(value) + "; path=/" + ((exp == null) ? "" : "; expires=" + exp.toGMTString()); 
} 

// get a cookie
function getCookie(name) {
	if (document.cookie.length>0) {
		start=document.cookie.indexOf(name + "=");
		if (start!=-1) { 
			start=start + name.length+1; 
			end=document.cookie.indexOf(";",start);
			if (end==-1) end=document.cookie.length;
				return unescape(document.cookie.substring(start,end));
		} 
	}
	return "";
}
