

//	This script handles all image highlighting and layer switching events.
//
//	---------------------------------
//	Basic image highlighting (non-layer images):
//	Images to be highlighted must have a [name="<image_name>"] tag in the HTML image definition;
//	the highlighted version of each image must be in the same folder as the basic image, it must be named like this:
//	basic image (Lowlight): e.g. "image_name.gif"  -> highlighted image = "image_name-a.gif" 
//	Both image types 'gif' and 'jpg' are supported.
//	The following line must be added to the images' <a href=....> tag:
//	onMouseOver="mouseOver('<image_name>'); self.status='<your browser-statusline text>'; return true;" onMouseOut="mouseOut('<image_name>'); self.status=' '; return true;"
//	A sample link here will look like this:
//	<a href="sitemap/sitemap.html" 
//	target="content" 
//	onMouseOver="mouseOver('bottom_sitemap'); self.status='Site Map'; return true;" 
//	onMouseOut="mouseOut('bottom_sitemap'); self.status=' '; return true;">
//	<img src="images/bottom_sitemap.gif" alt="" width="45" height="16" border="0" NAME="bottom_sitemap">
//	< /a>
//
//	---------------------------------
//	Image highlighting in layers:
//	Images to be highlighted must have a [name="<image_name>"] tag in the layers' HTML image definition;
//	the highlighted version of each image must be in the same folder as the basic image, it must be named like this:
//	basic image (Lowlight): e.g. "image_name.gif"  -> highlighted image = "image_name-a.gif" 
//	Both image types 'gif' and 'jpg' are supported.
//	The following line must be added to the images' <a href=....> tag:
//	onMouseOver="layerMouseOver('<image_name>','<layer_name>'); self.status='<your browser-statusline text>'; return true;" onMouseOut="layerMouseOut('<image_name>','<layer_name>'); self.status=' '; return true;"
//	A sample link here will look like this:
//	<a href="sitemap/sitemap.html" 
//	target="content" 
//	onMouseOver="layerMouseOver('top_overview','firstlayer'); self.status='Overview'; return true;" 
//	onMouseOut="layerMouseOut('top_overview','firstlayer'); self.status=' '; return true;">
//	<img src="images/top_overview.gif" alt="" width="45" height="16" border="0" NAME="top_overview">
//	< /a>
//
//	NOTE: the ticks around <image_name> on the MouseOver- and MouseOut-events.
//	NOTE: image names must be unique through the whole HTML document, including layers.
//
//	---------------------------------
//	Showing and hining layers:
//	use the following syntax:
//	vSwitch('<a_layername>',1): shows layer <a_layername>
//	vSwitch('<a_layername>',0): hides layer <a_layername>
//	as onClick-events in your <a href="..."> tag.
//	a sample link herefor will look like this:
//	<a href="#" onClick="vSwitch('layer1',0)"> to hide layer "layer1"
//	<a href="#" onClick="vSwitch('layer1',1)"> to show layer "layer1"
//
//	NOTE: the ticks around <a_layername> in the vSwitch function call.

//--BEGIN global variables, do not edit   --//
var counter=50001;
var counter1=1000;
var counter2=1;
var counter3=1;
var pictures = new Array();
var userAgent = window.navigator.userAgent;
var bVers = parseInt(userAgent.charAt(userAgent.indexOf("/")+1),10);
var preLoadIsComplete = false;
var teaserNo = 0;
var div = 0;

//--END global variables, do not edit   --//

//--BEGIN Delete temporary Preload-Arrays--//
// checked 06/02/00 by sweih
// im body-Tag ff einfuegen:
// --copy--
// onUnload="destroy();"
// --end copy--

function destroy() {
	destroyPreloads();
}

function destroyPreloads() {
	window.status="CLEARING CACHE...";
	if(document.layers){
		if(pictures) {
			delete pictures;
		}
		if(pic) {
			delete pic;	
		}	
	}
} 
//--end cleaning memory map for Netscape--//


//--BEGIN Netscape layer functionality  --//
function findElement(n,ly)
	{
	var curDoc = ly ? ly.document : document;
	var elem = curDoc[n];
	if (bVers < 4)
		return document[n];
	if (!elem)
		{
		for (var i=0;i<curDoc.layers.length;i++)
			{
			elem = findElement(n,curDoc.layers[i]);
			if (elem)
				return elem;
			}
		}
	return elem;
	}
//--END Netscape layer functionality  --//

//--BEGIN Netscape layer access  --//
function NSStyle(s)
	{
	return findElement(s,0);
	}
//--END Netscape layer access  --//

//--BEGIN Constructor for interactive image obbjects  --//
function activeImageConstructor(aName,aLowlightSrc,aHighlightSrc,layerName)
	{
	this.name  = aName;
	this.lowLight  = new Image();
	this.lowLight.src  = aLowlightSrc;
	this.highLight  = new Image();
	this.highLight.src  = aHighlightSrc;
	this.layerid = layerName;
	}
//--END Constructor for interactive image obbjects  --//

//--BEGIN preLoad function  --//

	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;
	*/
}

//--END preLoad fundtion  --//

//--BEGIN mouseOver function for body document --//
function mouseOver(aPic)
	{
	if (preLoadIsComplete)
		{
		for (i=0; i<pictures.length; i++)
			{
			if (pictures[i].name == aPic)
				{
				eval("document.images." + aPic + ".src = pictures[" + i + "].highLight.src");
				}
			}
		}
	else
		preLoad();
	}
//--END mouseOver function for body document --//

//--BEGIN mouseOut function for body document --//
function mouseOut(aPic)
	{
	if (preLoadIsComplete)
		{
		for (i=0; i<pictures.length; i++)
			{
			if (pictures[i].name == aPic)
				eval("document.images." + aPic + ".src = pictures[" + i + "].lowLight.src");
			}
		}
	else
		preLoad();
	}
//--END mouseOut function for body document --//

//--BEGIN mouseOver function in layers --//
function layerMouseOver(aPic,aLayer)
	{
	if (preLoadIsComplete)
		{
		for (i=0; i<pictures.length; i++)
			{
			if (pictures[i].name == aPic)
				if (document.layers)
					eval("NSStyle('"+aLayer+"').document.images['"+aPic+"'].src = pictures["+i+"].highLight.src");
				else
					eval("document.all.tags('div')."+aLayer+".document.images['"+aPic+"'].src = pictures["+i+"].highLight.src");
			}
		}
	else
		preLoad();
	}
//--END mouseOver function in layers --//

//--BEGIN mouseOut function in layers --//
function layerMouseOut(aPic,aLayer)
	{
	if (preLoadIsComplete)
		{
		for (i=0; i<pictures.length; i++)
			{
			if (pictures[i].name == aPic)
				if (document.layers)
					eval("NSStyle('"+aLayer+"').document.images['"+aPic+"'].src = pictures["+i+"].lowLight.src");
				else
					eval("document.all.tags('div')."+aLayer+".document.images['"+aPic+"'].src = pictures["+i+"].lowLight.src");
			}
		}
	else
		preLoad();
	}
//--BEGIN mouseOut function in layers --//

//--BEGIN Internet Explorer layer access  --//
function IEStyle(s)
	{
	return document.all.tags("div")[s].style;
	}
//--END Internet Explorer layer access  --//

//--BEGIN visibility switch for layers  --//
function vSwitch(aLayer,aBool)
	{
    
	if (preLoadIsComplete)
		{
		if (document.all)
        {
       
			IEStyle(aLayer).visibility = (aBool == 0) ? "hidden" : "visible";
        }
		else
			{
				
				NSStyle(aLayer).visibility = (aBool == 0) ? 'hide' : 'show';
			}
		}
	else
		preLoad();
	}
//--END visibility switch for layers  --//


//--BEGIN Image rotate function --//
var rotateArray = new Array();
var imgCounter = new Array();

function rotateImg (aPic, num, thisBild) { //-- 'name' of image, 'number' of images to rotate, the number for the bild rotation on the specific page i.e. 0 if only one bild rotation on page   1 if 2 bild rotations on page  etc. --//
	rotateArray[thisBild] = new Array();
	var imgSrc = eval("document.images['" + aPic + "'].src");
	var tmpImgSrc = imgSrc.substring(0,imgSrc.length-5);
	var tmpImgEnd = imgSrc.substring(imgSrc.length-4,imgSrc.length)
	for (p=0;p<num;p++){
		rotateArray[thisBild][p] = new Image();
		rotateArray[thisBild][p].src = tmpImgSrc + p + tmpImgEnd;
	}
	imgCounter[thisBild] = 0;
	rotateGo(aPic, num, thisBild);
}


function rotateGo(aPic, num, thisBild) {
	if (imgCounter[thisBild] == num){imgCounter[thisBild] = 0;}
	eval("document.images['"+aPic+"'].src = rotateArray["+thisBild+"]["+imgCounter[thisBild]+"].src");
	imgCounter[thisBild]++;
	setTimeout('rotateGo(\''+aPic+'\','+num+','+thisBild+')', 2000);
}
//--END Image rotate function --//




//--BEGIN Navigation Highlighting function --//


var rollName;
var rollName2;
var navbutt = "document.images";
var imgSource;
var imgSource2;

/********* highlights the given image - must be used with stopMenueOut() ***********/

function setNavHi(name,name2)
{
    
      //Initialisiert das Navigationsobjekt im Topframe
	  if(parent.frames['top_navigation'] && parent.frames['top_navigation'].init)
	  {
	      if(parent.frames['top_navigation'].isNavigationLoaded==1)
	         parent.frames['top_navigation'].init();
	  }
	  
	  
	  //Initialisiert das Navigationsobjekt fuer den Content
	  if(nav_pos.indexOf("_")==-1){
	        if((location.href.indexOf("/finanzberichte/geschaeftsberichte/")!=-1 || location.href.indexOf("/sustainable_value_report_")!=-1) && location.href.indexOf(".shtml")!=-1) {
			  if(parent.frames['content'].initContentNavi)initContentNavi(); // alte stat. Seiten z.B. GB oder sustainable value report -> (verwendet alte navi.class, navi_content und navi_conf)
			} else {
			  if(parent.frames['content'].init_contentFrame)init_contentFrame(); // aktuelle template-bas. Seiten + stat. Seiten mit layer.shtml Include 
			}
	  } 
		//  init_contentNavigation();
        //  resetBlindLayerTop(); 
				
	 
				 
}
function initSitemap()
{
    //Initialisiert das Navigationsobjekt im Topframe
    if(parent.frames['top_navigation'] && parent.frames['top_navigation'].init)
    {
        if(parent.frames['top_navigation'].isNavigationLoaded==1)
            parent.frames['top_navigation'].init();
    }		 
}
function setImgNavHi(name,name2){// wichtig für alte ContentSeiten mit ImageNavi 
    
		    rollName = name;
			rollName2 = name2;	
			for (p=0;p<pictures.length;p++){
				if (pictures[p].name == name){
					if (pictures[p].layerid){
						navbutt = "document.layers['" + pictures[p].layerid + "'].document.images";
					}
					imgSource = eval(navbutt + "['" + name + "']");
				}
				if (imgSource != null){
					if (imgSource.src == pictures[p].lowLight.src){
						imgSource.src = pictures[p].highLight.src;
					}
				}
				if (pictures[p].name == name2){
					imgSource2 = eval(navbutt + "['" + name2 + "']");
				}
				if (imgSource2 != null){
					if (imgSource2.src == pictures[p].lowLight.src){
						imgSource2.src = pictures[p].highLight.src;
					}
				}
			 }

}

/**** stops the "onMouseOut" event for the navigation button of the question which is currently visible                ****/
/**** "stopRollOut('img name')" must replace the mouseOut('img name');" function in the "onMouseOut" event. ****/
/**** The "which" argument is the number of the layer to be visible.                                                   ****/
/**** "stopLayerRollOut('img name','layer name');" must replace the layerMouseOut('img name');" function.                ****/	



function stopRollOut(name){
	if ((name != rollName) && (name != rollName2)){
		mouseOut(name);
	}
}

function stopLayerRollOut(name,layer){
	if ((name != rollName) && (name != rollName2)){
		layerMouseOut(name,layer);
	}
}


//-- END Navigation Highlighting function --//


//-- General open Window function --//

function openWindow(url,width,height,name,resize){
    // ibs maintenance popup		
    /*if(url.indexOf("recruiting.bmwgroup.de/ibs/")!= -1){
		  if(url.indexOf("sprache=en")!= -1){
		    url="http://www.bmwgroup.com/e/0_0_www_bmwgroup_com/karriere/popup.shtml";
		  } else {
		    url="http://www.bmwgroup.com/d/0_0_www_bmwgroup_com/karriere/popup.shtml";
		  }	
	}*/
	if (resize){resizable = 'yes';}
	else {resizable = 'no';}
	eigenschaften = "width="+width+",height="+height+",resizable="+resizable+",scrollbars=yes";
	popup = window.open(url,name,eigenschaften);
	popup.focus();
}

function centerPopup(popup_name,popup_url,popup_with,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_with/2 + myWidth);
	var popup_top  = (window.screen.height/2) - (popup_height/2 + myHeight);
	var fenster = window.open(popup_url ,popup_name,"toolbar=no,location=no,status=no,menubar=no,scrollbars=" + myScrollbar + ",resizable=no,width=" + popup_with + ",height=" + popup_height + ",left=" + popup_left + ",top=" + popup_top + ",screenX=" + popup_left + ",screenY=" + popup_top);
	fenster.focus();
}
function CenterPopup(Link,hoehe,breite){
        var iMyWidth = (window.screen.width/2) - (breite/2 + 10);
        var iMyHeight = (window.screen.height/2) - (hoehe/2 + 50);
       var win2 = window.open(Link ,"popup","toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=" + breite + ",height=" + hoehe + ",left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight);
        win2.focus();
}
function CenterPopup1(Link,hoehe,breite){
        // ibs maintenance popup		
	    /*if(Link.indexOf("recruiting.bmwgroup.de/ibs/")!= -1){
			  if(Link.indexOf("sprache=en")!= -1){
			    Link="http://www.bmwgroup.com/e/0_0_www_bmwgroup_com/karriere/popup.shtml";
			  } else {
			    Link="http://www.bmwgroup.com/d/0_0_www_bmwgroup_com/karriere/popup.shtml";
			  }	
		}*/
        var iMyWidth = (window.screen.width/2) - (breite/2 + 10);
        var iMyHeight = (window.screen.height/2) - (hoehe/2 + 50);
       var win2 = window.open(Link ,"popup","toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=" + breite + ",height=" + hoehe + ",left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight);
        win2.focus();
}
function CenterPopup2(Link,breite,hoehe){
        // ibs maintenance popup		
	    /*if(Link.indexOf("recruiting.bmwgroup.de/ibs/")!= -1){
			  if(Link.indexOf("sprache=en")!= -1){
			    Link="http://www.bmwgroup.com/e/0_0_www_bmwgroup_com/karriere/popup.shtml";
			  } else {
			    Link="http://www.bmwgroup.com/d/0_0_www_bmwgroup_com/karriere/popup.shtml";
			  }	
		}*/
        var iMyWidth = (window.screen.width/2) - (breite/2 + 10);
        var iMyHeight = (window.screen.height/2) - (hoehe/2 + 50);
       var win2 = window.open(Link ,"popup","toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=" + breite + ",height=" + hoehe + ",left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight);
        win2.focus();
}
var NN 	= document.layers;
var MO  = document.documentElement;

//-- open Window pdf Capter (Bloody) --//

function popupPdfKap(kapitelURL){
	pdf = window.open(kapitelURL, "_blank");
	pdf.window.focus();
}


function pulldown(strFormName, strArrName)
// Pulldown, selects onChange the Destination from strArrName.
{
	var objPdSelection;	   
	
	if (document.forms[strFormName].faq == null)
		return;
  
	objPdSelection = document.forms[strFormName].faq;	
		
	if (objPdSelection.selectedIndex > 0){	 	
	  	if((eval(strArrName)[objPdSelection.selectedIndex].length == 3)){// length=3 -> popup window
            //centerPopup('bmwgroup',eval(strArrName)[objPdSelection.selectedIndex][0],eval(strArrName)[objPdSelection.selectedIndex][1],eval(strArrName)[objPdSelection.selectedIndex][2],'','','yes');
			CenterPopup1(eval(strArrName)[objPdSelection.selectedIndex][0],eval(strArrName)[objPdSelection.selectedIndex][2],eval(strArrName)[objPdSelection.selectedIndex][1]);	
		} else {  
  		    location.href = (eval(strArrName)[objPdSelection.selectedIndex]); 		    		
		}
	}
}


function initOverviewTeaser() {  
// initializing rotating Teaser
moveLayer("teaserdiv"+div, xpos, (document.layers) ? ns_ypos:ypos);//ns_ypos = yOffset for Netscape 4.xx fonts

    if(teaserNo < teaser.length){
	  writeOverviewTeaser();	 
	} else if(teaserNo == teaser.length && teaser.length > 1){
	  teaserNo=0;
	  writeOverviewTeaser();	 
	}

}



function writeOverviewTeaser() {    
// OverviewPage Teaser Rotation
	var teaserStr;	
		teaserStr='<table width="280" border="0" cellspacing="0" cellpadding="0">';
        teaserStr+='<tr>';
        teaserStr+='<td><a href="'+ teaser[teaserNo][3] +'" target="'+ teaser[teaserNo][4] +'"><img src="'+ teaser[teaserNo][0] +'" alt="" width="280" height="40" border="0"></a></td>';
        teaserStr+='</tr><tr>';
        teaserStr+='<td bgcolor="#EFEEEA">';
        teaserStr+='<table border="0" width="280" cellspacing="10" cellpadding="0">';
        teaserStr+='<tr><td>';
        teaserStr+='<a href="'+ teaser[teaserNo][3] +'" target="'+ teaser[teaserNo][4] +'" class="color666666" id="link'+ teaserNo +'" onMouseOver="chgclass(\'link'+ teaserNo +'\',\'color336699\'); onMouseOver=chgclass(\'link2'+ teaserNo +'\',\'color336699\');" onMouseOut="chgclass(\'link'+ teaserNo +'\',\'color666666\'); onMouseOver=chgclass(\'link2'+ teaserNo +'\',\'color666666\');"><span class="font15line17bold">'+ teaser[teaserNo][1] +'</span></a></br>';
        teaserStr+='<a href="'+ teaser[teaserNo][3] +'" target="'+ teaser[teaserNo][4] +'" class="color666666" id="link2'+ teaserNo +'" onMouseOver="chgclass(\'link'+ teaserNo +'\',\'color336699\'); onMouseOver=chgclass(\'link2'+ teaserNo +'\',\'color336699\');" onMouseOut="chgclass(\'link'+ teaserNo +'\',\'color666666\'); onMouseOver=chgclass(\'link2'+ teaserNo +'\',\'color666666\');"><span class="font11line13">'+ teaser[teaserNo][2] +'</span></a>';
        teaserStr+='</td></tr></table><\/td><\/tr><\/table>';
                              
		 writeLayer("teaserdiv"+div,teaserStr);	 		 		
		 show("teaserdiv"+div);		 
	     if(div==0){
		    setTimeout("hide('teaserdiv1')",50);//smooth fade-in
			div=1;
		 } else {
		    setTimeout("hide('teaserdiv0')",50);//smooth fade-in
		    div=0;
		 }		 
		 teaserNo++;		
	     setTimeout("initOverviewTeaser()",4000);// teaser interval
}

//////////////////////////////////////////////////////////////////////////////////////////
///                 Layerfunktionen für das Navigationsobjekt   Stefan Niggl           ///
// get plain layer object
function getLayer(id) 
{
    // if id is alreadz the layer object just return the id
    if( (typeof id) == "object" ) return id; 

	if(document.getElementById) return document.getElementById(id);
	else if (document.layers) return findObject(id);
	else return document.all[id];
}
// get style object of layer (for ns4 it's the layer object itself)
function getLayerStyle(id) 
{ 
	if(document.layers) return getLayer(id);
	else return getLayer(id).style;
}
function getLayerObjectStyle(obj) 
{ 
	if(document.layers) return obj;
	else return obj.style;
}
function moveLayerObj(obj, x, y) {

	if(! document.layers) {
		x = x + "px";
		y = y + "px";
	}
	getLayerObjectStyle(obj).left = x;
	getLayerObjectStyle(obj).top = y;
}

function moveLayer(id, x, y) {
	if (location.href.indexOf('01_management_von_nachhaltigkeit') != -1 || location.href.indexOf('02_oekonomie') != -1  || location.href.indexOf('03_produktverantwortung') != -1  || location.href.indexOf('04_konzernweiter_umweltschutz') != -1 || location.href.indexOf('05_mitarbeiter') != -1 || location.href.indexOf('06_gesellschaftliches_engagement') != -1) {
		y = 318;
	}

	if(! document.layers) {
		x = x + "px";
		y = y + "px";
	}
	getLayerStyle(id).left = x;
	getLayerStyle(id).top = y;


}

function setVisibility(id, val) { // valid values for val are visible/hidden/inherit
	if(document.layers) 
    {
		if(val == "hidden") val = "hide";
		else if(val = "visible") val = "show";
	}
	getLayerStyle(id).visibility = val;
}
function setLayerObjVisibility(obj, val) { // valid values for val are visible/hidden/inherit
	if(document.layers) 
    {
		if(val == "hidden") val = "hide";
		else if(val = "visible") val = "show";
	}
	getLayerObjectStyle(obj).visibility = val;
}
// shortcuts to visibility property
function hide(id) { setVisibility(id, "hidden"); }
function show(id) { setVisibility(id, "visible"); }

// rewrite html-code of layer
function writeLayer(id, htmlText)
{
	if(document.layers) 
    {
		layObj = getLayer(id);
		layObj.document.open();
		layObj.document.write(htmlText);
		layObj.document.close();
	} 
    else getLayer(id).innerHTML = htmlText;
}

// rewrite html-code of layer
function writeLayerObject(obj, htmlText)
{
	if(obj && document.layers) 
    {
		obj.document.open();
		obj.document.write(htmlText);
		obj.document.close();
	} 
    else
    {
        
        obj.innerHTML = htmlText;
        
    }
}

// special function that looks recursively for a nested NS4 layer/forms
function findObject(id,d)
{
    var i,ret; 

    if(!d) d=document; 
    
    ret=d[id];
    if( !ret && d.all) ret=d.all[id]; 
    if( !ret && d.getElementById) ret=d.getElementById(id); 
    
    for(i=0; !ret && i<d.forms.length; i++) ret=d.forms[i][id];
    for(i=0; !ret && d.layers && i<d.layers.length; i++) ret=findObject(id,d.layers[i].document); 
    
    return ret;
}
// special function that looks recursively for a nested NS4 layer
function findNS4Layer(id, d) { 
	var ret,i; 
	if(!d) d=document; 
	ret = d.layers ? d.layers[id] : false;
	// look for sublayers
	for(i=0; !ret && i<d.layers.length;i++) {
		ret = findNS4Layer(id,d.layers[i].document); 
	}
	return ret;
}
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_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_showHideLayers() { //v6.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 changeTeaser() {
//change zum verhindern des Stylesheet-Nachladens K.Gregor

		for (i=1; i <= anzahlLayer; i++) {
			layerId = 'layer' + i;
			if(wechsel == i) {
				//document.getElementById(layerId).style.visibility = "visible";
				
				document.getElementById(layerId).style.zIndex = 100;
			} else {
				document.getElementById(layerId).style.zIndex = 1;
				//document.getElementById(layerId).style.visibility = "hidden";
			}
		}
		if(wechsel < anzahlLayer) {
			wechsel++;
		} else {
			wechsel = 1;
		}
	
	setTimeout('changeTeaser()', zeitBanner);
	
}

// swap publication overiew page download icons
function swapIconCollapsed(obj) {
	  imgSrc =  document.images[obj].src;
	  if(imgSrc.indexOf("-a")==-1){
	     tmpImgSrc = imgSrc.substring(0,imgSrc.length-4) + "-a.gif";
	  } else {
	     tmpImgSrc = imgSrc.substring(0,imgSrc.length-6) + ".gif";
	  }
	  document.images[obj].src = tmpImgSrc;
}


oldFAQ = 0;
	function showSp(spNo,styleHead) {
	
	idName = "sp" + spNo;
	idFrage = "frage" + spNo;
			
			if (spNo == 1||(styleHead&&styleHead=="yes")){
				document.getElementById(idFrage).className = 'boldString1';
			}
			else {
				document.getElementById(idFrage).className = 'boldString';
			}
			document.getElementById(idName).className = 'normalString1';	
			if(oldFAQ != 0 && oldFAQ != spNo) {
				idHideName = "sp" + oldFAQ;
				idHideFrage = "frage" + oldFAQ;
				document.getElementById(idHideName).className = 'hideSp';		
				document.getElementById(idHideFrage).className = 'normalString';	
			}
		oldFAQ = spNo;
	}
	
	function swap_a(name) {
			
	    document.images[name].src = 'http://www.bmwgroup.com/common/images/top-a.gif';
		window.status='';
		return true;
	}
	
	function swap_back(name) {
		document.images[name].src = 'http://www.bmwgroup.com/common/images/top.gif';
	}
	
	
	
	//neu tv1
	
	
function tv1_openIAATV(url, width, height, referer, setup) {

  var wdwUrl = "http://www.tv1.de/bmwtv/cms/_v" + (setup ? setup : "") + url + (referer ? "?referer="+referer : "");
  
  tv1_bmw_openPopup(wdwUrl, "tv1_bmw_webTV", width, height, true, true);
}

function tv1_openBMWChat(url, referer, setup, width, height) {

  var wdwUrl = "http://www.tv1.de/bmwtv/cms/_v" + (setup ? setup : "") + url + (referer ? "?referer="+referer : "");

  var wd = 785;
  if (width && !isNaN(width))
    wd = width;

  var ht = 520;
  if (height && !isNaN(height))
    ht = height;
  
  tv1_bmw_openPopup(wdwUrl, "tv1_bmw_Chat", wd, ht, true, true);
}

function tv1_openBMWVideo(url, referer, setup, width, height) {

  var wdwUrl = "http://www.tv1.de/bmwtv/cms/_v" + (setup ? setup : "") + url + (referer ? "?referer="+referer : "");

  var wd = 785;
  if (width && !isNaN(width))
    wd = width;

  var ht = 520;
  if (height && !isNaN(height))
    ht = height;
  
  tv1_bmw_openPopup(wdwUrl, "tv1_bmw_Video", wd, ht, true, true);
}


function tv1_BMWComVideo(url, referer, setup, width, height) {

  var wdwUrl = "http://www.tv1.de/bmwtv/cms/_v" + (setup ? setup : "") + url + (referer ? "?referer="+referer : "");

  var wd = 342;
  if (width && !isNaN(width))
    wd = width;

  var ht = 295;
  if (height && !isNaN(height))
    ht = height;
  
  var wdw = tv1_bmw_openPopup("", "_blank", wd, ht, true, true);
  var wdwY= (screen.availHeight-ht)/2;
  var wdwX= (screen.availWidth-wd)/2;
  wdw.moveTo(wdwX, wdwY);
  wdw.location.href=wdwUrl;
}


function tv1_bmw_openPopup (wdwUrl, wdwTarget, wdwWidth, wdwHeight, fixedSize, superSlimFlg) {
  var slim = false;
  if (superSlimFlg)
    slim = superSlimFlg;

  var fixed = false;
  if (fixedSize)
    fixed = fixedSize;

  var width = 800;
  if (wdwWidth && !isNaN(wdwWidth))
    width = wdwWidth;

  var height = 660;
  if (wdwHeight && !isNaN(wdwHeight))
    height = wdwHeight;


  var wdwParams = "menubar=" + (slim ? "no" : "yes" ) + ",status=" + (slim ? "no" : "yes" ) + ",width=" + width + ",height=" + height + ",toolbar=no,locationbar=no,resizable=" + (slim || fixed ? "no" : "yes" ) + ",scrollbars=no";
  
  return window.open(wdwUrl, wdwTarget, wdwParams);
}

//video popups
var popupImages = new Array();
		
function getVideoPath(){
	window.document.myFlash.SetVariable("VIDEO_PATH_HI", dataPathHi);
	window.document.myFlash.SetVariable("VIDEO_PATH_LO", dataPathLo);
	getImagePath(); 
	setImagePath();
}

function getImagePath(){
	for (i=0;i<document.getElementsByTagName('img').length;i++)
		popupImages.push(document.getElementsByTagName('img')[i].src)	
}

function setImagePath(){
	for (i=0;i<document.getElementsByTagName('img').length;i++)
		document.getElementsByTagName('img')[i].src = popupImages[i]
}


function openBMWFlashVideo(url) {
	 var width = 655;
	 var height = 540;
	 var slim = true;
	 
	 var wdwParams = "menubar=" + (slim ? "no" : "yes" ) + ",status=" + (slim ? "no" : "yes" ) + ",width=" + width + ",height=" + height + ",toolbar=no,locationbar=no,resizable=" + (slim || fixed ? "no" : "yes" ) + ",scrollbars=no";
  	 return window.open(url, "popup", wdwParams);
	
	 
}

function openVideo(tracking, url) {
	trackClickevent(tracking,url)
	openBMWFlashVideo(url);
	 
}

//umfrage verantwortung
function createCookie(name,value,hours) {
	if (hours) {
		var date = new Date();
		date.setTime(date.getTime()+(1*hours*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function existsCookie(name) {
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen) {
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg) return readCookie(name);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break; 
	}
	return null;
}

function rand(range) {
	return Math.ceil(Math.random() * 1000) % range + 1;
}

function showSurvey(language) {
	if (existsCookie('umfrage') == null) {
		if (rand(9) < 4) {
			if (language == 'd') {
				void(myWindow = window.open('http://www.bmwgroup.com/bmwgroup_prod/d/0_0_www_bmwgroup_com/verantwortung/umfrage/popup_umfrage.shtml','bestellcenter','height=700,width=690,scrollbars=1'));
			}
			else {
				void(myWindow = window.open('http://www.bmwgroup.com/bmwgroup_prod/e/0_0_www_bmwgroup_com/verantwortung/umfrage/popup_umfrage.shtml','bestellcenter','height=700,width=690,scrollbars=1'));
			}
			myWindow.focus();
		}
	}
}

function showSurveyAndSetCookie(language) {
	if (existsCookie('umfrageHome') == null) {
		if (rand(9) < 4) {
			if (language == 'd') {
				void(myWindow = window.open('http://www.bmwgroup.com/bmwgroup_prod/d/0_0_www_bmwgroup_com/verantwortung/umfrage/popup_umfrage.shtml','bestellcenter','height=700,width=690,scrollbars=1'));
			}
			else {
				void(myWindow = window.open('http://www.bmwgroup.com/bmwgroup_prod/e/0_0_www_bmwgroup_com/verantwortung/umfrage/popup_umfrage.shtml','bestellcenter','height=700,width=690,scrollbars=1'));
			}
			createCookie('umfrageHome','umfragedone',2400);
			myWindow.focus();
		}
	}
}

//urls d
//if (location.href.indexOf('verantwortung.html') != -1 && location.href.indexOf('/d/') != -1) {
	//showSurvey('d','verantwortung');
//}

//if (location.href.indexOf('unser_verstaendnis.html') != -1 && location.href.indexOf('/d/') != -1) {
	//showSurvey('d','unser_verstaendnis');
//}

//if (location.href.indexOf('kontakt.html') != -1 && location.href.indexOf('/d/') != -1) {
	//showSurvey('d','kontakt');
//}

//if (location.href.indexOf('umwelt.html') != -1 && location.href.indexOf('/d/') != -1) {
	//showSurvey('d','umwelt');
//}

//if (location.href.indexOf('sustainable_value_report_2007.shtml') != -1 && location.href.indexOf('/d/') != -1) {
	//showSurvey('d','sustainable_value_report_2007');
//}

//if (location.href.indexOf('gesellschaft.shtml') != -1 && location.href.indexOf('/d/') != -1) {
	//showSurvey('d','gesellschaft');
//}

//if (location.href.indexOf('clean_production.html') != -1 && location.href.indexOf('/d/') != -1) {
	//showSurvey('d','clean_production');
//}

//if (location.href.indexOf('home.html') != -1 && location.href.indexOf('/d/') != -1) {
	//showSurveyAndSetCookie('d','home');
//}


//urls e
//if (location.href.indexOf('verantwortung.html') != -1 && location.href.indexOf('/e/') != -1) {
	//showSurvey('e','verantwortung');
//}

//if (location.href.indexOf('unser_verstaendnis.html') != -1 && location.href.indexOf('/e/') != -1) {
	//showSurvey('e','unser_verstaendnis');
//}

//if (location.href.indexOf('kontakt.html') != -1 && location.href.indexOf('/e/') != -1) {
	//showSurvey('e','kontakt');
//}

//if (location.href.indexOf('umwelt.html') != -1 && location.href.indexOf('/e/') != -1) {
	//showSurvey('e','umwelt');
//}

//if (location.href.indexOf('sustainable_value_report_2007.shtml') != -1 && location.href.indexOf('/e/') != -1) {
	//showSurvey('e','sustainable_value_report_2007');
//}

//if (location.href.indexOf('gesellschaft.shtml') != -1 && location.href.indexOf('/e/') != -1) {
	//showSurvey('e','gesellschaft');
//}

//if (location.href.indexOf('clean_production.html') != -1 && location.href.indexOf('/e/') != -1) {
	//showSurvey('e','clean_production');
//}

//if (location.href.indexOf('home.html') != -1 && location.href.indexOf('/e/') != -1) {
	//showSurveyAndSetCookie('e','home');
//}

