
var original_frame_height;
var stored_window_height;
var value;


function init(){
	prepareForPrint();
	
	/*
  After the flash plugin detection (done in index_html.php), the variable flashinstalled can have three values:

    * 2: Flash installed
    * 1: Flash not installed
    * 0: Unknown if Flash is installed 

  The variable flashversion contains the version of Flash. If the version is unknown, it is 0.
  */
	
	if(flashinstalled==2){
    //alert("Flash is installed!");
    
    // nothing to do right now ...
    
  }else{
    
    //alert("Flash is not installed!");
    
    var topMsg = document.createElement("div");
    var img = document.createElement("img");
    var src = document.createAttribute("src");
    var align = document.createAttribute("align");
    var txt = document.createTextNode("Flash nicht ausführbar! Wenn Sie noch kein Flashplugin installiert haben, klicken Sie bitte hier! Andernfalls müssen die die Sicherheitseinstellungen Ihres Browsers anpassen!");
    var msg = document.createElement("a");
    var href = document.createAttribute("href");
    var target = document.createAttribute("target");
    
    href.nodeValue = "http://www.adobe.com/go/getflashplayer";
    msg.setAttributeNode(href);
    
    target.nodeValue = "blank";
    msg.setAttributeNode(target);
    
    src.nodeValue = "http://www.paulitsch.at/cms/pics/get_flash_player.gif";
    img.setAttributeNode(src);
    
    align.nodeValue = "middle";
    img.setAttributeNode(align);
    
    img.style.marginRight='0.5em';
    
    msg.appendChild(img);
    
    msg.appendChild(txt);
    msg.style.color='#000000';
    msg.style.textDecoration='none';
    
    topMsg.appendChild(msg);
    
    topMsg.style.backgroundColor='#ffffe1';
    topMsg.style.color='#000000';
    topMsg.style.border='1px solid #808080';
    topMsg.style.padding='0.5em';
    topMsg.style.fontSize='0.7em';
    topMsg.style.textAlign='left';
    topMsg.style.marginBottom='1em';
    
    document.getElementsByTagName("body")[0].insertBefore(topMsg,document.getElementById('frame'));
    
  }
  
  //setInterval("footerPos()",5);
  
  stored_window_height = window.innerHeight;
  if(document.all){
    original_frame_height = document.all.frame.offsetHeight;
  }else{
    original_frame_height = document.getElementById("frame").offsetHeight;
  }
  
  setInterval("footerPos2()",5);
}

function getPlatform(){
	window.location.href="index.php?platform="+navigator.platform;
}
	
function prepareForPrint(){
	if(document.all && navigator.appVersion.substring(22,23)==4) {
		self.focus();
	 	var OLECMDID_PRINT = 6;
	 	var OLECMDEXECOPT_DONTPROMPTUSER = 2;
	 	var OLECMDEXECOPT_PROMPTUSER = 1;
	 	var WebBrowser = '<object id="WebBrowser1" width="0" height="0" classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></object>';
	 	document.body.insertAdjacentHTML('beforeEnd',WebBrowser);
	 	WebBrowser1.ExecWB(OLECMDID_PRINT,OLECMDEXECOPT_DONTPROMPTUSER);
	 	WebBrowser1.outerHTML = '';
	}
}

function checkMailForm(){
	if(document.mailform.from.value.length==0 
		|| document.mailform.subject.value.length==0
		|| document.mailform.body.value.length==0
		|| document.mailform.email.value.length==0
		){ 
		alert("Bitte füllen Sie alle Felder aus!");
		return false;
	}
}

function printVersion(node){
	pWin = window.open("print.php?node="+node,"printversion","height=500,width=650,menubar=yes,toolbar=yes,scrollbars=yes");
	pWin.focus();
}

function footerPos(){
   var gescrollt = (document.all)? document.body.scrollTop :
                   window.pageYOffset;
   var neuPos = gescrollt + 100;
   if (document.layers) // Netscape 4
      document.footer.top = neuPos;
   else if (document.all){ // IE
      if(document.all.frame.offsetHeight > document.body.clientHeight){
        var neuPos = document.body.scrollTop + document.body.clientHeight - document.all.footer.offsetHeight;
        document.all.footer.style.width='878px';
        document.all.footer.style.position='absolute';
        document.all.footer.style.top = '' + neuPos + 'px';
        document.all.footer.style.zIndex='99';
      }
   }else if (document.getElementById){ // W3C
      var frame = document.getElementById("frame");
      var footer = document.getElementById("footer");
      
      if(frame.offsetHeight > window.innerHeight){
      
        var neuPos = window.pageYOffset + window.innerHeight - footer.offsetHeight;
        footer.style.position='absolute';
        footer.style.zIndex='99';
        footer.style.top = '' + neuPos + 'px';
        footer.style.width='878px';
        //document.getElementById("content").innerHTML = neuPos;
      }
    }
}
	
function footerPos2(){
  if (document.layers){ // Netscape 4
    // NO IMPLEMENTATION NOW
  }else if (document.all){ // IE
    var neuPos = document.body.clientHeight;
    var old_frame_height = document.all.frame.offsetHeight;
    
    if(document.all.frame.offsetHeight < document.body.clientHeight){
      document.all.frame.style.height = neuPos + 'px';
      var frame_added_pixels = document.all.frame.offsetHeight - old_frame_height;
      document.all.main_layout_table.style.height = (document.all.main_layout_table.offsetHeight + frame_added_pixels) + "px";
    }else if(document.all.frame.offsetHeight > document.body.clientHeight){
      if(original_frame_height > neuPos){
        neuPos = original_frame_height;
      }
      
      document.all.frame.style.height = '' + neuPos + 'px';
      var frame_reduced_pixels = old_frame_height - neuPos;
      
      if(frame_reduced_pixels < 1){
        frame_reduced_pixels = 0;
      }
      
      document.all.main_layout_table.style.height = (document.all.main_layout_table.offsetHeight - frame_reduced_pixels) + "px";
    }
  }else if (document.getElementById){ // W3C
    var frame = document.getElementById("frame");
    var footer = document.getElementById("footer");
    var table = document.getElementById("main_layout_table");
    
    var old_frame_height = frame.offsetHeight;
    stored_window_height = window.innerHeight;
    var neuPos = window.innerHeight;
    var offset = 8; // for mozilla firefox 8 will be the default value
    
    if(navigator.appVersion.substr(80,6)=="Safari")
      offset = 0;
    
    if(frame.offsetHeight < window.innerHeight){
      frame.style.height = '' + neuPos + 'px';
      var frame_added_pixels = frame.offsetHeight - old_frame_height;
      table.style.height = (table.offsetHeight + frame_added_pixels - offset) + "px";
    }else if(frame.offsetHeight > window.innerHeight){
      
      if(original_frame_height > neuPos){
        neuPos = original_frame_height;
      }
      
      frame.style.height = '' + neuPos + 'px';
      var frame_reduced_pixels = old_frame_height - neuPos;
      
      if(frame_reduced_pixels < 1){
        frame_reduced_pixels = 0;
      }
      
      table.style.height = (table.offsetHeight - frame_reduced_pixels - offset) + "px";
    }
  }
}
