<!-- All about Cookies -->

/* Creates a Cookies if not exists */
	function createCookie()
	{
		if( !document.cookie )
		{
			var a = new Date();
			a = new Date(a.getTime() +1000*60*60*24*365);
			document.cookie = 'expires='+a.toGMTString()+';path=/;';   
			//alert( 'Cookie existiert nicht' );
		}
		return document.cookie;
	}

/* Deletes a Cookies - Set ExpireDate to 'long time ago' */
	function deleteCookie()
	{
		if( document.cookie )
		{
			document.cookie = 'expires=Thu, 01-Jan-70 00:00:01 GMT;path=/;';
		}
	}

/* Set the name-value pair in a cookie */
	function setCookieValue( name, value )
	{
		document.cookie = name + '=' + value + ';path=/;time()+2592000;';
	}

/* Delete a cookie-value - Set it to empty */
	function deleteCookieValue( name )
	{
	 	document.cookie = name + '=;path=/;time()+2592000;';
	}

/* Returns the value of a Cookie by given name */
	function getCookieValue( name )
	{
		carray = new Array();
		carray = document.cookie.split(';');
		//alert( carray[1] );

		retVar = '';

		 for( i=0 ; i <= carray.length-1 ; i++ )
		 {

                        //alert(carray[i].substring( 0, carray[i].search( '=' ) ));
                        checkname = carray[i].substring( 0, carray[i].search( '=' ) );
                        checkname = checkname.replace(/ /g,'');

		 	if( checkname == name )
		 	{
		 		pair = carray[i];
				//alert( pair );
		 		retVar = pair.substring( pair.search( '=' )+1 );
		 	}
		 }

		return retVar;
	}
