var g_homemenu_hl_fontcolor = "rgb(204, 0, 0)";
var g_homemenu_hl_background_color = "rgb(255,255,255)";
var g_homemenu_hl_background_color_Level5 = "rgb(255,255,255)";
var g_homemenu_ll_fontcolor_level0 = "rgb(255,255,255)";
var g_homemenu_ll_fontcolor_level1 = "rgb(0, 0, 0)";
var g_homemenu_ll_background_color = "transparent";
var g_homemenu_ll_background_image_level0 = "url(/Images/arrow-white.gif)";
var g_homemenu_ll_background_image_level1 = "url(/Images/arrow-gray.gif)";
var g_jdpowerphase = "none";

var g_psyma_navi_clicked = null;

// var g_timeout = -1;
var g_timeout = 1;
/* var g_timeoutTime = 80; */
var g_timeoutTime = 250; 
var g_openZoom = 0;
var g_openKnowledgeBase = 0;
var g_imageNr = 1;
var g_req;
var g_is_home = false;

var g_pageWidth = 839;
var g_initHome = false;
var g_timeoutHide1 = 0;
var g_timeoutHide2 = 0;
var g_timeoutHide3 = 0;
var g_timeoutHide4 = 0;
var g_timeoutHead = 0;
var g_currentNav1 = "";
var g_currentNav2 = "";
var g_currentNav3 = "";
var g_currentNav4 = "";

var g_currentHi1 = "";
var g_currentHi2 = "";
var g_currentHi3 = "";
var g_currentHi4 = "";

var G_MAXSUBLAYERS = 16;

var g_blackValue = 0;
var g_blackTimeout = 0;
var g_navShadeMax = .35;

var g_currentModelLink = '';
var g_echoCount = 0;
var g_is_opera = false;
var g_is_ie = false;
var g_is_ie5 = false;
var g_is_ie5_5 = false;
var g_is_ie6 = false;
var g_is_safari = false;
// var g_is_macmoz = false; // mozilla on mac has flash problems on the homepage.
var g_is_mac = false;
var g_is_linux = false;
var g_contextDebug = "";
var g_fallbackImage = "";

var g_newWinFocus;

//global control variables for flash homepage.

var g_useFlashHomepage = true; // turns flash on homepage on/off globally.

//set this in initFlashHomepage() in the switch statement to "true", if the corresponding pool has a different fallback image than the default.jpg.
// also, copy the [pool].jpg into the fallback images directory.
var g_flashHPFallbackOverride = false;


var g_currentKBase = null;

$(document).ready(function() {
    initAll();
});

function initAll()
{
    var sClass = "";
    if (document.body.className) {
        sClass = document.body.className;
    }
    else {
        sClass = document.body.getAttribute("class");
    }
    if (sClass != undefined) {
        g_is_home = sClass.indexOf("home") >= 1;
    }
    else {
        g_is_home = false;
    }
    
    positionFooter();

    var noteConflict = false;
    sniffAll();
    if (document.getElementById) {
        g_canHandleTransparency = !g_is_ie5;
    }
    else if (noteConflict) {
        gotoUrl("/browser.htm");
    }
    if (g_is_home) {
        initHome();
		initFlashHomepage(sClass); //check if we want to load a flash animation on the homepage
    }
    checkKBase();
    HideIfLoggedIn("ifLoggedOut");
    ShowIfLoggedIn("ifLoggedIn");
    
    initGallerySubtitles();
}


function checkKBase() {
    // setup kBase link behaviour
    $('ul.galleryKBase li.kbase a,ul.knowledgeBases li.kbase a').bind('click', function(e) {
        var itemIndex = $('ul.galleryKBase li.kbase a').index($(this));
        log("kbase clicked. itemIndex: " + itemIndex);
        clickKnowledgebase($(this).attr("href"), itemIndex);
        e.preventDefault(); // don't really click on the <a>.
    });

    // if there is a direct kbase query,
    // open it.
    var query = getQueryString();
    if (query.match(/kbase=/)) {
        var kbaseUrl = query.substring(6);
        clickKnowledgebase(kbaseUrl, null);
    }
}


function getQueryString() {
    return window.location.search.substring(1);
}

function getQueryVariable(qv) {
    var pairs = getQueryString().split("&");
    for (i = 0; i < pairs.length; i++) {
        var pair = pairs[i].split("=");
        if (pair[0] == qv) {
            return pair[1];
        }
    }
    return '';
}


function clickKnowledgebase(sUrl, itemIndex) {
    if (sUrl == '') return;
    log("clickKnowledgebase entered.");
    if (g_currentKBase == null || (g_currentKBase != null && !g_currentKBase.isOpen)) {
        g_currentKBase = new KBase();
    }
    if (itemIndex >= 0) g_currentKBase.currentItemIndex = itemIndex;
    g_currentKBase.open(sUrl, itemIndex);
}



function initFlashHomepage(bodyClass)
{	
	var poolName = getPoolName().toLowerCase();
	
	// override these variables in case of deviation in the switch statement below.
	var timeOut = 2480;
	var flashName = "default.swf";
	var poolHasFlashHP = true;
	
	var claimPool;
	var claimId = "homepageteaser-cayenne-momentum-claim";
	var claimLang = "none";
	var claimLink = "/all/momentum/" + poolName + ".aspx";

	
	
	switch (poolName) {
		case "usa":
			claimPool = "uk";
			break;
		case "canada":
			claimPool = "uk";
			break;
		case "germany":
			claimPool = "germany";
			break;
		case "uk":
			claimPool = "uk";
			break;
		case "france":
			claimPool = "france";
			break;
		case "spain":
			claimPool = "spain";
			break;
		case "italy":
			claimPool = "italy";
			break;
		case "latin-america-en":
			claimPool = "uk";
			break;
		case "latin-america-es":
			claimPool = "spain";
			break;
		case "australia":
			claimPool = "uk";
			break;
		case "middle-east":
			claimPool = "uk";
			break;
		case "pap":
			claimPool = "uk";
			break;
		case "international":
			claimPool = "uk";
			break;
		case "portugal":
			claimPool = "uk";
			break;			
		case "russia":
			claimPool = "russia";
			break;
		case "china":
			claimLang = getPoolLang();
			switch (claimLang)
			{
				case "zh":
					claimPool = "china";
					claimId = "homepageteaser-cayennemomentum-claim";					
					claimLink = "http://www.porsche.com/all/momentum/china.aspx";
					break;
				case "en":
					claimPool = "pag";
					claimId = "%5Buk%5Dhomepageteaser-cayenne-momentum-claim";
					claimLink = "http://www.porsche.com/all/momentum/china-en.aspx";
					break;
				default:
					claimPool = "china";
					claimId = "homepageteaser-cayennemomentum-claim";					
					claimLink = "http://www.porsche.com/all/momentum/china.aspx";
					break;
			}
			break;
		default:
			poolHasFlashHP = false;
			break;
	}
	var antiCacheSuffix = "?rid=20061201";
	var flashPath = "/all/media/flash/videos/homepage/" + flashName + antiCacheSuffix;
	
	if (g_useFlashHomepage && poolHasFlashHP)
	{
		var introElem = document.getElementById('introImage');
		if (introElem) {
			var introImg = introElem.getElementsByTagName("img")[0];
			if (introImg) {
				showFlash(flashPath, "introImage", "839", "440", 8, "#000", "loop=true,menu=true,quality=high,wmode=opaque", "pool=" + claimPool +  ",id=" + claimId + ",type=image,lang=" + claimLang + ",filetype=normal,claimlink=" + claimLink);
				if (timeOut > 0) {
					window.setTimeout("showHomepageNavigation()", timeOut);
				}
				else {
					showHomepageNavigation();
					// Der Claim ist im in der Flash enthalten..
				}
			}
		}
	}
	else
	{
		showHomepageNavigation();
		showHomepageClaim();
	}
	
}

// this is a porschewebsite hack and would probably not work in other cases..
// paints a grey border below the introImage div. 
// Used by the flash videos which are triggered on the same page by a button (not hmoepage).
function setIntroImageBorder() {
	var elm = document.getElementById('introImage');
	if (elm) {
		elm.style.borderBottom = 'solid 1px #CECECE';
		elm.style.width = '615px';
	}
}

/*
Flash Homepage functions
*/

// Implementation of an elementary document function. 
// Returns: an array of found dom elements
// OBSOLETE!! (this is a brute force method and is slooooow..)
// USE getElementsByClassName instead.
//function getElementsByClass(cls)
//{
//  var my_array = document.getElementsByTagName("*");
//  var retvalue = new Array();
//  var i;
//  var j;

//  for (i = 0, j = 0; i < my_array.length; i++)
//  {
//    var c = " " + my_array[i].className + " ";
//    if (c.indexOf(" " + cls + " ") != -1)
//      retvalue[j++] = my_array[i];
//  }
//  return retvalue;
//}

// Delivers an array of DOM Elements matching the input criteria
// 
// Returns: an array of found dom elements
function getElementsByClassName(strClass, strTag, objContElm) {
  strTag = strTag || "*";
  objContElm = objContElm || document;
  var objColl = (strTag == '*' && document.all && !window.opera) ? document.all : objContElm.getElementsByTagName(strTag);
  var arr = new Array();
  var delim = strClass.indexOf('|') != -1  ? '|' : ' ';
  var arrClass = strClass.split(delim);
  for (var i = 0, j = objColl.length; i < j; i++) {
    var arrObjClass = objColl[i].className.split(' ');
    if (delim == ' ' && arrClass.length > arrObjClass.length) continue;
    var c = 0;
    comparisonLoop:
    for (var k = 0, l = arrObjClass.length; k < l; k++) {
      for (var m = 0, n = arrClass.length; m < n; m++) {
        if (arrClass[m] == arrObjClass[k]) c++;
        if (( delim == '|' && c == 1) || (delim == ' ' && c == arrClass.length)) {
          arr.push(objColl[i]);
          break comparisonLoop;
        }
      }
    }
  }
  return arr;
}


// finds the first Element carrying the class name and changes its visibility.
function showHideByClassName(clsName, visible)
{
	
	var visibility = (visible == true) ? 'visible' : 'hidden';
	var display = (visible == true) ? 'block' : 'none';
	
	// var elm = getElementsByClass(clsName)[0];
	var elm = getElementsByClassName(clsName)[0];
	if (elm)
    {
		elm.style.visibility = visibility;
		elm.style.display = display;
    }
}


// this loads back the original Fallback-Image manually, and make the navi visible, in case the Flash animation fails to load.
function fallBackFromFlash(pool)
{
	var introImg = document.getElementById('introImage').getElementsByTagName("img")[0];
	var fbSrc;
	if (introImg) {
		if (g_flashHPFallbackOverride) {
			fbSrc = pool + ".jpg";
		}
		else {
			fbSrc = "default.jpg";
		}
		introImg.src = "/all/media/flash/videos/homepage/fallback/" + fbSrc;
	}
	showHomepageClaim();
	showHomepageNavigation();
}


//shows Navigation bar and shopping buttons
function showHomepageNavigation()
{
	// we don't use showHideClassByName here because of speed issues in IE6..
	// document.getElementById('topnav1').parentNode.style.visibility = 'visible';
	// getElementsByClassName("shoppingButtons", "span", document)[0].style.visibility = 'visible';
	// getElementsByClassName("shoppingShade", "div", document)[0].style.visibility = 'visible';
	showHideByClassName("homeNavigation", true);
	showHideByClassName('shoppingButtons', true);
	showHideByClassName("shoppingShade", true);
}
//hides Navigation bar and shopping buttons
function hideHomepageNavigation()
{
	showHideByClassName("homeNavigation", false);
	showHideByClassName("shoppingButtons", false);
	showHideByClassName("shoppingShade", false);
}

// makes the claim element invisible (flash loaded)
function hideHomepageClaim() {
	/*
	var claimElm = getHomepageClaim();
	claimElm.style.visibility = 'hidden';
	claimElm.style.display = 'none';
	*/
	$(".homeHead, #homeHead").hide();
}

// makes the claim element visible (no flash loaded)
function showHomepageClaim() {
/*
	var claimElm = getHomepageClaim();
	claimElm.style.visibility = 'visible';
	claimElm.style.display = 'block';
	*/
	$(".homeHead, #homeHead").show();
}
// returns the claim element to hide when loading the flash animation.
function getHomepageClaim() {
	return document.getElementById('homeHead');
}
// extracts pool name from the url. Nasty.. veery nasty hack, my love..
function getPoolName() {
	var url = window.location.href;
	var startIndex = url.indexOf(window.location.hostname);
	var str = url.substr(startIndex, url.length-1);
	retVal = str.split("/")[1];
	return retVal;
}

function getPoolLang() {
	// for importer pools
	var retVal = "";
	var url = window.location.href;
	var startIndex = url.indexOf(window.location.hostname);
	var str = url.substr(startIndex, url.length-1);
	var lang = str.split("/")[2];
	if (lang == "en" || lang == "zh" || lang == "de" || lang == "fr" || lang == "it" || lang == "nl")
		retVal = lang;
	return retVal;
	
}




function fitFrameFromParent(iHeight)
{
    addContextDebug("iHeight", iHeight);

    var elm = document.getElementById("mainframe");
    var footer = document.getElementById("footer");
    var search = document.getElementById("search");

    if (elm) {
        addContextDebug("enteredElm", true);
        elm.style.height = (iHeight + 40 + 140) + "px";
        if (search) { search.style.display = "none"; }
        footer.style.bottom = "-1px";
        if (search) { search.style.display = "block"; }
        addContextDebug("finishedElm", true);
    }
}

function fitFrameFromParentMax(iMinHeight)
{
    var elm = document.getElementById("mainframe");
    var footer = document.getElementById("footer");
    var search = document.getElementById("search");

    if (elm) {
		elm.style.height = 120 + "px";
      	var scrollHeight = document.body.scrollHeight;
	    var offsetHeight = document.body.offsetHeight;	
        var height = scrollHeight;
        if (offsetHeight>scrollHeight)
        {
          height = offsetHeight;
        }
		
		if (height < iMinHeight) height = iMinHeight;
		
		// Leave space for Footer 
		height -= 46;

        elm.style.height = (height) + "px";
        if (search) { search.style.display = "none"; }
        footer.style.bottom = "-1px";
        if (search) { search.style.display = "block"; }
		
		return height;
    }
}

function addContextDebug(sName, sValue)
{
    g_contextDebug += sName + "=" + sValue + "\r\n";
}

function showContextDebug()
{
    if (g_contextDebug != "") {
        alert(g_contextDebug);
    }
}

function positionFooter()
{
    var footer = document.getElementById("footer");
    var search = document.getElementById("search");
    
    if (!g_is_home) setDocumentSize();

    if (footer) { footer.style.bottom = "-1px"; }
    if (search) { search.style.bottom = "-1px"; }
}

function setDocumentSize() {
	var size = 350; //160 + 105 + 85;

	var elm = document.getElementsByTagName("a");
	
	if (elm) {
		for (i = 0; i < elm.length; i++){
			var className = elm[i].className;
			
			switch (true) {
				case containsStr(className, "navigationBelowHome"):
					size += 24;
				break;
				case containsStr(className, "subNavigationChapter"):
				case containsStr(className, "subSubNavigation"):
				case containsStr(className, "subSubNavigationActive"):								
					size += 20; // 1 line: 16, 2 lines: 31;					
				break;		
			}
		}
	}		

	var elm = document.getElementsByTagName("div");
	
	if (elm) {
		for (i = 0; i < elm.length; i++){
			if (elm[i].className == "content") {
				//elm[i].style.border = "1px solid red";
				elm[i].style.minHeight = size + "px";
				elm[i].style.height = size + "px";
				break;			
			}
		}
	}
}

function containsStr(s, find) {
	return (s.indexOf(find) != -1);
}

function overHome()
{
    if (g_openKnowledgeBase == 0 && !g_is_safari) {
        if (g_timeout != -1) { clearTimeout(g_timeout); }
        showNavHomeSub();
    }
}

function outHome()
{
    if (g_openKnowledgeBase == 0 && !g_is_safari) {
        g_timeout = setTimeout("hideNavHomeSub()", g_timeoutTime);
    }
}

function overNavHomeSub()
{
    if (g_timeout != -1) { clearTimeout(g_timeout); }
}

function outNavHomeSub()
{
    if (g_timeout != -1) { clearTimeout(g_timeout); }
    g_timeout = setTimeout("hideNavHomeSub()", g_timeoutTime);
}

function showNavHomeSub()
{
    showLr("navigationHomeSub");
    showLr("navigationShade");
    //setBackground("navigationHome", "rgb(242,242,242)");
}

function hideNavHomeSub()
{
    hideLr("navigationHomeSub");
    hideLr("navigationShade");
    //setBackground("navigationHome", "rgb(255,255,255)");
}

function setBackground(id, sBack)
{
    var elm = document.getElementById(id);
    if(elm)elm.style.backgroundColor = sBack;
}

/* DIV Popup */
g_divPopupOpen = 0;
g_divPopupShadeborder = 8;
g_divPopupContentBorder = 15;
g_divPopupNaviSpace = 30;
g_divPopupHasCloseButton = false;

function openDivPopup(sUrl, imgWidth, imgHeight)
{
  if (g_divPopupOpen == 0)
  {
    g_divPopupHasCloseButton = true;
    // magic numbers follow, do not try at home
    var divHeight = imgHeight + (g_divPopupContentBorder * 2) + g_divPopupNaviSpace;
    var divWidth = imgWidth + (g_divPopupContentBorder * 2);
    var shadeHeight = imgHeight + (g_divPopupContentBorder * 2) + (g_divPopupShadeborder * 2) + g_divPopupNaviSpace + 2;
    var shadeWidth = imgWidth + (g_divPopupContentBorder * 2) + (g_divPopupShadeborder * 2) + 2;

    var elmShade = document.getElementById("divPopupShade");
    var elmDivPop = document.getElementById("divPopup");
    elmShade.className = 'bannerlibShade';
    elmDivPop.className = 'bannerlib';

    var imgX = g_pageWidth / 2 - imgWidth / 2;
    var imgY = Math.round( (viewportGetHeight() - imgHeight)/2 ) + viewportGetScrollY();

    if (imgY < 0) { imgY = 0; }
    if (imgX < 0) { imgX = 0; }

    elmShade.style.left = (imgX - g_divPopupShadeborder) + "px";
    elmShade.style.top = (imgY - g_divPopupShadeborder) + "px";
    elmShade.style.width = shadeWidth + "px";
    elmShade.style.height = shadeHeight + "px";

    elmDivPop.style.left = imgX + "px";
    elmDivPop.style.top = imgY + "px";
    elmDivPop.style.height = divHeight + "px";
    elmDivPop.style.width = divWidth + "px";

    var elmCloseButton = document.getElementById("closeButtonDivPopup");
    if (elmCloseButton) {
      elmCloseButton.style.left = (imgWidth - 19) + "px";
    }

    g_divPopupOpen = sUrl;

    prepareFillDivPopup(sUrl);
  }
}




function getTextBetween(sAll, sStart, sEnd)
{
    var sPart = "";
    var posStart = sAll.indexOf(sStart);
    var posEnd = sAll.indexOf(sEnd);
    if (posStart >= 0 && posEnd >= 0 && posEnd > posStart) {
        sPart = sAll.substring(posStart + sStart.length, posEnd);
    }
    return sPart;
}

function clickZoomable(id, imgWidth, imgHeight)
{
    if (g_openZoom == 0)
    {
        var shadeborder = 8;

        var elmShade = document.getElementById("zoomImageShade");
        var elmImage = document.getElementById("zoomImage" + id);
        var elmCloseButton = document.getElementById("closeButton" + id);

        var imgX = g_pageWidth / 2 - imgWidth / 2;
        var imgY = Math.round( (viewportGetHeight() - imgHeight)/2 ) + viewportGetScrollY();

        if (imgY < 0) { imgY = 0; }
        // if (imgX < 0) { imgX = 0; }

        elmShade.style.left = (imgX - shadeborder) + "px";
        elmShade.style.width = (imgWidth + shadeborder * 2) + "px";
        elmShade.style.top = (imgY - shadeborder) + "px";
        elmShade.style.height = (imgHeight + shadeborder * 2) + "px";

        elmImage.style.left = imgX + "px";
        elmImage.style.top = imgY + "px";
        if (elmCloseButton) {
            elmCloseButton.style.left = (imgWidth - 19) + "px";
        }

        elmImage.style.display = "block";
        elmShade.style.display = "block";

        g_openZoom = id;
    }
}

function clickZoomed()
{
    hideLr("zoomImageShade");
    hideLr("zoomImage" + g_openZoom);
    g_openZoom = 0;
}

function showLr(id)
{
    var elm = document.getElementById(id);
    if (elm) {
        elm.style.display = "block";
    }
}

function hideLr(id)
{
    var elm = document.getElementById(id);
    if (elm) {
        elm.style.display = "none";
    }
}


function toggleLr(id)
{
    var elm = document.getElementById(id);
    if (!elm) return;
    
    if (elm.style.display != "block") showLr(id);
    else hideLr(id);
}



/* Expandable module */

function expandCollapse(id)
{
    var elm = document.getElementById("expandable_" + id);

    if (elm)
    {
        /* Hack alert -- footer will be hidden temporarily
        to recalculate bottom position correctly.
        */

        var footer = document.getElementById("footer");
        footer.style.display = "none";

        if (elm.style.height != "auto")
        {
            collapseAllElements();
            showElement(id);        
        }
        else
        {
            collapseElement(id);
        }

        positionFooter();
        footer.style.display = "block";
    }
}

function showElement(id) {
    var elm = document.getElementById("expandable_" + id);
    elm.style.height = "auto";

    var h3 = document.getElementById("expandableHead_" + id);
    if (h3) {                
        h3.style.backgroundColor = "rgb(102,102,102)";                 
        h3.style.color = "rgb(255,255,255)";              
        h3.style.backgroundImage = "url(/Images/arrow-lightgray-down.gif)";            
        h3.style.backgroundPosition = "9px 9px";
    }
}

function collapseElement(id) {
    var elm = document.getElementById("expandable_" + id);
    elm.style.height = "19px";

    var h3 = document.getElementById("expandableHead_" + id);
    if (h3) {
        h3.style.backgroundColor = "rgb(204,204,204)";                
        h3.style.color = "rgb(0,0,0)";
        h3.style.backgroundImage = "url(/Images/arrow-gray.gif)";          
        h3.style.backgroundPosition = "11px 7px";
    }
}

function collapseAllElements() {
    var i=1;
    do {
        var elm = document.getElementById("expandable_" + i);
        if (elm) collapseElement(i);
        i++;
    } while(elm);
}

function viewportGetHeight()
{
    var retval = 0;

    if (window.innerHeight)
        retval = window.innerHeight - 18;
    else if (document.documentElement && document.documentElement.clientHeight) 
        retval = document.documentElement.clientHeight;
    else if (document.body && document.body.clientHeight) 
        retval = document.body.clientHeight;

    return retval;    
}

function viewportGetWidth()
{
    var retval = 0;

    if (window.innerWidth)
        retval = window.innerWidth - 18;
    else if (document.documentElement && document.documentElement.clientWidth) 
        retval = document.documentElement.clientWidth;
    else if (document.body && document.body.clientWidth) 
        retval = document.body.clientWidth;

    return retval;    
}

function viewportGetScrollY()
{
    var retval = 0;

    if (typeof window.pageYOffset == "number")
        retval = window.pageYOffset;
    else if (document.documentElement && document.documentElement.scrollTop)
        retval = document.documentElement.scrollTop;
    else if (document.body && document.body.scrollTop) 
        retval = document.body.scrollTop; 
    else if (window.scrollY)
        retval = window.scrollY;

    return retval;
}

function showGalleryFlash(pool, movieFolder, bandwidth, flashParams)
{
    var elmImg = document.getElementById("galleryImage");
    if (elmImg) {
        g_fallbackImage = elmImg.src;
    }

    var url = "/all/media/flash/videoplayer.swf";
    showFlash(url, "galleryContent", "595", "317", "7", "#FFFFFF",
            "loop=true,menu=true,quality=high,wmode=opaque",
            "pool=" + pool + ",id=" + movieFolder + ",bandwidth=" + bandwidth + ",eventhandler=flashEnded," + flashParams);
}

function showGalleryPanoramaFlash(url, flashParams)
{
    var elmImg = document.getElementById("galleryImage");
    if (elmImg) {
        g_fallbackImage = elmImg.src;
    }
   
    showFlash(url, "galleryContent", "595", "317", "7", "#FFFFFF","loop=true,menu=true,quality=high,wmode=opaque","eventhandler=flashEnded," + flashParams);
}

function flashEnded()
{
    if (g_fallbackImage != "") {
        var elmContent = document.getElementById("galleryContent");
        elmContent.innerHTML = "<img src=\"" + g_fallbackImage + "\" alt=\"\" id=\"galleryImage\" />";
    }
}


function showFlash(url, id, width, height, version, bgcolor, playerparamstr, flashparamstr) {
    var flashElmId = id + "_flash";

    width = "" + width;
    height = "" + height;
    version = "" + version;

    var elm = document.getElementById(id) || getElementsByClassName(id)[0];
    if (!elm) {
        return;
    }

    var flashvars = JSONify(flashparamstr);
    var params = JSONify(playerparamstr);
    var attributes = false;

    params.bgcolor = bgcolor;
    params.align = "middle";

    var expressinstall = "/all/media/flash/expressInstall.swf";
    if (g_is_home) {
        expressinstall = false;
    }

    var playFlash = true; // on the homepage, if flash check fails, do not attempt to run  flash..

    if (g_is_home) {
        if (!swfobject.hasFlashPlayerVersion(version)) {
            // fall back to regular page (without flash)
            fallBackFromFlash(getPoolName());
            playFlash = false; // on the homepage, if flash check fails, do not attempt to run  flash..
        }
        else {
            // prepare the homepage before loading flash animation.
            hideHomepageNavigation();
            hideHomepageClaim();
        }
    }
    else {
        if ((swfobject.getFlashPlayerVersion().major + '') == '0') // no Flash installed
            playFlash = false;
    }


    // go
    if (playFlash) {
        elm.innerHTML = "<div id=\"" + flashElmId + "\"></div>";
        swfobject.embedSWF(url, flashElmId, width, height, version, expressinstall, flashvars, params, attributes);
    }
}

// parses a json string and returns an object.
function JSONify(str) {

    //alert("JSONify ing: " + str);
    if (str == undefined || str == null) return "{}";
    var json = "{";
    var trap = false;
    var params = str.split(",");
    for (var i = 0; i < params.length; i++) {
        var param = params[i].split("=");
        if (param[0] == undefined || param[0] == null || param[0] == "") {
            trap = true;
            continue;
        }
        else {
            if (i > 0 && !trap) {
                json += ",";
                trap = false;
            }
            json += param[0] + ":\"" + param[1] + "\"";
        }
    }
    json += "}";
    return eval('(' + json + ')');

}



/* Gallery module */

var g_lastNumber = 1;

function setImage(elm, n)
{
    if (g_lastNumber != n)
    {
        var lastElm = document.getElementById("thumbnail" + g_lastNumber);
        lastElm.className = "";
        lastElm.style.border = "1px solid #ccc";

        var thisElm = document.getElementById("thumbnail" + n);
        thisElm.className = "selected";
        thisElm.style.border = "1px solid rgb(153,0,0)";

        g_lastNumber = n;

        sHref = elm.href;
        document.getElementById("galleryImage").src = sHref;
        
        showGallerySubtitle(n);
        showGalleryClaim(n);
    }
    return false;
}

function setThumbnail(elm, n)
{
    if (g_lastNumber != n)
    {
        var lastElm = document.getElementById("thumbnail" + g_lastNumber);
        lastElm.className = "";
        lastElm.style.border = "1px solid #ccc";

        var thisElm = document.getElementById("thumbnail" + n);
        thisElm.className = "selected";
        thisElm.style.border = "1px solid rgb(153,0,0)";

        g_lastNumber = n;
    }

    return false;
}

function prevgalleryImage(img, imgMax)
{
    var lastElm = document.getElementById("thumbnail" + g_lastNumber);
    if (lastElm) {    
    	lastElm.className = "";
    	lastElm.style.border = "1px solid #ccc";
    }

    var n = --g_lastNumber;
    if (n < 1) { n = getMaxNumberGallery(); }

    var thisElm = document.getElementById("thumbnail" + n);
    if (thisElm) {     
	    thisElm.className = "selected";
	    thisElm.style.border = "1px solid rgb(153,0,0)";
	}

    var elm = document.getElementById("href" + n);
    sHref = elm.href;
    document.getElementById("galleryImage").src = sHref;

    g_lastNumber = n;
    
    showGallerySubtitle(n);
	showGalleryClaim(n);
	
    return false;
}

function nextgalleryImage()
{
    var lastElm = document.getElementById("thumbnail" + g_lastNumber);
    if (lastElm) {
	    lastElm.className = "";
	    lastElm.style.border = "1px solid #ccc";
    }

    var n = ++g_lastNumber;
    var max = getMaxNumberGallery();
    if (n > max) { n = 1; }

    var thisElm = document.getElementById("thumbnail" + n);
    if (thisElm) {    
	    thisElm.className = "selected";
	    thisElm.style.border = "1px solid rgb(153,0,0)";
	}

    var elm = document.getElementById("href" + n);
    sHref = elm.href;
    document.getElementById("galleryImage").src = sHref;

    g_lastNumber = n;
    
    showGallerySubtitle(n);
    showGalleryClaim(n);

    return false;
}

function initGallerySubtitles()
{
	var n = getGalleryItemNo();
	if (n == -1) n=1;
		
    var subtitles = document.getElementById("gallerySubtitles")               	
    if (subtitles) {
        subtitles.style.display = "block";
        showGallerySubtitle(n);
    }

	var claims = document.getElementById("galleryClaims")
    if (claims) {        
			        
	    claims.style.display = "block";
	    showGalleryClaim(n);	        
    }
}


function getGalleryItemNo() 
{
    var no = -1;
    
    var regex = /itemindex=(\d*)/;
    var result = regex.exec(document.URL);
    
    if (result != null) { 
        no = result[1]
    }            
    
    return no;          
}

function showGallerySubtitle(n)
{
    var subtitles = document.getElementById("gallerySubtitles");

    if (subtitles) {   
		var tabSubtitles = subtitles.getElementsByTagName("div");
		 	        		
		var tab = document.getElementById("gallerySubtitlesTab" + getGallerySubtitleTabNo());
		if (tab) 
		{
			tabSubtitles = tab.getElementsByTagName("div");	
			tab.style.display = "block";				
		}
						
		if (tabSubtitles) 
		{            
			for (var i = 0; i < tabSubtitles.length; i++) {
				tabSubtitles[i].style.display = (i == n - 1) ? "block" : "none";				
			}
		}
    }
}


function showGalleryClaim(n) {
    var claims = document.getElementById("galleryClaims");	   
    if (claims) 
    {    	
        var tabClaims = claims.getElementsByTagName("div");  
        
        var tab = document.getElementById("galleryClaimsTab" + getGallerySubtitleTabNo());
		if (tab) 
		{
			// zuerst nach Div suchen
			tabClaims = tab.getElementsByTagName("div");
			// 15.03.2006 by BU + MIP 
			// wenn kein <Div> vorhanden dann <Img> nehmen
			if (tabClaims.length == 0) {
				tabClaims = tab.getElementsByTagName("img");
			}
			tab.style.display = "block";				
		}
		          
        if (tabClaims) {            
            for (var i = 0; i < tabClaims.length; i++) {
                tabClaims[i].style.display = (i == n - 1) ? "block" : "none";                
            }
        }
    }    
}


function getGalleryClaimTab()
{   
    var claim = document.getElementById("galleryClaims");
	return claim;	
}


function getGallerySubtitleTab()
{    
    var tab = document.getElementById("gallerySubtitles");    
    return tab;          
}


function getGallerySubtitleTabNo()
{
    var no = 1;
    
    var regex = /tabindex=(\d)/;
    var result = regex.exec(document.URL);
    
    if (result != null) { 
        no = result[1]
    }            
    
    return no;          
}

function getMaxNumberGallery()
{
    var max = 0;
    for (var i = 50; i >= 1 && max == 0; i--) {
        var testElm = document.getElementById("thumbnail" + i);
        if (testElm) {
            max = i;
            break;
        }
    }

    return max;
}

function showWallpaper(img, iWidth, iHeight)
{
    gotoUrlNewWin(img);
}


/* Open Selection Shop item in a window */
function openSelectionShopItem(dept_id, pf_id)
{
	gotoUrlNewWinSizeScrollableWithMenu('http://shop.eu.porsche.com/germany/product2.asp?dept_id=' + dept_id + '&pf_id=' + pf_id + '&comefrom=teq911', 870, 700)
}

function openPDDSShop(poolId) {
	switch (poolId) {
		case "germany":
			gotoUrlNewWinSizeScrollableWithMenuR('http://shop.porsche.com/germany/',870,700);
			break;
		
		case "usa":
			openPDDSPopup('http://shop.us.porsche.com/usa/',false);
			break;
		
		case "uk":
			openPDDSPopup('http://shop.eu.porsche.com/uk/', false);
			break;
		
		case "france":
			openPDDSPopup('http://shop.eu.porsche.com/france/', false);
			break;

		case "italy":
			openPDDSPopup('http://shop.eu.porsche.com/italy/', false);
			break;

		case "australia":
			openPDDSPopup('http://shop.eu.porsche.com/australia/', false);
			break;
	}
}

function openPDDSPopup(s, isRedesign) {
	var sWidth
	var sHeight;
	var sOffset;
	
	var resizable = 'no';
	var locationbar = 'no';
	var toolbar = 'no';
	var menubar = 'no';

	if (isRedesign) {
		sWidth = 890;
		sHeight = 750;
		resizable = 'yes';
		locationbar = 'yes';
		toolbar = 'yes';
		menubar = 'yes';
	}
	else {
		sWidth = 890;
		sHeight = 725;
	}
		
	
    if (screen.height < 768) {
        if (sHeight > 450) sHeight = 430;
        if (sWidth > 783) sWidth = 790;
        sOffset = 0;
    }
    else if (screen.height < 1024) {
        if (sHeight > 550) sHeight = 550;
        sOffset = 10;
    }
    else {
        sOffset = 40;
    }


    newWin = window.open(s, "newWin" + getRandomInt(10000), "width=" + sWidth + ",height=" + sHeight + ",left=40,top=40,dependent=yes,location=" + locationbar + ",menubar=" + menubar + ",toolbar=" + toolbar + ",resizable=" + resizable + ",scrollbars=yes,status=no");
}


/* Windows module */

function configureCar(marketId)
{
    /* For new CC inner size is important, but gotoUrlNewWinSizeByName() calcs outer size */
    var sWidth = 980;
    var sHeight = 680;
    sWidth -= g_is_ie ? 15 : 20;
    sHeight -= 25;
	
	/* R.W. Anpassung für den Intranet Server, um unterschiedliche CC URL's auszuliefern.*/
	var HostName = "";
	if (window.location.hostname == "intranet.porsche.com") {
		HostName = "http://cc.intranet.porsche.com";
	} else {
		HostName = "http://cc.porsche.com";
	}
		
    switch (marketId) {
        case "de":
            gotoUrlNewWinSizeByName(HostName + "/icc_euro/ui/pva/index.jsp?sprache=de&modelRange=null", sWidth, sHeight, "PVA");
            break;

        case "us":
            gotoUrlNewWinSizeByName(HostName + "/pva/ui/pva/index.jsp?sprache=us&modelRange=null", sWidth, sHeight, "PVA");
            break;

        case "ca":
            gotoUrlNewWinSizeByName(HostName + "/pva_new/ui/pva/index.jsp?sprache=ca&modelRange=null", sWidth, sHeight, "PVA");
            break;

        case "fr":
            gotoUrlNewWinSizeByName(HostName + "/icc_euro/ui/pva/index.jsp?sprache=fr&modelRange=null", sWidth, sHeight, "PVA");
            break;

        case "it":
            gotoUrlNewWinSizeByName(HostName + "/icc_euro/ui/pva/index.jsp?sprache=it&modelRange=null", sWidth, sHeight, "PVA");
            break;

        case "en":
            gotoUrlNewWinSizeByName(HostName + "/pva/ui/pva/index.jsp?sprache=en&modelRange=null", 960, 625, "PVA");
            break;

        case "sp":
            gotoUrlNewWinSizeByName(HostName + "/icc_euro/ui/pva/index.jsp?sprache=sp&modelRange=null", sWidth, sHeight, "PVA");
            break;

        case "ae":
            gotoUrlNewWinSizeByName(HostName + "/pva/ui/pva/index.jsp?sprache=ae&modelRange=null", 960, 625, "PVA");
            break;
            
        case "mx":
            gotoUrlNewWinSizeByName(HostName + "/pva/ui/pva/index.jsp?sprache=mx&modelRange=null", 960, 625, "PVA");
            break;
            
        case "sg":
            gotoUrlNewWinSizeByName(HostName + "/pva/ui/pva/index.jsp?sprache=sg&modelRange=null", 960, 625, "PVA");
            break;

        case "hk":
            gotoUrlNewWinSizeByName(HostName + "/pva/ui/pva/index.jsp?sprache=hk&modelRange=null", 960, 625, "PVA");
            break;
		
        case "me":
            gotoUrlNewWinSizeByName('/all/transitional/middle-east/models/countryselector/default.htm', sWidth, sHeight, 'PVA');
            break;
		
        case "jp":
            gotoUrlNewWinSizeByName(HostName + "/pva/ui/pva/index.jsp?sprache=pj&modelRange=null", 960, 625, 'PVA');
            break;

        default:
            gotoUrlNewWinSizeByName(HostName + "/icc_euro/ui/pva/index.jsp?sprache=" + marketId + "&modelRange=null", sWidth, sHeight, "PVA");
            break;

    }
}

/*
Function compareModels
Description: 
	Wrapper for compareModelMulti with empty model parameters. Is mainly used to open the CM Popup from the shopping buttons.
Input: 
	marketId: name of the market to be loaded in compare models.
Output: void
*/
function compareModels(marketId) {
	compareModelMulti(marketId, '', '', '', true);
}

/*
Function compareModelWith
Description:
	Wrapper for compareModelMulti to Open compare models tool (select page) with the given market name and two models to be compared to each other. 
Input:
	marketId: market name
	model1: First model's id.
	model2: Second model's id.	
Output: void.	
*/
function compareModelWith(marketId, model1, model2) {
	compareModelMulti(marketId, model1, model2, '', false);
}


/*
Function compareModelMulti
Description:
	Opens a popup window of variable size. 
	to load the compare models page for a given market, and three model IDs.
	The size can be adjusted for each market (pool) by setting the oneSizeFitsAll to false 
	and defining windowSizeX and windowSizeY for each pool.
Input:
	marketId: market (pool) name to be opened in the compare models tool.
	model1: First model's id.
	model2: Second model's id.	
	model3: Third model's id.
	openSelect: true if Select page is to be opened, false if compare page.
	(If further models are to be added, make the necessary changes in the url "cmUrl" and the window sizes.)
Output: void.	
*/
function compareModelMulti(marketId, model1, model2, model3, openSelect) {
	windowSizeX = 1003;
	windowSizeY = 625;
	oneSizeFitsAll = true;

	if (openSelect) 
		cmPage = "Select"
	else
		cmPage = "Compare";
		
	// make the window sizes pool dependent, if desired.
	if (!oneSizeFitsAll)
		switch (marketId) {
			case "usa":
				windowSizeX = 1003;
				windowSizeY = 625;
				break;
			case "canada":
				windowSizeX = 975;
				windowSizeY = 625;
				break;
		}
	// create the window and load the url.
	cmUrl = "/all/comparemodels/" +cmPage + ".aspx?pool=" + marketId + "&model1=" + model1 + "&model2=" + model2 + "&model3=" + model3 + "";
	gotoUrlNewWinSize(cmUrl, windowSizeX, windowSizeY);
}


function gotoUrlNewWinSimple(s)
{
    log('gotoUrlNewWinSimple enhanced version');
    //newWin = window.open(s, "newWin" + getRandomInt(10000));
    var newWin = window.open('', "newWin" + getRandomInt(10000));
    newWin.document.location = s;
}

function gotoUrlNewWin(s)
{
    sWidth = 826;
    sHeight = 610;

    sWidth += 20;
    sHeight += 25;
    newWin = window.open(s, "newWin" + getRandomInt(10000), "width=" + sWidth + ",height=" + sHeight + ",left=40,top=40,dependent=yes,location=no,resizable=no,scrollbars=no,status=no");
}

function gotoUrlNewWinSize(s, sWidth, sHeight)
{
    sWidth += 20;
    sHeight += 25;
    newWin = window.open(s, "newWin" + getRandomInt(10000), "width=" + sWidth + ",height=" + sHeight + ",left=40,top=40,dependent=yes,location=no,resizable=no,scrollbars=no,status=no");
}

	
function gotoUrlNewWinSizeCloseOnBlur(s, sWidth, sHeight)
{
    sWidth += 20;
    sHeight += 25;
    g_newWinFocus = window.open(s, "newWinCloseOnBlur", "width=" + sWidth + ",height=" + sHeight + ",left=40,top=40,location=no,resizable=no,scrollbars=no,status=no");	   	   	
    g_newWinFocus.focus();	    
    
    window.onfocus = function()
    {
    	if (g_newWinFocus)
    	{
    		g_newWinFocus.close()
    		g_newWinFocus = null;	    	
    	}
    }
}		

function gotoUrlNewWinSizeScrollable(s, sWidth, sHeight)
{
    sWidth += 20;
    sHeight += 25;
    newWin = window.open(s, "newWin" + getRandomInt(10000), "width=" + sWidth + ",height=" + sHeight + ",left=40,top=40,dependent=yes,location=no,resizable=no,scrollbars=yes,status=no");
}


function gotoUrlNewWinSizeScrollableWithMenu(s, sWidth, sHeight)
{
    sWidth += 20;
    sHeight += 50;

    if (screen.height < 768) {
        if (sHeight > 450) sHeight = 430;
        if (sWidth > 783) sWidth = 790;
        sOffset = 0;
    }
    else if (screen.height < 1024) {
        if (sHeight > 550) sHeight = 550;
        sOffset = 10;
    }
    else {
        sOffset = 40;
    }

    newWin = window.open(s, "newWin" + getRandomInt(10000), "width=" + sWidth + ",height=" + sHeight + ",left=" + sOffset + ",top=" + sOffset + ",dependent=yes,location=yes,menubar=yes,toolbar=yes,resizable=no,scrollbars=yes,status=yes");
}

function gotoUrlNewWinSizeScrollableWithMenuR(s, sWidth, sHeight)
{
    sWidth += 20;
    sHeight += 50;

    if (screen.height < 768) {
        if (sHeight > 450) sHeight = 430;
        if (sWidth > 783) sWidth = 790;
        sOffset = 0;
    }
    else if (screen.height < 1024) {
        if (sHeight > 550) sHeight = 550;
        sOffset = 10;
    }
    else {
        sOffset = 40;
    }

    newWin = window.open(s, "newWin" + getRandomInt(10000), "width=" + sWidth + ",height=" + sHeight + ",left=" + sOffset + ",top=" + sOffset + ",dependent=yes,location=yes,menubar=yes,toolbar=yes,resizable=yes,scrollbars=yes,status=yes");
}


function gotoUrlNewWinDefaultSize(s)
{
    sWidth = 570;
    sHeight = 610;

    sWidth += 20;
    sHeight += 25;
    newWin = window.open(s, "newWin" + getRandomInt(10000), "width=" + sWidth + ",height=" + sHeight + ",left=40,top=40,dependent=yes,location=no,resizable=no,scrollbars=no,status=no");
}

function gotoUrlNewWinSizeCentered(s, iWidth, iHeight)
{
    iWidth += 20;
    iHeight += 25;    
    iLeft = Math.round((screen.width - iWidth) / 2);
    iTop = Math.round((screen.height - iHeight) / 2);
    newWin = window.open(s, "newWin" + getRandomInt(10000), "width=" + iWidth + ",height=" + iHeight + ",left=" + iLeft + ",top=" + iTop + ",dependent=yes,location=no,resizable=no,scrollbars=no,status=no");
}

function gotoUrlNewWinSizeScrollableResizeable(s, sWidth, sHeight)
{
    sWidth += 20;
    sHeight += 25;
    newWin = window.open(s, "newWin" + getRandomInt(10000), "width=" + sWidth + ",height=" + sHeight + ",left=40,top=40,dependent=yes,location=no,resizable=yes,scrollbars=yes,status=no");
}

function gotoUrlNewWinSizeByName(s, sWidth, sHeight, sName)
{
    sWidth += g_is_ie ? 15 : 20;
    sHeight += 25;
    newWin = window.open(s, sName, "width=" + sWidth + ",height=" + sHeight + ",left=40,top=40,dependent=yes,location=no,resizable=no,scrollbars=no,status=no");
}

function openLeanWin(sUrl, sWidth, sHeight)
{
    sWidth += 20;
    sHeight += 25;
    newWin = window.open(sUrl, "newWin" + getRandomInt(10000), "width=" + sWidth + ",height=" + sHeight + ",left=140,top=140,dependent=yes,location=no,resizable=no,scrollbars=no,status=no,menubar=no,toolbar=no");
}

function gotoUrlFullscreen(sUrl) {
	var sProps = "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,left=0,top=0,width=" + (screen.width - 10) + ",height=" + (screen.height - 55);	
	var site = window.open(sUrl,"porschemicrosite", sProps);
	site.focus();		
}

function gotoFormUrlNewWinSizeByName(refForm, sWidth, sHeight, sName)
{

    sHeight += 25;
    newWin = window.open('', sName, "width=" + sWidth + ",height=" + sHeight + ",left=40,top=40,dependent=yes,location=no,resizable=no,scrollbars=no,status=no");
	refForm.target=sName;
	return true;
}

function openModelAdvisor(siteId)
{
	var iWidth = 831;
	var iHeight = 503;
	window.open("/all/modeladvisor/" + siteId + ".aspx", "newWin" + getRandomInt(10000) , "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,left=" + Math.round((screen.width - iWidth) / 2) + ",top=" + Math.round((screen.height - iHeight) / 2) + ",,width=" + iWidth + ",height=" + iHeight);
}



function getRandomInt(max)
{
    return Math.round( Math.random() * (max-1) );
}


/* Ad-Tracker module */

function getAdTrackerNumber()
{
    var axel = Math.random() + "";
    var a = axel * 10000000000000;
    return a;
}



/* Home module */

function initHome()
{
    if (document.getElementById) {
        g_initHome = true;
    }
    // teaser bar scroller
    setupTeaserbar();
}

function bannerLinkToHi(sId)
{

    if (g_initHome)
    {
        var elm = document.getElementById(sId);
        if (elm)
        {
            elm.style.color = "#900";
            elm.style.backgroundImage = "url(/pools/pco/Images/arrow-red.gif)";
        }
    }

}

function bannerLinkToLo(sId)
{

    if (g_initHome)
    {
        var elm = document.getElementById(sId);
        if (elm)
        {
            elm.style.color = "rgb(102,102,102)";
            elm.style.backgroundImage = "url(/Images/arrow-gray.gif)";
        }
    }
}

function navShadeIn(level)
{

    if (g_initHome)
    {
        if (level == 1)
        {
            if (g_timeoutHide1 != 0) { clearTimeout(g_timeoutHide1); }
        }
        else if (level == 2)
        {
            if (g_timeoutHide1 != 0) { clearTimeout(g_timeoutHide1); }
            if (g_timeoutHide2 != 0) { clearTimeout(g_timeoutHide2); }
        }
        else if (level == 3)
        {
            if (g_timeoutHide1 != 0) { clearTimeout(g_timeoutHide1); }
            if (g_timeoutHide2 != 0) { clearTimeout(g_timeoutHide2); }
            if (g_timeoutHide3 != 0) { clearTimeout(g_timeoutHide3); }
        }
    }
}

function navShadeOut(level)
{

    if (g_initHome)
    {
        if (level == 1)
        {
            g_timeoutHide1 = setTimeout("hideNav(1,\"" + g_currentNav1 + "\",\"" + g_currentHi1 + "\")", g_timeoutTime);
        }
        else if (level == 2)
        {
            g_timeoutHide1 = setTimeout("hideNav(1,\"" + g_currentNav1 + "\",\"" + g_currentHi1 + "\")", g_timeoutTime);
            g_timeoutHide2 = setTimeout("hideNav(2,\"" + g_currentNav2 + "\",\"" + g_currentHi2 + "\")", g_timeoutTime);
        }
        else if (level == 3)
        {
            g_timeoutHide1 = setTimeout("hideNav(1,\"" + g_currentNav1 + "\",\"" + g_currentHi1 + "\")", g_timeoutTime);
            g_timeoutHide2 = setTimeout("hideNav(2,\"" + g_currentNav2 + "\",\"" + g_currentHi2 + "\")", g_timeoutTime);
            g_timeoutHide3 = setTimeout("hideNav(3,\"" + g_currentNav3 + "\",\"" + g_currentHi3 + "\")", g_timeoutTime);
        }
    }
}

function overNav(level, sName, sSelf)
{
    if (g_initHome)
    {
        if (level == 0 || level == "0")
        {
            echo("level in 0");

            if (g_timeoutHide1 != 0) { clearTimeout(g_timeoutHide1); }

            hideSubLayers(g_currentNav1);
            loliteLr(level, g_currentHi1);

            if (g_currentNav1 != "") { hideSubLayers(g_currentNav1); }
            if (g_currentHi1 != "") { loliteLr(level, g_currentHi1); }

            showNav(level + 1, sName, sSelf);
            g_currentNav1 = sName;
            g_currentHi1 = sSelf;            
        }
        else if (level == 1 || level == "1")
        {
            echo("level in 1");

            if (g_timeoutHide1 != 0) { clearTimeout(g_timeoutHide1); }
            if (g_timeoutHide2 != 0) { clearTimeout(g_timeoutHide2); }

            if (g_currentNav2 != "") { hideSubLayers(g_currentNav2); }
            if (g_currentHi2 != "") { loliteLr(level, g_currentHi2); }

            showNav(level + 1, sName, sSelf);
            g_currentNav2 = sName;
            g_currentHi2 = sSelf;
        }
        else if (level == 2 || level == "2")
        {
            echo("level in 2");

            if (g_timeoutHide1 != 0) { clearTimeout(g_timeoutHide1); }
            if (g_timeoutHide2 != 0) { clearTimeout(g_timeoutHide2); }
            if (g_timeoutHide3 != 0) { clearTimeout(g_timeoutHide3); }

            if (g_currentNav3 != "") { hideSubLayers(g_currentNav3); }
            if (g_currentHi3 != "") { loliteLr(level, g_currentHi3); }

            showNav(level + 1, sName, sSelf);
            g_currentNav3 = sName;
            g_currentHi3 = sSelf;            
        }
        else if (level == 3 || level == "3")
        {
            echo("level in 3");

            if (g_timeoutHide1 != 0) { clearTimeout(g_timeoutHide1); }
            if (g_timeoutHide2 != 0) { clearTimeout(g_timeoutHide2); }
            if (g_timeoutHide3 != 0) { clearTimeout(g_timeoutHide3); }
            if (g_timeoutHide4 != 0) { clearTimeout(g_timeoutHide4); }

            if (g_currentNav4 != "") { hideSubLayers(g_currentNav4); }

            showNav(level + 1, sName, sSelf);
            g_currentNav4 = sName;
        }
    }
}

function loadImage(sName, sUrl)
{ 
    var elem = document.getElementById(sName + "_image");
    if (elem) elem.src = sUrl;
}

function outNav(level)
{
    if (g_initHome)
    {
        if (level == 0 || level == "0")
        {
            echo("level out 0");
            g_timeoutHide1 = setTimeout("hideNav(1,\"" + g_currentNav1 + "\",\"" + g_currentHi1 + "\")", g_timeoutTime);      
        }
        else if (level == 1 || level == "1")
        {
            echo("level out 1");
            g_timeoutHide1 = setTimeout("hideNav(1,\"" + g_currentNav1 + "\",\"" + g_currentHi1 + "\")", g_timeoutTime);
            g_timeoutHide2 = setTimeout("hideNav(2,\"" + g_currentNav2 + "\",\"" + g_currentHi2 + "\")", g_timeoutTime);
        }
        else if (level == 2 || level == "2")
        {
            echo("level out 2");
            g_timeoutHide1 = setTimeout("hideNav(1,\"" + g_currentNav1 + "\",\"" + g_currentHi1 + "\")", g_timeoutTime);
            g_timeoutHide2 = setTimeout("hideNav(2,\"" + g_currentNav2 + "\",\"" + g_currentHi2 + "\")", g_timeoutTime);
            g_timeoutHide3 = setTimeout("hideNav(3,\"" + g_currentNav3 + "\",\"" + g_currentHi3 + "\")", g_timeoutTime);
        }
        else if (level == 3 || level == "3")
        {
            echo("level out 3");
            g_timeoutHide1 = setTimeout("hideNav(1,\"" + g_currentNav1 + "\",\"" + g_currentHi1 + "\")", g_timeoutTime);
            g_timeoutHide2 = setTimeout("hideNav(2,\"" + g_currentNav2 + "\",\"" + g_currentHi2 + "\")", g_timeoutTime);
            g_timeoutHide3 = setTimeout("hideNav(3,\"" + g_currentNav3 + "\",\"" + g_currentHi3 + "\")", g_timeoutTime);
            g_timeoutHide4 = setTimeout("hideNav(4,\"" + g_currentNav4 + "\",\"" + g_currentHi4 + "\")", g_timeoutTime);
        }
        else
        {
            echo("level out is else: " + level);
        }         
    }
}

function dimHeadline(doOn)
{         
    var elem = document.getElementById("homeHead");
    
    if (elem) {
        if (parseInt(elem.style.top.replace(/px/, ""),10) > 88) {   
            
                if (doOn)
                {
                    elem.style.MozOpacity = ".99";
                    elem.style.filter = "alpha(opacity=100)";
                }
                else
                {
                    elem.style.MozOpacity = ".40";
                    elem.style.filter = "alpha(opacity=40)";
                }
        }
    }
}

function showNav(level, sName, sSelf)
{
    dimHeadline(false);

    hiliteLr(level - 1, sSelf);
    var foundOne = showSubLayers(sName);
    if (foundOne)
    {
        if (g_canHandleTransparency)
        {
            var elm = document.getElementById("navshade" + level);
            showLr("navshade" + level);
        }
        else
        {
            var elm = document.getElementById("navshadeSimple" + level);
            showLr("navshadeSimple" + level);
        }
    }
    else
    {
        if (g_canHandleTransparency)
        {
            hideLr("navshade" + level);
        }
        else
        {
            hideLr("navshadeSimple" + level);
        }
    }     
}

function hideNav(level, sName, sSelf)
{
    if (level == 1) { g_timeoutHide1 = 0; g_currentNav1 = ""; g_currentSelf1 = ""; dimHeadline(true); }
    if (level == 2) { g_timeoutHide2 = 0; g_currentNav2 = ""; g_currentSelf2 = ""; }
    if (level == 3) { g_timeoutHide3 = 0; g_currentNav3 = ""; g_currentSelf3 = ""; }
    if (level == 4) { g_timeoutHide4 = 0; g_currentNav4 = ""; }

    loliteLr(level - 1, sSelf);

    if (g_canHandleTransparency)
    {
        hideLr("navshade" + level);
    }
    else
    {
        hideLr("navshadeSimple" + level);
    }

    hideSubLayers(sName);
}
function fadeAllOut(elem)
{
  if(elem == undefined)
    return;

  if(g_jdpowerphase == "none")
   return;

  var ID = elem.id
  var i = 0;
  var which = parseInt(ID.replace('link', '').replace('topnav', ''));
  for( ; i <= 10; i++)
  {
    if((i <= 4) && (which != i))
    {
      fadeOut('topnavlink' + i.toString());
    }
    if((i >= 5) && (which != i))
      fadeOut('topnavlink' + i.toString());
  }
}
function fadeAllIn(elem)
{
  if(elem == undefined)
    return;

  if(g_jdpowerphase == "none")
   return;

  var ID = elem.id
  var i = 0;
  var which = parseInt(ID.replace('link', '').replace('topnav', ''));
  for( ; i <= 10; i++)
  {
    if((i <= 4) && (which != i))
    {
      fadeIn('topnavlink' + i.toString());
    }
    if((i >= 5) && (which != i))
      fadeIn('topnavlink' + i.toString());
  }
}
function fadeOut(ID)
{
  var elem = document.getElementById(ID);
  if(elem)
  {
    elem.style.MozOpacity = ".5"; 
    elem.style.Opacity = ".5"; 
    elem.style.opacity = ".5"; 
    elem.style.filter = "Alpha(opacity=50, finishopacity=50, style=2)";
  }
}
function fadeIn(ID)
{
  var elem = document.getElementById(ID);
  if(elem)
  {
    elem.style.MozOpacity = "1.00"; // hack around weeeiiird bug which causes "1" to break NS7.02
    elem.style.Opacity = "1.00"; 
    elem.style.opacity = "1.00"; 
    elem.style.filter = "Alpha(opacity=100, finishopacity=100, style=2)";
  }
}

function hiliteLr(level, sName)
{
    var elem = document.getElementById(sName);
    if (elem)
    {
        if (level == 0 || level == "0")
        {
            //////////////////////
            // JD-Power 2008 03 Mouseover Workaround Hack
            //var itemNo = parseInt(sName.substring(sName.length - 1, sName.length));
            var itemNo = parseInt(sName.replace('topnavlink', '').replace('topnav', ''));
            if (itemNo >= 5)
            {
                elem.style.backgroundColor = g_homemenu_hl_background_color_Level5;
            }
            else
            {
                elem.style.backgroundColor = g_homemenu_hl_background_color;
            }
            if ((g_jdpowerphase == "200803") && (itemNo <= 4))
            {
                var topNavi = document.getElementById("topnav" + itemNo.toString()); 
                topNavi.style.backgroundImage = "none";
                topNavi.style.backgroundColor = "transparent"; //"#FFFFFF";
                elem.style.backgroundImage = "none";
                /***************************************/
                /* HG Weiß mit 1% Deckkraft, bei 0% löst IE7 sonst das mouseout Event wieder aus */
                elem.style.backgroundColor = "white"; 
                elem.style.MozOpacity = ".01"; 
                elem.style.Opacity = ".01"; 
                elem.style.opacity = ".01"; 
                elem.style.filter = "Alpha(opacity=1, finishopacity=1, style=2)"; /* 1% Deckkraft, bei 0% löst IE7 sonst das mouseout Event wieder aus */
                /***************************************/
            }
            else
            {
                elem.style.color = g_homemenu_hl_fontcolor; 
                if (! (elem.className.indexOf("final") >= 0) )
                {
                //elem.style.backgroundImage = "url(/pools/pco/Images/arrow-red.gif)";
                }
            }
            fadeAllOut(elem);
            //////////////////////
        }
        else
        {
            elem.style.color = g_homemenu_hl_fontcolor; //"rgb(204, 0, 0)";
            elem.style.backgroundColor = "#FFFFFF";
            if (! (elem.className.indexOf("final") >= 0) )
            {
                elem.style.backgroundImage = "url(/pools/pco/Images/arrow-red.gif)";
            }

            elem.style.MozOpacity = ".99"; // hack around weeeiiird bug which causes "1" to break NS7.02
            elem.style.Opacity = "1.00"; 
            elem.style.opacity = "1.00"; 
            elem.style.filter = "alpha(opacity=100)";
        }
    }
}

function loliteLr(level, sName)
{
    var elem = document.getElementById(sName);
    if (elem)
    {
        if (level == 0 || level == "0")
        {

            //////////////////////
            // JD-Power 2008 03 Mouseover Workaround Hack
            //var itemNo = parseInt(sName.substring(sName.length - 1, sName.length));
            var itemNo = parseInt(sName.replace('topnavlink', '').replace('topnav', ''));
			if (itemNo >= 5)
            {
                elem.style.backgroundColor = g_homemenu_ll_background_color; 
            }
			
            if ((g_jdpowerphase == "200803") && (itemNo <= 4))
            {
                var topNavi = document.getElementById("topnav" + itemNo.toString()); // NOP
                topNavi.style.backgroundImage = "url(/images/jdpower/200803/hg.jpg)";
                var img = "";
                switch(itemNo)
                {
                    case 1: img = "url(/images/jdpower/200803/01boxster.gif)"; break;
                    case 2: img = "url(/images/jdpower/200803/02cayman.gif)"; break;
                    case 3: img = "url(/images/jdpower/200803/03911.gif)"; break;
                    default: img = "url(/images/jdpower/200803/04cayenne.gif)"; break;
                }
                elem.style.backgroundImage = img;
                elem.style.backgroundColor = "transparent";
                elem.style.MozOpacity = "1.00"; 
                elem.style.Opacity = "1.00"; 
                elem.style.opacity = "1.00"; 
                elem.style.filter = "Alpha(opacity=100, finishopacity=100, style=2)";
            }
            else
            {
                elem.style.color = g_homemenu_ll_fontcolor_level0; 
                elem.style.backgroundColor = g_homemenu_ll_background_color; 
                if (! (elem.className.indexOf("final") >= 0) )
                {
                    //elem.style.backgroundImage = g_homemenu_ll_background_image_level0; 
                }
            }
            fadeAllIn(elem);
            //////////////////////
        }
        else
        {
            elem.style.color = g_homemenu_ll_fontcolor_level1;
            elem.style.backgroundColor = "#FFFFFF";
            if (! (elem.className.indexOf("final") >= 0) )
            {
                elem.style.backgroundImage = g_homemenu_ll_background_image_level1;
            }

            elem.style.MozOpacity = ".86";
            elem.style.Opacity = ".86"; 
            elem.style.opacity = ".86"; 
            elem.style.filter = "alpha(opacity=86)";
        }
    }
}

function showSubLayers(sName)
{
    var i = 0;
    var foundOne = false;

    for (i = 1; i <= G_MAXSUBLAYERS; i++)
    {
        var s = "nav_" + sName + "_" + i;
        var elem = document.getElementById(s);
        if (elem)
        {
            foundOne = true;
        }
        else
        {
            break;
        }

        showLr(s);
    }

    return foundOne;
}

function hideSubLayers(sName)
{
    var i = 0;
    var foundOne = false;

    for (i = 1; i <= G_MAXSUBLAYERS; i++)
    {
        var s = "nav_" + sName + "_" + i;
        var elem = document.getElementById(s);
        if (elem)
        {
            foundOne = true;
        }
        else
        {
            break;
        }

        hideLr(s);
    }

    return foundOne;
}

function echo(s)
{
    /*
    var elDebug = document.getElementById("debug");
    elDebug.innerHTML = "<div><span>" + (++g_echoCount) + ".</span> " + s + "</div>" + elDebug.innerHTML;
    */
}

function setModel(s)
{

    if (g_initHome)
    {
        g_currentModelLink = s;
    }
}

function gotoModel()
{

    if (g_initHome)
    {
        if (g_currentModelLink != '')
        {
            gotoUrl(g_currentModelLink);
        }
    }
}

function gotoUrl(s)
{
    g_psyma_navi_clicked = true;
    document.location.href = s;
}

function gotoUrlDropDown(e)
{
	if (e.options)
	{
		var url = e.options[e.options.selectedIndex].value;
		if(url != '')gotoUrl(url);			
	}
}

function gotoUrlTimeout(s, timeout)
{
  setTimeout("gotoUrl('" + s + "')", timeout)
}
function nogo()
{
    //
}

function selectAllInput(elm)
{
    if (elm)
    {
        elm.focus();
        elm.select();
    }
}

function changedCountry(elmThis)
{
    if (document.getElementById)
    {
        var sUrl = elmThis.value;

        if (sUrl != "")
        {
            document.location.href = sUrl;
        }
    }
}

function sniffAll()
{
    /* JavaScript Browser Sniffer
       Eric Krok, Andy King, Michel Plungjan Jan. 31, 2002
       see http://www.webreference.com/ for more information
       This program is free software */

    var agt=navigator.userAgent.toLowerCase();
    var appVer = navigator.appVersion.toLowerCase();

    var is_minor = parseFloat(appVer);
    var is_major = parseInt(is_minor);

    var is_opera = (agt.indexOf("opera") != -1);

    /*
    var is_opera6 = (agt.indexOf("opera 6") != -1 || agt.indexOf("opera/6") != -1);
    var is_opera7 = (agt.indexOf("opera 7") != -1 || agt.indexOf("opera/7") != -1);
    var is_opera6up = (is_opera && !is_opera2 && !is_opera3 && !is_opera4 && !is_opera5);
    var is_opera7up = (is_opera && !is_opera2 && !is_opera3 && !is_opera4 && !is_opera5 && !is_opera6);
    */

    var iePos  = appVer.indexOf('msie');
    if (iePos !=-1) {
       is_minor = parseFloat(appVer.substring(iePos+5,appVer.indexOf(';',iePos)));
       is_major = parseInt(is_minor);
    }

	
    var is_konq = false;
    var kqPos   = agt.indexOf('konqueror');
    if (kqPos !=-1) {                 
       is_konq  = true;
       is_minor = parseFloat(agt.substring(kqPos+10,agt.indexOf(';',kqPos)));
       is_major = parseInt(is_minor);
    }

    var is_getElementById   = (document.getElementById) ? "true" : "false";
    var is_getElementsByTagName = (document.getElementsByTagName) ? "true" : "false";
    var is_documentElement = (document.documentElement) ? "true" : "false";

    var is_safari = ((agt.indexOf('safari')!=-1)&&(agt.indexOf('mac')!=-1))?true:false;
    var is_khtml  = (is_safari || is_konq);

    var is_gecko = ((!is_khtml)&&(navigator.product)&&(navigator.product.toLowerCase()=="gecko"))?true:false;
    var is_gver  = 0;
    if (is_gecko) is_gver=navigator.productSub;

    var is_moz   = ((agt.indexOf('mozilla/5')!=-1) && (agt.indexOf('spoofer')==-1) &&
                    (agt.indexOf('compatible')==-1) && (agt.indexOf('opera')==-1)  &&
                    (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1)     &&
                    (is_gecko) && 
                    ((navigator.vendor=="")||(navigator.vendor=="Mozilla")));

	var is_mac = ((agt.indexOf('macintosh')!=-1))?true:false;
	var is_linux = (navigator.platform.toLowerCase().indexOf('linux')!=-1)?true:false;
	var is_win = (navigator.platform.toLowerCase().indexOf('win')!=-1)?true:false;
	
    if (is_moz) {
       var is_moz_ver = (navigator.vendorSub)?navigator.vendorSub:0;
       if(!(is_moz_ver)) {
           is_moz_ver = agt.indexOf('rv:');
           is_moz_ver = agt.substring(is_moz_ver+3);
           is_paren   = is_moz_ver.indexOf(')');
           is_moz_ver = is_moz_ver.substring(0,is_paren);
       }
       is_minor = is_moz_ver;
       is_major = parseInt(is_moz_ver);
    }

    var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
                && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1)
                && (!is_khtml) && (!(is_moz)));

    if ((navigator.vendor)&&
        ((navigator.vendor=="Netscape6")||(navigator.vendor=="Netscape"))&&
        (is_nav)) {
       is_major = parseInt(navigator.vendorSub);
       is_minor = parseFloat(navigator.vendorSub);
    }

    var is_nav2 = (is_nav && (is_major == 2));
    var is_nav3 = (is_nav && (is_major == 3));
    var is_nav4 = (is_nav && (is_major == 4));
    var is_nav4up = (is_nav && is_minor >= 4); 
    var is_navonly  = (is_nav && ((agt.indexOf(";nav") != -1) ||
                          (agt.indexOf("; nav") != -1)) );

    var is_nav6   = (is_nav && is_major==6);
    var is_nav6up = (is_nav && is_minor >= 6);

    var is_nav5   = (is_nav && is_major == 5 && !is_nav6);
    var is_nav5up = (is_nav && is_minor >= 5);

    var is_nav7   = (is_nav && is_major == 7);
    var is_nav7up = (is_nav && is_minor >= 7);

    var is_ie   = ((iePos!=-1) && (!is_opera) && (!is_khtml));
    var is_ie3  = (is_ie && (is_major < 4));

    var is_ie4   = (is_ie && is_major == 4);
    var is_ie4up = (is_ie && is_minor >= 4);
    var is_ie5   = (is_ie && is_major == 5);
    var is_ie5up = (is_ie && is_minor >= 5);
    
    var is_ie5_5  = (is_ie && (agt.indexOf("msie 5.5") !=-1));
    var is_ie5_5up =(is_ie && is_minor >= 5.5);
    
    var is_ie6   = (is_ie && is_major == 6);
    var is_ie6up = (is_ie && is_minor >= 6);

	// OS
	g_is_win = is_win;
	g_is_mac = is_mac;
	g_is_linux = is_linux;
	
    g_is_ie = is_ie;
    g_is_opera = is_opera;
    g_is_ie5 = is_ie5;
    g_is_ie5_5 = is_ie5_5;
    g_is_ie6 = is_ie6;
    g_is_safari = is_safari;
}



/* Module Motorschaubild */

function showDetail(item) {
    getDiagramDetail(item).style.display = "block";
}
    
function hideDetail(item) {
    getDiagramDetail(item).style.display = "none";
}    
    
function getDiagramDetail(item) {
    return document.getElementById("engineDiagramDetail" + item.getAttribute("id").substr(17,2));
}

function switchDiagramPage()
{
   var page1 = document.getElementById("engineDiagramPage1");     
   var page2 = document.getElementById("engineDiagramPage2");
     
   if (page1 && page2) {
        var show2ndPage = ((page1.style.display == "") || (page1.style.display == "block"));
        
        var control = document.getElementById("engineDiagramControl");
                
        if (show2ndPage) {
                page1.style.display = "none";
                page2.style.display = "block";
                control.innerHTML = "<a href=\"javascript:switchDiagramPage();\">&lt; 2/2</a>";
        } else {
                page1.style.display = "block";
                page2.style.display = "none";
                control.innerHTML = "<a href=\"javascript:switchDiagramPage();\">1/2 &gt;</a>";                
        }
   } 
}

  
/* Module Image Switch */

function updateImageSwitch(elm, state)
{
	var elmChild = null;
	
	if (elm.childNodes[0].style != undefined) {
		elmChild = elm.childNodes[0];
	} else {
		elmChild = elm.childNodes[1];
	}

    switch (state) {
        case "active":    

            var i = 1;
            do {
                var elmInactive = document.getElementById("switchImage" + i);
                if (elmInactive != null) {
                    updateImageSwitch(elmInactive, "inactive");
                }
                i++;
            } while (elmInactive != null)
	
            elm.style.color = "rgb(153,0,0)";
            elm.style.background = "white url(/pools/pco/images/arrow-red.gif) no-repeat left 3px";
            elmChild.style.display = "block";                      
            break;
        case "inactive":
            elm.style.color = "rgb(102,102,102)";
            elm.style.background = "white url(/images/arrow-gray.gif) no-repeat left 3px";
            elmChild.style.display = "none";                                      
    }
}

/* Macht ein Redirect zur Value des ausgewählten Elements der angegebenen Select Box */
function RedirectToOptionValue(name)
{
  obj = document.getElementById(name);
  if(obj)
  {
    link = obj.options[obj.selectedIndex].value;
    if(link.length > 0)
    {
      document.location.href = link;
    }
  }
}


/* SSO Cookie Check (to support caching) */

function ShowIfLoggedIn(id)
{
    if ( isLoggedIn() ) {
        var elm = document.getElementById(id);
        if (elm) {
            elm.style.display = "inline";
        }
    }
}

function HideIfLoggedIn(id)
{
    if ( isLoggedIn() ) {
        var elm = document.getElementById(id);
        if (elm) {
            elm.style.display = "none";
        }
    }
}

function isLoggedIn()
{
    var status = getCookie("SSO_LOGIN");
    if (status == null || status=='false') { status = false; }
    return status;
}

function getCookie(name)
{
    var thisCookie = document.cookie;
    var index = thisCookie.indexOf(name + "=");
    if (index == -1) return null;
    index = thisCookie.indexOf("=", index) + 1;
    var endstr = thisCookie.indexOf(";", index);
    if (endstr == -1) endstr = thisCookie.length;
    return unescape(thisCookie.substring(index, endstr));
}

function replStr(str,oldStr,newStr)
{ var strPos=str.indexOf(oldStr);
  return (strPos>=0) ?
    str.substring(0,strPos) + newStr +
       replStr( str.substring(strPos +
       oldStr.length), oldStr, newStr ) :
    str
}

function gotoUrlIE(url)
{
    g_psyma_navi_clicked = true;
    if (g_is_ie) {
        gotoUrl(url);
    }
}

function submitSDSTrainingSearchForm()
{
	var sfsForm = document.getElementById("SDSTrainingSearchForm");
	if (sfsForm.month.options.selectedIndex != 0)
		sfsForm.submit();
}

//
// Function ieToggleDropDowns: 
//
// Description: Toggles dropdown visibility in case of a dynamic layer 
// covering them pops up, and has a z-index higher than these. IE does not handle them correctly.
//
// Input: 
// 		strAttr: String Array, whose elements are the <DIV> id's to toggle. See function: getListIEDropDowns() 
//		boolHide: Boolean toggle. true, if the layer should be made visible, false otherwise.
// Returns : none.
function ieToggleDropDowns(strArr, boolHide) {
	// collection of dropdowns
	
	if (strArr.length > 0) {
		for (i=0; i < strArr.length; i++) {
			dd = document.getElementById(strArr[i]);
			if (dd) 
				if (boolHide) 
				{
					dd.style.visibility = 'hidden'
				}
				else
				{
					dd.style.visibility = 'visible';
				}
		}
	}
}

//
// Function getListIEDropDowns():
//
// Description: Builds an array of Dropdowns whose visibility should be toggled 
// in case of a dynamic layer covering them.
// Input: none.
// Returns: String array of <DIV> id's.
function getListIEDropDowns() {
	return (new Array("monthDropDown"));
}

/*
	Created		: 09.01.2006 by Martin Ibanez
	Last edited	: 10.01.2006 by Martin Ibanez
	Comment		: Wurde für die Galerie erstellt
*/
function showGalleryQuicktime(src)
{
	var elmImg = document.getElementById("galleryImage");
    if (elmImg) {
        g_fallbackImage = elmImg.src;
    }
    
	showQuicktime(src, 'galleryContent', '595', '317');
}

/*
	Created		: 09.01.2006 by Martin Ibanez
	Last edited	: 28.03.2006 by Stefan Kokemueller
	Comment		: Wurde für die Galerie erstellt
*/
function showQuicktime(src, layer , width, height)
{
	var elm = document.getElementById(layer);
	
	if (src.indexOf('_fullscreen.mov') > 0)
	{
		showFullscreenQuicktime(src);
	}
    else if (src.indexOf('_object.mov') > 0)
	{
		showFullscreenQuicktimeObject(src);
	}
	else if (elm && haveqt)
	{
		var qtstring = '';
		qtstring += '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" width="'+width+'" height="'+height+'" id="galleryQuicktimeMovie">' 
		qtstring += '<param name="src" value="'+src+'"><embed height='+height+' width='+width+' src="'+src+'" type="video/quicktime" pluginspage="www.apple.com/quicktime/download" enablejavascript="true" name="galleryQuicktimeMovie" />'
		qtstring += '</object>'
		
		elm.innerHTML = qtstring;
	}
}

/*
	Created		: 09.01.2006 by Martin Ibanez
	Last edited	: 10.01.2006 by Martin Ibanez
	Comment		: Wurde für die Galerie erstellt
*/
function showFullscreenQuicktime(src)
{
	if (haveqt)
	{
		sWidth = window.screen.availWidth;
		sHeight = window.screen.availHeight;
		var doc = window.open("/all/transitional/all/panoramaPopup/panoramaPopup.asp?qt=" + src, "newWin" + getRandomInt(10000), "width=" + sWidth + ",height=" + sHeight + ",left=0,top=0,dependent=yes,location=no,resizable=yes,scrollbars=no,status=no");			
		doc.focus();
	}
}

/*
	Created		: 28.03.2006 by Stefan Kokemueller
	Last edited	: 28.03.2006 by Stefan Kokemueller
	Comment		: Wurde für die Galerie erstellt
*/
function showFullscreenQuicktimeObject(src)
{
	if (haveqt)
	{
		sWidth = window.screen.availWidth;
		sHeight = window.screen.availHeight;
		var doc = window.open("/all/transitional/all/panoramaPopup/objectPopup.asp?qt=" + src, "newWin" + getRandomInt(10000), "width=" + sWidth + ",height=" + sHeight + ",left=0,top=0,dependent=yes,location=no,resizable=yes,scrollbars=no,status=no");			
		doc.focus();
	}
}
function showPanoramaPopup(pool, id, lang, panoramaversion, width, height, callpath)
{
	sWidth = window.screen.availWidth;
	sHeight = window.screen.availHeight;
	
	if(width && width > 0)
	{
		sWidth = width;		
	}
	
	if(height && height > 0)
	{
		sHeight = height;		
	}
	
	var url = "/panoramaPopup.aspx?Pool=" + pool + "&ID=" + id + "&Lang=" + lang + "&Panoramaversion=" + panoramaversion;	
	if (callpath && callpath.length > 0)
	{
		url += "&callpath=" + callpath;
	}
	
	var doc = window.open(url , "newWin" + getRandomInt(10000), "width=" + sWidth + ",height=" + sHeight + ",left=0,top=0,dependent=yes,location=no,resizable=yes,scrollbars=no,status=no");			
	doc.focus();
}
function writePopupQuicktimeObject(src,width,height)
{	
	if(haveqt)
	{
		var s = '';								
	
		var sWidth = '100%';
		var sHeight = '100%';
	
		var divWidth = "100%";
		var divHeight = "87%";
		
		if (width && width > 0)
		{
			sWidth = width;
			divWidth = width;
		}
		
		if (height && height > 0)
		{			
			sHeight = height + 15;
			divHeight = height + 15;
			
			if ( viewportGetHeight() > (sHeight + 50) )
			{
			  spacerHeight = (viewportGetHeight() - sHeight) * 0.43;					  
			  s += '<div style="height: ' + spacerHeight + 'px; width:100%; font-size:1px;"></div>\n';
			}
			else
			{
			  document.body.style.overflow = 'auto';
			}			
		}	
		
		s += '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="'+sWidth+'" height="'+sHeight+'" codebase="http://www.apple.com/qtactivex/qtplugin.cab" id="quicktimePlugin">';
		s += '	<param name="scale" value="tofit"><param name="controller" value="true"><param name="cache" value="false"><param name="bgcolor" value="#E9E9E9"><param name="volume" value="30"><param name="kioskmode" value="false"><param name="moviename" value="spincontrolled">';
		s += '	<param name="src" value="'+src+'">';
		s += '	<embed src="'+src+'" ';
		s += '		width="'+sWidth+'" ';
		s += '		height="'+sHeight+'" ';
		s += '		type="video/quicktime" ';
		s += '		controller="true"';
		s += '		cache="false" ';
		s += '		volume="30"';
		s += '		kioskmode="false"';
		s += '		scale="tofit" ';
		s += '		pluginspage="http://www.apple.com/quicktime/download/" ';
		s += '		bgcolor="#E9E9E9"';
		s += '		moviename="spincontrolled"';
		s += '		/>';
		s += '</object>';
		
		var elm = document.getElementById('panorama');	
		if(elm)
		{
			elm.style.width = divWidth;
			elm.style.height = divHeight;		
			elm.innerHTML = s;
		}			
		
	}
	else
	{
		document.getElementById('noPlugin').style.display = 'block';
		document.getElementById('claim').style.display = 'none';
	}	
}
function myreplace(text,from,to) 
{
	ti = text.indexOf(from);
	text = text.substring(0,ti)+to+text.substr(ti+from.length);
	
	return text;
} 
function writePopupFlashObject(src,width,height)
{	
	if (getFlashVersion() > 6)
	{
		var sWidth = '100%';
		var sHeight = '100%';
		
		var divWidth = '100%';
		var divHeight = '87%';
		
		if (width && width > 0)
		{
			sWidth = width;
			divWidth = width;
		}
		
		if (height && height > 0)
		{
			sHeight = height;
			divHeight = height;
		}

		var elm = document.getElementById('panorama');	
		if(elm)
		{
			elm.style.width = divWidth;
			elm.style.height = divHeight;
		}	
			
		// show flash
		showFlash(src, 'panorama', sWidth, sHeight, 6, '#E9E9E9', 'loop=true,menu=true,quality=high,wmode=opaque', null)
		
	}
	else
	{
		document.getElementById('noPlugin').style.display = 'block';
		document.getElementById('claim').style.display = 'none';
	}	
}
// gehört zu jeder gescheiten JS-Bibliothek.
function trim(str)
{
 	return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
}

/* Toggleable language selector */

function writeLanguageSelector(pool, codes, texts, urls, selectedCode, containerId)
{
    if (document.addEventListener) 
    {
			document.addEventListener("DOMFocusIn", langSelectorCheckBlur, true);
	}
	document.onmousedown = langSelectorCheckBlur;
	listId = 'HomeLangSelect';
	var i;
	var selectedIndex = 0;
	
	for (i=0; i<codes.length; i++)
	{
	    if (codes[i] == selectedCode) 
	    {
	        selectedIndex = i;
	        break;
	    }
	}
	var html = "";
	html += "<div class=\"langSelect\" onclick=\"toggleLr('" + listId + "')\">\n";
	html += "<div id='langSelectDiv'><div type=\"text\" class=\"langSelectCurrent\">" + texts[selectedIndex]  + "</div>\n";
	html += "<div class=\"langSelectArrow\"></div></div>\n";
	html += "</div>\n";
	
	html += "<ul id=\"" + listId + "\" class=\"langSelectList\">\n";
	for (i=0; i< codes.length; i++)
	{
	    html += "<li onmouseover=\"mOverLangList(this, '"+ pool + "');\" onmouseout=\"mOutLangList(this, '"+ pool + "');\"><a href=\"" + urls[i] + "\">" + texts[i] + "</a></li>\n";
	}
	html += "</ul>\n";
	
	var container = document.getElementById(containerId);
	container.innerHTML = html;
}

function mOverLangList(elm, pool)
{
    if (!elm) return;
    poolid = pool.toLowerCase();
    switch(poolid)
    {
        case 'pco':
            elm.style.backgroundColor = '#E9E9E9';
			break;
        default:
            elm.style.backgroundColor = '#E9E9E9';
			break;
    }
}


function mOutLangList(elm, pool)
{
    if (!elm) return;
    poolid = pool.toLowerCase();
    switch(poolid)
    {
        case 'pco':
            elm.style.backgroundColor = '#FFFFFF';
			break;
        default:
            elm.style.backgroundColor = '#FFFFFF';
			break;
    }
}

if (window.Node && Node.prototype && !Node.prototype.contains) 
{
    Node.prototype.contains = function (arg)
    {
	    return !!(this.compareDocumentPosition(arg) & 16);
	};
}

function langSelectorCheckBlur(e)
{
    element = document.getElementById("langSelectDiv");	
	dropdownList = document.getElementById("HomeLangSelect");
	e = e || window.event;
	var target = e.target || e.srcElement || false;
	if (!target) {
		return;
	}

	if (target == element || element.contains(target) || target == dropdownList || dropdownList.contains(target)) 
	{		
	}
	else
	{
		hideLr("HomeLangSelect");
	}
	
}



function KBase() {
    var self = this;

    this.isOpen = false;
    this.currentPool = getPoolName();
    this.currentLanguage = getPoolLang(this.currentPool);
    this.isCuttingEdge = false;
    this.closeLabel = "";
    this.navigationBarTop = -1;
    this.navigationBarWidth = 857;
    this.navigationBarLeft = 106;
    this.flashContainerId = 'introImageKBase_flash';

    this.animateContent = function(isEnter, callback) {
        log("entering animateContent..");
        /*
        **  Animation Begin
        */
        var easing, animStartX, animEndX, transStart, transEnd;
        easing = 600;
        animStartX = 0;

        // cosmetic stuff. We'll show the bars again after the animation has ended.        
        if (isEnter) {
            animEndX = 0;
            transStart = 0.01;
            transEnd = 1.0;
        }
        else {
            if (self.prevRequested) {
                animEndX = self.contentWidth;
            }
            else {
                animEndX = -(self.contentWidth);
            }
            transStart = 1.0;
            transEnd = 0.01;
        }

        $("#knowledgeBase .animationWrapper")
            .css('opacity', transStart)
            .animate({
                opacity: transEnd,
                left: animEndX
            }, easing, 'swing', function() {

                //log("animateContent - Animation ended. Running callback : " + callback);            
                if (typeof (callback) == 'function') {
                    callback();
                }
            });
        /*
        ** Animation End
        */

    }

    this.clear = function() {
        $('#knowledgeBase').empty();
    }

    this.showLoadingScreen = function() {
        if ($('#knowledgeBase .loading').length == 0) {
            $("#knowledgeBase").append("<div class=\"loading\"></div>");
        }
        $('#knowledgeBase .loading').show();
    }

    this.hideLoadingScreen = function() {
        $("#knowledgeBase .loading").hide();
    }

    this.show = function(sUrl) {
        if (self.isCuttingEdge && self.isOpen) {
            var animStartX = self.prevRequested ? -(self.contentWidth) : self.contentWidth;

            $('#knowledgeBase .animationWrapper').css('left', animStartX + 'px');
            $("#knowledgeBaseShade, #knowledgeBase").css('visibility', 'visible');
            self.animateContent(true, null);
        }
        else {
            $('#knowledgeBase .animationWrapper').css('left', '0px');
            $("#knowledgeBaseShade,#knowledgeBase").css({ 'visibility': 'visible', 'display': 'block' });
            self.isOpen = true;
            log("kbase is open");
        }

    }

    this.prevRequested = false;
    this.nextRequested = false;

    this.contentTop = -1;
    this.contentHeight = -1;
    this.contentWidth = $('#knowledgeBase').width();

    this.currentItemIndex = 0;

    this.open = function(sUrl, itemIndex) {
        log("open - sUrl: " + sUrl);
        log("open - itemIndex: " + itemIndex);

        if (itemIndex != null && !isNaN(itemIndex)) {
            self.currentItemIndex = itemIndex;
            log('[KBase - open] self.currentItemIndex: ' + self.currentItemIndex);
        }
        if (self.isCuttingEdge) {
            if (self.isOpen) {
                // do animations
                self.animateContent(false, function() { self.showLoadingScreen(); self.retrieve(sUrl); });
            }
            else {
                self.retrieve(sUrl);
            }
        }
        else {
            self.retrieve(sUrl);
        }

    }

    // retrieve and show content
    this.retrieve = function(sUrl) {
        log("retrieve - sUrl: " + sUrl);
        $.ajax({
            url: sUrl,
            dataType: "html",
            success: function(data) {
                //**debug**
                //if (self.isOpen) return;
                // browser hacks
                ieToggleDropDowns(true);
                if (g_is_safari) {
                    //$("#introImage").css("visibility", "hidden");
                }

                // empty current content..
                // this also clears the "loading" screen.
                self.clear();

                //attach Content
                var animationWrapper = $("<div class=\"animationWrapper\"></div>");
                //add "CLOSE" Text;
                var closestr = '';
                if (self.isCuttingEdge) {
                    var closetext = self.closeLabel();
                    closestr = '<span>' + closetext + '</span>';
                }
                $("<div class=\"closeButton\" id=\"closeButtonKbase\">" + closestr + "<img src=\"/Images/close-button.gif\" alt=\"[X]\" title=\"Close\" /></div>")
                    .click(self.closebuttonCallback)
                    .appendTo(animationWrapper);

                animationWrapper.appendTo('#knowledgeBase');
                $(data.replace(/\<\/?content\>/g, '')).appendTo('.animationWrapper');

                self.toggleMilkyBackground("on");

                if (self.isCuttingEdge) {
                    //$("#knowledgeBaseShade, #knowledgeBase").css('display','block');
                    $("#knowledgeBaseShade, #knowledgeBase").fadeIn(350);
                }
                else {
                    // hide content for a moment.
                    $("#knowledgeBaseShade, #knowledgeBase").css({
                        'visibility': 'hidden',
                        'display': 'block'
                    });
                }

                self.setupNavigationBar();
                // content is inserted into DOM, set the dimensions accordingly
                self.adjustDimensions();

                // ta-daa!
                self.hideLoadingScreen();
                self.show(sUrl);

            },
            error: function(xhttpreq, errorTxt, exception) {
                // something went badly. Show error message..
                alert("Can't retrieve XML: " + errorTxt);
            }
        });
    }
    this.runVideo = function(sShowflashScript) { ; };
    this.stopVideo = function(sShowflashScript) { ; };

    this.closebuttonCallback = function() {
        self.close();
    }

    this.navigationElementSelector = "ul li.kbase";
    this.navigationItemCollection = null;
    this.setupNavigationBar = function() {
        if (!self.isCuttingEdge) return;

        self.navigationItemCollection = $(self.navigationElementSelector);

        if (self.navigationItemCollection.length > 1) {
            var navBlock;
            if ($('#kbNavi').length == 0) {
                log('Drawing navigation first time..');
                $('<div id=\"kbNavi\"></div>').insertBefore('#knowledgeBaseShade');
            }
            // calculate navigation bar position
            self.navigationBarTop = ($(window).height() - $('#kbNavi').height()) / 2 + viewportGetScrollY();


            $('#kbNavi')
                .css({ 'top': self.navigationBarTop + 'px',
                    'width': self.navigationBarWidth + 'px',
                    'left': self.navigationBarLeft + 'px'
                });

            // set-up next/prev links
            var prev, next;
            var prevLink = self.getPrev();
            var nextLink = self.getNext();
            var xOffset = '89px'; // $('#kbPrev').width() + 'px';
            log("xOffset: " + xOffset);

            // **
            // PREVIOUS
            //**
            if (prevLink) {
                // first time: create "previous" element
                log("prevLink found");
                var prevtitle = $(prevLink).find("span").text();
                if ($('#kbPrev').length == 0) {
                    prev = $('<div id=\"kbPrev\"><a title="' + prevtitle + '" href="javascript:void(0);"></a></div>')
                    .click(function() { self.clickPrev(); })
                    .appendTo('#kbNavi')
                    ;
                }
                else {
                    // link exists, update only its title
                    $('#kbPrev a').attr('title', prevtitle);
                }
                // finally, slide out, make it visible
                $('#kbPrev').animate({ 'left': 0 }, 200, 'swing');
            }
            else {
                // no previous link. Slide it back in 
                // remember: the animation will run only if the element exists.
                $('#kbPrev').animate({ 'left': xOffset }, 200, 'swing');
            }

            // **
            // NEXT
            // **
            if (nextLink) {
                log("nextLink found");
                // first time: create "next" element
                var nexttitle = $(nextLink).find("span").text();
                if ($('#kbNext').length == 0) {
                    next = $('<div id="kbNext"><a title="' + nexttitle + '"  href="javascript:void(0);"></a></div>')
                    .click(function() { self.clickNext(); })
                    .appendTo('#kbNavi')
                    ;
                }
                else {
                    // link exists, update only its title
                    $('#kbNext a').attr('title', nexttitle);
                }
                // slide out.
                $('#kbNext').animate({ 'right': 0 }, 200, 'swing');
            }
            else {
                // no next link. Slide it back in 
                $('#kbNext').animate({ 'right': xOffset }, 200, 'swing');
            }
        }
    }

    // private function, use getNext/getPrev instead
    // KBase
    this.getSibling = function(isNext) {
        var nextItemIndex = self.currentItemIndex + ((isNext) ? 1 : -1);
        log("self.currentItemIndex, nextItemIndex: " + self.currentItemIndex + " , " + nextItemIndex);

        if ((nextItemIndex < 0) || (self.navigationItemCollection.length <= nextItemIndex))
            return false;

        return self.navigationItemCollection[nextItemIndex];
    }

    this.getNext = function() {
        return this.getSibling(true);
    }

    this.getPrev = function() {
        return this.getSibling(false);
    }

    this.clickNext = function() {
        log("clickNext.");
        self.nextRequested = true;
        self.prevRequested = false;
        log("currentItemIndex: " + self.currentItemIndex);
        $(self.navigationItemCollection[self.currentItemIndex + 1]).find('a').trigger("click");
    }

    this.clickPrev = function() {
        log("clickPrev.");
        self.prevRequested = true;
        self.nextRequested = false;
        //console.dir(self.navigationItemCollection);
        log("currentItemIndex: " + self.currentItemIndex);
        $(self.navigationItemCollection[self.currentItemIndex - 1]).find('a').trigger("click");
    }

    this.toggleMilkyBackground = function(onOff) {
        if (onOff == "on") {
            // if it's already there, back off.
            if ($('#kbaseMilkyBG').length != 0) return;
            // insert semi-transparent milky background
            $('#knowledgeBase').parent().append('<div id=\"kbaseMilkyBG\"></div>');
        }
        else {
            $('#kbaseMilkyBG').remove();
        }
    }

    this.imgWidth = 656;
    this.imgHeight = 313;
    this.minContainerHeight = 500;
    this.name = "KBASE";
    this.kbWrapperHeightDiff = 67;    // height of old kbHeading/navigation
    this.kbShadeMarginTopBottom = 16; // minimum gap between browser window top/bottom and kbase shade
    this.shadeBorderWidth = 8;             // kbase shade border width
    this.kbMagicHightModifier = 1;

    this.getContentHeight = function() {
        log("$('#knowledgebaseWrapper').outerHeight(true): " + $('#knowledgebaseWrapper').outerHeight(true));
        return ($('#knowledgebaseWrapper').outerHeight(true) + 47);
    }
    this.setKbWrapperHeight = function(kbHeight) {
        if ($("#knowledgebaseWrapper").length > 0) {
            $("#knowledgebaseWrapper").height(kbHeight - this.kbWrapperHeightDiff);
        }
    }

    this.adjustDimensions = function() {
        log("entering setKBaseDimensions");

        var maxContainerHeight, contentHeight, kbHeight, shadeHeight;

        // settings max and min height a kbase container can have.
        maxContainerHeight = $(window).height() - (2 * self.kbShadeMarginTopBottom) - (2 * self.shadeBorderWidth);
        if (maxContainerHeight < 0) maxContainerHeight = 0;

        contentHeight = this.getContentHeight();

        if ($('#' + self.flashContainerId).length > 0) {
            var flashHeight = $('#' + self.flashContainerId).attr("height");
            log("flashHeight: " + flashHeight);
            if (flashHeight != '' && typeof (flashHeight) != 'undefined') {
                contentHeight += flashHeight;
            }
        }

        // Adjust container height according to content height
        if (contentHeight > maxContainerHeight)
            kbHeight = maxContainerHeight;
        else if (contentHeight < self.minContainerHeight)
            kbHeight = self.minContainerHeight;
        else
            kbHeight = contentHeight;

        kbHeight += self.kbMagicHightModifier; // BU: don't ask why.

        shadeHeight = kbHeight + (2 * self.shadeBorderWidth);

        this.setKbWrapperHeight(kbHeight);

        var elmShade = document.getElementById("knowledgeBaseShade");
        var elmKB = document.getElementById("knowledgeBase");

        var pageWidth;
        if ($('.page').length > 0)
            pageWidth = $('.page').width();
        else
            pageWidth = $('body').width(); // Comparemodels falls into this category.

        var imgX = pageWidth / 2 - self.imgWidth / 2;
        var imgY = Math.round(($(window).height() - shadeHeight) / 2) + viewportGetScrollY() + 8;

        if (imgY < 0) { imgY = 0; }
        if (imgX < 0) { imgX = 0; }

        // set KBase container height
        if (self.isCuttingEdge && self.contentHeight != -1 && kbHeight != self.contentHeight) {
            var diffH = "+=" + (kbHeight - self.contentHeight);
            var diffT = "+=" + (imgY - self.contentTop);

            // roll the animation
            $("#knowledgeBase,#knowledgeBaseShade").animate({
                'height': diffH,
                'top': diffT
            }, 300, 'swing');
        }
        else {
            // set KBase-Shade dimensions
            elmShade.style.left = (imgX - self.shadeBorderWidth) + "px";
            elmShade.style.top = (imgY - self.shadeBorderWidth) + "px";
            elmShade.style.height = shadeHeight + "px";

            // set KBase Dimensions
            elmKB.style.left = imgX + "px";
            elmKB.style.top = imgY + "px";
            elmKB.style.height = kbHeight + "px";
        }

        self.contentTop = imgY;
        self.contentHeight = kbHeight;
    }

    this.close = function() {
        // **********************
        // Closing KBase layer
        // **********************

        // turn off milky background layer
        log("closing KBase");

        // remove navigation (prev/next)
        $('#kbNavi').remove();

        // IE Hack for dropdowns
        ieToggleDropDowns(false);

        if (self.isCuttingEdge) {
            //$("#knowledgeBaseShade, #knowledgeBase").css('display','block');
            $("#knowledgeBaseShade, #knowledgeBase").fadeOut("fast", function() {
                //$("#knowledgeBaseShade, #knowledgeBase").empty().hide();
                self.toggleMilkyBackground("off");
            });
        }
        else {
            $("#knowledgeBaseShade, #knowledgeBase").empty().hide();
            self.toggleMilkyBackground("off");
        }

        this.isOpen = false;
        //$("html").css({ "overflow-y": "scroll" });
        log("KBase.isOpen: " + this.isOpen);
    }
}


/* 
Teaser Bar 
*/
var g_destroyOldTeaserBar = false;
function setupTeaserbar() {
    if (g_destroyOldTeaserBar) {
        $('#teaserbarNavLeft,#teaserbarNavRight,#teaserBarWrapper').remove();
        $('.innerContent').append('<a class="prevPage browse left disabled" id="teaserbarNavLeft" /><div id="teaserBarWrapper" /><a class="nextPage browse right" id="teaserbarNavRight" />');
    }

    $('ul.teaserBar').addClass('items').appendTo('#teaserBarWrapper').show();
    $('#teaserBarWrapper').addClass('scrollable').scrollable({ "size": (4), "speed": 300 }); 
    $('#teaserbarNavLeft').click(function() {
        click_track('Klick-Startseite/Teaser/Previous Teaser');
    });
    $('#teaserbarNavRight').click(function() {
        click_track('Klick-Startseite/Teaser/Next Teaser');
    });
}

/* For compatibility with the older version */
function moveTeaserbar() {
    g_destroyOldTeaserBar = true;
}




// Console logging for firebug.
// keep it silent on other browsers.
function log(str) {
    try {
        console.log(str);
    }
    catch (e) {
    }
}
