﻿firstclick=0; 
function firstclick_stichwort(where) {
 if (firstclick==0) {
  where.value="";
  firstclick=1;
 }
}
// TRACKING
// set path for tracking page
trackPage='';
// functions
function createRequestObject() {
 var ro;
 ro = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
 return ro;
}
var http = createRequestObject();
function sendTrackingRequest(trackingName,trackingValue) {
    http.open('get', trackPage+'?'+trackingName+'=_'+trackingValue);




    http.send(null);
}
function showTrackingParameters () {  //show tracking parameters in smartedit mode
   for (i = 0; i < document.getElementsByTagName('span').length; i++) {
                if (document.getElementsByTagName('span')[i].className=="trackingOn") {
                        document.getElementsByTagName('span')[i].className="trackingOff"
                 } else if (document.getElementsByTagName('span')[i].className=="trackingOff") {
                        document.getElementsByTagName('span')[i].className="trackingOn"
                 }
        }    
}

//  font size / contrast changing
function toggleContrast() {
 if (document.getElementById('contrast')) {
  if (document.getElementById('contrast').disabled==false) {
   document.getElementById('contrast').disabled=true;
   eraseCookie('contrastToggle');
  } else {
   document.getElementById('contrast').disabled=false;
   createCookie('contrastToggle','ON','1');
  }
 }
}
function change_size(whatstyle,firsttime) {
 document.getElementById('small').disabled=true;
 document.getElementById('medium').disabled=true;
 document.getElementById('large').disabled=true;
 document.getElementById(whatstyle).disabled=false;
 eraseCookie('resize_fontsize');
 createCookie('resize_fontsize',whatstyle,'1');
 if (firsttime!='first_time') {set_size_button(whatstyle);}
}
var feedsExist;
function set_feedSize() {
 sizeToSet = document.location.href.split('?')[1];
 if (sizeToSet) {
     document.getElementById('small').disabled=true;
     document.getElementById('medium').disabled=true;
     document.getElementById('large').disabled=true;
     document.getElementById(sizeToSet).disabled=false;
 }
}
function set_size_button(new_style) {
/*
 document.getElementById('button_small').style.backgroundImage="url(/ir/images/shared/schriftgroesse_bg.gif)";
 document.getElementById('button_medium').style.backgroundImage="url(/ir/images/shared/schriftgroesse_bg.gif)";
 document.getElementById('button_large').style.backgroundImage="url(/ir/images/shared/schriftgroesse_bg.gif)";
 document.getElementById('button_'+new_style).style.backgroundImage="url(/ir/images/shared/schriftgroesse_bg_x.gif)";
*/
}
var current_style;
function set_size_first_time() {
try {
 if (!readCookie('resize_fontsize')) {
   document.getElementById('small').disabled=false;
   current_style='small';

   document.getElementById('medium').disabled=true;
   document.getElementById('large').disabled=true;
 } else {
   current_style=readCookie('resize_fontsize')
   change_size(current_style,'first_time');
 }
} catch (e) {}
try {
 if (readCookie('contrastToggle')) {
   document.getElementById('contrast').disabled=false;
 } else {
   document.getElementById("contrast").disabled=true;
 }
} catch (e) {}
}
if (document.getElementById('small')) {
    set_size_first_time();
}
// Cookie handling
function createCookie(name,value,hours)
{
 if (hours)
 {
  var date = new Date();
  date.setTime(date.getTime()+(hours*60*60*1000));
  var expires = "; expires="+date.toGMTString();
 }
 else var expires = "";
 document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name)
{
 var nameEQ = name + "=";
 var ca = document.cookie.split(';');
 for(var i=0;i < ca.length;i++)
 {
  var c = ca[i];
  while (c.charAt(0)==' ') c = c.substring(1,c.length);
  if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
 }
 return null;
}
function eraseCookie(name)
{
 createCookie(name,"",-1);
}

/*
function openPrintPopup() {
    printPopup=window.open('','trgpopup','width=635,height=600,scrollbars=yes,resizable=no'); printPopup.focus();
}
*/

/* shows description in description div */
function showNote(posId,msg) {
    toolDisplayObj = document.getElementById(posId);
    if (toolDisplayObj) {
     toolDisplayObj.innerHTML = msg;
    }
}

// LINKING FROM OPTION LIST
function linkFromOption(what) {
  stringToSplit=document.getElementById(what).options[document.getElementById(what).selectedIndex].value
  splitTrackingName=stringToSplit.split('&$&$')[0];
  splitTrackingValue=stringToSplit.split('&$&$')[1];
  splitUrl=stringToSplit.split('&$&$')[2];
  splitTarget=stringToSplit.split('&$&$')[3];
  splitHeight=stringToSplit.split('&$&$')[4];
  splitWidth=stringToSplit.split('&$&$')[5];
  splitSroll=stringToSplit.split('&$&$')[6];
  splitResize=stringToSplit.split('&$&$')[7];
  if (splitUrl) {
      if (splitTrackingName && splitTrackingValue) {   // send tracking values to tracking function
        sendTrackingRequest(splitTrackingName,splitTrackingValue)
      }
      if (splitTarget!='_self' && splitWidth!='' && splitHeight!='') {
          popupParams='width='+splitWidth+',height='+splitHeight+',scrollbars='+splitSroll+',resizable='+splitResize;
//          height='height='+splitHeight;
//          width=',width='+splitWidth;
//          scrollbars=',scrollbars='+splitSroll;
//          resize=',resizable='+splitResize; else resize='';
//alert('"'+popupParams+'"');
          focusPopup=window.open(splitUrl,splitTarget,popupParams);
          focusPopup.focus();
      }
      else {
          focusPopup=window.open(splitUrl,splitTarget);
          focusPopup.focus();
      }
//      document.getElementById(what).selectedIndex=0;
  }
}
var firstselect;
function resetOptionList(what) {
    if (firstselect=='yes') {
        document.getElementById(what).selectedIndex=0;
        firstselect='no';
    }
    if (document.getElementById(what).selectedIndex!=0) firstselect='yes';
}
// openSesame - be sure all needed classes are define in css file
function openSesame(whatid) {
 if (document.getElementById(whatid).className=="sesameOpened") {
  document.getElementById(whatid).className="sesameClosed"
 } else {
  document.getElementById(whatid).className="sesameOpened"
 }
}

// alert function for external links
lastBoxOpened="";
function buildAlertBox(boxID,mode) {
 className=document.getElementById('xLink'+boxID).className;
 innerHTML=document.getElementById('xLink'+boxID).innerHTML;
 HREF=document.getElementById('xLink'+boxID).href;
 TARGET=document.getElementById('xLink'+boxID).target;
 if(!TARGET) TARGET="_self";
 boxCode="<div id='externalAlert"+boxID+"' class='alertBox'>";
 boxCode=boxCode+"<span id='alertText"+boxID+"'></span>";
 boxCode=boxCode+"<div style='height:20px;'><a href='"+HREF+"' target='"+TARGET+"' onclick=\" openCloseAlert('"+boxID+"');\">accept</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"javascript:openCloseAlert('"+boxID+"','');\">reject</a></div>";
 boxCode=boxCode+"</div>";
 boxCode=boxCode+"<a href=\"javascript:openCloseAlert('"+boxID+"','"+mode+"');\" class='"+className+"' id='modifiedLink"+boxID+"'>"+innerHTML+"</a>";
 document.getElementById('fLink'+boxID).innerHTML=boxCode;
}
function openCloseAlert(alertId,mode) {
    if (document.getElementById('externalAlert'+alertId).style.display=='block') {
        document.getElementById('alertText'+alertId).innerHTML="";
        document.getElementById('fLink'+alertId).style.zIndex='1';
        document.getElementById('externalAlert'+alertId).style.display='none';
        document.getElementById('externalAlert'+alertId).style.left='0px';
        document.getElementById('externalAlert'+alertId).style.top='0px';
        lastBoxOpened="";
    } else {
        if (lastBoxOpened!="") {
            openCloseAlert(lastBoxOpened);
        }
        alertText="";
        if (mode=="external") alertText="When you access this link, you are leaving the Deutsche Bank website. The information provided on any websites accessed through this link has been produced by independent providers and Deutsche Bank does not endorse or accept any responsibility for information provided on any such sites. Any opinions or recommendations expressed on such other websites are solely those of the independent providers and are not the opinions or recommendations of Deutsche Bank. The existence of a link from this Website to any other such websites does not constitute a recommendation or other approval by Deutsche Bank of such websites or any provider thereof.";
        if (mode=="internal") alertText="When you access this link, you are leaving the Deutsche Bank Corporate Website and enter that of another member of the Deutsche Bank Group of Companies. Access to and use of such other website may be subject to separate eligibility criteria and terms and conditions.";
        if (document.getElementById("alertOverride"+alertId)) alertText=document.getElementById("alertOverride"+alertId).innerHTML;
        document.getElementById('alertText'+alertId).innerHTML=alertText;
        document.getElementById('fLink'+alertId).style.zIndex='9999';
        document.getElementById('externalAlert'+alertId).style.display='block';
        document.getElementById('alertText'+alertId).style.height=(document.getElementById('alertText'+alertId).scrollHeight+12)+"px";
        alertBoxCoordinates('externalAlert'+alertId,mode);
        lastBoxOpened=alertId;
    }
}
//create alertBox position
function alertBoxCoordinates(objId,mode) {
 if (mode=='external') {pixelsTop=130;} else {pixelsTop=70;}
 ob = document.getElementById(objId);
 relativeRight=(580-(document.body.clientWidth-findPosX(ob)))-document.body.scrollLeft;
 relativeBottom=document.body.clientHeight-(findPosY(ob)-document.body.scrollTop);
 if (relativeRight>0) {
   if (relativeRight>findPosX(ob)) relativeRight=findPosX(ob);
   ob.style.left="-"+relativeRight+"px";
  }
 if (relativeBottom<pixelsTop) {
   ob.style.top="-"+pixelsTop+"px";
 }
}
function findPosX(obj) {
 var curleft = 0;
 if (obj.offsetParent)
 {
  while (obj.offsetParent)
  {
   curleft += obj.offsetLeft
   obj = obj.offsetParent;
  }
 }
 else if (obj.x)
  curleft += obj.x;
 return curleft;
}
function findPosY(obj)
{
 var curtop = 0;
 if (obj.offsetParent)
 {
  while (obj.offsetParent)
  {
   curtop += obj.offsetTop
   obj = obj.offsetParent;
  }
 }
 else if (obj.y)
  curtop += obj.y;
 return curtop;
}
// EXTENDED REDDOT DIV OPENING

// OTHER FUNCTIONS
// BLUE BACKGROUND
var pageIsInactive;
hiddenIFrames = new Array();
try {if(flashVars){}}catch (e){flashVars= new Array();}
function lightboxx(objID,mode,obj) {
    if(!document.getElementById("lightbox")) {
        lightboxOuter=document.createElement("span");
        lightboxOuter.id="lightbox";
        lightbox=document.createElement("a");
        lightbox.href= "javascript:lightboxx('"+objID+"','self')";
        lightbox.className="lightbox";
        lightbox.title="close window";
        resizeLightBox();
        window.onresize= function() {
            resizeLightBox();
        };
        for(i=0; i<document.getElementsByTagName("select").length; i++) {
            document.getElementsByTagName("select")[i].style.visibility="hidden";
        }
        if (obj) {
            jQuery("#layoutPositioner")
                .prepend(obj)
//            document.body.insertBefore(obj,document.body.firstChild);
        }
        jQuery("#layoutPositioner")
            .prepend(lightboxOuter)
//        document.body.insertBefore(lightboxOuter,document.body.firstChild);
        lightboxOuter.appendChild(lightbox);
    } else {
        window.onresize= "";
        for(i=0; i<document.getElementsByTagName("select").length; i++) {
            document.getElementsByTagName("select")[i].style.visibility="visible";
        }
        jQuery("#lightbox").remove();        
//        document.body.removeChild(document.getElementById('lightbox'));
        if (mode=="self" && flashVars[objID]) { // ONLY FOR MOVIE PLAYER
            closeMovie(objID,"internal");
        } else if (obj) {
            jQuery(obj).remove();        
//            document.body.removeChild(obj);
        } else if (mode=="self" && document.getElementById(objID)) {
            jQuery("#"+objID).remove();        
//            document.body.removeChild(document.getElementById(objID));
        }
    }
}
function resizeLightBox() {
    lightbox.style.height="0px";
    if (document.documentElement.scrollHeight>document.body.scrollHeight) {
        lightbox.style.height=document.documentElement.scrollHeight+"px"
    } else {
        lightbox.style.height=(document.body.scrollHeight)+"px";
    }
}


function pageActiveSwitch(toggle,movieID,mode) {
    if (toggle=="ON") {
        if (mode!="others") {
            for (var i = 0; i < document.getElementsByTagName("iframe").length; i++) {
                hiddenIFrames[document.getElementsByTagName("iframe")[i].id]="";
                if (document.getElementsByTagName("iframe")[i].id!="flashBox"+movieID && getStyle(document.getElementsByTagName("iframe")[i],"display")!="none") {
                    hiddenIFrames[document.getElementsByTagName("iframe")[i].id]=getStyle(document.getElementsByTagName("iframe")[i],"display");
                    document.getElementsByTagName("iframe")[i].style.display="none";
                    if (document.getElementById("alternateImage"+document.getElementsByTagName("iframe")[i].id.split("flashBox")[1])) {
                        document.getElementById("alternateImage"+document.getElementsByTagName("iframe")[i].id.split("flashBox")[1]).style.display="block";
                    }
                }
            }
            document.getElementById("documentInactive").innerHTML="<a href='javascript:closeMovie("+movieID+",\"internal\");'><div style='height:"+(document.body.scrollHeight)+"px' class='documentInactive'></div></a>";
        } else {
            document.getElementById("documentInactive").innerHTML="<a href='javascript:pageActiveSwitch(\"OFF\",\""+movieID+"\",\"others\");'><div style='height:"+(document.body.scrollHeight)+"px' class='documentInactive'></div></a>";
            document.getElementById("primer"+movieID).style.display=document.getElementById(movieID).style.display="block";
        }
        pageIsInactive=1;
    } else {
        if (pageIsInactive==1) {
            if (mode!="others") {
                for (var i = 0; i < document.getElementsByTagName("iframe").length; i++) {
                    if (hiddenIFrames[document.getElementsByTagName("iframe")[i].id]!="") {
                        document.getElementsByTagName("iframe")[i].style.display=hiddenIFrames[document.getElementsByTagName("iframe")[i].id];
                        if (document.getElementById("alternateImage"+document.getElementsByTagName("iframe")[i].id.split("flashBox")[1])) {
                            document.getElementById("alternateImage"+document.getElementsByTagName("iframe")[i].id.split("flashBox")[1]).style.display="none";
                        }
                    }
                }
            }
            hiddenIFrames = new Array();
            document.getElementById("documentInactive").innerHTML="";
            pageIsInactive=0;
            if (mode!="others") {
                  closeMovie(movieID,"internal");
            } else {
                  document.getElementById("primer"+movieID).style.display=document.getElementById(movieID).style.display="none";
            }
        }
    }
}
function getStyle(where,whatStyle) {
 if (eval("where.style."+whatStyle)) {
    styleToGet=eval("where.style."+whatStyle);
 } else {
  try {
   styleToGet=window.getComputedStyle(where,'').getPropertyValue(whatStyle);
  } catch (a) {
   try {
    styleToGet=eval("where.currentStyle."+whatStyle);
   } catch (b) {
    styleToGet="";
   }
  }
 }
 return styleToGet;
}
///////////
//function is in templates
//ADDITIONAL SCRIPTS//
//
jQuery(function() {
jQuery("#leftNavi ul").find('li:last')
    .addClass("last")
});
//

var previewOrPublish="publish"



// the following function will strip the local project domain from published external navigation urls if they match (=relative urls)
// function will only work if Js_new references to ASP Include 
stripLocalDomainFromExternalURL = function(URLToCheck) {
  var localDomain1="";
  var localDomain2="";
  rgxp= new RegExp(localDomain1);
  if (previewOrPublish=="publish"  && localDomain1!="" && URLToCheck.search(rgxp)==0) { // published and url to check starts with localdomain 1
      URLToCheck=URLToCheck.replace(rgxp,"")
  }
  rgxp= new RegExp(localDomain2);
  if (previewOrPublish=="publish"  && localDomain2!="" && URLToCheck.search(rgxp)==0) { // published and url to check starts with localdomain 1
      URLToCheck=URLToCheck.replace(rgxp,"")
  }
  return URLToCheck;
}



// ********************* 
// Topmenu hover function (for IE - make hover available for other than a-tag)
// *********************
var hoverBase;
sfHover = function() {
    guidsToParse="49FAEC4017C147758282C19394C801F5, InvestorRelations, Presse, SocialResponsibility, JobsCareers";
    if (document.getElementById("list_main1") && document.getElementById("list_main1").hasChildNodes()){
        var sfEls = document.getElementById("list_main1").childNodes;
        for (var i=0; i<sfEls.length; i++) {
          if (sfEls[i].childNodes[0]) {

            if(typeof(mainNaviJSON)!='undefined') {
                for (var projectGuid in mainNaviJSON) {
                    if (guidsToParse.search(projectGuid)!=-1 && typeof(mainNaviJSON[projectGuid])!='undefined') {
                        var extNavJSON=mainNaviJSON[projectGuid][0];
if(typeof(extNavJSON)!='undefined') {
                        for (var j=0; j<extNavJSON.length; j++) {
                            if (extNavJSON[j].headline==sfEls[i].childNodes[0].innerHTML) { 
                                var createExtHovNav=1;
                                if (sfEls[i].childNodes[1]) {


                                    sfEls[i].removeChild(sfEls[i].childNodes[1]);



                                }
                                if (createExtHovNav==1) {
                                    sfEls[i].childNodes[0].href=extNavJSON[j].href;
                                    sfEls[i].childNodes[0].target=extNavJSON[j].target;
                                    sfEls[i].childNodes[0].id=extNavJSON[j].id;
                                    if (extNavJSON[j].nav!="") {
                                        var obj=extNavJSON[j].nav;
                                        var newUl=document.createElement("ul");
                                        newUl.className="horNav";
                                        newUl.id="extHovNav_"+obj.headline;
                                        for (var k=0; k<obj.length; k++) {
                                            if (obj[k].href) {
                                                var newLi=document.createElement("li");
                                                newLi.className=obj[k].li_class;
                                                var newA=document.createElement("a");
                                                newA.href=stripLocalDomainFromExternalURL(obj[k].href);
                                                newA.id=obj[k].id;
                                                obj[k].target? newA.target=obj[k].target : "";
                                                newA.className=obj[k].className;
                                                newA.innerHTML=obj[k].headline;
                                                newLi.appendChild(newA);
                                                newUl.appendChild(newLi);
                                            }
                                        }
                                        sfEls[i].appendChild(newUl);

                                    }
                                }
                            }
                        }
}
                    }
                }
            }


            if (jQuery(sfEls[i]).parent().find("ul").length) {
//            if (sfEls[i].childNodes[1]) {
                jQuery(sfEls[i])
                    .hover(
                        function() {
                            var obj=jQuery(this)
                            /* FIX WIDTH OF HOVER IF WIDTH IS SMALLER THAN PARENT */
                            if ((obj.width()+16)>obj.find("ul:first").width()) {
                                obj.find("ul:first").css({width:(obj.width()+16)+"px"});
                            }  
//alert('bang');
                            obj
                                .addClass("sfhover")
//                                .find("ul:first").show(300);
                                .find("ul:first").css({visibility:"visible", display:"block"}) //.show(300);
                            obj.next().css("background-position","-10px top");
/*
                            if (document.all) { // if IE, create iframe 'base layer' to prevent select boxes from shining through
                                hoverBase=document.createElement("iframe");
                                jQuery(hoverBase)
                                    .addClass("hoverBase")
                                    .attr(
                                        src:"/ir/images/shared/tp.gif"                                        
                                    )
                                    .css(
                                        height:this.childNodes[1].offsetHeight+"px"
                                    )
                                obj.prepend(hoverBase)
                            }
*/
                        },
                        function() {
                            var obj=jQuery(this)
                            obj
                                .removeClass("sfhover")
                                .find("ul:first").css({visibility: "hidden"});
//                                .find("ul:first").css({display:"none"});
                            obj.next().css("background-position","left center");
/*
                            document.all ? this.removeChild(hoverBase) : ""; // if IE, delete iframe 'base layer'                 }
*/
                        }
                    )
            }

          }
        }
        try {zo.createTrackValues("#list_main1 ");} catch(e) {}
    }
}
jQuery(sfHover)
// ******************** END


//