/**
 * Cookies
*/
Cookie=new Object;
Cookie.get=function(name){
	var ckh=document.cookie;
    var index=ckh.indexOf(name+"=");
    if(index==-1){
    	return null;
    }
    index=ckh.indexOf("=",index)+1;
    var endstr=ckh.indexOf(";",index);
    if(endstr==-1){
    	endstr=ckh.length;
    }
    return unescape(ckh.substring(index,endstr));
}

Cookie.set=function(name,value,expire){
	var ckh=document.cookie;
	var today=new Date();
	if (typeof expire=='undefined'){
		expire=null;
	}
	switch (expire){
		case 0: //Cookie will expire at the end of session
			expirestr='';
			break;
		case null: //Cookie will expire after 28 days (break MUST NOT be used at the end of this block!)
			expire=28*24*60*60;
		default: //Cookie will expire after expire seconds
			expire=expire*1000;
			var expiredate=new Date(today.getTime()+expire);
			var expirestr="; expires="+expiredate.toGMTString();
			break;
	}
	var expiredate=new Date();
	if(value!=null&&value!="")
		document.cookie=name+"="+escape(value)+"; path=/"+expirestr;
	ckh=document.cookie;
}

Cookie.del=function(name){
	var today=new Date();
	var expire=new Date(today.getTime()-28*24*60*60*1000);
	document.cookie=name+"="+escape('')+"; path=/;expires="+expire.toGMTString();
	ckh=document.cookie;
}

Cookie.contains=function(key){
	return (Cookie.get(key)!=null && Cookie.get(key)!='');
}
