var version=parseFloat(navigator.appVersion), agent=navigator.userAgent.toLowerCase();
var isOpera=(agent.indexOf('opera')!=-1)?true:false;
var isIE=((document.all)&&(version>=4.0)&&(!isOpera))?true:false;
var isGecko=((version>=5.0)&&((agent.indexOf('netscape')>=0)||(agent.indexOf('gecko')>=0)))?true:false;
var isWin=(navigator.appVersion.indexOf("Windows") != -1) ? true : false; 
var isDOM=document.getElementById?true:false;
var isNN4=(document.layers?true:false);


// Flash-Detection

var verRequired=4;

// globals
var flash2Installed=false;
var flash3Installed=false;
var flash4Installed=false;
var flash5Installed=false;
var flash6Installed=false;
var flash7Installed=false;
var maxVersion=7;
var actualVersion=0;
var fFlash=false;
var jsVersion=1.0;


jsVersion = 1.1;

if(isIE && isWin){ 
	document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
	document.write('on error resume next \n');
	document.write('flash2Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.2"))) \n');
	document.write('flash3Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3"))) \n');
	document.write('flash4Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4"))) \n');
	document.write('flash5Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5"))) \n');
	document.write('flash6Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6"))) \n');
	document.write('flash7Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.7"))) \n');
	document.write('</SCR' + 'IPT\> \n'); 
}

function flashInstalled(){
	if (navigator.plugins){								
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]){		
			var isVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + isVersion2].description;
			var flashVersion = parseInt(flashDescription.charAt(flashDescription.indexOf(".") - 1));
			flash2Installed = flashVersion == 2;		
			flash3Installed = flashVersion == 3;
			flash4Installed = flashVersion == 4;
			flash5Installed = flashVersion == 5;
			flash6Installed = flashVersion == 6;
			flash7Installed = flashVersion == 7;
		}
	}
	
	for (var i = 2; i <= maxVersion; i++) {	
		if (eval("flash" + i + "Installed") == true) actualVersion = i;
	}
	if(navigator.userAgent.indexOf("WebTV") != -1) actualVersion = 2;	
	if (actualVersion >= verRequired) fFlash = true;
	return fFlash;
}


// Popups

function zoom(filename,text,w,h) {
	var l=10, t=10;
	if (!w) w=600;
	if (!h) h=500;
	if ((screen.width)&&(!isOpera)) {
		l=(screen.width)?(screen.width-w)/2:0;
		t=(screen.height)?(screen.height-h)/2:0;
	}
	var p=window.open("../../shared/zoom.php?filename="+escape(filename)+"&text="+escape(text), "zooma", "toolbar=no,scrollbars=auto,location=no,directories=no,status=no,menubar=no,resizable=yes,width="+w+",height="+h+",left="+l+",top="+t);
	if (p) {p.opener=self;p.focus();}
}


function zoomRefWin(filename,text,url,w,h) {
	var l=10, t=10;
	if (!w) w=600;
	if (!h) h=500;
	if ((screen.width)&&(!isOpera)) {
		l=(screen.width)?(screen.width-w)/2:0;
		t=(screen.height)?(screen.height-h)/2:0;
	}
	s=new String(filename);	
	if (s.lastIndexOf('/')<(s.length-1)) {
		var p=window.open("../shared/zoom.php?filename="+escape(filename)+"&text="+escape(text), "zoomb", "toolbar=no,scrollbars=auto,location=no,directories=no,status=no,menubar=no,resizable=yes,width="+w+",height="+h+",left="+l+",top="+t);
	} else {
		var p=window.open(filename, "zoom", "toolbar=no,scrollbars=auto,location=no,directories=no,status=no,menubar=no,resizable=yes,width="+w+",height="+h+",left="+l+",top="+t);
	}
	if (p) {p.opener=self;p.focus();}
}


function popup(filename,w,h) {
	var l=10, t=10;
	if (!w) w=600;
	if (!h) h=500;
	if ((screen.width)&&(!isOpera)) {
		l=(screen.width)?(screen.width-w)/2:0;
		t=(screen.height)?(screen.height-h)/2:0;
	}
	var p=window.open(filename, "zoomc", "toolbar=no,scrollbars=auto,location=no,directories=no,status=no,menubar=no,resizable=yes,width="+w+",height="+h+",left="+l+",top="+t);
	if (p) {p.opener=self;p.focus();}
}


var layProps = new Array();
var x=0, y=0;

function posLayer(id,x,y){
	if (isIE) p=document.all[id].style;
	else if (isDOM) p=document.getElementById(id).style;
	else if (isNN4) p=document.layers[id];
	p.left=x; p.top=y;
}

function floatLayer(i) {
	if (document.all) {
		x = document.body.scrollLeft + layProps[i].originX;
		y = document.body.scrollTop + layProps[i].originY;
	} else {
		x = window.pageXOffset + layProps[i].originX;
		y = window.pageYOffset + layProps[i].originY;
	}
	
	d1 = x - layProps[i].x;
	d2 = y - layProps[i].y;
	layProps[i].x = layProps[i].x + (x - layProps[i].x) * layProps[i].smooth;
	layProps[i].y = layProps[i].y + (y - layProps[i].y) * layProps[i].smooth;
	
	posLayer(layProps[i].oldLayer, layProps[i].x, layProps[i].y);
	setTimeout("floatLayer(" + i + ")",55);	
}

/*
	Aufrufen mit Layer-Id, Start-X/Y-Pos., Weichheitsfaktor
*/
function floatingLayer(alayer,ax,ay,delay) {
	if (isNN4) return;
	x=ax; y=ay;
	layProps[layProps.length] = new Array();
	i = layProps.length - 1;
	layProps[i].oldLayer = alayer;
	posLayer(layProps[i].oldLayer,x,y);
	layProps[i].x = x;
	layProps[i].y = y;
	layProps[i].originX = x;
	layProps[i].originY = y ;
	layProps[i].smooth = 1.0/delay;
	setTimeout("floatLayer(" + i + ")",55);
}

