/**
 * 
 * @param name Name of the cookie
 * @param value Value the cookie should use
 * @param Number if days the cookie should be valid (optional)
 * @return
 */
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

/**
 * Read the cookie with the given name.
 * @param name Name of the cookie
 * @return the cookie's value
 */
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

/**
 * Erase the cookie with the given name.
 * @param name Name of the cookie to erase
 * @return -
 */
function eraseCookie(name) {
	createCookie(name,"",-1);
}

/**
 * Check if cookies are available in the clients browser.
 * If cookies are not enabled, an information is shown.
 */
function checkCookies(){
	createCookie( 'test', 'none', '' );
	if ( readCookie( 'test' ) )
	{
		eraseCookie('test');
	}
	else
	{
		showCookieDisabledLayer();
	}
	
}

function showCookieDisabledLayer(){ 
	var win = document.getElementById("cookieInfo");
	if (win){
		win.style.visibility="visible";
	}
}

function hideCookieDisabledLayer(){
	var win = document.getElementById("cookieInfo");
	if(win){
		win.style.visibility="hidden";
	}
}
