// Globale Funktionen
// (c) by come medien ag 2000-2001, www.come.de
// (w) by Jürgen Richter
// Version: 2.0, 23.01.01

var glbFunctions = -1;				// gibt an, dass diese Datei schon geladen  ist

//status=sw+" "+sh;
//var s = 'navigator.appName='+navigator.appName+', navigator.appVersion='+navigator.appVersion+', navigator.platform='+navigator.platform;
//alert (s);

//Check the Environment (Browser, Platform)
function EnvironmentCheck() {
	var b = navigator.appName.toLowerCase();
	var agt=navigator.userAgent.toLowerCase();

	if (b=="netscape") { 
		this.browser = "ns";
	} else {
		if (b=="microsoft internet explorer") {
			this.browser = "ie";
		} else {
			this.browser = browser;
		}
	}
	this.versionStr = navigator.appVersion;			// 4.01 [en] (Win95; I)"
	this.versionMajor = parseInt(this.versionStr);	// 4
	this.versionMinor = parseFloat(this.versionStr);// 4.01
	
	this.ns = (this.browser=="ns");						// irgendein Netscape
	this.nsMin = (this.browser=="ns" && this.versionMajor>=4);			// NS >= 4
	this.ns4 = (this.browser=="ns" && this.versionMajor==4);
	this.ns5 = (this.browser=="ns" && this.versionMajor==5);

	this.ie = (this.browser=="ie");
	this.ieMin = (this.browser=="ie" && this.versionMajor>=4);
	this.ie4 = (this.versionStr.indexOf('MSIE 4')>0);
	this.ie5 = (this.versionStr.indexOf('MSIE 5')>0);
	
	this.min = (this.nsMin||this.ieMin);				// Mindestanforderung Vers4

	this.aol = (agt.indexOf("aol") != -1);
	this.aol4 = (this.aol && this.ie4);

	this.opera = (agt.indexOf("opera") != -1);
	this.webtv = (agt.indexOf("webtv") != -1); 

	// os detection
	this.pc=(navigator.platform.substring(0,3)=='Win');
	this.mac=(navigator.platform.substring(0,3) == 'Mac');
	this.unix=(navigator.platform.indexOf('Unix')>0 || navigator.platform.indexOf('Linux')>0);

	// resolution check
	this.sw=screen.width;
	this.sh=screen.height;

	// Anzeigenbreich  Anm.: braucht id im body-tag und kann erst nach dem </html> tag bestimmt werden
/*	if (this.ns){
		wh = window.innerHeight; // innere fensterhöhe
		ww = window.innerWidth; 
	} else {
		ww = document.all.BodyTag.offsetWidth;		// Achtung braucht id="BodyTag"
		wh = document.all.BodyTag.offsetHeight;
	}
*/

}
myEnv = new EnvironmentCheck();


function selectCSSByUserAgent(pathToCss) {
	if (myEnv.mac) {
		document.write('<link rel=stylesheet type="text/css" href="' + pathToCss + 'stylemac.css">')
	} else {
		if (myEnv.ie) {
			document.write('<link rel=stylesheet type="text/css" href="' + pathToCss + 'stylepc.css">')
		} else {
			document.write('<link rel=stylesheet type="text/css" href="' + pathToCss + 'stylepcns.css">')
		}
	}
}


function popitup(destination,win_name,width,height, withScrollbar) 
{
	if (popitup.arguments.length < 5) withScrollbar = true;			// default ist mit scrollbars

	if (width==0 ||  height == 0)
	{
		fs = window.open (destination,win_name);
	} else {
		if (withScrollbar){
			fs = window.open (destination,win_name,'width=' + width + ',height=' + height + ',resizable=no,scrollbars=YES,toolbar=no,status=no,directories=no,menuebar=no,location=tabelle');
		} else {
			fs = window.open (destination,win_name,'width=' + width + ',height=' + height + ',resizable=no,scrollbars=no,toolbar=no,status=no,directories=no,menuebar=no,location=tabelle');
		}
		fs.resizeTo(width,height);

	}
	fs.focus();
}
	

function full(fullpath, winname)  // pfad zu html Datei, name des Browsers
{
if(myEnv.sw>1024)
	{
	var myLeft = (myEnv.sw-1024)/2;
	var myTop = (myEnv.sh-768)/2-20;
	if(myEnv.ieMin&&myEnv.pc) fs=window.open(fullpath,winname,"width=1024,height=768,left="+myLeft+",top="+myTop+",directories=0,location=0,menubar=0,scrollbars=0,status=0,toolbar=0")
	else if(myEnv.ieMin&&myEnv.mac) fs=window.open(fullpath,winname,"width=1012,height=789,left="+myLeft+",top="+myTop+",directories=0,location=0,menubar=0,scrollbars=0,status=0,toolbar=0")
	else if(myEnv.nsMin&&myEnv.pc) fs=window.open(fullpath,winname,"width=1024,height=768,left="+myLeft+",top="+myTop+",directories=0,location=0,menubar=0,scrollbars=0,status=0,toolbar=0")	
	else if(myEnv.nsMin&&myEnv.mac) fs=window.open(fullpath,winname,"width=1010,height=734,left="+myLeft+",top="+myTop+",directories=0,location=0,menubar=0,scrollbars=0,status=0,toolbar=0")	
	}
else if(myEnv.sw==1024){
	if(myEnv.ieMin&&myEnv.pc) fs=window.open(fullpath,winname,"fullscreen=1,type=fullWindow,directories=0,location=0,menubar=0,scrollbars=0,status=0,toolbar=0");
	else if(myEnv.ieMin&&myEnv.mac) fs=window.open(fullpath,winname,"scrollbars=0,left=0,top=0,width="+myEnv.sw+",height="+myEnv.sh+",directories=0,location=0,menubar=0,scrollbars=0,status=0,toolbar=0");
	else if(myEnv.nsMin) fs=window.open(fullpath,winname,"screenX=0,screenY=0,outerWidth="+myEnv.sw+",outerHeight=" +myEnv.sh+",directories=0,location=0,menubar=0,scrollbars=0,status=0,toolbar=0");
	}
else{
	if(myEnv.ieMin&&myEnv.pc) fs=window.open(fullpath,winname,"fullscreen=1,type=fullWindow,directories=0,location=0,menubar=0,scrollbars=0,status=0,toolbar=0");
	else if(myEnv.ieMin&&myEnv.mac) fs=window.open(fullpath,winname,"scrollbars=0,left=0,top=0,width="+myEnv.sw+",height="+myEnv.sh+",directories=0,location=0,menubar=0,scrollbars=0,status=0,toolbar=0");
	else if(myEnv.nsMin) fs=window.open(fullpath,winname,"screenX=0,screenY=0,outerWidth="+myEnv.sw+",outerHeight="+myEnv.sh+",directories=0,location=0,menubar=0,scrollbars=0,status=0,toolbar=0");
	}

fs.focus();
}

function normalView(w,h)  // Fensterobjekt(breite,höhe)
{
	window.resizeTo(w,h);
}


function clearForm(formName){	//loescht alle Formularfelder, auch die vorausgewaehlten
//alert("function clearForm()");
	for(i=0; i<document[formName].length; i++) {
		if(document[formName].elements[i].type == "text") document[formName].elements[i].value = "";
		if(document[formName].elements[i].type == "textarea") document[formName].elements[i].value = "";
		if(document[formName].elements[i].type == "checkbox") document[formName].elements[i].checked = false;
		if(document[formName].elements[i].type == "radio") document[formName].elements[i].checked = false;
		
		if(document[formName].elements[i].type == "select-one") {
			for(n=0; n<document[formName].elements[i].length; n++) {
				if(document[formName].elements[i].options[n].value == "Please Select") document[formName].elements[i].options[n].selected= true;		
				else if(document[formName].elements[i].options[n].value == "bitte wählen Sie") document[formName].elements[i].options[n].selected= true;	
				else if(document[formName].elements[i].options[n].value == "") document[formName].elements[i].options[n].selected= true;	
				else if(document[formName].elements[i].options[n].value == "0") document[formName].elements[i].options[n].selected= true;	
			}
		}
	}
}


function MM_preloadImages() { //v3.0 
	var d=document; 
	if(d.images){ 
		if(!d.MM_p){
			d.MM_p=new Array();
		}
		var i,j=d.MM_p.length,a=MM_preloadImages.arguments; 
		for(i=0; i<a.length; i++){ 
			if (a[i].indexOf("#")!=0){
				d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];
			}
		}
	} 
} 


function change(strBildname1,strSource1){	  			
	document.images[strBildname1].src = strSource1;
}

function doubleChange(strBildname1,strSource1,strBildname2,strSource2){	  			
	document.images[strBildname1].src = strSource1;
	document.images[strBildname2].src = strSource2;
}


