function Fensterweite() {
	if (window.innerWidth) {
		return window.innerWidth;
	}
	else if (document.body && document.body.offsetWidth) {
		return document.body.offsetWidth;
	}
	else {
		return 0;
	}
}

function Fensterhoehe() {
	if (window.innerHeight) {
		return window.innerHeight;
	}
	else if (document.body && document.body.offsetHeight) {
		return document.body.offsetHeight;
	}
	else {
		return 0;
	}
}


function GetUsableWindowWidth() {
	Weite = Fensterweite();
	Hoehe = Fensterhoehe();
	
	if (Hoehe >= (Weite/1.5)) { 
		tWeite = Weite-40;
		tHoehe = Math.round(tWeite/1.5);
	} else {
	    tHoehe = Hoehe-40;
	    tWeite = Math.round(tHoehe*1.5);
	}
	return tWeite;
}

function GetUsableWindowHeight() {
	Weite = Fensterweite();
	Hoehe = Fensterhoehe();
	tabRand = 30;
	
	if (Hoehe >= (Weite/1.5)) { 
		tWeite = Weite-40;
		tHoehe = Math.round(tWeite/1.5);
	} else {
	    tHoehe = Hoehe-40;
	    tWeite = Math.round(tHoehe*1.5);
	}
	
	return tHoehe;
}

function showhide(name) {
	var e = document.getElementById(name);
	e.style.display = (e.style.display == 'block') ? 'none' : 'block';
}

function show(name) {
	var e = document.getElementById(name);
	e.style.display = 'block';
}
	
function hide(name) {
	var e = document.getElementById(name);
	e.style.display = 'none';
}

function changeclass(name) {
	var e = document.getElementById(name);
	e.className = (e.className == 'close') ? 'open' : 'close';
}

function changeButtonMed(name) {
	var e = document.getElementById(name);
	e.className = (e.className == 'medres') ? 'medreshell' : 'medres';
}

function setlightboxsize(name) {
	set_h = (document.getElementById("tbl").offsetHeight);
	set_h = set_h + "px";
	set_w = parseInt(document.body.clientWidth);
	set_w = set_w + "px";
  document.getElementById(name).style.height = set_h;
  document.getElementById(name).style.width = set_w;
}
	
function loadswf(pfad, pw, ph) {
	
	var h = '';
	
	if ((pw/ph >= 1.5)) { 
		var uwidth = GetUsableWindowWidth()-20;
		
		if (uwidth > pw) {uwidth = pw;}
		
		h = '<img src="' + pfad + '" width="' + uwidth + '" onClick="if (this.width=='+pw+'){this.width = ' + uwidth +'}else{this.width =  '+pw+'}" style="cursor: ne-resize "  >';
	} else {
		var uheight = GetUsableWindowHeight()-20;
		
		if (uheight > ph) {uheight = ph;}
		
		h = '<img src="' + pfad + '" height="' + uheight +'" onClick="if (this.height=='+ph+'){this.height = ' + uheight +'}else{this.height =  '+ph+'}" style="cursor: ne-resize "  >';
	}	
	
	
	document.getElementById('video').innerHTML=h;
}

function change(name, oc) {
	var object = document.getElementById(name).style;
	object.opacity = (oc / 100);     
	object.MozOpacity = (oc / 100);  
	object.filter="Alpha(opacity="+oc+")";
	object.KhtmlOpacity = (oc / 100);
}

function fade(name, nooc, ocs, oce, millisec, text) {
	var object = document.getElementById(name).style;
	var speed = Math.round(millisec / 100);
  var timer = 0; 
	if( ocs < oce ) {
		change(name, 1);
		object.display = 'block';
		for(oc = ocs; oc <= oce; oc++) {
			setTimeout("change('" + name + "'," + oc + ")", (speed*timer));	
			timer++;
		}
		document.getElementById('comment').innerHTML = text;
		window.scrollTo(0, 0);
		setTimeout("show('"+ nooc +"');", (timer*speed));
	}
	else if( ocs >= oce ) {
		hide(nooc);
		for(oc = ocs; oc >= oce; oc--) {
			setTimeout("change('" + name + "'," + oc + ")", (speed*timer));	
			timer++;		
		}
		object.display = 'none';
		document.getElementById('video').innerHTML = "";
	}
}

function includeLightbox(name, nooc ,ocs, oce, millisec, pfad, text, pw, ph) {
	setlightboxsize(name);
	setlightboxsize(nooc);
	fade(name, nooc, ocs, oce, millisec, text);
	loadswf(pfad, pw, ph);
}


  

function ResizeVideoTbl() {
			
		Weite = Fensterweite();
		Hoehe = Fensterhoehe();
		tabRand = 20;
		
		tHoehe = GetUsableWindowHeight();
		tWeite = GetUsableWindowWidth();			
				
		if (tWeite >= 500) {
			document.getElementById('videotbl').style.width = (tWeite) + 'px';
			document.getElementById('video').style.width = (tWeite) + 'px';
			
			document.getElementById('videotbl').style.height = (tHoehe+tabRand) + 'px';
			document.getElementById('video').style.height = (tHoehe) + 'px';
			
			document.getElementById('videotbl').style.marginTop = Math.round((Hoehe-tHoehe-tabRand)/2) + 'px';							
		}	
}

