String.prototype.trim=function(){
	return this.replace(/^\s*/, '').replace(/\s*$/, '');
}

function jsCookie(){
	var name;
	var value;
	var domain;
	var path;
	var cookiestring;
	var secure;
	var expires

	this.secure=false;
	this.exists=false;
	this.domain=document.domain;
	this.path="/";
	this.expires="";

	this.setexpires=function(arg){

		var exp="";

		if (arg.match(",")){
			newargs=arg.split(",");
			var min=newargs[0];
			var hour=newargs[1];
			var day=newargs[2];
			var year=newargs[3];

			var minmil=60*1000;
			var hourmil=60*(minmil);
			var daymil=24*(hourmil);
			var yearmil=365*(daymil);
			var now=new Date();
			exp=new Date(now.getTime()+(hour*hourmil)+(min*minmil)+(day*daymil)+(year*yearmil));
		}
		else{
			exp=new Date(arg);
		}

		this.expires=exp.toGMTString();

	}

	this.jsCookie=function(){
		this.get();
	}

	this.set=function(){
		var strSecure;
		this.setexpires(this.expires)
		strSecure=this.secure==true ? strSecure="; SECURE" : "";
		this.cookiestring=this.name+"="+escape(this.value)+";path="+this.path+";expires="+this.expires+strSecure;
		document.cookie=this.cookiestring;
	}

	this.get=function(){
		var cookiefile=document.cookie;
		var cookies=cookiefile.split(";");

		for (i=0;i<cookies.length;i++){
			var thecookie=Array();
			thecookie=cookies[i].split("=");

			if (this.name==thecookie[0].trim()){
				this.value=unescape(thecookie[1]);
				return;
			}
		}
	}

	this.exists=function(){
		var cookiefile=document.cookie;
		var cookies=cookiefile.split(";");
		var blnexists=false;


		for (i=0;i<cookies.length;i++){
			var thecookie=Array();
			thecookie=cookies[i].split("=");

			if (this.name==thecookie[0].trim()){
				blnexists=true;
				break;
			}
		}
		blnexists ? this.get() : '';
		return blnexists;

	}

	this.destroy=function(){
		var strSecure;
		strSecure=this.secure==true ? strSecure="; SECURE" : "";
		this.cookiestring=this.name+"="+escape(this.value)+";path="+this.path+";expires="+this.setexpires("0,0,0,-20");
		document.cookie=this.cookiestring;
	}

}