//  Version 1.2
//  2005/05/03
resetModulNaviTimer = 5000;
hideCo2LayerTimer   = 5000;
var highbandUser    = false;
var i, e;
var browserAtributeLength, browserId, platform;
var imgCountTotal, lowImageSrc, highImageSrc, currentImg, currentState, currentAct, currentPerm, checkLoad;
var slideAmount;
var divNum, documentLeftScroll, documentTopScroll, mouseX, mouseY, loopDragging;
var speedHorizontal, speedVertical, currentBack, goup, godown, speed, currentObjNo;
var setDivPosition, setBackPosition, currentObjId, currentSpeed, currenDirection, currentDelay;
var diffWidth,diffHeight, lastWidth, lastHeight, currentDiv;
var popup_window, winUrl;
var ua                  = navigator.userAgent.toLowerCase();
var an                  = navigator.appName.toLowerCase();
var framesetPage        = "index.html";
var currentStep         = 0;
var windowWidth         = 0;
var windowHeight        = 0;
var browserVersion      = 0;
var loaded              = 0;
var divLeft             = 0;
var divTop              = 0;
var looping             = -1;
var slideCount          = -1;
var writeBrowser        = "";
var tempAct             = "";
var slideNumber         = "";
var slideDescription    = "";
var preLoadArray        = new Array();
var preLoadCounter      = new Array();
var highImages          = new Array();
var lowImages           = new Array();
var slideText           = new Array();
var permanentActive     = new Array();
var slideImages         = new Array();
var allowedDomain       = new Array();
    allowedDomain[0]    = "://www.bmw.";
    allowedDomain[1]    = "://bmw.";
    allowedDomain[2]    = "://origin.bmw.";
    allowedDomain[3]    = "://secure.bmw.";
    allowedDomain[4]    = "://wcms30.bmwgroup.com";
    allowedDomain[5]    = "://liintra.muc";
    allowedDomain[6]    = "://ltintra.muc";
    allowedDomain[7]    = "://www-at.bmw";
    allowedDomain[8]    = "://www-nl.bmw";
    allowedDomain[9]    = "://www-be.bmw";
    allowedDomain[10]   = "://www-lu.bmw";
    allowedDomain[11]   = "://www-pt.bmw";  
    allowedDomain[12]   = "://www-ie.bmw";  
    allowedDomain[13]   = "://www-jp.bmw";  
    allowedDomain[14]   = "://www-fr.bmw";  
    allowedDomain[15]   = "://www-cz.bmw";  
    allowedDomain[16]   = "://www-sk.bmw";  
    allowedDomain[17]   = "://www-se.bmw";  
    allowedDomain[18]   = "://www-it.bmw";
    allowedDomain[19]   = "://www8i.muc";
    allowedDomain[20]   = "://ltintra.muc";
    allowedDomain[21]   = ".bmw.";
    allowedDomain[22]   = "://liintrab.muc";
    allowedDomain[23]   = "://ltintrab.muc";
    allowedDomain[24]   = "://accessories.bmw.com";
    allowedDomain[25]    = ".bmwgroup.com";
    allowedDomain[26]    = "://partnerorigin.bmw.";
    allowedDomain[27]    = "://partnersecure.bmw.";
    allowedDomain[28]    = "://hbk.bmw-motorrad.com";
var supportedOS         = false;
var supportedVersion    = false;
var currentLoop         = false;
var dragAllowed         = false;
var divIsMoving         = false;
var flashversion        = false;
var topFrame            = null;
var contentFrame        = null;
var bottomFrame         = null;
var historyFrame        = null;
var hiddenFrame         = null;
var allowClose          = true;
var modulNaviOverImage  = true;
var idmodulsSpecial     = "";
var minFlashVersion     = 7;
var isMainnavigation    = false;
var indexParameters     = "";
var query = new Object();
var parameterArray = new Array();
var scrollerDefaultSize=978;
var scrollerCheckElements = new Array();
var scrollerSize = scrollerDefaultSize;
var scrollerBgImage;
var scrollerSliderImage;
var scrollerImageUp;
var scrollerImageDown;
var divsToBeAltered = [];
var useCurtain = "false";
var showFlashMovie = true;
var newContentStart = "";
var suspendAjaxLoad = false;

if (typeof browser != 'object') {
  browser     = new Array();
  browser[0]  = new Array('Opera',    'opera ',     '6.5', '',        '',             '');
  browser[1]  = new Array('Safari',   'safari/',    '125', '',        'mac os x',     '');
  browser[2]  = new Array('Netscape', 'netscape/',  '7.1', 'windows', 'mac os x',     'other');
  browser[3]  = new Array('Firefox',  'firefox/',   '1.0', 'windows', 'mac os x',     'other');
  browser[4]  = new Array('Mozilla',  'rv:',        '1.7', 'windows', 'mac os x',     'other');
  browser[5]  = new Array('MSIE',     'msie ',      '5.5', 'windows', '',             '');
  browser[6]  = new Array('Netscape4','mozilla/',   '4.0',  '',       '',             '');
}
function ssoCloseDialog() {
}
function checkFrameset() {
}
function checkClient() {
  var browserLength = browser.length;
  for (i = 0; i < browserLength; i++) {
    browserAtributeLength = browser[i].length;
    if (ua.indexOf(browser[i][1]) != -1) {
      browserId = browser[i][0];
      for (e = 3; e < browserAtributeLength; e++) {
        if (browser[i][e] != '' && (ua.indexOf(browser[i][e]) != -1 || browser[i][e] == 'other')) {
            supportedOS = true;
            platform = browser[i][e];
            break;
        } else {
          supportedOS = false;
        }
      }
      browserVersion = ua.split(browser[i][1]);
      browserVersion = parseFloat(browserVersion[1].slice(0,3));
      if (browserVersion >= browser[i][2]) {
        supportedVersion = true;
      } else {
        supportedVersion = false;
      }
      break;
    } else {
      browserId = 'unknown';
    }
  }
}

function checkFlashCompatibility() {
	checkClient();
	if (browserId == 'Safari') {
		showFlashMovie = false;
	}
	if (platform == 'other') {
		if (browserId == 'Firefox') {
			showFlashMovie = false;
		}
	}
	/*
	if (platform == 'mac os x') {
		if (browserId == 'Firefox') {
			if (document.getElementById("navigation")) {
				document.getElementById("navigation").style.MozOpacity = "1.0";
			}
			if (document.getElementById("mainNavigationIFrame")) {
				window.mainNavigationIFrame.document.getElementById("lineMainNavigation").style.MozOpacity = "1.0";
			}
		}
	}
	*/
}

function pageHandler() {
	splitSearchString();
  if(query.content){
    if(query.content.indexOf("://") != -1) {
      var domainIsAllowed=false;
      for (i = 0; i < allowedDomain.length; i++) {
				if(query.content.indexOf(allowedDomain[i]) != -1) {
					domainIsAllowed = true;
          break;
        }
      }
      if(domainIsAllowed) {
        initContentURL = query.content;
        indexParameters="";
        for(x in query){
          if(x=="content") continue;
          if(indexParameters=="") {
             indexParameters+="?";
          } else {
             indexParameters+="&";
          }
         indexParameters+=x+"="+query[x];
        }
      }
    }
    else {
      initContentURL = query.content;
      indexParameters="";
      for(x in query){
        if(x=="content") continue;
        if(indexParameters=="") {
           indexParameters+="?";
        } else {
           indexParameters+="&";
        }
       indexParameters+=x+"="+query[x];
      }
    }
  }
}
function setFrameVariables(){
  contentFrame = frames['frameContent'];
  bottomFrame  = frames['frameBottom'];
  historyFrame = frames['frameBottom'];
  hiddenFrame  = frames['frameHidden'];
}
function getFrameset(version){
  var frameSetSource   = "";
  pageHandler();
  if(version == "flash" || version == "html"){
    frameSetSource += '<'+'frameset rows="*,29" frameborder="no" border="0" onload="setFrameVariables()">';
    frameSetSource += '<'+'frame src="' + initContentURL + '" name="frameContent" frameborder="0" marginwidth="0" marginheight="0" noresize="noresize" scrolling="auto" />';
    frameSetSource += '<'+'frameset cols="*,1" frameborder="no" border="0">';
    frameSetSource += '  <'+'frame src="' + initBottomURL  + '" name="frameBottom"  frameborder="0" marginwidth="0" marginheight="0" noresize="noresize" scrolling="no" />';
    frameSetSource += '  <'+'frame src="' + initHiddenURL  + '" name="frameHidden"  frameborder="0" marginwidth="0" marginheight="0" noresize="noresize" scrolling="no" />';
    frameSetSource += '<'+'/frameset>';
  } else if(version == "shortcut") {
    frameSetSource += '<'+'frameset rows="99%,1%" frameborder="no" border="0">';
    frameSetSource += ' <'+'frame src="' + initContentURL + '" name="frameContent" frameborder="0" marginwidth="0" marginheight="0" noresize="noresize" scrolling="auto" />';
    frameSetSource += ' <'+'frame src="' + initHiddenURL  + '" name="frameHidden"  frameborder="0" marginwidth="0" marginheight="0" noresize="noresize" scrolling="no" />';
  } else if(version == "popup") {
    frameSetSource += '<'+'frameset rows="96,*" frameborder="no" border="0">';
    frameSetSource += ' <'+'frame src="' + initTopURL  + '" name="frameTop"  frameborder="0" marginwidth="0" marginheight="0" noresize="noresize" scrolling="no" />';
    frameSetSource += ' <'+'frame src="' + initContentURL + '" name="frameContent" frameborder="0" marginwidth="0" marginheight="0" noresize="noresize" scrolling="auto" />';
  } else {
    frameSetSource = "Error: Function getFrameset called with illegal parameter (" + version + ")";
  }
  frameSetSource += '<'+'/frameset>';
  return frameSetSource;
}
function preload() {
  if (typeof slideImagesCollection != 'undefined') {
    slideAmount = slideImagesCollection.length;
  }
  for (i = 0; i < slideAmount; i++) {
    slideImages[i] = new Image();
    slideImages[i].src = slideImagesCollection[i];
  }
  loaded = 2;
  imgCountTotal = document.images.length;
  for (i = 0; i < imgCountTotal; i++) {
    if (typeof document.getElementsByTagName('img')[i].getAttribute('preload') == 'string') {
      lowImageSrc = document.getElementsByTagName('img')[i].src;
      if (document.getElementsByTagName('img')[i].getAttribute('preload').indexOf('/') != -1) {
        highImageSrc = document.getElementsByTagName('img')[i].getAttribute('preload');
      } else {
        var highImageUrl = lowImageSrc.split('/');
        var fileLevel = highImageUrl.length;
        var highImagePath = '';
        for (e = 0; e < fileLevel - 1; e++) {
          highImagePath += highImageUrl[e] + '/';
        }
        highImageSrc = highImagePath + document.getElementsByTagName('img')[i].getAttribute('preload');
      }
      highImages[document.images[i].id] = new Image();
      highImages[document.images[i].id].src = highImageSrc;
      lowImages[document.images[i].id] = new Image();
      lowImages[document.images[i].id].src = lowImageSrc;
    }
    if (i < imgCountTotal - 1) {
      loaded = 3;
    }
    if (i == imgCountTotal - 1) {
      loaded = 1;
    }
  }
}
function switchImage(imgId,state,act,permanent,dropPerm) {
  currentImg = imgId;
  currentState = state;
  currentAct= act;
  currentPerm = permanent;
  if (typeof dropPerm == 'string' && dropPerm != 'all') {
    document.getElementsByTagName('img')[dropPerm].src = lowImages[dropPerm].src;
    delete permanentActive[dropPerm];
    if (dropPerm == tempAct) {
      tempAct = '';
    }
  } else if (dropPerm == 'all') {
    dropPermanentAll ();
  }
  if (loaded == 1) {
    clearTimeout(checkLoad);
    if (tempAct != '' && imgId != tempAct && act == 1 && !permanentActive[tempAct]) {
      document.getElementsByTagName('img')[tempAct].src = lowImages[tempAct].src;
    }
    if ((tempAct == '' || imgId != tempAct) && !permanentActive[imgId]) {
      if (state == 1) {
        document.getElementsByTagName('img')[imgId].src = highImages[imgId].src;
      } else {
        document.getElementsByTagName('img')[imgId].src = lowImages[imgId].src;
      }
    }
    if (act == 1) {
      tempAct = imgId;
    }
    if (permanent == 1) {
      permanentActive[imgId] = imgId;
    }
  } else if (loaded == 2){
    checkLoad = setTimeout('switchImage(currentImg,currentState,currentAct,currentPerm)',50);
  } else if (loaded == 3){
    preload();
    checkLoad = setTimeout('switchImage(currentImg,currentState,currentAct,currentPerm)',50);
  }
}
function dropPermanentAll () {
  for (var dropImg in permanentActive) {
    document.getElementsByTagName('img')[dropImg].src = lowImages[dropImg].src;
    delete permanentActive[dropImg];
  }
  if (tempAct != '') {
    document.getElementsByTagName('img')[tempAct].src = lowImages[tempAct].src;
    tempAct = '';
  }
}
function setSlideshow(direction,delay) {
  currenDirection = direction;
  currentDelay = delay;
  if (direction == "forward") {
    slideCount ++;
    if (slideCount > slideAmount - 1) {
      slideCount = 0;
    }
  } else if (direction == "backward") {
    slideCount --;
    if (slideCount < 0) {
      slideCount = slideAmount - 1;
    }
  } else {
    slideCount = 0;
  }
  if (delay) {
    looping = setTimeout("setSlideshow(currenDirection,currentDelay)",currentDelay);
  } else {
    clearTimeout(looping);
    looping = -1;
  }
  document.getElementById('slideshow').src = slideImages[slideCount].src;
}
function toggleSlideshow(direction,delay) {
  if (!direction) {
    direction = currenDirection;
  }
  if (!delay) {
    delay = currentDelay;
  }
  if (looping > -1) {
    clearTimeout(looping);
    looping = -1;
  } else {
    setSlideshow(direction,delay);
  }
}
function setClassName(tagId,nameOfClass) {
  if (typeof tagId != 'object') {
    tagId = document.getElementById(tagId);
  }
  if (tagId) {
    tagId.className = nameOfClass;
  }
}
function setColor(objId,color) {
  if (typeof objId != 'object') {
    objId = document.getElementById(objId);
  }
  if (objId) {
    objId.style.color = color;
  }
}
function getAbsoluteLeft(obj) {
  if (typeof obj != 'object') {
    obj = document.getElementById(obj);
  }
  var x = 0;
  if (obj){
    while (obj.offsetParent !== null) {
      x += obj.offsetLeft;
      obj = obj.offsetParent;
    }
    x += obj.offsetLeft;
  }
  return x;
}
function getAbsoluteTop(obj) {
  if (typeof obj != 'object') {
    obj = document.getElementById(obj);
  }
  var y = 0;
  if (obj){
    while (obj.offsetParent !== null) {
      y += obj.offsetTop;
      obj = obj.offsetParent;
    }
    y += obj.offsetTop;
  }
  return y;
}
function getDivInformation(objId,attribute) {
  divInformation = new Array();
  if (typeof objId != 'object') {
    objId = document.getElementById(objId);
  }
  if (objId){
    divInformation['offsetLeft']  = objId.offsetLeft;
    divInformation['offsetTop']   = objId.offsetTop;
    divInformation['styleLeft']   = parseInt(objId.style.left);
    divInformation['styleTop']    = parseInt(objId.style.top);
    divInformation['width']       = objId.offsetWidth;
    divInformation['height']      = objId.offsetHeight;
    divInformation['visibility']  = objId.style.visibility;
    divInformation['display']     = objId.style.display;
    divInformation['zIndex']      = objId.style.zIndex;
    return divInformation[attribute];
  }
}
function writeIntoLayer(objId,content) {
  if (typeof objId != 'object') {
    objId = document.getElementById(objId);
  }
  if (objId){
    objId.innerHTML = content;
  }
}
lastPositions     = new Array();
currentPositions  = new Array();
currentPositions['navigation'] = [,];
function moveObject(objId,left,top,speed,backLink) {
  if (typeof objId != 'object') {
    objId = document.getElementById(objId);
  }
  if (objId) {
    if (left) {
      divLeft = left;
    } else if ((typeof left == 'undefined' || typeof left == 'string') && (typeof backLink == 'undefined' || backLink == 0)) {
      divLeft = getDivInformation(objId,'offsetLeft');
    }
    if (top) {
      divTop = top;
    } else if ((typeof top == 'undefined' || typeof top == 'string') && (typeof backLink == 'undefined' || backLink == 0)) {
      divTop = getDivInformation(objId,'offsetTop');
    }
    if (!lastPositions[objId.id]) {
      lastPositions[objId.id] = [,];
    }
    if (typeof backLink != 'undefined' && backLink == 1 && left == lastPositions[objId.id][0] && top == lastPositions[objId.id][1]) {
      currentBack = backLink;
      divLeft = currentPositions[objId.id][0];
      divTop  = currentPositions[objId.id][1];
    }
    if (!divIsMoving) {
      currentPositions[objId.id] = [getDivInformation(objId,'offsetLeft'),getDivInformation(objId,'offsetTop')];
    }
    if (speed) {
      var horizontalRange = currentPositions[objId.id][0] - divLeft;
      var verticalRange   = currentPositions[objId.id][1] - divTop;
      currentObjId = objId;
      currentSpeed = speed;
      currentStep ++;
      if (left != '' || left == 0) {
        if (horizontalRange > 0) {
          objId.style.left = (currentPositions[objId.id][0] - Math.round(currentStep * speed)) + 'px';
          if (divLeft - getDivInformation(objId,'offsetLeft') > 5) {
            objId.style.left = divLeft + 'px';
          }
        } else if (horizontalRange < 0) {
          objId.style.left = (currentPositions[objId.id][0] + Math.round(currentStep * speed)) + 'px';
          if (divLeft - getDivInformation(objId,'offsetLeft') < 5) {
            objId.style.left = divLeft + 'px';
          }
        }
      }
      if (top != '' || top == 0) {
        if (verticalRange > 0) {
          objId.style.top = (currentPositions[objId.id][1] - Math.round(currentStep * speed)) + 'px';
          if (divTop - getDivInformation(objId,'offsetTop') > 5) {
            objId.style.top = divTop + 'px';
          }
        } else if (verticalRange < 0) {
          objId.style.top = (currentPositions[objId.id][1] + Math.round(currentStep * speed)) + 'px';
          if (divTop - getDivInformation(objId,'offsetTop') < 5) {
            objId.style.top = divTop + 'px';
          }
        }
      }
      if (getDivInformation(objId,'offsetLeft') == left && getDivInformation(objId,'offsetTop') == top) {
        divIsMoving = false;
        currentStep = 0;
        currentBack = 0;
        divLeft     = 0;
        divTop      = 0;
        lastPositions[objId.id]=[left,top];
        clearTimeout(setDivPosition);
      } else {
        divIsMoving = true;
        setDivPosition = setTimeout('moveObject(currentObjId,divLeft,divTop,currentSpeed)',10);
      }
    } else {
      if (divLeft != '' || divLeft == 0) {
        objId.style.left = divLeft + 'px';
      }
      if (divTop != '' || divTop == 0) {
        objId.style.top = divTop + 'px';
      }
      currentBack = 0;
      divLeft     = 0;
      divTop      = 0;
      lastPositions[objId.id]=[left,top];
    }
  }
}
function mousePosition(currentevent){
  if(window.event) {
    currentevent = window.event;
  }
  mouseX = currentevent.clientX;
  mouseY = currentevent.clientY;
}
function getWindowInformation(value) {
  windowInformation = new Array();
  windowInformation['winWidth'] = document.body.clientWidth;
  if (document.body.clientHeight == 0) {
    windowInformation['winHeight'] = window.innerHeight;
  } else {
    windowInformation['winHeight'] = document.body.clientHeight;
  }
  windowInformation['docWidth'] = document.body.scrollWidth;
  windowInformation['docHeight'] = document.body.scrollHeight;
  windowInformation['scrollLeft'] = document.body.scrollLeft;
  windowInformation['scrollTop'] = document.body.scrollTop;
  return windowInformation[value];
}
function getCurrentStyle(nodeObject,propertyName) {
  var propertyValue;
  if (document.documentElement && document.defaultView) {
    propertyValue = document.defaultView.getComputedStyle(nodeObject,"").getPropertyValue(propertyName);
  }
  else if (document.documentElement && document.documentElement.currentStyle) {
    var regX = /([a-z]*)\-([a-z])([a-z]*)/;
    while (regX.test(propertyName)) {
      regX.exec(propertyName);
      propertyName = RegExp.$1 + RegExp.$2.toUpperCase() + RegExp.$3;
    }
    propertyValue = nodeObject.currentStyle[propertyName];
  }
  return propertyValue;
}
var currentState, currentDisplayState;
function setVisibility(objId,visibility,display,initialSet) {
  if (typeof objId != 'object') {
    objId = document.getElementById(objId);
  }
  if (objId) {
    if (typeof visibility == 'undefined' && typeof display == 'undefined') {
      currentState        = getDivInformation(objId,'visibility');
      currentDisplayState = getDivInformation(objId,'display');
      if (currentState == '') {
        if (initialSet) {
          currentState = 'visible';
        } else {
          currentState = 'hidden';
        }
      }
      if (currentDisplayState == '') {
        if (initialSet) {
          currentDisplayState = initialSet;
        } else {
          currentDisplayState = 'none';
        }
      }
      if (currentState == 'hidden') {
        objId.style.visibility = 'visible';
      } else if (currentState == 'visible'){
        objId.style.visibility = 'hidden';
      }
      if (currentDisplayState == 'none') {
        objId.style.display = 'block';
        objId.style.visibility = 'visible';
      } else if (currentDisplayState == 'block' || currentDisplayState == 'inline') {
        objId.style.display = 'none';
      }
    } else if(visibility == 1) {
        objId.style.visibility = 'visible';
    } else if(visibility == 0) {
      objId.style.visibility = 'hidden';
    }
    if(display) {
      objId.style.display = display;
    }
  }
}
function setZIndex(obj,n) {
  if (typeof obj != 'object') {
    obj = document.getElementById(obj);
  }
  if (obj) {
    obj.style.zIndex = n;
  }
}
function resizeLayer(objId, newWidth, newHeight) {
  if (typeof objId != 'object') {
    objId = document.getElementById(objId);
  }
  if (objId) {
    currentDiv = objId;
    lastWidth = getDivInformation(objId,'width');
    lastHeight = getDivInformation(objId,'height');
    if (newWidth) {
      if (typeof newWidth == 'string') {
        objId.style.width = newWidth;
      } else {
        objId.style.width = newWidth + 'px';
      }
    }
    if (newHeight) {
      if (typeof newHeight == 'string') {
        objId.style.height = newHeight;
      } else {
        objId.style.height = newHeight + 'px';
      }
    }
  }
}
function clipLayer(objId, top, right, bottom, left) {
  if (typeof objId != 'object') {
    objId = document.getElementById(objId);
  }
  if (objId) {
    currentDiv = objId;
    lastWidth = getDivInformation(objId,'width');
    lastHeight = getDivInformation(objId,'height');
    objId.style.clip = "rect("+top+"px "+right+"px "+bottom+"px "+left+"px)";
  }
}
function getClipping(objId) {
  if (typeof objId != 'object') {
    objId = document.getElementById(objId);
  }
  if (objId) {
    return objId.style.clip;
  }
}
function restoreLayer () {
  if (typeof currentDiv == 'object') {
    if (typeof currentDiv.style.width != 'undefined') {
      currentDiv.style.width = lastWidth + 'px';
    }
    if (typeof currentDiv.style.height != 'undefined') {
      currentDiv.style.height = lastHeight + 'px';
    }
    if (typeof currentDiv.style.clip != 'undefined') {
      currentDiv.style.clip = "rect("+0+"px "+lastWidth+"px "+lastHeight+"px "+0+"px)";
    }
  }
}
function centerPopup(popup_url,popup_name,popup_with,popup_height,reopen,myScrollbar,myLeftPos,myTopPos) {
  if(!myLeftPos)  {myLeftPos    = 5;}
  if(!myTopPos)   {myTopPos     = 15;}
  if(!myScrollbar){myScrollbar  = 0;}
  if(myScrollbar) {myScrollbar  = 'yes';}
  var popup_left                = (window.screen.width/2)  - (popup_with/2 + myLeftPos);
  var popup_top                 = (window.screen.height/2) - (popup_height/2 + myTopPos);
  if ((typeof popup_window != 'object') || (typeof popup_window == 'object' && popup_window.closed)) {
    if (document.all) {
      var xyPos                 = 'left=' + popup_left + ',top=' + popup_top;
    } else {
      var xyPos                 = 'screenX=' + popup_left + ',screenY=' + popup_top;
    }
    popup_window                = window.open(popup_url, popup_name, "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=" + myScrollbar + ",resizable=no,width=" + popup_with + ",height=" + popup_height + ",copyhistory=no," + xyPos + "");
    popup_window.opener         = self;
    popup_window.focus();
    winUrl                      = popup_url;
    windowWidth                 = popup_with;
    windowHeight                = popup_height;
  } else {
    if ((winUrl != popup_url) || reopen) {
      popup_window.location.href = popup_url;
    }
    if ((windowWidth + windowHeight > 0) && (popup_with != windowWidth || popup_height != windowHeight || myLeftPos != diffWidth || myTopPos != diffHeight)) {
      var newWidth              = popup_with  - windowWidth;
      var newHeight             = popup_height - windowHeight;
      popup_window.resizeBy(newWidth,newHeight);
      popup_window.moveTo(popup_left,popup_top);
    }
    popup_window.focus();
    winUrl                      = popup_url;
    windowWidth                 = popup_with;
    windowHeight                = popup_height;
  }
  diffWidth                     = myLeftPos;
  diffHeight                    = myTopPos;
}
function openPopupLink(url,popupString){
  var params=popupString.split(",");
  if(params.length==3){
    centerPopup(url,params[0],params[1],params[2],false,false);
  } else {
    centerPopup(url,"searchwin",800,600,false,false);
  }
}
function openPopupParams(popup_url,popup_name,popup_params) {
  if ((typeof popup_window != 'object') || (typeof popup_window == 'object' && popup_window.closed)) {
    if (popup_params) {
      popup_window              = window.open(popup_url, popup_name, popup_params);
    } else {
      popup_window              = window.open(popup_url, popup_name);
    }
    popup_window.opener         = self;
    popup_window.focus();
    winUrl                      = popup_url;
  } else {
    if (winUrl != popup_url) {
      popup_window.location.href = popup_url;
    }
    popup_window.focus();
    winUrl                      = popup_url;
  }
}
function splitSearchString() {
   if (self.location.search.indexOf("=") == -1) return;
  parameterArray = self.location.search.substring(1).split("&");
  for (i=0;i<parameterArray.length;i++){
    pair= parameterArray[i].split("=");
    query[unescape(pair[0])]=(pair[1]?unescape(pair[1]):"");
  }
}

// workaround: import der funktionen getCookieVal() + getCookie() aus bmw.de
function getCookieVal (offset) {
    var endstr = document.cookie.indexOf (";", offset);
    if (endstr == -1)
        endstr = document.cookie.length;
    return unescape(document.cookie.substring(offset, endstr));
}
function getCookie (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 getCookieVal (j);
        i = document.cookie.indexOf(" ", i) + 1;
        if (i == 0) break;
    }
    return null;
}
// end workaround

function getCookieValue(name) {
  var arg = name + "=";
  var alen = arg.length;
  var i = 0;
  while (i < document.cookie.length) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg) {
      var endstr = document.cookie.indexOf (";", j);
      if (endstr == -1) {
        endstr = document.cookie.length;
      }
      return unescape(document.cookie.substring(j, endstr));
    }
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) {
      break;
    }
  }
  return false;
}
function isCookiesEnabled(){
  document.cookie="bmwCookieEnabled=true";
  if(document.cookie.indexOf("bmwCookieEnabled=true")!= -1) {
    var expire=new Date();
    document.cookie = "bmwCookieEnabled=;expires=" + expire.toGMTString();
    return true;
  } else {
    return false;
  }
}

function setCookie(name, value, expires, path, domain, secure){
  document.cookie = name + "=" + escape(value) +
  ((expires) ? "; expires=" + expires : "") +
  ((path) ? "; path=" + path : "") +
  ((domain) ? "; domain=" + domain : "") +
  ((secure) ? "; secure" : "");
}

function onLoadFunctions(){
}
function onUnloadFunctions(){
}
function checkWindowSize(){
  if(getWindowInformation('winWidth') < scrollerSize){
    if(document.getElementById('mainNavi')){
      resizeLayer('mainNavi', 1024);
    }
    for(i = 0;i < scrollerCheckElements.length;i++){
      if (document.getElementById(scrollerCheckElements[i])){
        resizeLayer(scrollerCheckElements[i], 1024);
      }
    }
  } else{
    if(document.getElementById('mainNavi')){
      resizeLayer('mainNavi', '100%');
    }
    for(i=0;i < scrollerCheckElements.length;i++){
      if (document.getElementById(scrollerCheckElements[i])){
        resizeLayer(scrollerCheckElements[i], '100%');
      }
    }
  }
}

function myAlert(alertText){
  if(top.location.search.indexOf("debug") != -1){
    alert(alertText);
  }
}

function buildLinkList(){
  var links=new Array(document.getElementsByTagName('a').length);
  for (var i = 0; i < document.getElementsByTagName('a').length; i++){
    links[i]=document.getElementsByTagName('a')[i].href;
  }
  return links;
}
/*change for seo*/
function highlightBottomNavigation(){
 if(self.name=="frameContent"){
    if(parent.frames[1] && parent.frameBottom.bottomNavigationLoaded==true){
      parent.frameBottom.highlightBottomNavigation(self.location.href);
    } else {
      setTimeout('highlightBottomNavigation()',300);
    }
  }
}
/* remove for seo
function resetBottomNavigation(){
  if(self.name=="frameContent"){
    parent.frameBottom.resetBottomNavigation(self.location.href);
  }
}*/
function evaluateHighlighting(contentUrl, linkList){
  var navLinkFull="";
  var navLinkPath="";
  var navLinkFile="";
  var navLinkQuery="";
  var navLinkPathParts=new Array();
  var contentLinkFull="";
  var contentLinkPath="";
  var contentLinkFile="";
  var contentLinkQuery="";
  var contentLinkPathParts=new Array();
  var evaluatedLinks=new Array();
  if(contentUrl.indexOf('?')!=-1){
    contentLinkFull=contentUrl.substring(0,contentUrl.lastIndexOf('?'));
    contentLinkQuery=contentUrl.substring(contentUrl.lastIndexOf('?'),contentUrl.length);
    if(contentLinkQuery.indexOf("&")!=-1){
      contentLinkQuery=contentLinkQuery.substring(0,contentLinkQuery.indexOf("&"));
    }
  } else {
    contentLinkFull=contentUrl;
  }
  if(contentLinkFull.charAt(contentLinkFull.length-1)=='/') {
    contentLinkFull=contentLinkFull.substring(0,contentLinkFull.length-1);
  }
  if(contentLinkFull.lastIndexOf('/') < contentLinkFull.lastIndexOf('.')){
    contentLinkFile=contentLinkFull.substring(contentLinkFull.lastIndexOf('/')+1,contentLinkFull.length);
    contentLinkPath=contentLinkFull.substring(0, contentLinkFull.lastIndexOf('/'));
  } else {
    contentLinkPath=contentLinkFull;
    contentLinkFile="";
  }
  contentLinkPathParts=contentLinkPath.split('/');
  for(i=0; i < linkList.length;i++){
    navLinkFull=linkList[i];
    if(navLinkFull.indexOf('javascript:')!=-1 || navLinkFull=='' || (navLinkFull.indexOf('http') != -1  && navLinkFull.indexOf(self.location.host) == -1)) {
       evaluatedLinks.push(999);
      continue;
    }
    
    
    if(navLinkFull.indexOf('?')!=-1){
      navLinkQuery=navLinkFull.substring(navLinkFull.lastIndexOf('?'),navLinkFull.length);
      if(navLinkQuery.indexOf("&")!=-1){
        navLinkQuery=navLinkQuery.substring(0,navLinkQuery.indexOf("&"));
      }
      navLinkFull=navLinkFull.substring(0,navLinkFull.lastIndexOf('?'));
    } else {
       navLinkQuery="";
    }
    if(navLinkFull.charAt(navLinkFull.length-1)=='/') {
      navLinkFull=navLinkFull.substring(0,navLinkFull.length-1);
    }
    if(navLinkFull.lastIndexOf('/') < navLinkFull.lastIndexOf('.')){
      navLinkFile=navLinkFull.substring(navLinkFull.lastIndexOf('/')+1,navLinkFull.length);
      navLinkPath=navLinkFull.substring(0, navLinkFull.lastIndexOf('/'));
    } else {
      navLinkPath=navLinkFull;
      navLinkFile="";
    }
    navLinkPathParts=navLinkPath.split('/');
    var contentIndex=0;
    var navIndex=0;
    var bestmatchFound=false;
    var charMatch=null;
    while(navLinkPathParts[navIndex]==contentLinkPathParts[contentIndex]){
      navIndex++;
      contentIndex++;
      if(contentIndex==contentLinkPathParts.length && navIndex==navLinkPathParts.length){
        if(navLinkFile==contentLinkFile){
           if(navLinkQuery==contentLinkQuery){
             evaluatedLinks.push(-2);
             bestmatchFound=true;
           } else {
            evaluatedLinks.push(-1);
          }
        } else {
          charMatch=stringCompare(navLinkFile,contentLinkFile);
         evaluatedLinks.push(0.99-(charMatch/100));
        }
        break;
      } else if(contentIndex==contentLinkPathParts.length){
        evaluatedLinks.push(999);
        break;
      } else if(navIndex==navLinkPathParts.length){
         if(  confCountryTopic != null
				 			&& confDealerTopic != null
              && confLanguageTopic != null
              && navLinkPathParts.length >= 3
              && navLinkPathParts[navLinkPathParts.length-1] == confLanguageTopic
							&& navLinkPathParts[navLinkPathParts.length-2] == confDealerTopic
              && navLinkPathParts[navLinkPathParts.length-3] == confCountryTopic){
           evaluatedLinks.push(999);
        // } else if(confCountryTopic != null && navLinkPath.indexOf("/"+confCountryTopic+"/")==-1){
         //  evaluatedLinks.push(999);
         } else {
          evaluatedLinks.push(contentLinkPathParts.length-contentIndex);
        }
        break;
      } else if(navLinkPathParts[navIndex]!=contentLinkPathParts[contentIndex]){
        evaluatedLinks.push(999);
        break;
      }
    }
    if(bestmatchFound){
      break;
    }
  }
  return evaluatedLinks;
}
function stringCompare(comparator1, comparator2){
   var shorter=null;
   var longer=null;
   if(comparator1.length > comparator2.length){
     longer=comparator1.toLowerCase();
     shorter=comparator2.toLowerCase();
   } else {
     longer=comparator2.toLowerCase();
     shorter=comparator1.toLowerCase();
   }
   var matchCount=0;
   for(var x=0;x < shorter.length;x++){
     if(shorter.charAt(x)==longer.charAt(x)){
       matchCount++;
     }  else {
       break;
     }
   }
   return matchCount;
}
function buildValidServerRelativeUrl(simpleServerRelativeUrl){
   if(typeof simpleServerRelativeUrl != 'string' || simpleServerRelativeUrl==''){
     return '';
   }
   
   if(simpleServerRelativeUrl.charAt(0) != '/'){
     return  simpleServerRelativeUrl;
   }
   var validServerRelativeUrl='';
   var simpleSeverrelativeUrlNoParams='';
   if(simpleServerRelativeUrl.indexOf('?')!=-1){
     simpleSeverrelativeUrlNoParams=simpleServerRelativeUrl.substring(0,simpleServerRelativeUrl.indexOf('?'));
  } else {
     simpleSeverrelativeUrlNoParams=simpleServerRelativeUrl;
  }
  if(self.location.href.indexOf('/bikedealer_edit/') != -1 && simpleSeverrelativeUrlNoParams.indexOf('/bikedealer_edit/')==-1){
    validServerRelativeUrl ='/bikedealer_edit'+simpleServerRelativeUrl;
  } else if(self.location.href.indexOf('/bikedealer_qa/') != -1 && simpleSeverrelativeUrlNoParams.indexOf('/bikedealer_qa/')==-1){
    validServerRelativeUrl ='/bikedealer_qa'+simpleServerRelativeUrl;
  } else if(self.location.href.indexOf('/bikedealer_prod/') != -1 && simpleSeverrelativeUrlNoParams.indexOf('/bikedealer_prod/')==-1){
    validServerRelativeUrl ='/bikedealer_prod'+simpleServerRelativeUrl;
  } else {
     validServerRelativeUrl=simpleServerRelativeUrl;
  }
  return validServerRelativeUrl;
}
function getFullPath(basePath,relativePath) {
  var fullPath = basePath.substring(0,(basePath.lastIndexOf("/")+1));
  var regXHostPath = /((^(https{0,1}\:\/\/[^\/]*\/))|(^(file\:\/\/[^\:]*\:\/))|(^([a-z]+\:\\))|(^([a-z]+\:\/))|(^(\\\\))|(^(\/\/)))/i;
  if (regXHostPath.test(relativePath)) {
    fullPath = relativePath;
  } else {
    var regXGoingUp = /(\.\.\/)/g, goingUpArr = [], i;
    if (regXGoingUp.test(relativePath)) {
      goingUpArr = relativePath.match(regXGoingUp);
    }
    for (i=0; i<goingUpArr.length; ++i) {
      fullPath = fullPath.substring(0,(fullPath.lastIndexOf("/",(fullPath.length-2))+1));
    }
    fullPath += relativePath.replace(regXGoingUp,"");
  }
  return fullPath;
}
function setModuleHeader(hasLink) {
 var headerHTML="";
   if(hasLink){
     headerHTML='<a href="javascript:moveMenu();" style="position:relative;display:block;margin-top:1px;">'+moduleHeader+'</a>';
   } else {
    headerHTML='<span style="position:relative;display:block;margin-top:1px;">'+moduleHeader+'</span>';
  }
  if (typeof document.getElementsByTagName('div')['moduleHeaderContainer'] == 'object') {
    writeIntoLayer('moduleHeaderContainer',headerHTML);
    setVisibility('moduleHeaderContainer',1);
  } else {
    moveObject(document.getElementsByTagName('div')['naviClipArea'],null,0);
  }
}
/*change for seo*/
function closeMainNavigation() {
	if (window.frames && allowClose == true && (document.getElementById('mainNavi') || isMainnavigation)) {
  	if (parent.frames['frameContent'] && parent.frames['frameContent'].window.frames['mainNavigationIFrame'] && parent.frames['frameContent'].window.frames['mainNavigationIFrame'].menuOpen != false){
    	parent.frames['frameContent'].window.frames['mainNavigationIFrame'].closeMenu('close');
   	} else if (parent.frames['mainNavigationIFrame'] && parent.frames['mainNavigationIFrame'] && parent.frames['mainNavigationIFrame'].menuOpen != false) {
			parent.frames['mainNavigationIFrame'].closeMenu('close');
    }
	}
}
if (window.frames) {
  if (self.location.href.indexOf('https://')==-1) {
    document.onclick = closeMainNavigation;
  }
}
function download(fileUrl) {
  var downloadUrl=buildValidServerRelativeUrl(downloadJSP+'?file='+buildValidServerRelativeUrl(fileUrl));
  self.location.href=downloadUrl;
}

function downloadExternal(url) {
  var downloadUrl = buildValidServerRelativeUrl(downloadExternalJSP + '?file=' + buildValidServerRelativeUrl(url));
  self.location.href=downloadUrl;
}

function download_sync(fileUrl) {
  // download sync should only be used for files in sync folders
  // Some of the passed fileUrls will be server relative, without sync-folders, correct these, based on own url
  if(self.location.pathname.indexOf('/sync/') != -1){
  	// we are in synced page
  	if(fileUrl != null && fileUrl.indexOf('/sync/') == -1 && fileUrl.indexOf('..') == -1){
  		// add sync paths (first two of current page)
  		var splittedPath = self.location.pathname.split('/');
  		fileUrl = '/' + splittedPath[1] + '/' +splittedPath[2]+ fileUrl
  	}
  }
  var downloadUrl=buildValidServerRelativeUrl(fileUrl) + "?download=true";
  self.location.href=downloadUrl;
}

function writeFramesetTitle(titleText) {
}
function preloader(ticketId) {
  preLoadCounter[ticketId] = 0;
  preload[ticketId] = new Array();
  for(j=0;j<preLoadArray[ticketId].length;j++) {
    preload[ticketId][j]          = new Image();
    preload[ticketId][j].onabort  = function(){loadUpdate(ticketId,j);}
    preload[ticketId][j].onerror  = function(){loadUpdate(ticketId,j);}
    preload[ticketId][j].onload   = function(){loadUpdate(ticketId,j);}
    preload[ticketId][j].src      = preLoadArray[ticketId][j];
  }
}
function loadUpdate(ticketId,imageId) {
  preLoadCounter[ticketId]++;
  if(preLoadCounter[ticketId] == preLoadArray[ticketId].length) {
    preLoadReady(ticketId);
  }
}
function preLoadReady(ticketId) {
}
function showCo2() {
  setVisibility('co2HeaderOn',1);
  setVisibility('co2HeaderOff',0);
  setVisibility('co2body',1);
}
function hideCo2() {
  setVisibility('co2HeaderOn',0);
  setVisibility('co2HeaderOff',1);
  setVisibility('co2body',0);
}
function stopPlayingMp3(){}

//
// create invisible IFrame object
//
var IFrameObj;
function createPageIframe(args) {
  if (!document.createElement) {return true};
  var IFrameDoc;
  var iFrameUrl = args;
  if (!IFrameObj && document.createElement) {
    // create the IFrame and assign a reference to the
    // object to global variable IFrameObj.
    // this will only happen the first time 
    // createPageIframe() is called
   try {
      var tempIFrame=document.createElement('iframe');
      tempIFrame.setAttribute('id','HiddenIFrame');
      tempIFrame.style.border='0px';
      tempIFrame.style.width='0px';
      tempIFrame.style.height='0px';
      IFrameObj = document.body.appendChild(tempIFrame);
      
      if (document.frames) {
        // this is for IE5 Mac, because it will only
        // allow access to the document object
        // of the IFrame if we access it through
        // the document.frames array
        IFrameObj = document.frames['HiddenIFrame'];
      }
    } catch(exception) {
      // This is for IE5 PC, which does not allow dynamic creation
      // and manipulation of an iframe object. Instead, we'll fake
      // it up by creating our own objects.
      iframeHTML='\<iframe id="HiddenIFrame" style="';
      iframeHTML+='border:0px;';
      iframeHTML+='width:0px;';
      iframeHTML+='height:0px;';
      iframeHTML+='"><\/iframe>';
      document.body.innerHTML+=iframeHTML;
      IFrameObj = new Object();
      IFrameObj.document = new Object();
      IFrameObj.document.location = new Object();
      IFrameObj.document.location.iframe = document.getElementById('HiddenIFrame');
      IFrameObj.document.location.replace = function(location) {
        this.iframe.src = location;
      }
    }
  }
  
  if (navigator.userAgent.indexOf('Gecko') !=-1 && !IFrameObj.contentDocument) {
    // we have to give NS6 a fraction of a second
    // to recognize the new IFrame
    setTimeout('createPageIframe()',10);
    return false;
  }
  
  if (IFrameObj.contentDocument) {
    // For NS6
    IFrameDoc = IFrameObj.contentDocument; 
  } else if (IFrameObj.contentWindow) {
    // For IE5.5 and IE6
    IFrameDoc = IFrameObj.contentWindow.document;
  } else if (IFrameObj.document) {
    // For IE5
    IFrameDoc = IFrameObj.document;
  } else {
    return true;
  }
  
  IFrameDoc.location.replace(iFrameUrl);
  return false;
}
// end create iframe

// disable select-list-entries by dbl-click (in liveEdit-dialogs), if there is no multiple selectoption
function disableSelection( pFormField ){
  if( typeof(document["sel_" + pFormField.name] ) != 'undefined' && pFormField.selectedIndex == document["sel_" + pFormField.name] ) {
    pFormField.selectedIndex = -1;
  }
  document["sel_" + pFormField.name] = pFormField.selectedIndex;
}


// copied from bmw.com for some synced pages in showroom
function setElementClass(elementTagName, currentClass, newClass) {
	for (var i = 0; i < document.getElementsByTagName(elementTagName).length; i++) {
		if(document.getElementsByTagName(elementTagName)[i].className == currentClass) {
			document.getElementsByTagName(elementTagName)[i].className = newClass;
		}
	}
}




//Methods to get dealer specific topics from hostname START

function getTopicsFromHost(){
  var host = self.location.hostname;
  var path = self.location.pathname;
  var result = null;
  
  // host = "www.osaka.bmw.jp";
  // path = "/sync/showroom_rebrush/se/sv/newvehicles";
  if (self.location.search.indexOf("debug") > -1) {
  //  alert(host);
    host = self.location.hostname;
    path = self.location.pathname;
    alert(path);
  //  alert(host);
  }
  // Location in showroom looks like this: 
  // http://ah-funke.bmw.de/sync/showroom/de/de/newvehicles/...
  // http://nl-muenchen.bmw.de/sync/showroom/de/de/newvehicles/...
  // http://www.goteborg.bmw.se/sync/showroom/se/sv/newvehicles
  // http://oslo.stenshagen.bmw.no/sync/showroom/no/no/newvehicles
  
  // domains germany nl_
  if(host.search(/nl-.*\.bmw\..*/) > -1){
    result = host.replace(/nl-(.*)\.bmw\..*/, "nl_$1"); 
  // domains germany ah_
  } else if(host.search(/ah-.*\.bmw\..*/) > -1){
    result = host.replace(/ah-(.*)\.bmw\..*/, "ah_$1"); 
  // domains japan standard
  } else if(host.search(/www\.(.*)\.bmw\..*\..*/) > -1){
    result = host.replace(/www\.(.*)\.bmw\..*\..*/, "$1"); 
  // domains standard
  } else if(host.search(/www\.(.*)\.bmw\..*/) > -1){
    result = host.replace(/www\.(.*)\.bmw\..*/, "$1"); 
  // domains norway
  } else if(host.search(/(.*)\.(.*)\.bmw\..*/) > -1){
    result = host.replace(/(.*)\.(.*)\.bmw\..*/, "$1"+"-"+"$2"); 
  // domains standard w/o www
  } else if(host.search(/(.*)\.bmw\..*/) > -1){
    result = host.replace(/(.*)\.bmw\..*/, "$1"); 
  // domains japan specific
  } else if(host.search(/www\.(.*)\.co\.jp/) > -1){
    result = host.replace(/www\.(.*)\.co\.jp/, "$1"); 
  // domains japan specific
  } else if(host.search(/www\.(.*)\..*/) > -1){
    result = host.replace(/www\.(.*)\..*/, "$1"); 
  }
  
  result = path.replace(/\/sync\/showroom_rebrush\/(.*?)\/(.*?)\/.*/,"$1/"+result+"/$2");
  if (self.location.hostname.indexOf("liintra")>-1) {
    result = "se/dealer_master/sv";
  }
  if (self.location.hostname.indexOf("li0412")>-1) {
    result = "de/ah_interone/de";
  }
  return result.split('/');
}

function getCountryTopicFromHost(){
  var topics = getTopicsFromHost();
  return topics[0];
}

function getDealerTopicFromHost(){
  var topics = getTopicsFromHost();
  return topics[1];
}

function getLanguageTopicFromHost(){
  var topics = getTopicsFromHost();
  return topics[2];
}

function getCountryDealerLanguageTopicFromHost(){
   var topics = getTopicsFromHost();
   return '/'+topics[0]+'/'+topics[1]+'/'+topics[2];
}

function getCountryNSCAdminLanguageTopicFromHost(){
   var topics = getTopicsFromHost();
   return '/'+topics[0]+'/_nsc_admin/'+topics[2];
}

// Methods to get dealer specific topics from hostname END

  var prefix = "";
  if (self.location.href.indexOf('/bikedealer_edit/') != -1) {
    prefix = "/bikedealer_edit";
  } else if (self.location.href.indexOf('/bikedealer_qa/') != -1) {
    prefix = "/bikedealer_qa";
  } else if (self.location.href.indexOf('/bikedealer_prod/') != -1) {
    prefix = "/bikedealer_prod";
  }


// SEO-specific 
function changeLinksAccordingToStage(){
  if (prefix != "") {
    divsToBeAltered.push("mainNavigationContainer");
    divsToBeAltered.push("metaNavigationText");
    divsToBeAltered.push("metaNavigationMax");
    for (var x = 0; x < divsToBeAltered.length; x++) {
      if (document.getElementById(divsToBeAltered[x]) && document.getElementById(divsToBeAltered[x]) != null && document.getElementById(divsToBeAltered[x]).getElementsByTagName('a').length != 0) {
        
          for (var i = 0; i < document.getElementById(divsToBeAltered[x]).getElementsByTagName('a').length; i++) {
            evaluatedLink = document.getElementById(divsToBeAltered[x]).getElementsByTagName('a')[i].href;
            if (evaluatedLink.indexOf('javascript:') == -1 && evaluatedLink != '' && evaluatedLink.indexOf(prefix) == -1) {
              toBeReplaced = "http://" + window.location.hostname;
              document.getElementById(divsToBeAltered[x]).getElementsByTagName('a')[i].href = evaluatedLink.replace(toBeReplaced, prefix);
            }
          }
     
        for (var i = 0; i < document.getElementById(divsToBeAltered[x]).getElementsByTagName('img').length; i++) {
          evaluatedLink = document.getElementById(divsToBeAltered[x]).getElementsByTagName('img')[i].src;
          toBeReplaced = "http://" + window.location.hostname;
          if (evaluatedLink.indexOf(prefix) == -1) {
            document.getElementById(divsToBeAltered[x]).getElementsByTagName('img')[i].src = evaluatedLink.replace(toBeReplaced, prefix);
          }
        }
      }
    }
  }
  changeLinksAccordingToStageDone = true;
}


/** This method removes a single class from the given object
 * @param {DOMElement} obj defines the element to remove the class from
 * @param {String} cssClass is the name of the class to be removed
 */
function removeClassName(obj, cssClass){
  if (hasClassName(obj, cssClass)) {
    obj.className = obj.className.replace(new RegExp(cssClass), '');
  }
}
/** This method replaces a single class of the given object with a new class
 * @param {DOMElement} obj defines the element to replace the class from
 * @param {String} oldCssClass is the name of the class to be replaced
 * @param {String} newCssClass is the name of the class will be added instead
 */
function replaceClassName(obj, oldCssClass, newCssClass){
  if (hasClassName(obj, oldCssClass)) {
    obj.className = obj.className.replace(new RegExp(oldCssClass), newCssClass);
  }
}
/** This method checks if the given objects has a specific class defined
 * @param {DOMElement} obj defines the element to check for the class
 * @param {String} cssClass is the name of the class to look for
 * @return {Boolean}
 */
function hasClassName(obj, cssClass){
  return (obj.className.indexOf(cssClass) != -1);
}
/** This method adds a class to a specific objects
 * @param {DOMElement} obj defines the element to add the class
 * @param {String} cssClass is the name of the class to add
 */
function addClassName(obj, cssClass){
  if (!hasClassName(obj, cssClass)) {
    obj.className += ' ' + cssClass;
  }
}

//set cookie for navigations
function getNavigationDetails(){
var cookieName = "BMWDealerNavigation"
var cookieValue1 = "stage:";
var cookieValue2 = "country:";
var cookieValue3 = "dealer:";
var cookieValue4 = "language:";
    if( confCountryTopic != null && confDealerTopic != null && confLanguageTopic != null){
      cookieWert1 = "stage:" + prefix;
      cookieWert2 = "country:" + confCountryTopic;
      cookieWert3 = "dealer:" + confDealerTopic;
      cookieWert4 = "language:" + confLanguageTopic;
    }
var cookieValue = cookieWert1+";"+cookieWert2+";"+cookieWert3+";"+cookieWert4+";";
setCookie(cookieName, cookieValue, "Sun, 31-Dec-2100 00:00:00 GMT", "/");
}

var cookieHosts = /^(http\:\/\/)(wcms30\.bmw)|(dealerorigin\.bmw)|(partnerorigin\.bmw)|(liintra)|(li0412.muc:5601)|(www8i\.muc)/g;
if(self.location.href.indexOf('/sync/') < 0 && cookieHosts.test(self.location.href)){
  getNavigationDetails();
}

/** Fix display problems with the bottom navigation with small screen resolutions
 *  onResize-Action
 */
function checkBottomNavi() {
  var currentWindowWith = getWindowInformation("winWidth");
  if(currentWindowWith < 982) {
    document.getElementById('metaNavigationInline').style.width = currentWindowWith + "px";
  }
  else {
    document.getElementById('metaNavigationInline').style.width = "982px";
  }
}

/***/
var videoTeasers = [];
var currentVideoTeaser = false;
function showVideoTeaser(videoTeaserId, videoTeaserWidth, videoTeaserHeight, layerTop, layerLeft){
  currentVideoTeaser = "videoTeaser" + videoTeaserId;
  var videoTeaser = new SWFObject(videoTeaserFlashWrapper, "videoTeaser" + videoTeaserId + "FlashID", videoTeaserWidth, videoTeaserHeight + 16, "8.0.22", "#ffffff");
  videoTeaser.addParam("quality", "high");
  videoTeaser.addParam("allowScriptAccess", "always");
  videoTeaser.addParam("wmode", "transparent");
  videoTeaser.addVariable("prm_contentgetter", "videoTeaserGetContent");

  var originalObj = document.getElementById(currentVideoTeaser);
  var clonedObj = originalObj.cloneNode(true);
  originalObj.parentNode.removeChild(originalObj);
  document.body.appendChild(clonedObj);
  videoTeaser.write("videoTeaser" + videoTeaserId + "Player");
  setVisibility("videoTeaser" + videoTeaserId, 1, 'block');
}
/***/
function videoTeaserGetContent(){
  if (currentVideoTeaser) {
    return videoTeasers[currentVideoTeaser];
  }
}
/**
 * @param {String} fileName
 * @param {Number} videoStatus
 */
function videoTeaserTracking(fileName, videoStatus){
  var trackingUrl = self.location.href.substring(0, self.location.href.lastIndexOf("/"));
  var pageName = self.location.href.substring(self.location.href.lastIndexOf("/") + 1, self.location.href.lastIndexOf("."));
  var flvName = fileName.substring(fileName.lastIndexOf("/") + 1, fileName.lastIndexOf("."));
  trackingUrl = trackingUrl + "/" + pageName + "_video_" + flvName + "_" + videoStatus + ".html";
  if (confTrackingEnabled) {
    trackAbsolute(trackingUrl, '', true);
  }
}


if (self.location.href.indexOf("/bikedealer_edit/" > -1) && navigator.appName.indexOf("Internet Explorer") > -1) {
  window.attachEvent("onload", liveEditToolBoxHack);
}

function liveEditToolBoxHack() {
  if(document.getElementById("LETB")) {
    var originalObj = document.getElementById("LETB");
    var clonedObj = originalObj.cloneNode(true);
    originalObj.parentNode.removeChild(originalObj);
    document.body.appendChild(clonedObj);

    originalObj = document.getElementById("LETBhider");
    clonedObj = originalObj.cloneNode(true);
    originalObj.parentNode.removeChild(originalObj);
    document.body.appendChild(clonedObj);
  }
}

function setCurtain(mode){
  if ((useCurtain) && (useCurtain == "true")) {
    if (mode == 1) {
      setVisibility(document.getElementById('iFrameContainer'), 0);
      moveObject(document.getElementById('iFrameContainer'), ((window.screen.width * 2) * (-1)));
      setVisibility(document.getElementById('curtain'), null, 'block');
    } else {
      setVisibility(document.getElementById('curtain'), null, 'none');
      if (typeof leftPos != 'undefined') {
        moveObject(document.getElementById('iFrameContainer'), leftPos);
      } else {
        moveObject(document.getElementById('iFrameContainer'), 0);
      }
      setVisibility(document.getElementById('iFrameContainer'), 1);
    }
  }
}