// JavaScript Document

var active_lang = 'ger'; 
var lang_select_bgtop = '"fileadmin/templates/fls/gfx/lang_select_bgtop.gif"'; 
var lang_select_bgactive = '"fileadmin/templates/fls/gfx/lang_select_bgactive.gif"'; 
var lang_select_bgboxed = '"fileadmin/templates/fls/gfx/lang_select_bgboxed.gif"';
var lang_select_bglast = '"fileadmin/templates/fls/gfx/lang_select_bglast.gif"';
var languages = new Array('ger','eng','fre');
var lang_pos = 0
var clicked=0;
var timeout = 0;

function initPage(){
	hidelang();	
	resizeContent();
	
}

function resize(){
	langpos();
	resizeContent();
}

function hidelang(){
	
	if (timeout == 0){
		browser_info = navigator.userAgent.split(";");
		if (navigator.appName ==  "Microsoft Internet Explorer"){
			ie_number = browser_info[1].replace(/[^0-9]/g,"").substring(0,2);
			if (ie_number<55){
				clicked++;
				lang_pos = -76*clicked;
			}
		}
		for (i=0;i<languages.length;i++){
			if ( active_lang != languages[i] ) {
				document.getElementById(languages[i]).style.display = "none";
			}
		}
		
		document.getElementById('lang_select').style.marginTop = lang_pos+"px";
		document.getElementById('activelang').style.backgroundImage = "url("+lang_select_bgboxed+")";
	}
}

function hidesoon(){
	timeout=0;
	window.setTimeout('hidelang()',1200);
}

function showlang(){
	timeout = 1
	list_pos = 19;
	hidelangs = document.getElementsByName('hiddenlang');
	
	for (i=0;i<languages.length;i++){
		list_pos -=19;
	}
	document.getElementById('lang_select').style.marginTop = (list_pos + lang_pos )+"px";
	document.getElementById('activelang').style.backgroundImage = "";
	
	for (i=0;i<languages.length;i++){
		if ( active_lang != languages[i] ) {
			document.getElementById(languages[i]).style.display = "block";
		}
	}
	document.getElementById('activelang').style.backgroundImage = "url("+lang_select_bgtop+")";
	document.getElementById('fre').style.backgroundImage = "url("+lang_select_bglast+")";
}

function langpos(){
	document.getElementById('lang_select').style.marginTop = "0px";
}

function setTextOfTextfield(id, text) {
  document.getElementById(id).value = text;
}


// -----------------------------------------------------------------------------------

//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function resizeContent(){
	// contentframe ref
	if (document.getElementById('innerframe').offsetHeight < document.getElementById('ref').offsetHeight){
		document.getElementById('innerframe').style.height = document.getElementById('ref').offsetHeight + "px";
	}
}
