	/*****************************************************************
			JavaScript für iFrame und Flash im PWK System 3.x
			Jens Liebelt,September 2009
	*****************************************************************/
	// Animation
	var pos_end = 200;
	var pos_start = -20;
	var pos_counter = 0;
	var animation = 1;
	
	// Fenster Titelleiste
	var bar_height = 20;
	
	// Flash oder was auch immer im Iframe platziert werden soll
	var flash_padding = 16;
	var flash_width = 827 + flash_padding;
	var flash_height = 408 + flash_padding;
	var flash_src = "";
	
	// Elternelement für den iFrame mit der Flashdatei
	var elem_width = 827 + (flash_padding *2);
	var elem_height = 408 + bar_height +(flash_padding*2);
	var elem_left = 50;
	var elem_top = 50;	
	action_elem = new Object;	


	// Cookie
	var cookie_day = 1;
	var cookie_ablauf = new Date();
	var cookie_lifetime = cookie_ablauf.getTime() + ( cookie_day * 24 * 60 * 60 * 1000);
	cookie_ablauf.setTime(cookie_lifetime);

	var intro = false;
	/*****************************************************************
			Funktionen für den Benutzer
	*****************************************************************/
	function fly_setup(a_pos_end,a_pos_start,a_animation,a_flash_padding,a_flash_width,a_flash_height,a_flash_src,a_elem_width,a_elem_height,a_elem_left,a_elem_top,a_cookie_day){

		pos_end = a_pos_end;
		pos_start = a_pos_start;
		animation = a_animation;

		flash_padding = a_flash_padding;
		flash_width = a_flash_width + flash_padding;
		flash_height = a_flash_height + flash_padding;
		flash_src = a_flash_src;

		elem_width = a_elem_width + (flash_padding *2);
		elem_height = a_elem_height + bar_height +(flash_padding*2);
		elem_left = a_elem_left;
		elem_top = a_elem_top;
		
		cookie_day = a_cookie_day;
		cookie_ablauf = new Date();
		cookie_lifetime = cookie_ablauf.getTime() + ( cookie_day * 24 * 60 * 60 * 1000);
		cookie_ablauf.setTime(cookie_lifetime);
	
		check_intro();
		
	}

	function check_intro(){
		pos_counter = 0;
		fly_content();
		// umgeht das Cookie
		if(cookie_day == 0)
			fly();
	}

	function  show_intro(a_pos_end,a_pos_start,a_animation,a_flash_padding,a_flash_width,a_flash_height,a_flash_src,a_elem_width,a_elem_height,a_elem_left,a_elem_top,a_cookie_day){

		pos_end = a_pos_end;
		pos_start = a_pos_start;
		animation = a_animation;

		flash_padding = a_flash_padding;
		flash_width = a_flash_width + flash_padding;
		flash_height = a_flash_height + flash_padding;
		flash_src = a_flash_src;

		elem_width = a_elem_width + (flash_padding *2);
		elem_height = a_elem_height + bar_height +(flash_padding*2);
		elem_left = a_elem_left;
		elem_top = a_elem_top;
		
		cookie_day = a_cookie_day;
		cookie_ablauf = new Date();
		cookie_lifetime = cookie_ablauf.getTime() + ( cookie_day * 24 * 60 * 60 * 1000);
		cookie_ablauf.setTime(cookie_lifetime);
		
		pos_counter = 0;
		intro = true;
		fly_content();
		fly();
	}

	
	function fly_content(){
		if (navigator.cookieEnabled == true){
			if(check_cookie(window.location.hostname + '_run_in') == true && intro == false)
				return;
		}
		// Rahmen
		div = document.createElement("div");
		div.style.width = elem_width + "px";
		div.style.height = elem_height + "px";
		div.style.backgroundColor = "#fff";
		div.style.border ="2px solid gray"
		div.style.display ="none";
		div.style.position = "absolute";
		div.style.zIndex = "3000000";
		div.style.left = elem_left + "px";
		div.style.top = elem_top + "px";
		// Bar
		bar = document.createElement("div");
		bar.style.width = elem_width + "px";
		bar.style.height = bar_height + "px";
		bar.style.backgroundColor = "#0078B8";
		
		// Close Button
		button = document.createElement("div");
		button.style.width = "40px";
		button.style.height = "20px";
		button.innerHTML = "Schließen";
		button.style.cssText ="float:right;margin-right:10px;position:relative;cursor:pointer;font-family:arial;font-size:11px;padding-top:5px;color:#fff;";
		regEvent(button,'click',function(evt){
			if(!document.all)
			elem = this.parentNode.parentNode;
	
			if(document.all)
			elem = evt.srcElement.parentElement.parentElement
			
			document.getElementsByTagName('body')[0].removeChild(elem);
		},false);
		
		bar.appendChild(button);
		div.appendChild(bar);
		
		// Inhalt
		iframe = document.createElement("iframe");
		iframe.src = flash_src;
		iframe.scrolling ="no"
		iframe.setAttribute("frameborder","0");
		iframe.setAttribute("frameBorder","0");
		iframe.style.cssText ="width:"+flash_width+"px;height:"+flash_height  +"px;padding:"+flash_padding+""; 
		div.appendChild(iframe);
		
		document.getElementsByTagName('body')[0].appendChild(div);
		
		action_elem = div;
			
		if (navigator.cookieEnabled == true){
			if(check_cookie(window.location.hostname + '_run_in') == false)
				fly();
		}else{
			fly();
		}
	}
	
	function fly(){

		if(animation == 0)
		fly_null();
		
		if(animation == 1)
		action = window.setInterval("fly_in()",2);
		
		if(animation == 2)
		action = window.setInterval("fly_left()",1);
	}
	
	function fly_null(){
		if(action_elem.style.display == "none")
			action_elem.style.display = "block";	
	}
	
	function fly_in(){
		if(action_elem.style.display == "none")
			action_elem.style.display = "block";
			
		action_elem.style.top = pos_start + pos_counter + "px";
		pos_counter++;
		
		if(pos_start + pos_counter == pos_end){
			window.clearInterval(action);
			document.cookie = window.location.hostname +  "_run_in=1"+";expires=" + cookie_ablauf.toGMTString();		
		}
	}
	
	function fly_left(){
		if(action_elem.style.display == "none")
			action_elem.style.display = "block";
			
		action_elem.style.left = pos_start + pos_counter + "px";
		pos_counter++;
		
		if(pos_start + pos_counter == pos_end){
			window.clearInterval(action);
			document.cookie = window.location.hostname +  "_run_in=1"+";expires=" + cookie_ablauf.toGMTString();		
		}
		
	}
	
	function flash_href(file){
		//alert("Später gehe ich zu: " +file)
		location.href= window.location.hostname + "/" +file;
	}
	
	function check_cookie(findThis){
			var info = document.cookie;
			if(!info)
				return false;
			info = info.split(";");
			for(var x = 0; x < info.length; x++){
				_info = info[x].split("=");
				if(getReplace(" ","",_info[0]) ==findThis){
					return true;
				}
			}
			return false;
	}
	/***********************************************************************************
		Erstetzt innerhalb eines String einen Ausdruck durch einen anderen * alle Vorkommen
	***********************************************************************************/
	function getReplace(matchThis,replaceWidth,source){		
		var ausdruck = new RegExp(matchThis, "g");
		var new_Value = source.replace(ausdruck, replaceWidth);
		return new_Value;
	}
