cookieControl = {

	set: function(name, value, timetolive, path, domain, secure) {
		cookie = [name+'='+    escape(value),
		 		  'path='+    ((!path   || path=='')  ? '/' : path),
		 		  'domain='+  ((!domain || domain=='')?  window.location.hostname : domain)];

		if (timetolive)  cookie.push(cookieControl.hoursToExpireDate(timetolive));
		if (secure)      cookie.push('secure');
		return document.cookie = cookie.join('; ');
	},

	unset: function(name, path, domain) {
		path   = (!path   || typeof path   != 'string') ? '' : path;
        domain = (!domain || typeof domain != 'string') ? '' : domain;
		if (cookieControl.get(name)) cookieControl.set(name, '', 'Thu, 01-Jan-70 00:00:01 GMT', path, domain);
	},

	get: function(name) {
		tmp =  document.cookie.match((new RegExp(name +'=[a-zA-Z0-9.()=|%/]+($|;)','g')));
		if(!tmp || !tmp[0]) return null;
		else return unescape(tmp[0].substring(name.length+1,tmp[0].length).replace(';','')) || null;

	},

	hoursToExpireDate: function(timetolive) {
		if (parseInt(timetolive) == 'NaN' ) return '';
		else {
			now = new Date();
			now.setTime(now.getTime() + (parseInt(timetolive) * 60 * 60 * 1000));
			return now.toGMTString();
		}
	}
}
