var _fuehren_UserDisplayNameFromCookie = null;


//-----------------------------------------------------------------------------
function _fuehren_RedirectToFranklinCoveyDe()
//-----------------------------------------------------------------------------
{
	if ( 	(window.location.hostname != 'franklincovey.de') 	// production
		&&	(window.location.hostname != 'dmz.altmann.de') 		// local env
		&&	(window.location.hostname != '192.168.1.211') 		// FC Working Server
		&&	(window.location.hostname != '') 					// FP preview
	)
	{
		location.replace('http://franklincovey.de'+window.location.pathname);
	}
}


//-----------------------------------------------------------------------------
function _fuehren_GetUserDisplayNameFromCookie()
//-----------------------------------------------------------------------------
{
	var cookiename = 'FCFuehrenUserDisplayName';
	var re = new RegExp(cookiename + "=([^;]+)"); 
	var value = re.exec(document.cookie); 
	if (value!= null)
	{
		_fuehren_UserDisplayNameFromCookie = unescape(value[1]);
	}
	return _fuehren_UserDisplayNameFromCookie;
}
//-----------------------------------------------------------------------------
function _fuehren_StoreUserDisplayNameToCookie(name)
//-----------------------------------------------------------------------------
{
	document.cookie = 'FCFuehrenUserDisplayName='+escape(name)+'; path=/buecher/fuehren';
	_fuehren_GetUserDisplayNameFromCookie();
}
//-----------------------------------------------------------------------------
function _fuehren_DisplayUserName(id)
//-----------------------------------------------------------------------------
{
	//window.status = _fuehren_UserDisplayNameFromCookie+'-'+document.getElementById(id+"_block")+'-'+document.getElementById(id+"_name")+'-'+document.getElementById(id+"_text");
	var winstatus = _fuehren_UserDisplayNameFromCookie+'-'+document.getElementById(id+"_block")+'-'+document.getElementById(id+"_name")+'-'+document.getElementById(id+"_text");
	if (
			(_fuehren_UserDisplayNameFromCookie != null) 
		&&	(document.getElementById(id+"_block") != null)	
		&&	(document.getElementById(id+"_name") != null)	
		&&	(document.getElementById(id+"_text") != null)	
		)
	{
		//alert(id+' Elements found! '+ winstatus);
		document.getElementById(id+"_name").innerHTML = _fuehren_UserDisplayNameFromCookie+', ';
		if (window.location.pathname.indexOf('/protected') > 0)	{document.getElementById(id+"_text").innerHTML = 'Sie befinden sich im exklusiven Leserbereich zum Buch "Führen unter neuen Bedingungen".';}
		else													{document.getElementById(id+"_text").innerHTML = 'Sie sind im exklusiven Leserbereich zum Buch "Führen unter neuen Bedingungen" angemeldet.';}
		document.getElementById(id+"_block").style.display = 'block';
	}
	else 
	{
		//alert( id+' Elements NOT found! '+ winstatus); 
		window.setTimeout('_fuehren_DisplayUserName("'+id+'")', 500);
	}
}





_fuehren_RedirectToFranklinCoveyDe();
_fuehren_GetUserDisplayNameFromCookie();

