//
if (document.cookie)
{
	// Testen ob Root-Url oder Sub-Url
	//if (location.href.match(/(\/.+)/) && !location.search.match(/clearcookie/))
	if (location.href != "http://www.krankenversicherer.ch/" && !location.search.match(/clearcookie/))
	{
		//document.write("<div style='color:transparent;font-size:5px'>BMTEST-1 '" + RegExp.$1 + "'</div>");
		// Sub-Url: Client-CSS laden sofern Cookie vorhanden
	
		// Cookie lesen und entsprechende CSS-Datei referenzieren
		var clientCss = asf();		
		if (clientCss != null)
		{
			//alert("test: " + clientCss);
			document.writeln('<link rel="stylesheet" type="text/css" href="css/' + clientCss + '/clientCss.css">');
		}		
		
	}
	else
	{
		//document.write("<div style='color:transparent;font-size:5px'>BMTEST-2</div>");
		// Root-Url: Cookie löschen
		if ( asf() ) document.cookie = "clientCss" + "=" +
			( ( true ) ? ";path=" + "/" : "") +
			( ( false ) ? ";domain=" + "" : "" ) +
			";expires=Thu, 01-Jan-1970 00:00:01 GMT";
	}
	
	// Test-Methode ohne Produktive Nutzung	
	if (location.search.match(/thistest/))
		{
			alert("location: " + location.href  + "\n" + "cookie: " + document.cookie);
		}
	
}

function asf()
{
	var check_name = "clientCss";
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false;
	
	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		a_temp_cookie = a_all_cookies[i].split( '=' );		
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found ) 
	{
		return null;
	}
}
