function showNote(posId,msg) {
    toolDisplayObj = document.getElementById(posId);
    if (toolDisplayObj) {
     toolDisplayObj.innerHTML = msg;
    }
}

function clearInput(obj) {
    obj.value="";
    obj.onclick="";
}

function lightboxx(objID,mode,obj) {
    if(!document.getElementById("lightbox")) {
        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) {
            document.body.insertBefore(obj,document.body.firstChild);
        }
        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";
        }
        document.body.removeChild(document.getElementById('lightboxOuter'));
        if (mode=="self" && flashVars[objID]) { // ONLY FOR MOVIE PLAYER
            closeMovie(objID,"internal");
        } else if (obj) {
            document.body.removeChild(obj);
        } else if (mode=="self" && document.getElementById(objID)) {
            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="/de/data/js/flashbuilder.js"


function buildToolBox() {}



///* BACKGROUND PADDING */

/* 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!');
zo.cBg = {
    init: function() {
        this.resizeBg();
        this.switchBg();
    },
    resizeBg: function() {
        var w = jQuery(window),
            wWidth = w.width(),
            c = jQuery('div#layoutPositioner'),
            cWidthOuter = cWidthOrigin = c.outerWidth(),
            cWidthInner = c.width(),
            originPadding = newPadding = parseInt((cWidthOuter - cWidthInner)/2, 10)
        ;
        w.bind('resize', function() {
            wWidth = w.width();
            cWidthOuter = c.outerWidth();
            switch (true) {
                case ((wWidth < cWidthOuter && wWidth > cWidthInner) || (wWidth > cWidthOuter && wWidth < cWidthOrigin)):
                    // window width inside the width with padding
                    newPadding = (wWidth-cWidthInner)/2;
                    newPadding = newPadding > 0 ? newPadding : "0";
                    newPadding = "0 " +(newPadding.toString(10)+ "px");
                    break;
                case (wWidth < cWidthInner):
                    // window width is lesser than content width
                    newPadding = "0";
                    break;
                case (wWidth > cWidthOrigin):
                    // window width is greater than content width with padding
                    newPadding = "0 " +(originPadding.toString(10)+ "px");
                    break;
            }
            c.css('padding', newPadding);
        });
    },

    switchBg: function() {
        jQuery('a.switch').bind('mouseover', function(ev) {
            ev.preventDefault();

            window.clearInterval(cbInterval);

            var swClass = jQuery(this).attr('id'),
                acClass = jQuery.trim(jQuery('div[class*=bgImg-]').attr('class')).match(/bgImg-.+/)[0]
            ;
            if (swClass !== acClass) {
                var leftPos = swClass.split('-');
                leftPos = 65 + (parseInt(leftPos[1]) - 1) * 83;

                // move arrow and text
                jQuery('img#arrow').css('left', leftPos);

                jQuery('div#hoverText')
                    .css('left',leftPos-130)
                    .children().hide()
                    .end()
                    .children('span#'+swClass).show();
                jQuery('div[class*=bgImg-]').removeClass(acClass).addClass(swClass);
            }
        }).bind('mouseout', function(ev) {
            counter = jQuery(this).attr('id').split('-');
            counter = counter[1];

            cbInterval = window.setInterval("changeBackground()", timeToChange);

        });
    }
};



jQuery(function() {
    zo.cBg.init();
    jQuery(window).trigger('resize');
});

/* /BACKGROUND PADDING */


function clearInputVal(elem) {
    alert('clear');
}

printPageURL="/de/data/js/print_popup.htm";
function buildToolBox(boxPosition,printOpt,sendafriendOpt,bookmarkOpt,feedbackOpt,trckPrefix) {
 if("ON"=="ON") {
    clearToolbarNote =function(e) {
        showNote("ToolBarNote_"+boxPosition,"")
    };
    document.write("<span id='toolBarArea_"+boxPosition+"'></span>");
    toolBarOuter=document.createElement("div");
    toolBarOuter.id="ToolBar_"+boxPosition;
    toolBarOuter.className="toolBarOuter";




    //boxPosition=="bottom" ? toolBarOuter.style.paddingTop="10px" : "";
    toolBarOuter.style.paddingTop="";

    toolBarNote=document.createElement("span");
    toolBarNote.id="ToolBarNote_"+boxPosition;
    toolBarNote.className="ToolBarNote";
    toolBarNote.innerHTML="&nbsp;";
    toolBarInner=document.createElement("div");
    toolBarInner.className="toolBarInner";
    document.getElementById("toolBarArea_"+boxPosition).appendChild(toolBarOuter);//
    toolBarOuter.appendChild(toolBarNote);
    toolBarOuter.appendChild(toolBarInner);
    buttonMargin=6;


    if ("ON"!="OFF" && bookmarkOpt!="OFF") {
        toolBarBookmark=document.createElement("a");
        toolBarBookmark.title="Add bookmark";
        toolBarBookmark.style.marginRight=buttonMargin+"px";
        toolBarBookmark.className="toolBarBookmark";
        toolBarBookmark.onclick=function(e) {
            setBookmark();
        };
        if (boxPosition != 'bottom') {
            toolBarBookmark.onmouseover=function(e) {
                showNote("ToolBarNote_"+boxPosition,"Bookmark");
            };
            toolBarBookmark.onmouseout=clearToolbarNote;
        }
        buttonMargin=6;
        toolBarInner.appendChild(toolBarBookmark);
    }


    if ("ON"!="OFF" && sendafriendOpt!="OFF" && "/de/data/php/sendafriend.php"!="") {
        var sendafriendLayer = jQuery('<div id="sendafriendLayer"></div>')
                .append(jQuery('<div class="header"></div>'))
                .append(jQuery('<div class="inner"></div>')
                    .append(jQuery('<a href="#close" title="close window" class="closeButton font2" onclick="jQuery.fancybox.close();">close window</a>'))
                    .append(jQuery('<h1>Recommend this page</h1>'))
                    .append(
                        setForm()
                    )
                    .append(jQuery('<p class="footer font2">Copyright &copy; Xella Group, Duisburg</p>'))
                )
        ;

        toolBarInner.appendChild(
            jQuery('<a href="#sendAfriend" class="toolBarSendafriend" style="margin-right:' +buttonMargin+ 'px;" title="Recommend this page"></a>')
                .bind({
                    mouseover: function() { if (boxPosition != 'bottom') showNote('ToolBarNote_' +boxPosition, 'E-mail'); },
                    mouseout: function() { if (boxPosition != 'bottom') showNote('ToolBarNote_' +boxPosition, ''); }
                })
                .fancybox({content:sendafriendLayer, titleFormat:null, titleShow:false})
                .get(0)
        );
        buttonMargin=6;
    }


    if ("ON"!="OFF" && printOpt!="OFF") {
        toolBarInner.appendChild(
            jQuery('<span></span>')
                .append(jQuery('<a href="#print" title="Print this page" class="toolBarPrint"></a>')
                    .bind({
                        click: function(ev) {
                            ev.preventDefault();
                            window.print();
                        },
                        mouseover: function() { if (boxPosition != 'bottom') showNote('ToolBarNote_' +boxPosition, 'Print'); },
                        mouseout: function() { if (boxPosition != 'bottom') showNote('ToolBarNote_' +boxPosition, ''); }
                    })
                )
                .get(0)
        );
        buttonMargin=10;
    }




    if ("OFF"!="OFF" && feedbackOpt!="OFF" && "https://secure.deutsche-bank.de/feedbackmanager/"!="") {
        toolBarFeedback=document.createElement("a");
        toolBarFeedback.title="Vote this page";
        toolBarFeedback.style.marginLeft=buttonMargin+"px";
        toolBarFeedback.className="toolBarFeedback";
        toolBarFeedback.onclick=function(e) {
            loadToolBoxIFrame("https://secure.deutsche-bank.de/feedbackmanager/?lang=en&decorator=dbag&","736","700");
        };
        toolBarFeedback.onmouseover=function(e) {
            showNote("ToolBarNote_"+boxPosition,"Feedback");
        };
        toolBarFeedback.onmouseout=clearToolbarNote;
        buttonMargin=6;
        toolBarInner.appendChild(toolBarFeedback);
    }

  }
}


/** form handling */
var validMailAddress = /^[\d\w!\#\$%&\'*+\-/=?\^_`{|}~]+(\.?([\d\w!\#\$%&\'*+\-/=?\^_`{|}~]+\.)*[\d\w!\#\$%&\'*+\-/=?\^_`{|}~]+)?\@(([a-zA-Z0-9]+-?)*[a-zA-Z0-9]+\.)+[a-zA-Z]{2,6}$/,
clearInputVal = function(elem) {
    var $this = jQuery(elem);
    if ($this.val() === 'name@domain.tld') { $this.val('').removeClass('default'); }
},
checkInputVal = function(elem) {
    var $this = jQuery(elem);
    if ($this.hasClass('required')) {
        if ($this.val() && $this.val() !== 'name@domain.tld' && !$this.val().match(validMailAddress)) { $this.addClass('ERROR'); }
        else if ($this.hasClass('ERROR')) { $this.removeClass('ERROR'); }
    }
    if (!$this.val()) { $this.val('name@domain.tld').addClass('default'); }
},
checkInputVals = function(elem) {
    var $form = jQuery(elem),
        $input = $form.find('input:text'),
        validate = true;
    $input.each(function(i) {
        var $this = jQuery(this);
        if ($this.hasClass('required') && validate == true) {
            if (!$this.val() || $this.val() === 'name@domain.tld' || $this.hasClass('ERROR')) {
                validate = false;
                jQuery($input[i]).addClass('ERROR');
            }
        }
    });

    if(validate == true) {
        /*
            jQuery.ajax({
                type:'POST',
                async: false,
                url: $form.attr('action'),
                data: $form.serialize(),
                success: function(data, textStatus) {
                    returnValue = data.replace (/^\s+/, '').replace (/\s+$/, '');

                    if(returnValue == "mailSent"){
                        $form.replaceWith(jQuery('<div id="messageBlock"><p>The page was recommended to the recipient.</p></div>').append(jQuery('<p></p>').append('<a href="#" onclick="jQuery(\'div#messageBlock\').replaceWith(setForm());">Recommend this page again</a>')));
                    } else {
                        $form.replaceWith(jQuery('<p>There was an error, please try again.</p>'));
                    }
                }
            });
        */

        jQuery.post($form.attr('action'),$form.serialize(),function(data,textStatus){
            returnValue = data.replace (/^\s+/, '').replace (/\s+$/, '');

            if(returnValue == "mailSent"){
                $form.replaceWith(jQuery('<div id="messageBlock" style="margin-bottom: 150px;"><p>The page was recommended to the recipient.</p><br /></div>').append(jQuery('<p></p>').append('<a href="#" onclick="jQuery(\'div#messageBlock\').replaceWith(setForm());">Recommend this page again</a>')));
            } else {
                $form.replaceWith(jQuery('<div id="messageBlock" style="margin-bottom: 150px;"><p>There was an error, please try again.</p><br /></div>').append(jQuery('<p></p>').append('<a href="#" onclick="jQuery(\'div#messageBlock\').replaceWith(setForm());">Recommend this page again</a>')));
            }
        });
    }
    return false;
};


function setForm() {
    var ownUrl = location.href;

    if(location.hash) {
        ownUrl = ownUrl.substring(0,ownUrl.indexOf('#'));
    }
    var $form = jQuery('<form id="sendafriendForm" method="post" action="/de/data/php/sendafriend.php" onsubmit="return checkInputVals(this)"></form>')
                        .append(jQuery('<p>I would like to recommend this page:</p><br />'))
                        .append(jQuery('<label for="sendafriendFormRecipient" class="font2">Recipient Email:</label>'))
                        .append(jQuery('<input type="text" class="sendafriendAddressfield default required" id="sendafriendFormRecipient" name="sendafriendFormRecipient" value="name@domain.tld" onfocus="clearInputVal(this);" onblur="checkInputVal(this);" /><br /><br />'))
                        .append(jQuery('<label for="sendafriendFormSender" class="font2">Sender Email:</label>'))
                        .append(jQuery('<input type="text" class="sendafriendAddressfield default required" id="sendafriendFormSender" name="sendafriendFormSender" value="name@domain.tld" onfocus="clearInputVal(this);" onblur="checkInputVal(this);" />'))
                        .append(jQuery('<input type="hidden" name="url" value="' + ownUrl + '" />'))
                        .append(jQuery('<input type="submit" class="submit" value="Send" />'));

    return $form;
}



/* 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) {
    document.getElementById("toolBoxParent") ? document.body.removeChild(document.getElementById("toolBoxParent")) : "";
    toolBoxParent=document.createElement("div");
    toolBoxParent.id="toolBoxParent";
    toolBox=document.createElement("div");
    toolBox.className="toolBox";
    toolBox.id="toolBox";
    toolBoxClose=document.createElement("a");
    toolBoxClose.className="toolBoxClose icon close";
    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");
    myfunction= function(e) {document.getElementById("closeButton").style.display="inline";}
    toolBoxIFrame.attachEvent ? toolBoxIFrame.attachEvent("onload", myfunction) : toolBoxIFrame.onload = myfunction;
    toolBoxIFrame.style.width=boxWidth+"px";
    toolBoxIFrame.style.height=boxHeight+"px";
    lightboxx('toolBoxParent','insert',toolBoxParent);
    toolBoxParent.appendChild(toolBox);
    toolBox.appendChild(toolBoxClose);
    toolBox.appendChild(toolBoxIFrame);
    document.getElementById(toolBoxIFrame.id).src=boxSrc;
    window.scrollTo(100, 100);
}


// 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);
}



/** FONT AND CONTRAST TOGGLING */

var buildFontToggleButtons = function() {
    jQuery('<div id="fontToggleButtons"></div>')
        .append(buildButtons('fontToggle','font_large','Change text size'))
        .append(buildButtons('contrastToggle','contrast_high','Change Contrast'))
        .prependTo('#ToolBar_bottom')
    ;
},
buildButtons = function(type, state, text) {
    if (jQuery.cookie(type)) { state = jQuery.cookie(type); }
    var button = jQuery('<div id="' +type+ '" class="' +state+ '"></div>')
        .attr('title', text)
        .bind('click', function(ev) {
            var $this = jQuery(this),
                parts = $this.attr('class').split('_');
            if (parts[0] == 'contrast') {
                if (parts[1] == 'low') {
                    jQuery('link#css_contrast').removeAttr('href');
                    $this.attr('class', 'contrast_high');
                    jQuery.cookie(type, null);
                } else {
                    jQuery('link#css_contrast').attr('href','/de/data/css/966.css');
                    $this.attr('class', 'contrast_low');
                    jQuery.cookie(type, 'contrast_high', {expires:7});
                }
            } else {
                if (parts[1] == 'small') {
                    jQuery('link#css_font').attr('href','/de/data/css/font_size.css');
                    $this.attr('class', 'font_large');
                    jQuery.cookie(type, null);
                } else {
                    jQuery('link#css_font').attr('href','/de/data/css/965.css');
                    $this.attr('class', 'font_small');
                    jQuery.cookie(type, 'font_large', {expires:7});
                }
            }
        })
    ;
    if (jQuery.cookie(type)) { button.trigger('click'); }
    return button;
};function fadeStages(elements, waitTime, counter){
            jQuery(elements[counter]).children().first().stop(true, true);
            var element = jQuery(elements[counter]).children().first();
            if(counter < elements.length-1){
                var recCounter = (counter + 1);
            }
            else{
                var recCounter = 0;
            }
            //jQuery(element).delay(500);
            jQuery(element).fadeIn( function(){
                jQuery(element).delay(waitTime);
                jQuery(element).fadeOut( function(){
                        fadeStages(elements, waitTime, recCounter);
                    }
                );
            });
        }
      jQuery(document).ready(function(){
          jQuery("#mediastage").show();
          jQuery("#content_2").hide();
          jQuery("#content_3").hide();
          jQuery("#content_4").hide();
        jQuery("#stage_tab_2").hide();
        jQuery("#stage_tab_3").hide();
        jQuery("#stage_tab_4").hide();
        jQuery("#stage_tab_5").hide();
        jQuery("#stage_tab_6").hide();
        jQuery("#stage_tab_7").hide();
        jQuery(".stageImage").hide();
        jQuery(".stageImage").first().show();
        // When a link is hovered
        jQuery("a.tab").hover(function (){
            jQuery(".stageImage").hide();
            // switch all tabs off
            jQuery(".active").removeClass("active");
            // switch this tab on
            jQuery(this).addClass("active");
            jQuery(this).find("img").fadeTo('fast',0.5);
            jQuery(this).find("span").addClass('hoverArrow');
            // hide all elements with the class 'content'
            jQuery(".content").hide();
            // hide all elements with the class 'stage'
            jQuery(".stage").hide();
            //figure out what the 'title' attribute value is and find the element with that id.  Then show.
            var content_show = jQuery(this).attr("title");
            jQuery("#"+content_show).show();
        }, function(){
            jQuery(this).find("img").fadeTo('fast',1.0);
            jQuery(this).find("span").removeClass('hoverArrow');
        });
        jQuery("a.tab").hover(function(){
            var stage_show = jQuery(this).attr("id");
            var stage_show2 = "#stage_"+stage_show;
            var elements = jQuery(stage_show2).children();
            //show stage according to hovered tab
            jQuery(stage_show2).show();
            for(var j=0; j < elements.length; j++)
            {
                jQuery(elements[j]).find("img").stop(true, true);
            }
            if (elements.length > 1){
                //slideshow for hovered tab
                fadeStages(elements, 5000, 0);
            }
            else
            {
                jQuery(elements).first().children().first().fadeIn();
            }
        },function(){
            var stage_show = jQuery(this).attr("id");
            var stage_show2 = "#stage_"+stage_show;
            var elements = jQuery(stage_show2).children();
        });
      });/**
 * *****************************************************************************
 *
 * The dmf core package
 *
 *
 * @package:    dmf.core
 * @version:    0.1
 * @requires:   -
 * @author:     Stefan Kloiber <hello@10.fresh-flava.net>
 * @copyright:  c 2010
 *
 * $Revision: 22 $
 * $Author: stefan $
 * $Date: 2010-05-13 14:44:11 +0200 (Do, 13 Mai 2010) $
 *
 * *****************************************************************************
 */

(function(window) {
// define only one global symbol, named 'dmf'
var dmf = window.dmf =
{
    core:
    {
        // the current version of the core package
        version:0.1,
        // define a new class
        defineClass: function(name, config)
        {
            //
            var classname = name,
                superclass = config.extend || Object,
                constructor = config.construct || function() {},
                methods = config.methods || {},
                statics = config.statics || {},
                requires,
                provides
            ;
            //
            if (!config.requires) requires = [];
            else if (config.requires instanceof Array) requires = config.requires;
            else requires = [ config.requires ];
            //
            if (!config.provides) provides = [];
            else if (config.provides instanceof Array) provides = config.provides;
            else provides = [ config.provides ];
            //
            var proto = new superclass();
            //
            for (var p in proto)
                if (proto.hasOwnProperty(p)) delete proto[p];
            // check for requirements
            for (var i=-1, l=requires.length; ++i<l;) {
                var r = requires[i];
                if (window[ r.symbol ]) {
                    if (r.version && window[ r.symbol ].version) {
                        if (r.version === window[ r.symbol ].version) continue;
                        else throw new Error('Version clash');
                    }
                } else throw new Error(r.symbol+ ' is required!');
            }
            //
            for (var p in methods) proto[p] = methods[p];
            //
            proto.constructor = constructor;
            proto.superclass = superclass;
            //
            if (classname) proto.classname = classname;
            //
            for (var i=-1, l=provides.length; ++i<l;) {
                var c = provides[i];
                for (var p in c.prototype) {
                    if (typeof c.prototype[p] != "function") continue;
                    if (p == "constructor" || p == "superclass") continue;
                    if (p in proto &&
                        typeof proto[p] == "function" &&
                        proto[p].length == c.prototype[p].length) continue;
                    throw new Error('Class \'' +classname+ '\' doesn\'t provide the following methods: ' +c.classname + '.' +p);
                }
            }
            //
            constructor.prototype = proto;

            //
            for (var p in statics) constructor[p] = config.statics[p];
            //
            return constructor;
        },
        // validates if a package with the given name already exists
        isDefined: function(name) {
            return name in this.packages;
        },
        // reference to the global namespace
        globalNamespace: this,
        // list of loaded packages
        packages: {},
        // define a package
        Package: function(name, version)
        {
            // check the validity of the given name: the name must be declared,
            // should not start or end with a dot or having one dot after
            // another
            if (!name) throw new Error('dmf.core.package(): name required');
            if (name.charAt(0) == '.' ||
                name.charAt(name.length-1) == '.' ||
                name.indexOf('..') != -1)
                throw new Error('dmf.core.package(): illegal name: ' +name);
            // split the name at the dots and create the needed hierarchy
            var parts = name.split('.');
            // for each namespace component either a object will be initiated
            // or it will be ensured that the object still exists
            var container = dmf.core.globalNamespace;
            for (var i=-1, l=parts.length; ++i<l;) {
                var part = parts[i];
                // if the container doesn't hold a property with the name, a
                // empty container will be created
                if (!container[part]) container[part] = {};
                else if (typeof container[part] != "object") {
                    // if the property is already set, ensure that it is a
                    // object
                    var n = parts.slice(0,i).join('.');
                    throw new Error(n+ ' still exists, but is not an object!');
                }
                container = container[part];
            }
            // the last traversed container is the new namespace
            var namespace = container;
            // check if a name already exists for the new namespace
            if (namespace.NAME) throw new Error('Package ' +name+ ' already exists');
            // initialise name and version
            namespace.NAME = name;
            if (version) namespace.VERSION = version;
            // register the namespace into the list if all packages
            dmf.core.packages[name] = namespace;
            return namespace;
        }
    }
};
})(window);/**
 * *****************************************************************************
 *
 * The dmf utils package
 *
 *
 * @package:    dmf.utils
 * @version:    0.1
 * @requires:   dmf.core 0.1, jQuery 1.4.2
 * @author:     Stefan Kloiber <hello@10.fresh-flava.net>
 * @copyright:  c 2010 FreshFlava
 *
 * $Revision: 23 $
 * $Author: stefan $
 * $Date: 2010-05-13 14:46:47 +0200 (Do, 13 Mai 2010) $
 *
 * *****************************************************************************
 */

dmf.core.Package('dmf.utils', 0.1);
/**
 * String extensions
 *
 * endsWith:
 * startWith:
 * ucFirst:
 *
 */
String.prototype.endsWith = function(str) {
    return this.match(/str$/) == str;
};
String.prototype.startsWith = function(str) {
    return this.match(/^str/) == str;
};
String.prototype.ucFirst = function() {
    var str = this.match(/^(\w{1})(\w*)/);
    return str[1].toUpperCase()+str[2];
};


dmf.utils =
    dmf.core.defineClass('utils', {
        construct: function() {
            this.$doc = jQuery(document);
        },
        requires: [{symbol:'jQuery',version:'1.4.2'}],
        methods: {
            include: function(type, opt) {
                if (!type) throw new Error('type not set');
                if (!opt || typeof opt !== 'object') throw new Error('options not set');
                var $head = this.$doc.find('head');
                switch (type) {
                    case "js":
                    case "javascript":
                    case "JavaScript":
                        var $lastScript = $head.find('script[type=text/javascript]:last'),
                            inc = jQuery('<script type="text/javascript" src="' +opt.src+ '"></script>');
                        if ($lastScript.length) inc.insertAfter($lastScript);
                            else $head.append(inc);
                        break;
                    case "css":
                    case "stylesheet":
                    case "cascadingstylesheet":
                    case "CascadingStyleSheet":
                        // IE
                        if (document.createStyleSheet) document.createStyleSheet(opt.src);
                        // W3C DOM
                        else {
                            var $lastSheet = $head.find('link[type=text/css]:last'),
                                inc = jQuery('<link type="text/css" href="' +opt.src+ '" rel="stylesheet" media="' +opt.media+ '" />');

                            if ($lastSheet.length) inc.insertAfter($lastSheet);
                                else $head.append(inc);
                        }
                        break;
                }
            }
        }
    })
;

/**
 * *****************************************************************************
 *
 * Xella Feature Box
 *
 *
 * @package:    xella.featureBox
 * @requires:   dmf.core 0.1, dmf.utils 0.1,
 *              jQuery 1.4.2, jQuery.ui 1.8.1, jQuery.cookie
 * @version:    0.1
 * @author:     Stefan Kloiber <s.kloiber@zeros.ones.de>
 * @copyright:  c 2010 zeros+ones, Agentur fuer neue Medien GmbH
 *
 * *****************************************************************************
 */
var fbFromAjax = false;

dmf.core.Package('xella.featureBox', 0.1);

xella.featureBox =
{
    curNavItem: null,
    curNavTimer: null,

    init: dmf.core.defineClass('xella.featureBox', {
        requires: [{symbol:'jQuery', version:'1.4.2'}],
        construct: function(options) {
            var _this = this;
            // check the application state
            this.stateCookieName = "fbState";
            this.state = this.getState();





            // save a root elemen reference
            this.$doc = jQuery(document);
            // featureBox container
            this.$fbContainer = options.featureBox
                ? this.$doc.find(options.featureBox)
                : this.$doc.find('div#featureBox');
            this.$fbContent = this.$fbContainer.children();

            // check for IE
            this.isIE = !jQuery.support.opacity ? true : false;
            // check for IE6
            this.isIE6 = (jQuery.browser.msie && jQuery.browser.version <= 6) ?
                true : false;

            //
            this.buildFeatureBox();
        },

        methods: {

            buildFeatureBox: function() {
                // remove nodes from container
                this.$fbContainer.empty();
                // rebuild the featureBox
                this.$fbContainer.append(
                    '<div id="fbMain">'
                    + '<ul id="fbNav"></ul>'
                    + '<div id="fbContent"></div>'
                    + '</div>'
                );
                var _this = this,
                    content = this.parseContent(),
                    fbGlobal = content.global,
                    fbLocale = content.locale,
                    $fbNav = this.$fbContainer.find('ul#fbNav'),
                    $fbContent = this.$fbContainer.find('div#fbContent'),
                    $bgContainer = jQuery('#typeA #layoutPositioner');

                // global top
                if (fbGlobal.top) {
                    this.$fbContainer.prepend('<div id="fbTop">' +fbGlobal.top.html()+ '</div>');
                }
                // content
                for (var i=-1, l=fbLocale.length; ++i<l;) {
                    var item = fbLocale[i],
                        ident = "";
                    // first nav level
                    $fbNav.append(
                        jQuery(item.navItem).find('a').bind('click', function(ev) {
                            ev.preventDefault();
                            var $this = jQuery(this),
                                $elem = jQuery('div#featureBox div#fbContent')
                            ;

                            // former method doesn't work with RedDot/IE
                            //ident = $this.attr('href').substring(2);
                            ident = jQuery(this).attr('href').split("#_");
                            ident = ident[1];

                            // hide overlay gallery
                            if ($elem.find('div.overlayFrame').length) {
                                $elem.find('div.overlayFrame').remove();
                            }

                            // set active nav item
                            $this.parent()
                                .addClass('active')
                                .siblings().removeClass('active')
                                .find('li').removeClass('active')
                                .end().end()
                                .find('li:first').addClass('active')
                                .siblings().removeClass('active')
                                .parent()
                                .children()
                                .find('li').removeClass('active');


                            // change background
//                            $bgContainer.removeClass().addClass('bg'+ident).data('ident', 'bg'+ident);

                            // display content
                            $elem
                                .find('>div').hide()
                                .filter('div#' +ident).show()
                            ;
                            $elem =  $elem.find('div#' +ident);
                            // scrollable content
                            if ($elem.find('div.scrollable').length) {
                                // scrollable content
                                $elem.find('div.fbcontent')
                                    .scrollable({vertical:true, mousewheel:true, clickable:false, size:4})
                                ;
                            }

                            // image tooltip on news items
                            _this.newsTooltip($elem);

                            // scroll bar news
                            if($elem.find('div.news').length){
                                jQuery('#scroll-pane100').jScrollPane({showArrows:true,scrollbarWidth:16});
                            }

                            // photo gallery: references
                            if ($elem.find('div.fbcontent div.referenceGallery div.galleryItem').length) {
                                _this.switchGalleryItem($elem);
                            } else {
                                // remove background image on page change (if no reference gallery is set)
                                $elem
                                    .find('div.fbcontent')
                                    .css('background-image', 'none')
                                    .find('div.descriptionNew')
                                    .remove();
                            }

                            // photo gallery: overlay
                            if ($elem.find('div.fbcontent div.overlayGallery div.galleryItem').length) {
                                _this.showOverlayItem($elem);
                            }

                            // check for a second level navigation
                            if (jQuery('div#featureBox div#fbContent').find('div#' +ident+ ':contains(div.submenu)')) {
                                jQuery('div#featureBox div#fbContent')
                                    .find('div#' +ident+ ' div.submenu div.subpage').hide()
                                    .end()
                                    .find('div#' +ident+ ' div.submenu div.subpage:first').show()
                                    .end()
                                    .find('div.subnavigationRight li').removeClass('active')
                                    .end()
                                    .find('div.subpageContent').css('right','-415px');
                            }

                            // Title-Flash-Hash Bug in IE
                            if(_this.isIE) {
                                fixAnchorTitleBug();
                            }

                        })
/*
                        .bind('mouseover', function(ev) {
                            ev.preventDefault();
                            var $this = jQuery(this),
                                ident = jQuery(this).attr('href').split("#_"),
                                ident = ident[1],
                                fastIdent = jQuery(ev.currentTarget).attr('href').split('#_'),
                                fastIdent = fastIdent[1];
                            xella.featureBox.curNavItem = fastIdent;
                            if (xella.featureBox.curNavTimer !== null) {
                                clearTimeout(xella.featureBox.curNavTimer);
                            }
                            xella.featureBox.curNavTimer = setTimeout(function() {
                                if (xella.featureBox.curNavItem !== null) {
                                    $bgContainer.removeClass().addClass('bg'+ident);
                                }
                            },250);
                        })
                        .bind('mouseleave', function(ev) {
                            xella.featureBox.curNavItem = null;
                        })
*/
                        .end()
                    );

                    // add and hide content
                    $fbContent.append(jQuery(item.content).hide());

                    // second nav level
                    if (item.subNavItems) {

                        $fbContent.find('div#'+item.ident+' div.submenu')
                            .append(jQuery('<div class="subnavigationRight"></div>')).find('div.subnavigationRight')
                            .append('<h3>'+$fbNav.find('li:last').text()+'</h3>')
                            .append(
                                jQuery(item.subNavItems).find('a').bind('click', function(ev) {
                                    ev.preventDefault();

                                    // former method doesn't work with RedDot/IE
                                    //ident = jQuery(this).attr('href').substring(2);
                                    var ident = jQuery(this).attr('href').split("#_"),
                                        ident = ident[1],
                                        parentIdent = ident.split('Sub'),
                                        parentIdent = parentIdent[0];

                                    // change background
//                                    $bgContainer.removeClass().addClass('bg'+parentIdent).data('ident', 'bg'+parentIdent);

                                    // set parent nav item active
                                    jQuery('a[href*=#_' +parentIdent+ ']')
                                        .parent()
                                        .addClass('active');

                                    // set active nav item
                                    jQuery(this)
                                        .parent().addClass('active')
                                        .siblings().removeClass('active')
                                        .parent()
                                        .closest('li').addClass('active')
                                        .siblings().removeClass('active');
                                    var $elem = jQuery('div#featureBox div#fbContent');




                                    // animate submenu
                                    $elem
                                        .find('div.subpageContent').hide()
                                        .end()
                                        .find('div#' +ident)
                                        .find('div.subpageContent').css('right','-415px').show().animate({right:'0px'}, 'slow');

                                    $elem
                                        .find('>div').hide().end()
                                        .find('div#' +ident).show()
                                        .closest('div.submenu').find('div.subpage').not('div#' +ident).hide()
                                        .closest('div.fbSubPage:hidden').show()
                                    ;

                                    // photo gallery
                                    if ($elem.find('div.fbcontent div.overlayGallery div.galleryItem').length) {
                                        _this.showOverlayItem($elem);
                                    } else {
                                        // remove background image on page change (if no reference gallery is set)
                                        $elem
                                            .find('div.fbcontent')
                                            .css('background-image', 'none')
                                            .find('div.descriptionNew')
                                            .remove();
                                    }

                                })
                                .end()
                        ).addClass('item_submenu')
                         .find('li:last').find('a').addClass('sub_last');
                        // hide second nav content
                        $fbContent.find('div.fbcontent.submenu:last div.subpage').hide();
                    }

                }

/*                $fbNav.bind('mouseleave', function() {
                    $bgContainer.removeClass().addClass($bgContainer.data('ident'));
                });
*/




            },

            // reference gallery
            switchGalleryItem: function(elem) {
                var $cont = elem.find('div.referenceGallery'),
                    firstItem = elem.find('div.galleryItem:first'),
                    firstImageSrc = firstItem.find('a').attr('href'),
                    firstImageDesc = firstItem.find('div.description').html(),
                    fbContent = jQuery('div#'+this.state+' div.fbcontent');

                // automatically set first reference image as background
                fbContent
                        .css('background-image', 'url(' + firstImageSrc + ')')
                        .find('div.descriptionNew').remove()
                        .end()
                        .append(
                            jQuery('<div class="descriptionNew">' + firstImageDesc + '</div>')
                        );
                // reset all thumbnail border colors
                elem
                    .find('div.galleryItem > a')
                    .removeClass('coloredBorder');
                // set first thumbnail border color
                firstItem.find('a').addClass('coloredBorder');
                $cont.delegate('div.galleryItem a', 'click', function(ev) {
                    ev.preventDefault();
                    var $this = jQuery(this),
                        imgSrc = $this.attr('href'),
                        imgDesc = $this.parent().find('div.description').html()
                    ;
                    // set link active
                    $this
                        .addClass('coloredBorder')
                        .parent()
                        .siblings()
                        .find('a').removeClass('coloredBorder');
                    fbContent
                            .css('background-image', 'url(' + imgSrc + ')')
                            .find('div.descriptionNew').remove()
                            .end()
                            .append(
                                jQuery('<div class="descriptionNew">' + imgDesc + '</div>')
                            );

                });
            },

            // overlay gallery
            showOverlayItem: function(elem) {

                var $cont = elem.find('div.overlayGallery');

                $cont.delegate('div.galleryItem a', 'click', function(ev) {
                    ev.preventDefault();
                    var $this = jQuery(this),
                        imgSrc = $this.attr('href'),
                        ident = window.location.hash.substring(2).split('Sub')[0],
                        imgClose = '<div class="closeFrame"><a href="#close"><img src="/de/img/overlay_close.gif" border="0" alt="Close frame" title="Close frame"></a></div>',
                        imgDesc = '<div class="descriptionNew">' +$this.parent().find('div.description').html()+'</div>'
                    ;

                    $this.addClass('coloredBorder')
                        .parent()
                        .siblings()
                        .find('a').removeClass('coloredBorder');

                   if (!elem.find('div.overlayFrame').length) {
                        jQuery('div#'+ident+' div.overlayGallery').before(
                            jQuery('<div class="overlayFrame"></div>')
                        );
                    }

                    elem.find('div.overlayFrame')
                        .css('background','url('+ imgSrc +') no-repeat')
                           .find('div.closeFrame').remove()
                        .end()
                        .append(imgClose)
                        .find('div.descriptionNew').remove()
                        .end()
                        .append(imgDesc);

                    elem.find('div.overlayFrame a[href*=#close]')
                        .bind('click', function(ev) {
                            ev.preventDefault();
                            elem.find('div.overlayFrame').remove();

                           $this.removeClass('coloredBorder')
                            .parent()
                            .siblings()
                            .find('a').removeClass('coloredBorder');

                        });
                });
            },

            // image tooltip on news items
            newsTooltip: function(elem)
            {
                if (elem.find('div.news').length) {
                    var newsItems = elem.find('div.news div.sNewsEntry'),
                        $newsItemFirstSrc = elem.find('div.news:first img').attr('src'),
                        $newsImageBig = jQuery('div#newsImageBig')
                    ;
                    if($newsItemFirstSrc != "") {
                        $newsImageBig
                               .removeClass('dummyPic')
                            .css('background','url('+$newsItemFirstSrc+') no-repeat');
                    } else {
                        $newsImageBig.addClass('dummyPic');
                    }
                    newsItems.each(function() {
                        var $newsItem = jQuery(this),
                            $newsItemImg = $newsItem.find('img').hide()
                        ;
                            $newsItem.hover(
                                function() {
                                    if($newsItemImg.attr('src') != "") {
                                        $newsImageBig
                                            .removeClass('dummyPic')
                                            .css('background','url('+$newsItemImg.attr('src')+') no-repeat');
                                    } else {
                                        $newsImageBig.addClass('dummyPic');
                                    }
                                }
                            );
                    });
                }
            },

            // state accessors
            setState: function(ident){
                this.state = ident;
                jQuery.cookie(this.stateCookieName, ident);
                window.location.hash = "_" +ident;
            },
            getState: function() {
                if (this.state) return this.state;
                var fbHash = window.location.hash.substring(2);
                fbHash = (fbHash && jQuery('div#featureBox div#' +fbHash).length)
                    ? fbHash : false;
                this.state = fbHash || jQuery.cookie(this.stateCookieName);
                return this.state;
            },

            parseContent: function() {
                var _this = this,
                    $subPages = this.$fbContent.filter('div.fbSubPage'),
                    content = {
                        global:{
                            footer:this.$fbContent.filter('div.footer')
                        },
                        locale:[]
                    },
                    tmpContent = {};
                $subPages.each(function(key,value) {
                    var $this = jQuery(this),
                        tmpContent = {},
                        subNavItems = "",
                        ident = $this.attr('id'),
                        specialPage = $this.hasClass('fbNoBorder') ? ' class="fbNoBorderMenu"' : '';

                    if ($this.find('>div.fbcontent').hasClass('submenu')) {
                        $this.find('>div.fbcontent div.subpage').each(function(k,v) {
                            var $sub = jQuery(this);
                            subNavItems += '<li><a href="#_' +ident+ 'Sub' +k+ '">' +$sub.find('>h3').remove().html()+ '</a></li>';
                            $sub.attr('id', ident+ 'Sub'+k);
                            // add the global footer if the photo-gallery is empty
                            _this.addGlobalFooter($sub, content.global.footer.html());

                            // add content box to subpage
                            var subpageContent = $sub.find('div.fbcontent').html();
                            $sub.find('div.fbcontent')
                                .html('')
                                .append('<div class="outerSubpageContent"><div class="subpageContent">'+subpageContent+'</div></div>');
                        });
                    }

                    // add the global footer if the photo-gallery is empty
                    _this.addGlobalFooter($this, content.global.footer.html());

                    tmpContent = {
                        ident: ident,
                        navItem: jQuery('<li' +specialPage+ '><a href="#_' +$this.attr('id')+ '">' +$this.find('>h2').remove().html()+ '</a></li>'),
                        subNavItems: $this.find('>div.fbcontent').hasClass('submenu') ? jQuery('<ul class="submenu">' +subNavItems+ '</ul>') : '',
                        content: $this
                    };
                    content.locale.push(tmpContent);
                });
                return content;
            },

            addGlobalFooter: function(elem, content) {
                // add the global footer if the photo-gallery is empty
                if (!elem.find('div.photoGallery').children().length) {
                    elem.find('div.photoGallery').append(content);
                }
            }

        }

    })
};

function initPage() {
}

function addEvent( obj, type, fn )
{
   if (obj.addEventListener) {
      obj.addEventListener( type, fn, false );
   } else if (obj.attachEvent) {
      obj["e"+type+fn] = fn;
      obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
      obj.attachEvent( "on"+type, obj[type+fn] );
   }
}
function removeEvent( obj, type, fn )
{
   if (obj.removeEventListener) {
      obj.removeEventListener( type, fn, false );
   } else if (obj.detachEvent) {
      obj.detachEvent( "on"+type, obj[type+fn] );
      obj[type+fn] = null;
      obj["e"+type+fn] = null;
   }
}


// Product Template jQuery
jQuery(document).ready(function(){
    jQuery('div.imageHover > a').hover(
        function() {
            jQuery(this).children().first().css('display','none');
            jQuery(this).children().last().css('display','block');
        },
        function() {
            jQuery(this).children().first().css('display','block');
            jQuery(this).children().last().css('display','none');
        }
    );
});
