



/* JQuery */ 



/* define namespace */
var zo; // declares a global symbol
if (!zo) zo = {};
    else if (typeof zo != 'object')
        throw new Error('zo exists, but is not an object!');


// 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 showNote(posId,msg) {
    toolDisplayObj = document.getElementById(posId);
    if (toolDisplayObj) {
     toolDisplayObj.innerHTML = msg;
    } 
}
  
function clearInput(obj) {
    obj.value="";
    obj.onclick="";
}

function openPopup(anch,opt) {

    opt ? myOpt= opt : myOpt = 'width=612, height=612, resizable=yes, scrollbars=yes';
    ppup=window.open(anch.href,anch.target,myOpt); ppup.focus();
    ppup.focus();


}

function openLightbox(anch,opt) {

    loadToolBoxIFrame(anch.href,612,612,"off");


}

function lightboxx(objID,mode,obj) {
    if(!document.getElementById("lightbox")) {
        jQuery("#layoutPositioner").css({position:"relative"})
        lightboxOuter=document.createElement("span");
        lightboxOuter.id="lightboxOuter";
        lightbox=document.createElement("a");
        lightbox.href= "javascript:lightboxx('"+objID+"','self')";
        lightbox.title="close window";
        lightbox.className="lightbox";
        lightbox.id="lightbox";
        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("#layoutPositioner").css({position:"static"})
        jQuery("#lightbox").remove();        
//        document.body.removeChild(document.getElementById('lightboxOuter'));
        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";
    }
}

try {if(flashVars){}}catch (e){flashVars= new Array();}

flashBuilderSRC="/flashbuilder.js"

generateFlashScript = function() {
    if (!document.getElementById("generatedFlashScript")) {
        var generatedFlashScript=document.createElement('script');
        generatedFlashScript.src="/flashbuilder.js";
        generatedFlashScript.id="generatedFlashScript";
        generatedFlashScript.type="text/javascript";
        document.getElementsByTagName('head')[0].appendChild(generatedFlashScript);
    }
};

// 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="";
  previewOrPublish="publish";
  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;
}


function buildToolBox() {}
function buildFontSizeButtons() {}


//right column box display toggling
lastBoxToggleState = new Object();
tglFct = new Object();
animSpeed = new Object();
toggleBox = function(id,defaultState,cookieMode,animSpeedRatio) {
    var thisBox=document.getElementById("box"+id);
    var cookieName="toggleBox_"+id+"_46512E1306AA4BD8ABD7C3130B8D5689_ENG"
// Check if a cookie has been set already for the display mode
    if (lastBoxToggleState[id]) {
        var toggleState =  lastBoxToggleState[id];
    }  
    else if (readCookie(cookieName) && cookieMode=="ON") {
        var toggleState =  readCookie(cookieName);
    } else {
        var toggleState =  defaultState;
    };   
// create object with values 
    var values = {
        ToggleOpened: {
            reverseValue:"ToggleClosed",
            title:"hide box content"
        },
        ToggleClosed: {
            reverseValue:"ToggleOpened",
            title:"show box content"
        }
    };
    if (!animSpeed[id]) {animSpeed[id]=(jQuery(thisBox).find(".content:first").height()*0.7*animSpeedRatio)+1;}
    if (toggleState=="ToggleClosed") {
        jQuery(thisBox).addClass("multiBoxToggleClosed");
        jQuery(thisBox).find(".content:first").css({display:"none"})
    };
// check if the anchor for toggling exists, if not, add to DOM
    if (!document.getElementById("box"+id+"toggle")) {
        if (!jQuery(thisBox).find("h6.multiBoxHd").length) {
            jQuery(thisBox).prepend("<h6 class='multiBoxHd'>&nbsp;</h6>");
        }
        var toggleSwitch=document.createElement("A");
        toggleSwitch.id="box"+id+"toggle";
        toggleSwitch.onclick = function() {
            toggleBox(id,'',cookieMode); 
        };
        toggleSwitch.href="javascript:void(0)";
        toggleSwitch.className="multiBoxDisplayToggle";
        jQuery(thisBox).find("h6:first").append(toggleSwitch);
        var toggleValue= toggleState;
    } else {
        replaceClass = new RegExp("multiBoxDisplay"+toggleState);
        tglFct[id] = function() {
            jQuery(thisBox).toggleClass("multiBoxToggleClosed");
            if(cookieMode=="ON") {createCookie(cookieName,values[toggleState].reverseValue,1000)}
        }
        jQuery(thisBox).find(".content:first").slideToggle(animSpeed[id]-1,tglFct[id]());
       var toggleValue= values[toggleState].reverseValue;
    }
    lastBoxToggleState[id]= toggleValue;
    document.getElementById("box"+id+"toggle").title=values[toggleValue].title;
};


/* */


// ********************* 
// Topmenu hover function (for IE - make hover available for other than a-tag)
// *********************
var hoverBase;
var lastFocus;
sfHover = function() {
    guidsToParse="";
    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(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 (htmlEntityDecode(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) {
                                    var renderChildNav=function(parentElement,navObj){
                                        var obj=navObj.nav;
                                        var newUl=document.createElement("ul");
                                        newUl.className="horNav "+navObj.navHoverClass;
                                        newUl.id=(navObj.headline).split(' ').join('')+"SubNav";
                                        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;
                                                newA.title=obj[k].title;
                                                obj[k].target? newA.target=obj[k].target : "";
                                                //newA.className=obj[k].className;
                                                newA.innerHTML=obj[k].headline;
                                                newLi.appendChild(newA);
                                                if (obj[k].nav!="") {
                                                    renderChildNav(newLi,obj[k]);
                                                }
                                                newUl.appendChild(newLi);
                                            }
                                        }
                                        parentElement.appendChild(newUl);
                                        
                                    }


                                    sfEls[i].childNodes[0].href=stripLocalDomainFromExternalURL(extNavJSON[j].href);
                                    sfEls[i].childNodes[0].target=extNavJSON[j].target;
                                    sfEls[i].childNodes[0].title=extNavJSON[j].title;
                                    sfEls[i].childNodes[0].id=extNavJSON[j].id;
                                    if (extNavJSON[j].nav!="") {
                                        renderChildNav(sfEls[i],extNavJSON[j]);
                                    }

                                }
                            }
                        }
}
                    }
                }
            }


            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"});
                            }  
                            obj
                                .addClass("sfhover")
                                .find("ul:first")
                                .css({visibility:"visible", display:"block"})
                                .next().css("background-position","-10px top");
                            var myIframeWidth=obj.find("ul:first").outerWidth()-1;
                            var myIframeHeight=obj.find("ul:first").outerHeight()-2;
                            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:'about:blank',frameborder:'0',border:'0' } )
                                    .css( {
                                        border:"none",     
                                        height:myIframeHeight+"px",
                                        width:myIframeWidth+"px"
                                     } )
                                obj.prepend(hoverBase)
                            }

                        },
                        function() {
                            var obj=jQuery(this)
                            obj
                                .removeClass("sfhover")
                                .find("ul:first").css({visibility: "hidden"})
                                .next().css("background-position","left center");
                            document.all ? this.removeChild(hoverBase) : ""; // if IE, delete iframe 'base layer'

                        }
                    )
/* dev for accsessible navi
                    .find("a").focus(
                        function() {
                            var obj=jQuery(this).parent('li');
                            if ((obj.width()+16)>obj.find("ul:first").width()) {
                                obj.find("ul:first").css({width:(obj.width()+16)+"px"});
                            }  
                            obj
                                .addClass("sfhover")
                                .find("ul:first")
                                .css({visibility:"visible", display:"block"})
                                .next().css("background-position","-10px top");
                            var myIframeWidth=obj.find("ul:first").outerWidth()-1;
                            var myIframeHeight=obj.find("ul:first").outerHeight()-2;
                        }
                    )
*/
            }

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


 
/* *//* */
 
var zo; // declares a global symbol
if (!zo) zo = {};
    else if (typeof zo != 'object')
        throw new Error('zo exists, but is not an object!');


function flashMovieResize(object,width,height) {
    if (object=="") return;
    if (document.getElementById("flashobject"+object) ) {
        document.getElementById("flashobject"+object).width=width;
        document.getElementById("flashobject"+object).height=height;
    }
    if (document.getElementById("flashcontent"+object) ) {
        document.getElementById("flashcontent"+object).style.width=width+"px";
        document.getElementById("flashcontent"+object).style.height=height+"px";
    }
}

zo.submitSearch = function () {
 searchwindow = window.open('','db_search','toolbar=yes,location=no,directories=no,scrollbars=yes,status=yes,menubar=no,resizable=yes,width=717,height=600');
 searchwindow.focus();
}

zo.str_replace = function(repsearch, repreplace, repsubject) { return repsubject.split(repsearch).join(repreplace); }

zo.createTabsInTarget = function(targetElement,fullWidth,tabWidth,startTabHash) {  
    if (!startTabHash) {startTabHash="";}

    var numTabs = targetElement.find(".tabContent").length;
    if (numTabs<=1) {
        // TODO: Headergrafik bei Non-Tab-Optik
        return;
    }
    
    targetElement.find(".tabContent").each(function(ev){

        var backgroundImage = jQuery(this).closest('.tabContainer').css('background-image');
        if (typeof jQuery(this).find('a.tabBackground').attr('rel')!='undefined') {
            backgroundImage = jQuery(this).find('a.tabBackground').attr('rel');
        }
        var tabUrl = "";
        if (typeof jQuery(this).find('a.tabBackground').attr('name')!='undefined') {
            tabUrl = jQuery(this).find('a.tabBackground').attr('name');
        }

        jQuery(this).find('a.tabBackground').remove();

        headline = jQuery(this).find(".tabHeadline").remove().html();
        targetElement.find("ul:first")
          .removeClass("boxTop")
          .append(jQuery("<li></li>")
          .addClass("tab")
          .append(jQuery("<div></div>")
            .append(jQuery("<a></a>")
              .attr({href: "#"+tabUrl })
              .click(function(e){this.blur(); e.preventDefault();})
              .addClass("noTrack")
              .html(headline)
              .mouseenter(function(ev){
                this.blur();
                jQuery(this).trigger('changeTab');
                var targetHeight = jQuery(jQuery(this).data("myContent")).outerHeight()+"px";
                jQuery(jQuery(this).data("myContent"))
                    .addClass('activeContentTab')
                    .removeClass('inActiveContentTab')
                    .siblings()
                      .removeClass('activeContentTab')
                      .addClass('inActiveContentTab')
                    .end()
                    .closest('.tabContainer')
                       .css({backgroundImage:jQuery(this).data("myBackground")})
                    .end()
                    .closest(".tabContainer")
                       .css({height:targetHeight})
                ;
                jQuery(this)
                    .closest('li')
                    .addClass('active')
                    .siblings()
                      .removeClass('active')
                ;       
                })
              .data("myContent",this)              
              .data("myBackground",backgroundImage ) 
            )
          )
        )
        ;
    });

    if (tabWidth == 0) {
        tabWidth = parseInt((fullWidth + 3) / numTabs - 3); 
    }
    var calcWidth = (tabWidth + 3) * numTabs - 3;

    targetElement.find(".tabContainer .tabContent").css({position:"absolute"})
    targetElement.find(".tabContainer .tabContent:first")
        .addClass('activeContentTab')
        .siblings()
            .addClass('inActiveContentTab')
    ;

    var targetHeight = targetElement.find(".tabContainer .tabContent:first").outerHeight()+"px";
    targetElement.find(".tabContainer").css({height:targetHeight});

    targetElement.find("ul:first li:first").addClass("active");
    targetElement.find("ul:first li:last").addClass("last");

    targetElement.find("ul:first li").css("width",tabWidth+"px");

    var floatDiff = fullWidth - calcWidth; 
    if (floatDiff != 0) {
        targetElement.find("ul:first li:lt(" + Math.abs(floatDiff) + ")").css("width",(tabWidth + 1 )+"px");
    }

    var startTab = "";
    if (window.location.hash.length > 1) {
        startTab = targetElement.find("a[href='" + window.location.hash + "']");
    } else if (startTabHash.length > 0) {
        startTab = targetElement.find("a[href='#" + startTabHash + "']");
    }

    if (startTab.length==1) {
        jQuery(function(){startTab.trigger('mouseenter')});
    }

}

zo.createStockFeed = function(feedContent) {
    if (typeof(sharepriceObj)=='undefined') return "<span></span>";
    return "<span class='stockfeedJSON'>" + feedContent
      .replace(/%h/g, sharepriceObj.time[1].toString().split(":")[0])        // hours
      .replace(/%m/g, sharepriceObj.time[1].toString().split(":")[1])        // minutes
      .replace(/%t/g, sharepriceObj.time[0])                                 // timezone
      .replace(/%c/g, sharepriceObj.shareprice[0])                           // currency
      .replace(/%i/g, sharepriceObj.shareprice[1].toString().split(",")[0])  // value before comma
      .replace(/%d/g, sharepriceObj.shareprice[1].toString().split(",")[1])  // decimal value
      + "</span>";
}


zo.showHide = {
    init: function(pageID, closeAll) {
        var entries = jQuery('div#shBox' + pageID + '.toggleShowHide div.showHideEntry'),
            headlines = entries.find('h2'),
            content = entries.find('div.shItem'),
            self = this
        ;
        headlines
            .filter(':first')
            .addClass('closeClick')
            .css({'cursor': 'default'})
            .end()
            .not(':first')
            .addClass('openClick')
            .end()
            .bind('click', function(ev) {
                if (jQuery(this).hasClass('openClick') === true) {
                    self.toggle(this);
                }
            })
            .hover(
                function(){
                    if (jQuery(this).hasClass('openClick') === true) {
                        jQuery(this).addClass('newBlue clickHover');
                    }
                },
                function(){
                    jQuery(this).removeClass('newBlue clickHover');
                }
            )
        ;
        content.not(':first').hide();
    },
    toggle: function(evTarget) {
        jQuery(evTarget)
            .removeClass('openClick')
            .removeClass('newBlue clickHover')
            .css({'cursor': 'default'})
            .addClass('closeClick')
            .next('div.shItem:hidden')
            .slideDown(500)
            .end()
            .closest('div.toggleShowHide')
            .find('h2.closeClick')
            .not(evTarget)
            .removeClass('closeClick')
            .addClass('openClick')
            .css({'cursor': 'pointer'})
            .next('div.shItem:visible')
            .slideUp(500)
        ;
    }
};


zo.initAwards = function(awardslist) {
    awardslist 
        .find('.awardsEntry .awardsHead').each(function() {
            jQuery(this)
                .addClass("closeClick")
                .bind("click",function(ev){
                    if (jQuery(this).hasClass('openClick')===true) {
                        jQuery(this).closest('.awardsEntry').find('.closeMe').slideDown(300);
                    } else {
                        jQuery(this).closest('.awardsEntry').find('.closeMe').slideUp(200);
                    }
                    jQuery(this)
                        .toggleClass('openClick')
                        .toggleClass('closeClick');
                    return false;
                })
                .hover(function(){
                    jQuery(this).addClass('newBlue clickHover');
                },function(){
                    jQuery(this).removeClass('newBlue clickHover');
                })
            ;
        })
    ;

    awardslist.children().each( function() {
        var monthHead = jQuery(this);
        if (monthHead.hasClass('newslistMonth')) {
            monthHead
                .wrapInner('<a></a>')
                .find("a")
                .addClass('openClick')
                .addClass('newBlue2')
                .hover(function(e){jQuery(this).addClass('clickHover newBlue').removeClass('newBlue2');},function(e){jQuery(this).removeClass('clickHover newBlue').addClass('newBlue2');})
                .click(function(e){
                    var headl = jQuery(this);
                    if (headl.hasClass('openClick')) { // Open
                        headl.removeClass('openClick').addClass('closeClick');
                        headl.parent().next().slideDown(300);
                    } else { // Close
                        headl.addClass('openClick').removeClass('closeClick');
                        headl.parent().next().slideUp(200);
                    }
                })
                    .parent()
                    .next()
                    .hide()
            ;
        }
    });
    
    awardslist.find('.newslistMonth:first a')
            .addClass('closeClick')
            .removeClass('openClick')
                .parent()
                .next()
                .show();
}


zo.collapseNews = function(newslistClassID) {
  
  var newslist = jQuery(newslistClassID);
  newslist.children().each( function() {
      var monthHead = jQuery(this);
      if (monthHead.hasClass('newslistMonth')) {
          monthHead
              .wrapInner('<a></a>')
              .find("a")
              .addClass('openClick')
              .addClass('newBlue2')
              .hover(function(e){jQuery(this).addClass('clickHover newBlue').removeClass('newBlue2');},function(e){jQuery(this).removeClass('clickHover newBlue').addClass('newBlue2');})
              .click(function(e){
                  var headl = jQuery(this);
                  if (headl.hasClass('openClick')) { // Öffnen
                      headl.removeClass('openClick').addClass('closeClick');
                      headl.parent().next().slideDown(300)
                          .closest('.dbnNewsList').find('.newsEntries:not(:animated)')
                      ;
                  } else { // Schliessen
                     headl.addClass('openClick').removeClass('closeClick');
                     headl.parent().next().slideUp(200);
                  }
              })
                  .parent()
                  .next()
                  .hide()
          ;
      }
  });
  newslist.find('.newslistMonth:first a')
          .addClass('closeClick')
          .removeClass('openClick')
              .parent()
              .next()
              .show();
}



zo.alertBox = function(ev) {
    ev.preventDefault();
    jQuery('div.alertContainer').remove(); 
    var evTarget = jQuery(ev.target),
        isExtern = evTarget.closest('a').hasClass('alertBoxExtern'),
        alertText = isExtern ? "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." : "",
        alertAccept = "accept",
        alertDeny = "reject",
        target = evTarget.closest('a').attr('target'),
        href = evTarget.closest('a').attr('href'),
        posTop = evTarget.closest('a').offset().top - 10
    ;
    jQuery('<div></div>')
        .addClass('alertContainer font3')
        .css({'top': posTop+ 'px'})
        .append(jQuery('<div></div>')
            .addClass('alertBox colWidth3')
            .append(jQuery('<p></p>').html(alertText))
            .append(jQuery('<a></a>')
                .attr({'href': href,'target':target})
                .bind('click', function(ev) {
                    jQuery(this).closest('div.alertContainer').remove();
                })
                .html(alertAccept)
            )
            .append(jQuery('<a></a>')
                .attr({'href': '#close'})
                .bind('click', function(ev) {
                    ev.preventDefault();
                    jQuery(this).closest('div.alertContainer').remove();
                })
                .html(alertDeny)
            )
        )
        .appendTo('div#layoutComplete')
    ;


    jQuery(document).bind('click', function(ev) {
        if ((!jQuery(ev.target).closest('a').hasClass('alertBoxExtern') && !jQuery(ev.target).closest('a').hasClass('alertBoxIntern')) && !jQuery(ev.target).closest('div.alertContainer').length) {
            jQuery('div.alertContainer').remove();
            jQuery(document).unbind('click');
        }
    });


    // ESC: escape key pressed quits the alert box
    jQuery(document)
        .bind('keydown', function(ev) {
            if (ev.keyCode === 27) {
                jQuery('div.alertContainer').remove();
                jQuery(this).unbind('keydown');
            }
        })
    ;
};

// Initial Parsings after DomReady
jQuery(function() {
    jQuery('a.alertBoxIntern,a.alertBoxExtern').bind('click', function(ev) {
        zo.alertBox(ev);
    });

    jQuery('hr').wrap('<div class="hr"></div>');

});

/* TWITTER SNIPPET */





zo.twitterImport =
{
    conf: {
        // default values, do not change
        twFormat: 'JSON', // the response will use the JSONP format with a callback
        twUsername: '', // get tweets from a specified username
        twLang: '', // restricts tweets to the given language, given by an ISO 639-1 code
        twRpp: 0 // number of tweets to return per page
    },

    init: function(options)
    {
        var conf = this.conf;
        conf.twFormat = options.format;
        conf.twUsername = options.username;
        conf.twLang = options.lang;
        conf.twRpp = options.rpp;
        this.importTweets();
    },
    // import tweets using the JSONP format with an callback
    importTweets: function()
    {
        var conf = this.conf;
        if (conf.twFormat.toUpperCase() === "JSON") {
            jQuery.getJSON('http://search.twitter.com/search.json?q=from%3A' +conf.twUsername+ '&rpp=' +conf.twRpp+ '&callback=?',
                function(data) {
                    zo.twitterImport.buildTweetShow(data);
                }
            );
        }
    },
    
    buildTweetShow: function(data)
    {
        var conf = this.conf,
            url = /(\w+):\/\/([\w.]+)\/(\S*)/g;
        jQuery.each(data.results, function(i) {
            var twDate = new Date(this.created_at),
                twShowDate = strFormatDate("%B %e, %Y",twDate),
                twText = this.text,
                twUrl = twText.match(url), // parse urls
                twLink
            ;
            if (twUrl !== null) {
                for (var i=0, l=twUrl.length; i<l; i++) {
                    // build anchor with the parsed url
                    twLink = " <a href=\"" +twUrl[i]+ "\" target=\"_blank\">" +twUrl[i]+ "</a>";
                    // replace the url-string with the built anchor
                    twText = twText.replace(twUrl[i], twLink);
                }
            }
            // create tweet container with date and text
            jQuery('<div style=font-size:11px;></div>')
                .addClass('zoTweet')
                .append(jQuery('<p></p>')
                    .addClass('twDate block')
                    .text(twShowDate)
                )
                .append(jQuery('<p></p>')
                    .addClass('twText')
                    .html(twText)
                )
                .appendTo(jQuery('div#zoTweets'))
            ;
        });
    }
};



/* DateFormat Function */
var strFormatDate = function(dateFormat, date) {
  var date = date || new Date();
  var twDateMonthNames = ["January","February","March","April","May","June","July","August","September","October","November","December"];
  var dateFormatRe = new RegExp("%[eBY]","g");  
  
  return dateFormat.replace(dateFormatRe, function(m){
    switch(m) {
      case "%B" : return twDateMonthNames[date.getMonth()];
      case "%e" : return date.getDate();
      case "%Y" : return date.getFullYear();
      default   : return "";
    }
  }); 
}

/* Decodes HTML special characters */
var htmlEntityDecode = function(undecoded) {
    return jQuery('<div>'+undecoded+'</div>').remove().html();
}


/**/
 
zo.initFAQ = function (shId) {
jQuery('#'+shId).find('h2')
    .addClass('openClick')
    .hover(
        function(e){
            jQuery(this).addClass('newBlue clickHover');
        },
        function(e){
            jQuery(this).removeClass('newBlue clickHover');
        }
    )
    .click(
        function(e){
            e.preventDefault();
            this.blur();
            var hideContent = jQuery(this).closest('.FAQEntry').find('.hideContent');
            if (hideContent.hasClass('FAQHidden')) {
                hideContent
                    .slideDown(200)
                    .removeClass('FAQHidden');
                    jQuery(this).addClass('closeClick').removeClass('openClick');
            } else {
                hideContent
                    .slideUp(200)
                    .addClass('FAQHidden');
                    jQuery(this).addClass('openClick').removeClass('closeClick');
            }
        }
    )
    ;
}
 
/* *///
 




///* */
printPageURL="/extras/_css/print_popup.jsp";
swfToggleCookieName="swfToggle_46512E1306AA4BD8ABD7C3130B8D5689_ENG"
optEnableSwfDisplayToggle="false"
if (readCookie(swfToggleCookieName)) {
    parent.swfToggleState=readCookie(swfToggleCookieName)
} else {
    parent.swfToggleState=optEnableSwfDisplayToggle
}
var swfToggleValues = {
   swfToggleOFF: {
     reverseValue:"swfToggleON"
   },
   swfToggleON: {
     reverseValue:"swfToggleOFF"
   }
}
toggleSwfAbility= function(val) {
    createCookie(swfToggleCookieName,val,1000);
    location.reload();
}
if (readCookie('resize_fontsize')) {
    fontToggleState = readCookie('resize_fontsize')
} else {
    fontToggleState = "small"
}
var fontToggleValues = {
    small: {
        reverseValue: "medium"
    },
    medium: {
        reverseValue: "small"
    }
}
zo.getRightPos = function(obj) {
    var rightPos = (jQuery(obj).parent().offset().left+jQuery(obj).parent().width())-(jQuery(obj).offset().left+jQuery(obj).width());
    return rightPos;
}
  


function buildToolBox(boxPosition,printOpt,sendafriendOpt,bookmarkOpt,feedbackOpt,swfToggleOpt,trckPrefix) {
 var toolBarOuter = {};
 if("ON"=="ON") {
    clearToolbarNote =function(e) {
        showNote("ToolBarNote_"+boxPosition,"")
    };
    toolBarOuter=document.createElement("div");
    toolBarOuter.id="ToolBar_"+boxPosition;
    toolBarOuter.className="toolBarOuter";
    
        
    
    toolBarNote=document.createElement("span");
    toolBarNote.id="ToolBarNote_"+boxPosition;
    toolBarNote.className="ToolBarNote";
    toolBarNote.innerHTML="&nbsp;";
    toolBarInner=document.createElement("div");
    toolBarInner.className="toolBarInner";
    toolBarOuter.appendChild(toolBarNote);
    toolBarOuter.appendChild(toolBarInner);
    buttonMargin=6;
    if ("ON"!="OFF" && printOpt!="OFF") {
        toolBarPrint=document.createElement("a");
        toolBarPrint.title="Print version";
        toolBarPrint.className="toolBarPrint";
        toolBarPrint.href="#print";
        toolBarPrint.onclick=function(e) {
            printPopup=window.open('/extras/_css/print_popup.jsp','trgpopup','width=796,height=600,scrollbars=yes,resizable=no,menubar=yes,toolbar=yes'); printPopup.focus();
        };
        toolBarPrint.onmouseover=function(e) {
            jQuery("#ToolBarNote_"+boxPosition).css({right:zo.getRightPos(this)+"px"});
            showNote("ToolBarNote_"+boxPosition,"Print");
        };
        toolBarPrint.onmouseout=clearToolbarNote;
        toolBarInner.appendChild(toolBarPrint);
        buttonMargin=10;
    }
    if ("ON"!="OFF" && sendafriendOpt!="OFF" && "/extras/send-to-friend.jsp"!="") {
        toolBarSendafriend=document.createElement("a");
        toolBarSendafriend.title="Recommend  this page";
        toolBarSendafriend.className="toolBarSendafriend";
        //toolBarSendafriend.style.marginLeft=buttonMargin+"px";
        toolBarSendafriend.href="#sendafriend";
        toolBarSendafriend.onclick=function(e) {
            uriAnnex=encodeURIComponent(document.title);
            loadToolBoxIFrame("/extras/send-to-friend.jsp?lang=en&decorator=dbag&description="+uriAnnex+"&url="+window.parent.location.href,"540","700");
        };
        toolBarSendafriend.onmouseover=function(e) {
            jQuery("#ToolBarNote_"+boxPosition).css({right:zo.getRightPos(this)+"px"});
            showNote("ToolBarNote_"+boxPosition,"Email ");
        };
        toolBarSendafriend.onmouseout=clearToolbarNote;
        buttonMargin=6;
        toolBarInner.appendChild(toolBarSendafriend);
    }
    if ("ON"!="OFF" && bookmarkOpt!="OFF") {
        toolBarBookmark=document.createElement("a");
        toolBarBookmark.title="Add bookmark";
        //toolBarBookmark.style.marginLeft=buttonMargin+"px";
        toolBarBookmark.className="toolBarBookmark";
        toolBarBookmark.href="#bookmark";
        toolBarBookmark.onclick=function(e) {
            setBookmark();
        };
        toolBarBookmark.onmouseover=function(e) {
            jQuery("#ToolBarNote_"+boxPosition).css({right:zo.getRightPos(this)+"px"});
            showNote("ToolBarNote_"+boxPosition,"Bookmark");
        };
        toolBarBookmark.onmouseout=clearToolbarNote;
        buttonMargin=6;
        toolBarInner.appendChild(toolBarBookmark);
    }

    if ("OFF"!="OFF" && feedbackOpt!="OFF" && "https://secure.deutsche-bank.de/feedbackmanager/"!="") {
        toolBarFeedback=document.createElement("a");
        toolBarFeedback.title="Vote for this page";
        //toolBarFeedback.style.marginLeft=buttonMargin+"px";
        toolBarFeedback.className="toolBarFeedback";
        toolBarFeedback.href="#feedback";
        toolBarFeedback.onclick=function(e) {
            loadToolBoxIFrame("https://secure.deutsche-bank.de/feedbackmanager/?lang=en&decorator=dbag&","540","700");
        };
        toolBarFeedback.onmouseover=function(e) {
            jQuery("#ToolBarNote_"+boxPosition).css({right:zo.getRightPos(this)+"px"});
            showNote("ToolBarNote_"+boxPosition,"Feedback");
        };
        toolBarFeedback.onmouseout=clearToolbarNote;
        buttonMargin=6;
        toolBarInner.appendChild(toolBarFeedback);
        //var socialMediaButton = buildSocialMediaButton();
        //toolBarInner.appendChild(socialMediaButton);
        //jQuery('div.toolBarInner').append(socialMediaButton);
    }












  }
  return toolBarOuter;
}


/* handle >bookmark< klick */
function setBookmark() {
    ap=navigator.appName;
    url=location.href;
    t=document.getElementsByTagName("title")[0].innerHTML;
    if (window.sidebar) {
        window.sidebar.addPanel(t,url,'');
    } else if (window.external) {
        window.external.AddFavorite(url,t);
    } else if (window.addNet) {
        addNet(url,t);
    } else {
        alert("Ihr Browser unterst&uuml;tzt diese Funktion nicht.\nBitte Legen Sie das Lesezeichen manuell an.");
    }
}
var toolBoxParent;
function loadToolBoxIFrame(boxSrc,boxWidth,boxHeight,closeIconMode) {
    document.getElementById("toolBoxParent") ? document.body.removeChild(document.getElementById("toolBoxParent")) : "";
    toolBoxParent=document.createElement("div");
    toolBoxParent.id="toolBoxParent";
    toolBox=document.createElement("div");
    toolBox.className="toolBox";
    toolBox.style.left=((994-boxWidth)/2)+"px";

    toolBoxClose=document.createElement("a");
    toolBoxClose.className="toolBoxClose icon close hovericon";
    toolBoxClose.id="closeButton";
    toolBoxClose.href="javascript:void(0)";
    toolBoxClose.onclick= function() {
        toolBox.removeChild(toolBoxIFrame);
        lightboxx('toolBoxParent','self');
    };

    // toolBoxClose.innerHTML="close window";

    toolBoxIFrame=document.createElement("iframe");
    toolBoxIFrame.className="toolBoxIFrame";
    toolBoxIFrame.id="toolBoxIFrame";
    toolBoxIFrame.setAttribute("scrolling","No");
    toolBoxIFrame.setAttribute("frameBorder","0");
    toolBoxIFrame.style.width=boxWidth+"px";
    toolBoxIFrame.style.height=boxHeight+"px";
    lightboxx('toolBoxParent','insert',toolBoxParent);
    toolBoxParent.appendChild(toolBox);
    if(closeIconMode!="off") {
        toolBox.appendChild(toolBoxClose);
        myfunction= function(e) {document.getElementById("closeButton").style.display="inline";}
        toolBoxIFrame.attachEvent ? toolBoxIFrame.attachEvent("onload", myfunction) : toolBoxIFrame.onload = myfunction;
    }
//    toolBox.appendChild(toolBoxClose);
    toolBox.appendChild(toolBoxIFrame);
    document.getElementById(toolBoxIFrame.id).src=boxSrc;
    window.scrollTo(100, 100);
}
function resizeToolBoxIFrame(boxWidth,boxHeight) {
    toolBoxIFrame.style.width=boxWidth+"px";
    toolBoxIFrame.style.height=boxHeight+"px";
}

activateFontResizing="ON";


function buildFontSizeButtons()
{
    

    return {};
    


}


function buildSocialMediaButton()
{
    return jQuery('<a></a>')
        .attr({ 'href': '#socialmedia', 'name': 'socialmedia', 'id': 'socialmedia' })
        .addClass('fontSizeButton')
        .click(function(ev) {
            ev.preventDefault;
            if (jQuery('#socialmediaList').length) {
                jQuery('#socialmediaList').show();
            }
            else {
                jQuery(this)
                    .parent()
                    .append(jQuery('<div></div>')
                        .attr('id', 'socialmediaList')
                        .css({
                            'position': 'absolute',
                            'bottom': '20px',
                            'left': '10px',
                            'width': '100px',
                            'background': '#333',
                            'display': 'block'
                        })
                        .click(function() { jQuery(this).hide() })
                        .append(jQuery('<span></span>')
                            .html('Social Media')
                        )
                        .append(jQuery('<ul></ul>')
                            .append(jQuery('<li></li>')
                                .append(jQuery('<a></a>')
                                    .attr('href', '#browser')
                                    .html('Browser')
                                )
                                .addClass('browser spacer')
                            )
                            .append(jQuery('<li></li>')
                                .append(jQuery('<a></a>')
                                    .attr('href', '#delicious')
                                    .html('Del.Icio.Us')
                                )
                                .addClass('delicious')
                            )
                            .append(jQuery('<li></li>')
                                .append(jQuery('<a></a>')
                                    .attr('href', '#mrwong')
                                    .html('Mister Wong')
                                )
                                .addClass('mrwong')
                            )
                            .append(jQuery('<li></li>')
                                .append(jQuery('<a></a>')
                                    .attr('href', '#linkarena')
                                    .html('Linkarena')
                                )
                                .addClass('linkarena')
                            )
                            .append(jQuery('<li></li>')
                                .append(jQuery('<a></a>')
                                    .attr('href', '#yigg')
                                    .html('Y!GG')
                                )
                                .addClass('yigg')
                            )
                            .append(jQuery('<li></li>')
                                .append(jQuery('<a></a>')
                                    .attr('href', '#google')
                                    .html('Google')
                                )
                                .addClass('google')
                            )
                        )
                    )
                ;
            }
        })
        .hover(
            function() { showNote('fontResizingBarNote', 'Social Media'); },
            function() { showNote('fontResizingBarNote', ''); }
        )
    ;
}



cssHref= new Object();
cssHref['small']= "/extras/_css/fontsize_default.css";
cssHref['medium']= "/extras/_css/fontsize_medium.css";
cssHref['large']= "/extras/_css/fontsize_large.css";

function change_size(fontSize) {
    document.getElementById("fontSizeCSS").href=cssHref[fontSize];
    eraseCookie('resize_fontsize');
    createCookie('resize_fontsize',fontSize,'2160');
}
if (readCookie('resize_fontsize') && activateFontResizing=="ON") {
    change_size(readCookie('resize_fontsize'));
/**
    jQuery(document).ready(function() {
        jQuery('a#font').trigger('click');
    });
*/
}
function toggleContrast() {
 if (document.getElementById('contrastCSS')) {
    document.getElementById('contrastCSS').href="";
    document.getElementsByTagName('head')[0].removeChild(document.getElementById('contrastCSS'));
    eraseCookie('contrastToggle');
  } else {
    contrastCSS  = document.createElement('link');
    contrastCSS.rel  = "stylesheet";
    contrastCSS.type = "text/css";
    contrastCSS.href = "/extras/_css/contrast.css";
    contrastCSS.id = "contrastCSS";
    document.getElementsByTagName('head')[0].appendChild(contrastCSS);
    createCookie('contrastToggle','ON','2160');
  }
}
if (readCookie('contrastToggle') && activateFontResizing=="ON") {
    toggleContrast();    
}
/* */activateFontResizing="ON";

function buildFontSizeButtons()
{
    if(activateFontResizing=="ON") {
        var fontResizingBarOuter = jQuery('<div></div>').addClass('fontResizingBarOuter'),
            fontResizingBarNote = jQuery('<span></span>').attr('id', 'fontResizingBarNote').addClass('ToolBarNote').html('&nbsp;'),
            fontResizingBarInner = jQuery('<div></div>').addClass('toolBarInner'),
            fontButton = jQuery('<a></a>')
                .attr({ 'href': '#fontsize', 'name': 'smallfont', 'id': 'font', 'title': 'Change text size', 'accesskey': '#' })
                .addClass('fontSizeButton')
/**
                .toggle(
                    function() { change_size('medium'); },
                    function() { change_size('small'); }
                )
*/
                .click(function() {
                    this.blur();
                    change_size(fontToggleValues[fontToggleState]['reverseValue']);
                    fontToggleState = fontToggleState == "small" ? "medium" : "small";
                })
                .hover(
                    function() {
                        jQuery("#fontResizingBarNote").css({right:zo.getRightPos(this)+"px"});
                        showNote('fontResizingBarNote', 'Text size');
                    },
                    function() { showNote('fontResizingBarNote', ''); }
                )
            ,
            contrastButton = jQuery('<a></a>')
                .attr({ 'href': '#contrast', 'name': 'contrast', 'id': 'contrast', 'title': 'Change contrast', 'accesskey': 'K'  })
                .addClass('fontSizeButton')
                .click(function() { this.blur(); toggleContrast(); })
                .hover(
                    function() { 
                        jQuery("#fontResizingBarNote").css({right:zo.getRightPos(this)+"px"});
                        showNote('fontResizingBarNote', 'Contrast'); 
                    },
                    function() { showNote('fontResizingBarNote', ''); }
                )
        ;

/**



*/
        fontResizingBarOuter
            .append(fontResizingBarNote)
            .append(
                fontResizingBarInner
                    .append(contrastButton)
                    .append(fontButton)
            )
        ;
        return fontResizingBarOuter;
    } else {
        return {};
    }

}


function launchLayer(theLayer, URL, Title, TitleParent) {
          if (theLayer.contains('send-to-friend')) {
                    var sendToFriendURL = window.location.pathname;
                    if (window.location.search.length > 0) {
                        sendToFriendURL = sendToFriendURL + '&' + window.location.search.Right(window.location.search.length - 1);
                    }        
                    if (window.location.hash.length > 0) {
                        sendToFriendURL = sendToFriendURL + window.location.hash;
                    }        
                    $('sendToFriendURL').value = sendToFriendURL;
                    $('sendToFriendTitle').value = document.title;
                    
                    if ((URL) && (Title) && (TitleParent)) {
                        $('sendToFriendPreview').setStyle('display','block');
                        $('messagePreview').setStyle('display','none');
                        $('sendToFriendTitlePreview').set('html', Title);
                        var sendToFriendURLPreview;
                        // remove host
                        if (URL.indexOf('http') > -1) { 
                          //  alert(URL.indexOf('/', 8))
                            URL = URL.substring(URL.indexOf('/', 8))
                            sendToFriendURLPreview = URL;
                            // alert('already has HTTP') 
                        } 
                        
                        $('sendToFriendURLPreview').set('html', 'https://' + location.host + URL);
                        $('sendToFriendTitle2Preview').set('html', TitleParent);
                        $('sendToFriendURL2').value = URL;
                        $('sendToFriendTitle').value = TitleParent;
                        $('sendToFriendTitle2').value = Title;
                        if ($('customSubject')) { $('customSubject').value = document.title; }
                    }
          }
}

// ****************************
//  FORM VALIDATION / LAYERS
// ****************************    
layerErrors = new Object();
layerErrors.username = "Please enter your username.";
layerErrors.password = "Please enter your password.";
layerErrors.new_password0 = "Please enter your new password.";
layerErrors.new_password_1 = "Please retype your new password.";
layerErrors.personalid = "Please enter your Personal ID.";
layerErrors.decodedphrase = "Please enter your Decoded Phrase.";
layerErrors.captcha = "Please enter a value in the Captcha field.";
layerErrors.question1 = "Please select your first challenge question.";
layerErrors.question2 = "Please select your second challenge question.";
layerErrors.question3 = "Please select your third challenge question.";
layerErrors.answer1 = "Please enter your first answer.";
layerErrors.answer2 = "Please enter your second answer.";
layerErrors.answer3 = "Please enter your third answer.";
layerErrors.sender_name = "Please enter your name.";
layerErrors.sender_email = "Please enter your email address.";
layerErrors.captchaText = "Please enter the text shown.";
layerErrors.primaryEmail = "Please enter your email address";
writeLayerErrors = function(errorArray,theForm) {
    // get height of div
    var divSize = $(theForm).getParent().getSize();
    // moo11 - divHeight = divSize.size.y;
    divHeight = divSize.y;
    // place error messages container
    new Element('ul', {'id': 'errorMessages', 'class': 'error'}).setStyle('padding-bottom','20px').injectBefore(theForm);
    
    // write error messages
    errorArray.each(function(item) {
        // moo11 - new Element('li').setHTML(layerErrors[item]).injectInside('errorMessages');
        new Element('li').set('html', layerErrors[item]).injectInside('errorMessages');
    });
    // get error messages height
    var errorsSize = $('errorMessages').getSize();
    // moo11 - errorsHeight = errorsSize.size.y;
    errorsHeight = errorsSize.y;
    $(theForm).getParent().setStyle('height', divHeight + errorsHeight);
}
removeLayerErrors = function(theForm) {
    // alert('hit removeLayerErrors');
    if ($('errorMessages')) {
        // alert('yes removeLayerErrors');
        var divSize = $(theForm).getParent().getSize();
        // moo11 - divHeight = divSize.size.y;
        divHeight = divSize.y;
        var errorsSize = $('errorMessages').getSize();
        // moo11 - errorsHeight = errorsSize.size.y;
        errorsHeight = errorsSize.y;
        $(theForm).getParent().setStyle('height', divHeight - errorsHeight);
        // moo11 - $('errorMessages').remove();
        $('errorMessages').dispose();
    }
    
    // moo11 - $ES('.error', theForm).each(function(item) { $(item).removeClass('error'); });
    $$('#' + theForm + ' .error').each(function(item) { $(item).removeClass('error'); });
}

submitLayerForm = function(theForm) {
    if (validateLayerForm(theForm)) {
        /* moo11 - $(theForm).send({
            update: $('layerContainer'), 
            evalScripts: 'true', 
            headers: {'If-Modified-Since': 'Sat, 1 Jan 2000 00:00:00 GMT'}
        }); */
                    
        $(theForm).set('send', {
            noCache: true,
            onSuccess: function(response) {
                $('layerContainer').set('html', response);
            },
            evalScripts: true
        }).send();  
        return false;
    }
    else { 
        return false; 
    }
}
validateLayerForm = function(theForm) {
    // alert('hit validateLayerForm');
    var isError = false;
    var errorFields = new Array();
    
    removeLayerErrors(theForm);
    
    // alert($$('#' + theForm + ' .reqField').length);
    
    // moo11 - $ES('.reqField', theForm).each(function(item) {
    $$('#' + theForm + ' .reqField').each(function(item) {
        
        // alert('hit switch');
        // check blank fields
        switch (item.type) {
            
            case "text":
            case "password":
            case "select-one":
            case "textarea":
            
                // moo11 - if (item.id == 'username' && (item.getValue().length == 0 || item.getValue().toLowerCase() == 'username')) {
                if (item.id == 'username' && (item.get('value').length == 0 || item.get('value').toLowerCase() == 'username')) {
                    isError = true;
                    errorFields.push(item.id);
                    $(item).getParent().addClass('error');
                }
                // moo11 - else if (item.id == 'password' && (item.getValue().length == 0 || item.getValue().toLowerCase() == 'password')) {
                else if (item.id == 'password' && (item.get('value').length == 0 || item.get('value').toLowerCase() == 'password')) {
                    isError = true;
                    errorFields.push(item.id);
                    $(item).getParent().addClass('error');
                }
                // moo11 - else if ((item.id == 'sender_name' && $(item).getValue() == 'Name') || (item.id == 'sender_email' && $(item).getValue() == 'Email')) {
                else if ((item.id == 'sender_name' && $(item).get('value') == 'Name') || (item.id == 'sender_email' && $(item).get('value') == 'Email')) {
                    isError = true;
                    errorFields.push(item.id);
                    $(item).getParent().addClass('error');
                }
                else if (item.id == 'personalid' && (item.get('value').length == 0 || item.get('value').toLowerCase() == 'personal id')) {
                    isError = true;
                    errorFields.push(item.id);
                    $(item).getParent().addClass('error');
                }
                else if (item.id == 'decodedphrase' && (item.get('value').length == 0 || item.get('value').toLowerCase() == 'decoded phrase')) {
                    isError = true;
                    errorFields.push(item.id);
                    $(item).getParent().addClass('error');
                }
                // moo11 - else if ($(item).getValue().length == 0) {
                else if ($(item).get('value').length == 0) {
                    isError = true;
                    errorFields.push(item.id);
                    $(item).getParent().addClass('error');
                }
                break;
        }
        
    });
    if (!isError) { return true; }
    else {
        // alert('YES errors');
        writeLayerErrors(errorFields, theForm); 
    }
}

closeLayer = function() {
        // moo11 - $('layerContainer').remove();
        $('layerContainer').dispose();
        // moo11 - $('siteOverlay').remove();
        $('siteOverlay').dispose();
    }

//leaving the site check
initPage =  function() {
    // moo11 - $ES('a',startID).each(function(item) {
    $$('body a').each(function(item) {
        // external links
        if (item.href && item.href.substring(0, 4) == 'http') { //&& item.href.substring(0, 6) != 'mailto' // external links
            if (item.hostname.split(':')[0] != location.hostname.split(':')[0]) {
                // portal.rreef.com only open in a new window
                if (item.hostname.toLowerCase().contains('portal.rreef.com') || item.hostname.toLowerCase().contains('rreefclientconnect.com') || item.href == "http://www.businesshealth.com.au/mini/?SurveyID=DWS2008&l=1") {
                    item.target = "_blank";
                //any domain other than rreef.com, go through the Disclaimer page
                }else if(!item.href.toLowerCase().contains('rreef.com')){                    
                    var exitURL = '/extras/bye.jsp?url=' + item.protocol + '//' + item.hostname;
                    
                    if (item.pathname.substring(0, 1) != '/') { exitURL += '/'; }
                    exitURL += item.pathname;
                    
                    if (item.search.length > 0) {
                        exitURL = exitURL + '&' + item.search.substring(this.length -(item.search.length - 1));
                    }
                    item.href = exitURL;
                    item.target = "_blank";
                }
            }
            else {
                // pdfs, ppt, doc, DST pages
                if (item.href.toLowerCase().substring(this.length - 3) == 'pdf' || item.href.toLowerCase().substring(this.length - 3) == 'ppt' || item.href.toLowerCase().substring(this.length - 3) == 'doc') {
                    item.target = "_blank";
                }
            }
        }
    });
}

//FILTERING
 filterArticles = function(tag, yearId) {
    var yearVal = 'all';
    
    yearVal   = document.getElementById(yearId).value;
    
    var tagList = $A(document.getElementsByTagName(tag));
        
    $$(tagList).each(function(item) { 
        
        if (yearVal == 'all') {
            $(item).show();        
        }else {
                if($(item).hasClass(yearVal) || yearVal == 'all'){
                    $(item).show();
                }else{
                    $(item).hide();
                }
              }
        
    });
}

addOption = function(listbox, value){
  if(value != ""){ 
    var itemExists = false;
    $("#" + listbox + " option").each(function() {
      if ($(this).text() == value) {
         itemExists = true;                        
      }
    });
                
    if(!itemExists) {
      $("#" + listbox + "").append("<option value=\"" + value + "\">" + value + "</option>");
    }
  }
}

$(document).ready(function()
  {
    $("div.clientLogin").mouseover(function () 
    {
     $(this).addClass("clientLoginOn");
    });
    $("div.clientLogin").mouseout(function () 
    {
     $(this).removeClass("clientLoginOn");
    });
  });

function initPage() {
}

//
