/**
 * Methoden zum Setzen, Auslesen und Löschen von Cookies
 *
 * @authors		Martin Widemann
 * @copyright	Copyright 2008 - Netigo GmbH
 * @version		1.1
 * @modified	2009-01-29
 */
var Cookie = {

	/**
	 * Cookie auslesen
	 *
	 * @param String name Name des Cookies
	 */
	get: function(name){
		if(name == void(0)){ throw 'Missing Parameter \'name\' in Method \'get\'.'; } // if

		if(document.cookie.length > 0){ 
			begin = document.cookie.indexOf(name + '='); 
	
			if (begin != -1){ 
				begin += name.length+1; 
				end = document.cookie.indexOf(';', begin);
	
				if (end == -1){
					end = document.cookie.length;
				} // if
	
				return unescape(document.cookie.substring(begin, end));
			} // if
		} // if
	
		return null; 
	}, // function

	/**
	 * Cookie setzen
	 *
	 * @param String name Name des Cookies
	 * @param String value Inhalt des Cookies
	 * @param Number expire_days Haltbarkeit des Cookies (Anzahl Tage)
	 */
	set: function(name, value, expire_days, path){
		if(name == void(0)){ throw 'Missing Parameter \'name\' in Method \'set\'.'; } // if
		if(value == void(0)){ throw 'Missing Parameter \'value\' in Method \'set\'.'; } // if

		if(path == null){
			path = '/';
		} // if

		var expire_date = new Date ();
		expire_date.setTime(expire_date.getTime() + (expire_days * 24 * 3600 * 1000));
		document.cookie = name + '=' + escape(value) + ((expire_days == null) ? '' : '; expires=' + expire_date.toGMTString()) + '; path=' + path;
	}, // function

	/**
	 * Cookie löschen
	 *
	 * @param String name Name des Cookies
	 */
	del: function(name){
		if(name == void(0)){ throw 'Missing Parameter \'name\' in Method \'del\'.'; } // if

		if(Cookie.get(name)){
			document.cookie = name + '=' + '; expires=Thu, 01-Jan-70 00:00:01 GMT';
		} // if
	} // function

} // class

