onerror = ErrorFunction;
function ErrorFunction(){
   return true;
}
//pseudo logout
/*function logout(){
	document.cookie = "be_typo_user=; expires=Thu, 01-Jan-70 00:00:01 GMT;";
    location.reload();

}*/

var http = null;
var url   = window.location.search.substr(1);
var get_param = new Array;
var param_value = new Array;
var browserArray = new Array ();
var flash = false;
var baseUrl = "http://www.christian-schiester.com/"
var cookie = getCookie("be_typo_user");
var ref = document.referrer;

if( ( ((url == "") && (cookie == false) )) ){
	location.href=baseUrl+"flash/index.php";
	}

function getCookie(name){
   var i=0;  //Suchposition im Cookie
   var suche = name+"=";
   while (i<document.cookie.length){
      if (document.cookie.substring(i, i+suche.length)==suche){
         var ende = document.cookie.indexOf(";", i+suche.length);
         ende = (ende>-1) ? ende : document.cookie.length;
         var cook = document.cookie.substring(i+suche.length, ende);
         return true;
      }
      i++;
   }
   return false;
}

if (window.XMLHttpRequest) {
   http = new XMLHttpRequest();
} else if (window.ActiveXObject) {
   http = new ActiveXObject("Microsoft.XMLHTTP");
}
		if (http != null) {
		   http.open("GET", url, true);
		   http.onreadystatechange = decode;
		   http.send(null);
		}
		
		function decode() {
		   if (http.readyState == 4) {
		   	   cookie = getCookie("be_typo_user");
		       flashdetection();
		       brw_detection();
		          	
		   		if (url != "")  {
		       	   
		           liste = url.split("&");
		           for (i=0;i<=liste.length-1;i++) {
		           		temp = liste[i].split("=");
		           		
		           		temp[1]=temp[1].replace(/\+/g, ""); 
		           		temp[1]=unescape(temp[1]);
		        		get_param[i] = temp[0];
		        		param_value[i] = temp[1];
		        		
		           }
		          		           
		           redirect();
		         		           
		   		}
			}
		
		}
		
		function flashdetection(){
			
			//Detection for Firefox & other Gecko-Browser
		   	if ((navigator.mimeTypes) && (navigator.mimeTypes.length > 0)){
		   		for (a = 0; a < navigator.mimeTypes.length; a++){
		      		if (navigator.mimeTypes[a].type.indexOf("application/x-shockwave-flash")>= 0){
		         		return flash = true;
		      		}
		   		}
		   }
		   
		   //Detection for IE & NS
		  // else return flash =  checkActiveXFlash(); 
		   
		}
		
		function brw_detection(){
			var ua = navigator.userAgent.toLowerCase();
			browserArray[0] = (ua.indexOf("gecko/") != -1);
			browserArray[1] = (ua.indexOf("msie") > -1 && ua.indexOf("opera") == -1);
			browserArray[2] = (ua.indexOf("opera") > -1);
			browserArray[3] = (ua.indexOf("staroffice") != -1);
			browserArray[4] = (ua.indexOf("webtv") != -1);
			browserArray[5] = (ua.indexOf("beonex") != -1);
			browserArray[6] =  (ua.indexOf("chimera") != -1);
			browserArray[7] = (ua.indexOf("netpositive") != -1);
			browserArray[8] = (ua.indexOf("phoenix") != -1);
			browserArray[9] = (ua.indexOf("firefox") != -1);
			browserArray[10] = (ua.indexOf("safari") != -1);
			browserArray[11] = (ua.indexOf("skipstone") != -1);
			browserArray[12] = (ua.indexOf("netscape") != -1);	
		}
		
		function redirect() {
			var engine = false;
			var no_flash = false;
			//var no_redirect = false;
			
			
			for(i=0;i<browserArray.length;i++){
				if(browserArray[i] == true){
					engine = true;
					break;		
				}
			}
			
			for(i=0;i<get_param.length;i++){
				
				if( (get_param[i] == "no_flash") && (param_value[i] == "1") || (flash == false) || (cookie == true)){
					no_flash = true;
					break;
				}
			}
						
			if((engine==true)&&(no_flash==false)&&(flash = true))
				location.href=baseUrl+"flash/index.php?"+url;	
				
		}
