// 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, toolBar) 
{
	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=' +toolBar + ',status=no,directories=no,menuebar=no,location=tabelle');
		} else {
			fs = window.open (destination,win_name,'width=' + width + ',height=' + height + ',resizable=no,scrollbars=no,toolbar=' +toolBar + ',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);
}


// Für Dokument "productSearch"

function toggleGroup(check) {
	var box = "";
	for(i=0; i<4; i++) {
		box = "segment["+i+"]";
		document.productSearch.elements[box].checked = check;
	}
}

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;	
			}
		}
	}
}

/* -----------------
	Flash Detection
   ----------------- */

function FlashInstalled()
{
	if ((top.hasFlash == "true") || (top.hasFlash == "false"))
	{
		return;  // hasFlash already set !!
	}

	var version = parseInt(navigator.appVersion.substring(0,1));
	hasFlash = "false";

	// Netscape Navigator
	if ( version >= 3)
	{
		for ( i = 0; i < navigator.plugins.length; i++)
		{
			if (navigator.plugins[ i ].name == "Shockwave Flash")
			{
				shock = navigator.plugins[ i ].description;
				if (shock.substring (16, 17) >= 6)
				{
					top.hasFlash = "true";
				}
			}
		}
	}

	// Internet Explorer Windows only -- check for ActiveX control, have to hide code in eval from Netscape (doesn't like try)
	if (document.all && (navigator.appVersion.indexOf("Mac")==-1))
	{
		eval ('try {var xObj = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");if (xObj)	top.hasFlash = "true"; xObj = null;	} catch (e)	{}');
	}
}


// flash detection flag
var hashFlash="undetected";
 // call flash detection function
FlashInstalled();

function getClientInfo(imgSrc, imgScriptSrc, imgSizeWidth, imgSizeHeight){
	
	var imgTag			= "";
	var flashExists		= '0';

	var browser			= navigator.appName;

	var screen_w		= screen.width;			//gesamte Bildschirmbreite
	var screen_h		= screen.height;		//gesamte Bildschirmhoehe

	var screenAvail_w	= screen.availWidth;	//nutzbare Bildschirmbreite (ohne vertikale Taskleiste)
	var screenAvail_h	= screen.availHeight;	//nutzbare Bildschirmhoehe (ohne horizontale Taskleiste)

	var colorDepth		= screen.colorDepth;	//Farbtiefe (Anzahl Bit)

	var browser_w		= 0;					//Fensterbreite	
	var browser_h		= 0;					//Fensterhoehe

//	FlashInstalled();
	if (top.hasFlash == "true") flashExists = '1';
//alert (flashExists);

//Achtung: Breite und Hoehe nicht pixelgenau verwendbar!
	if(browser!="Microsoft Internet Explorer"){
		browser_w = window.innerWidth;
		browser_h = window.innerHeight;
	}

	else{
		browser_w = document.body.offsetWidth;
		browser_h = document.body.offsetHeight;
	}

	imgTag = '<img border="0" width="'+imgSizeWidth+'" height="'+imgSizeHeight+'" src="'+imgScriptSrc+'?ci%5Bjavascript%5D=1&ci%5Bscreen_w%5D='+screen_w+'&ci%5Bscreen_h%5D='+screen_h+'&ci%5BscreenAvail_w%5D='+screenAvail_w+'&ci%5BscreenAvail_h%5D='+screenAvail_h+'&ci%5BcolorDepth%5D='+colorDepth+'&ci%5Bbrowser_w%5D='+browser_w+'&ci%5Bbrowser_h%5D='+browser_h+'&ci%5BflashExists%5D='+flashExists+'&img='+imgSrc+'"></img>';

//alert(imgTag);
	
	return imgTag;

}

function UnCryptMailto(s, shift) {
	var n=0;
	var r="";
	for(var i=0;i<s.length;i++) { 
		n=s.charCodeAt(i); 
		if (n>=8364) {n = 128;}
		r += String.fromCharCode(n-(shift)); 
	}
	return r;
}
function linkTo_UnCryptMailto(s, shift)	{

//alert(shift);
//Shift wird in der HTML Seite im Head definiert und im href bereits nur als Variable benutzt.

	location.href=UnCryptMailto(s, shift);
}


// Macromedia Functions

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
//MM_reloadPage(true);

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

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 MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_jumpMenuGo(selName,targ,restore){ //v3.0
  var selObj = MM_findObj(selName); if (selObj) MM_jumpMenu(targ,selObj,restore);
}
