function Cookie(name, expires, domain, path, secure)
{
	this.name     = name;
  	this.expires  = expires;
  	this.domain   = domain;
 	this.path     = path;
  	this.secure = secure;

}

function setCookie(str)
{
  	document.cookie = this.name + "=" + escape(str) + 
    			  ((this.expires) ? "; expires=" + this.expires.toGMTString() : "") + 
    			  ((this.path) ? "; path=" + this.path : "") + 
    			  ((this.domain) ? "; domain="  + this.domain : "") + 
   			  ((this.secure) ? "; secure" : "");
}

function deleteCookie()
{
  	document.cookie = this.name + "=" +
    			  ((this.expires) ? "; expires=" + (new Date(0)).toGMTString() : "") + 
    			  ((this.path) ? "; path=" + this.path : "") + 
   			  ((this.domain) ? "; domain=" + this.domain : "");
}

function readCookie()
{
  	var cookieVal = document.cookie;
	var cookiePos = cookieVal.indexOf(this.name);

	if (cookiePos != -1) {
		start = cookiePos + this.name.length + 1;
	}
	else {
		return "";
	}

	var end = cookieVal.indexOf(";", start);
   
  	if (end == -1)
    		end = cookieVal.length;   
   
  	var cookiePiece = cookieVal.substring(start, end);

  	return unescape(cookiePiece);
}

new Cookie();  
Cookie.prototype.write = setCookie;
Cookie.prototype.read = readCookie;
Cookie.prototype.clear = deleteCookie;


