// globale PopUp- Funktion
function openWindow(url,name,parameter) {
	name0 = window.open(url,name,parameter);
	name0.focus();
}

// Netscape Resize Problem
function resizeHandler() {
	parent.content.location.reload();
}
if (document.layers) {
	window.captureEvents(Event.RESIZE); window.onresize = resizeHandler;
}


// MINI Image Swap Functions
function swap_a(name) {
	var img = document.images[name];
	if (typeof(document.images[name].active)=='object') {
		document.images[name].src = document.images[name].active.src;
	}
	window.status='';
	return true;
}

function swap_b(name) {
	var img = document.images[name];
	if (typeof(document.images[name].down)=='object') {
		document.images[name].src = document.images[name].down.src;
	}
	window.status='';
	return true;
}


function swap_back(name) {
	if (typeof(document.images[name].inactive)=='object') {
		document.images[name].src = document.images[name].inactive.src;
	}
}

function preloadActiveImage(name,src) {
	document.images[name].inactive = new Object;
	document.images[name].inactive.src = document.images[name].src;
	document.images[name].active = new Image;
	document.images[name].active.src = src;
}

function preloadDownImage(name,src) {
	document.images[name].inactive = new Object;
	document.images[name].inactive.src = document.images[name].src;
	document.images[name].down = new Image;
	document.images[name].down.src = src;
}

// end Image Swap Functions


// show and hide Layer function
function show(name) {getElement(name).visibility = "visible";}

function hide(name) {getElement(name).visibility = "hidden";}

// additional functions used in main navigation
function killAll() {
	for (i=0; i<5; i++) {
 	 hide('menu' + i);
	}
}

var timedelay = 1000;
var openflag = "";

function hideWann(which) {
	openflag = 'menu' + which;
	timedelay = setTimeout('hide(openflag)',1000);
}

function dontHide() {
 clearTimeout(timedelay);
}


// Write LayerContent
function writeLayer(parentLayerName,layerName,layerContent) {
	if (document.layers) {
	  // Function also works with one Layer
   	if (parentLayerName == "") {
   			document.layers[layerName].document.open(); document.layers[layerName].document.write(layerContent); document.layers[layerName].document.close();
   	 } else {
   	 		document.layers[parentLayerName].document.layers[layerName].document.open(); document.layers[parentLayerName].document.layers[layerName].document.write(layerContent); document.layers[parentLayerName].document.layers[layerName].document.close();
   	 }
	}
	else if (document.all) {document.all[layerName].innerHTML = layerContent;}
	else if (!document.all && document.getElementById) {document.getElementById(layerName).innerHTML = layerContent;}
}


/*  Set the Postition of a Layer
 *  
 *  This Function is doubled in the "BMW Scriptlib" below.
 *  
 *  function setLayerPosition(thisLayer,positionLeft,positionTop) {
 *    thisLayer = getElement(thisLayer);
 *    thisLayer.left = positionLeft;
 *    thisLayer.top  = positionTop;
 *  }
 */

// Get the Postition of a Layer
function getLayerPosition(thisLayer) {
  thisLayerPosition = new Array();
  thisLayer = getElement(thisLayer);
  thisLayerPosition["height"] = document.all ? thisLayer.offsetHeight : thisLayer.document.height;
  thisLayerPosition["width"] = document.all ?  thisLayer.offsetWidth : thisLayer.document.width;
  thisLayer = document.layers ? thisLayer : thisLayer.style;
  thisLayerPosition["top"]    = document.all ? thisLayer.pixelTop     : thisLayer.top;
  thisLayerPosition["left"]   = document.all ? thisLayer.pixelLeft    : thisLayer.left;
  thisLayerPosition["right"]   = thisLayerPosition["left"] + thisLayerPosition["width"];
  thisLayerPosition["bottom"]  = thisLayerPosition["top"] +  thisLayerPosition["height"];
  return(thisLayerPosition);
}


function setClip(thisLayer,clipTop,clipRight,clipBottom,clipLeft) {
  oj = getElement(thisLayer);
  if(document.layers) {
    with(oj.clip) {top=clipTop;right=clipRight;bottom=clipBottom;left=clipLeft;}
  } else {
   oj.clip= 'rect('+clipTop+','+clipRight+','+clipBottom+','+clipLeft+')'
  }
}

function selfReload() {
 document.location.href = document.location.href;
}



// function to clear frames and open an external URL

var url = '';
function threedUrl(url) {
top.location.href = url;
}







/* ===================
 *  The BMW Scriptlib
 * ===================
 */

//Version 3.1, 02.07.2002
//Copyright 2002 BBDO InterOne Hamburg





var nn4                  = document.layers;
var nn6                  = document.documentElement;if(document.all) {nn6 = false;}
var ie4                  = (document.all && !document.getElementById);
var ie5                  = (document.all && document.getElementById);
var mac                  = false; if(navigator.platform.indexOf("Mac") >= 0){mac = true;}

var lyr                  = new Array();
var pictures             = new Array();
var userAgent            = window.navigator.userAgent;
var preLoadIsComplete    = false;
var ToggleStatus		     = new Array ();
var oldImg               = "";
var oldCnt;

var loopCounter          = 0;
var CheckAnimationStatus = 0;
var loadImgList;
var loadImgCount;
var LoopAnimation;

var layerLoadingStatus   = new Array();
var query				         = new Object();
var parameterArray       = new Array();


function findElement(n,ly) {
	var curDoc = ly ? ly.document : document;
	var elem = curDoc[n];
	if (!elem) {
		for (var i=0;i<curDoc.layers.length;i++) {
			elem = findElement(n,curDoc.layers[i]);
			if (elem) {
				return elem;
			}
		}
	}
	return elem;
}


function NSStyle(s) {
	return findElement(s,0);
}


function IEStyle(s) {
	return document.all.tags("div")[s].style;
}


function activeImageConstructor(aName,aLowlightSrc,aHighlightSrc) {
	this.name          = aName;
	this.lowLight      = new Image();
	this.lowLight.src  = aLowlightSrc;
	this.highLight     = new Image();
	this.highLight.src = aHighlightSrc;
	this.storeLight     = new Image();
	this.storeLight.src = aLowlightSrc;
}

function addJpgToPictureList(imageName, imageUrl, activeImageUrl){
  activeImageObj     = new activeImageConstructor(imageName, imageUrl, activeImageUrl);
  activeImageData    = new Array(activeImageObj);
  pictures           = pictures.concat(activeImageData);
}

function preLoad() {
	var preLoadedImgs = "";
	if (document.all) {
		for (i=0; i < document.all.tags("img")[i].length; i++) {
			if (document.all.tags("img")[i].name) {
				if (preLoadedImgs.indexOf(document.all.tags("img")[i].name) < 0) {
					var imgSrc = document.all.tags("img")[i].src;
					var tmpPrefix = imgSrc.substr(0,imgSrc.length-4);
					var tmpSuffix = imgSrc.substr(imgSrc.length-4,imgSrc.length-1);
					if (tmpSuffix == ".gif") {
						var tmpActiveSrc = tmpPrefix + "-a" + tmpSuffix;
						var IEFix = new activeImageConstructor(document.all.tags("img")[i].name,document.all.tags("img")[i].src,tmpActiveSrc);
						var tmpData = new Array(IEFix);
						pictures = pictures.concat(tmpData);
						preLoadedImgs = preLoadedImgs.concat(document.all.tags("img")[i].name);
					}
				}
			}
		}
	} else if (document.getElementsByTagName) {
		for (i=0; i<document.getElementsByTagName("img")[i].length; i++) {
			if (document.getElementsByTagName("img")[i].name) {
				if (preLoadedImgs.indexOf(document.getElementsByTagName("img")[i].name) < 0) {
					var imgSrc = document.getElementsByTagName("img")[i].src;
					var tmpPrefix = imgSrc.substr(0,imgSrc.length-4);
					var tmpSuffix = imgSrc.substr(imgSrc.length-4,imgSrc.length-1);
					if (tmpSuffix == ".gif") {
						var tmpActiveSrc = tmpPrefix + "-a" + tmpSuffix;
						var IEFix = new activeImageConstructor(document.getElementsByTagName("img")[i].name,document.getElementsByTagName("img")[i].src,tmpActiveSrc);
						var tmpData = new Array(IEFix);
						pictures = pictures.concat(tmpData);
						preLoadedImgs = preLoadedImgs.concat(document.getElementsByTagName("img")[i].name);
					}
				}
			}
		}
	} else if (document.layers) {
		for (i=0; i<document.layers.length; i++) {
			for (j=0; j<document.layers[i].document.images.length; j++)	{
				if (document.layers[i].document.images[j].name) {
					if (preLoadedImgs.indexOf(document.layers[i].document.images[j].name) < 0) {
						var imgSrc = document.layers[i].document.images[j].src;
						var tmpPrefix = imgSrc.substr(0,imgSrc.length-4);
						var tmpSuffix = imgSrc.substr(imgSrc.length-4,imgSrc.length-1);
						if (tmpSuffix == ".gif") {
							var tmpActiveSrc = tmpPrefix + "-a" + tmpSuffix;
							var IEFix = new activeImageConstructor(document.layers[i].document.images[j].name,document.layers[i].document.images[j].src,tmpActiveSrc);
							var tmpData = new Array(IEFix);
							pictures = pictures.concat(tmpData);
							preLoadedImgs = preLoadedImgs.concat(document.layers[i].document.images[j].name);
						}
					}
				}
			}
		}
	}
	for (i=0; i<document.images.length; i++) {
		if (document.images[i].name) {
			if ( preLoadedImgs.indexOf(document.images[i].name) < 0) {
				var imgSrc = document.images[i].src;
				var tmpPrefix = imgSrc.substr(0,imgSrc.length-4);
				var tmpSuffix = imgSrc.substr(imgSrc.length-4,imgSrc.length-1);
				if (tmpSuffix == ".gif") {
					var tmpActiveSrc = tmpPrefix + "-a" + tmpSuffix;
					var IEFix = new activeImageConstructor(document.images[i].name,document.images[i].src,tmpActiveSrc);
					var tmpData = new Array(IEFix);
					pictures = pictures.concat(tmpData);
					preLoadedImgs = preLoadedImgs.concat(document.images[i].name);
				}
			}
		}
	}
	preLoadIsComplete = true;
}


function chgclass(tagname,css) {
  if (!document.layers) {
		if (ie4){eval("document.all."+tagname+".className='"+css+"'");}
		else    {eval("document.getElementById('"+tagname+"')"+".className='"+css+"'");}
  }
}


function mouseOver(aPic,aLayer) {
	if (preLoadIsComplete) {
		for (i=0; i<pictures.length; i++) {
			if (pictures[i].name == aPic) {
				if(document.layers && aLayer) {
					NSStyle(aLayer).document.images[aPic].src = pictures[i].highLight.src;
				}
				else {
					document.images[aPic].src = pictures[i].highLight.src;
				}
			}
		}
	}
	else {
		preLoad();
	}
}


function mouseOut(aPic,aLayer) {
	oldImg = "";
	if (preLoadIsComplete) {
		for (i=0; i<pictures.length; i++) {
			if (pictures[i].name == aPic) {
				if(document.layers && aLayer) {
					NSStyle(aLayer).document.images[aPic].src = pictures[i].lowLight.src;
				} 
				else {
					document.images[aPic].src = pictures[i].lowLight.src;
				}
			}
		}
	}
	else {
		preLoad();
	}
}


function setPermanentHigh(picName,layerName) {
	if (preLoadIsComplete) {
		for (i=0; i<pictures.length; i++) {
			if (pictures[i].name == picName) {
				pictures[i].lowLight.src = pictures[i].highLight.src;
				if(document.layers && layerName) {
					NSStyle(layerName).document.images[picName].src = pictures[i].highLight.src;
				}
				else {
					document.images[picName].src = pictures[i].highLight.src;
				}
			}
		}
	}
	else {
		preLoad();
	}
}


function dropPermanentHigh(picName,layerName) {
	if (preLoadIsComplete) {
		for (i=0; i<pictures.length; i++) {
			if (pictures[i].name == picName) {
				pictures[i].lowLight.src = pictures[i].storeLight.src;
				if(document.layers && layerName) {
					NSStyle(layerName).document.images[picName].src = pictures[i].lowLight.src;
				}
				else {
					document.images[picName].src = pictures[i].lowLight.src;
				}
			}
		}
	}
	else {
		preLoad();
	}
}


function vSwitch(aLayer,aBool) {
	if (preLoadIsComplete) {
		if (document.all) {
			IEStyle(aLayer).visibility = (aBool == 0) ? "hidden" : "visible";
		}
		else {
			if (document.layers) {
				NSStyle(aLayer).visibility = (aBool == 0) ? 'hide' : 'show';
			}
			else if (nn6) {
				document.getElementById(aLayer).style.visibility= (aBool == 0) ? "hidden" : "visible";
			}
		}
	}
	else {
		preLoad();
	}
}


function toggleLayer(Layer) {
	if (ToggleStatus[Layer]) {
		vSwitch(Layer,0);
		ToggleStatus[Layer] = 0;
	}
	else {
		vSwitch(Layer,1);
		ToggleStatus[Layer] = 1;
	}
}


function centerPopup(popup_name,popup_url,popup_width,popup_height,myWidth,myHeight,myScrollbar) {
	if(!myWidth) {myWidth = 10;}
	if(!myHeight){myHeight = 50;}
	if(!myScrollbar){myScrollbar = 0;}
	var popup_left = (window.screen.width/2)  - (popup_width/2 + myWidth);
	var popup_top  = (window.screen.height/2) - (popup_height/2 + myHeight);
	thisCenterPopup = window.open(popup_url ,popup_name,"toolbar=no,location=no,status=no,menubar=no,scrollbars=" + myScrollbar + ",resizable=no,width=" + popup_width + ",height=" + popup_height + ",left=" + popup_left + ",top=" + popup_top + ",screenX=" + popup_left + ",screenY=" + popup_top);
	thisCenterPopup.focus();
}

function justifyPopup(popup_name,popup_url,popup_width,popup_height,myScrollbar,myLeft,myTop) {
  if(!myScrollbar) {myScrollbar = 0;}
  if(!myLeft)      {myLeft      = 0;}
  if(!myTop)       {myTop       = 0;}

  if (document.all) {
    var popup_left = window.screenLeft + myLeft;
    var popup_top  = window.screenTop  + myTop;
  }
  else {
    var popup_left = window.screenX;
    var popup_top  = window.screenY;
  }

	thisJustifyPopup = window.open(popup_url ,popup_name,"toolbar=no,location=no,status=no,menubar=no,scrollbars=" + myScrollbar + ",resizable=no,width=" + popup_width + ",height=" + popup_height + ",left=" + popup_left + ",top=" + popup_top + ",screenX=" + popup_left + ",screenY=" + popup_top);
	thisJustifyPopup.focus();
}

function loadPage(layerName,sourcePath,layerWidth) {
	if(!layerWidth) {layerWidth = 0;}
	iFrameName = layerName + "I";
	if (document.layers) {
		NSStyle(layerName).load(sourcePath,layerWidth);
	}
	else if (ie4) {
		parent[iFrameName].location = sourcePath;
	}
	else {
		document.getElementById(iFrameName).src = sourcePath;
	}
}


function loadAllLayers(layerName,layerURL,thisLayerNumber) {
	loadPage(layerName,layerURL);
	thisLayerNumber++;
	checkLoading(layerName,thisLayerNumber);
}


function checkLoading(layerName,thisLayerNumber) {
	if(layerLoadingStatus[thisLayerNumber]) {
		initLayerLoad(thisLayerNumber);
	}
	else {
		setTimeout("checkLoading('"+layerName+"',"+thisLayerNumber+")",10);
	}
}


function initLayerLoad(thisLayerNumber) {
	numberOfLayers = layerNames.length;
	if(thisLayerNumber <= (numberOfLayers-1)) {
		loadAllLayers(layerNames[thisLayerNumber],layerURLs[thisLayerNumber],thisLayerNumber);
	}
}


function setLayerPosition(thisLayer,positionLeft,positionTop) {
	var unit = "";
	thisLayer = document.all ? document.all[thisLayer] : document.getElementById ? document.getElementById(thisLayer) : NSStyle(thisLayer);
	thisLayer = document.layers ? thisLayer : thisLayer.style;
	if(document.getElementById) {unit = "px";}
	thisLayer.left = positionLeft + unit;
	thisLayer.top  = positionTop + unit;
	return;
}


function getLayerInformation(thisLayer) {
	thisLayerPosition = new Array();
	thisLayer = document.all ? document.all[thisLayer] : document.getElementById ? document.getElementById(thisLayer) : NSStyle(thisLayer);
	thisLayerPosition[0] = document.layers ? thisLayer.top : thisLayer.offsetTop;
	thisLayerPosition[1] = document.layers ? thisLayer.left : thisLayer.offsetLeft;
	thisLayerPosition[2] = document.layers ? thisLayer.document.width : thisLayer.offsetWidth;
	thisLayerPosition[3] = document.layers ? thisLayer.document.height : thisLayer.offsetHeight;
	return(thisLayerPosition);
}


function getScreenInformation() {
	thisScreenInformation = new Array();
	thisScreenInformation[0] = screen.width;
	thisScreenInformation[1] = screen.height;
	thisScreenInformation[2] = screen.colorDepth;
	thisScreenInformation[3] = document.all ? document.body.offsetWidth  : window.innerWidth; //Innerer Anzeigebereich
	thisScreenInformation[4] = document.all ? document.body.offsetHeight : window.innerHeight; //Innerer Anzeigebereich
	return(thisScreenInformation);
}


function getMouseInformation(myEvent) {
	thisMousePosition = new Array();
	if(document.layers || nn6) {
		thisMousePosition[0] = myEvent.pageX;
		thisMousePosition[1] = myEvent.pageY;
	}
	else {
		thisMousePosition[0] = window.event.clientX;
		thisMousePosition[1] = window.event.clientY;
	}
	return(thisMousePosition);
}

function disableEventHandlers() {
	document.releaseEvents(Event.MOUSEMOVE);
}

function enableEventHandlers() {
	document.captureEvents(Event.MOUSEMOVE);
	document.onmousemove = getMouseInformation;
}


function loadStart(srcList) {
	loadImgCount = 0;
	loadImgList = new Array();
	for (i = 0; i < srcList.length; i++) {
		loadImgList[i]					= new Image();
		loadImgList[i].onabort	= loadUpdate;
		loadImgList[i].onerror	= loadUpdate;
		loadImgList[i].onload 	= loadUpdate;
		loadImgList[i].src			= ImagePath + srcList[i];
	}
}

function loadUpdate() {
  loadImgCount++;
  if (loadImgCount == loadImgList.length) {
		loadImgCount = 0;
		startAnimation();
	}
}

function startAnimation() {
	ImageAmount = animationImages.length;
	if (animationImages[loopCounter] == "") {loopCounter++;}
	if (loopCounter >= ImageAmount) {loopCounter = 0;}
 	if(aniLayerName && document.layers) {
 		NSStyle(aniLayerName).document.images[imageName].src = loadImgList[loopCounter].src;
 	}
 	else {
		document.images[imageName].src = loadImgList[loopCounter].src;
	}
	loopCounter++;
	LoopAnimation = setTimeout("startAnimation()",loopTime[loopCounter-1]);
}

function ToggleAnimation () {
	if (CheckAnimationStatus == 0) {
		clearTimeout(LoopAnimation);
		CheckAnimationStatus = 1;
	}
	else {
		startAnimation();
		CheckAnimationStatus = 0;
	}
}


function setZIndex(thisLayer,thisIndex) {
	if(document.layers) {
			NSStyle(thisLayer).zIndex=thisIndex;
	}
	else if (ie4) {
		document.all[thisLayer].style.zIndex=thisIndex;
	}
	else {
		document.getElementById(thisLayer).style.zIndex=thisIndex;
	}
	return;
}


function writeIntoLayer(thisLayer,layerContent) {
	if(ie4) {
		document.all.tags("div")[thisLayer].innerHTML = layerContent;	
	}
	else if(document.layers) {
		NSStyle(thisLayer).document.open("text/html");
		NSStyle(thisLayer).document.write(layerContent);
		NSStyle(thisLayer).document.close();
	}
	else {
		document.getElementById(thisLayer).innerHTML = layerContent;
	}
}

var isScrolling;
var baseScrollSpeed = 1;

if(!nn6) {
  var baseScrollStep = 1;
 }
else {
  var baseScrollStep = 3;
 }

function initScroller() {
 for (var i=0; i<initScroller.arguments.length; ++i) {
	parentLayerName = initScroller.arguments[i] + "ScrollParent";
	parentLayerData = new Array();
	parentLayerData = getLayerInformation(parentLayerName);
	childLayerName  = initScroller.arguments[i] + "ScrollChild";
	childLayerData  = new Array();
	childLayerData  = getLayerInformation(childLayerName);
	if(document.layers) {
     clipHeight = document.layers[parentLayerName].clip.height;
	 }
	else {
     clipHeight = parentLayerData[3];
    }
	if(childLayerData[3] > clipHeight) {
	  vSwitch(initScroller.arguments[i]+"ScrollControl",1);
	 }
  }
}

function stopScroll() {
 isScrolling = false;
}

function startScroll(scrollStep, layerName) {
 this.scrollStep = scrollStep;
 this.layerName  = layerName;
 isScrolling     = true;
 parentLayerName = layerName + "ScrollParent";
 childLayerName  = layerName + "ScrollChild";
 doScroll(scrollStep);
}

function doScroll(scrollStep) {
 this.scrollStep = scrollStep;
 
 parentLayerData = new Array();
 parentLayerData = getLayerInformation(parentLayerName);

 childLayerData  = new Array();
 childLayerData  = getLayerInformation(childLayerName);

 if(scrollStep>0) {
   if(document.layers) {
     clipHeight = document.layers[parentLayerName].clip.height;
    }
   else {
     clipHeight = parentLayerData[3];
    }
  
   if(childLayerData[0] > -(childLayerData[3] - clipHeight)) {
     setLayerPosition(childLayerName,0,(childLayerData[0]-scrollStep));
    }
  }
 else {
   if(childLayerData[0] < 0) {
     setLayerPosition(childLayerName,0,(childLayerData[0]-scrollStep));
    }
  }
 if(isScrolling) {
 	setTimeout("doScroll(scrollStep)",baseScrollSpeed);
  }
}

function splitSearchstring() {
	parameterArray = unescape(self.location.search).substring(1).split("&");
	if (self.location.search.indexOf("=") == -1) {return;}
	for (var i=0;i<parameterArray.length;i++) {
		parameterArray[i] = parameterArray[i].split("=");
		eval("query." + parameterArray[i][0] + " = \"" + parameterArray[i][1] + "\"");
	}
}

function emailCheck(emailStr) {
	var emailPat=/^(.+)@(.+)$/;
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]";
	var validChars="\[^\\s" + specialChars + "\]";
	var quotedUser="(\"[^\"]*\")";
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
	var atom=validChars + '+';
	var word="(" + atom + "|" + quotedUser + ")";
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
	var matchArray=emailStr.match(emailPat)
	if (matchArray==null) {
		return false;
	}
	var user=matchArray[1]
	var domain=matchArray[2]
	if (user.match(userPat)==null) {
		return false;
	}
	var IPArray=domain.match(ipDomainPat);
	if (IPArray!=null) {
		for (var i=1;i<=4;i++) {
			if (IPArray[i]>255) {
				return false;
			}
		}
		return true;
	}
	var domainArray=domain.match(domainPat);
	if (domainArray==null) {
		return false;
	}
	var atomPat=new RegExp(atom,"g");
	var domArr=domain.match(atomPat);
	var len=domArr.length;
	if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>3) {
		return false;
	}
	if (len<2) {
		return false;
	}
	return true;
}
