/**
 * Textreplacement will be called inside the footer of the template because of the behaviour of the internet explorer. 
 * Textreplacement - http://wiki.github.com/sorccu/cufon/usage 
 */
Cufon.replace("#mainNav>ul:first-child>li>a",{hover:true, fontSize:'13px'});
Cufon.replace("#mainNav .tab a",{hover:true,fontSize:'13px'});
Cufon.replace('#content h1',{fontSize: '24px'});
Cufon.replace("body#thickbox h1",{fontSize: '24px'});
Cufon.replace("h1.imageTeaser",{fontSize: '29px'});
Cufon.replace("h1.imageTeaserBig",{fontSize: '29px'});
Cufon.replace("#contactForm h1");
Cufon.replace("h2");
Cufon.replace("#content h2");
Cufon.replace("#content h3");
Cufon.replace(".zoomListBig h3");
Cufon.replace(".headlineTeaser");
Cufon.replace(".NewimageTeaser");
Cufon.replace(".shortImageTeaser");
Cufon.replace(".shortImageTeaserGreen");
Cufon.replace(".relatedBox h2",{fontSize: '16px'});
Cufon.replace(".relatedBoxGreen h2",{fontSize: '16px'});
Cufon.replace(".relatedBox h3",{fontSize: '17px'});
Cufon.replace(".relatedBoxGreen h3",{fontSize: '16px'});
Cufon.replace(".overview4BtnTeaser h3",{fontSize: '18px'});
Cufon.replace(".overview4BtnTeaserSmall h3",{fontSize: '16px'});
Cufon.replace(".overviewSitemap h3",{fontSize: '18px'});
Cufon.replace(".overviewSitemap a",{fontSize: '13px'});
Cufon.replace(".threeColumnTeaser h3",{fontSize: '18px'});
Cufon.replace(".threeColumnTeaserCareer h3",{fontSize: '18px'});
Cufon.replace(".tabNavigation .tabs a",{fontSize: '16px'});
Cufon.replace(".tabNavigation .tabsHi a",{fontSize: '16px'});
Cufon.replace(".contactPerson dl");
Cufon.replace(".contactTrainer dl");
Cufon.replace(".contactTrainer dd.destination", {fontSize: '14px'});
Cufon.replace(".teaserBox .heading");
Cufon.replace("#industryList h3");
Cufon.replace(".selectServiceBox");
Cufon.replace("#shareTable .title .title1 span",{fontSize: '16px'});
Cufon.replace("#shareTable .title .title2 span",{fontSize: '16px'});
Cufon.replace("#shareTable .title .title3 span",{fontSize: '16px'});
Cufon.replace("#shareTable .title .title4 span",{fontSize: '16px'});
Cufon.replace("#mainTable .title .title2 span",{fontSize: '16px'});
Cufon.replace(".mDownload .dwnd-title a");
Cufon.replace("form label",{fontSize: '14px'});
Cufon.replace("#survey .contact label",{fontSize: '18px'});
Cufon.replace(".relatedBoxQuote p",{fontSize: '16px'});
Cufon.replace(".relatedBoxQuote .footer p",{fontSize: '13px'});
Cufon.replace("#dialogue p",{fontSize: '16px'});
Cufon.replace("#dialogue p.training",{fontSize: '15px'});
Cufon.replace(".relatedBox h3.training",{fontSize: '17px'});
Cufon.replace(".locationButtons dt",{fontSize: '18px'});
Cufon.replace(".locationButtons h3",{fontSize: '18px'});
Cufon.replace(".coursesButtons dt",{fontSize: '18px'});
Cufon.replace(".coursesButtons h3",{fontSize: '18px'});
Cufon.replace(".pullDownSearch dt",{fontSize: '18px'});
Cufon.replace(".pullDownSearchCourses dt",{fontSize: '18px'});
Cufon.replace(".pullDownSearchCourses label",{fontSize: '18px'});
Cufon.replace(".s2cBox dt",{fontSize: '13px'});
Cufon.replace(".s2cBox dd.title",{fontSize: '13px'});
Cufon.replace(".vacancyList th",{fontSize: '18px'});
Cufon.replace(".coursesList th",{hover:true, fontSize:'18px'});
Cufon.replace("#content .smallColumn h3",{fontSize: '14px'});
Cufon.replace(".selectserviceBox .text",{fontSize: '16px'});
Cufon.replace("#tradingInfo .text");
Cufon.replace(".bookmarkWrapper .bm_header",{fontSize: '14px'});
Cufon.replace(".logoListing .top h3", {fontSize: '21px'});
Cufon.replace(".wideColumn h3.top", {fontSize: '16px'});
Cufon.replace(".longBox .headSeminar", {fontSize: '16px'});



//Cufon.replace(".relatedBox h1",{textShadow: "#000 2px 2px .2px"});

/**
 * Starts all javascript which is needed after dom has been built.
 */
$(document).ready(function() {
     if($.browser.msie && $.browser.version.substr(0,1) < 7) { // IE6
        mainNavInitIE6();
        metaNavInitIE6();
        courseChangeInitIE6();
        cssInit();

    } else {
        mainNavInit();
        metaNavInit();
        courseChangeInit();

    }
    
    initOverview4BtnTeaser();
    initOverview4BtnTeaserSmall();
    initThreeColumnTeaser();
    initThreeColumnTeaserCareer();
    initIndustryBox();
    initInvestorsBox();
    initLocationButtons();
    initCoursesButtons();
    initStudyButtons();

   });
/**
 * Course change
 */
function courseChangeInit() {
    
    $("#courseChange li:has(.layer)").each(function() {
        $(this).find(".layer").wrapInner('<div class="wrapper">&nbsp;</div');
        $(this).find(".wrapper").prepend('<div class="topRight">&nbsp;</div').
        append('<div class="bottomRight">&nbsp;</div');
        
        var link = $(this).children("a").attr("href");
        var name = $(this).children("a").text();
        $(this).find(".wrapper").before('<div class="tab"><a href="' + link + '"><span>' + name +'</span></a></div>');
        //$(this).find(".tab").css("width",$(this).find(".tab").width());
    });
    
    $("#courseChange .wrapper").each(function() {
        var wrapperWidth = $(this).width();
        var wrapperHeight = $(this).innerHeight() + $(this).parent().find(".tab").height() - 5;
        
        $(this).css({"width":wrapperWidth + 30, "height":wrapperHeight});
        $(this).find(".bottomRight").css({"height":wrapperHeight - 20});
    });
    
    $("#courseChange li:has(.layer) a").mouseenter(function() {
        $(this).siblings(".layer").css("left","-1px");
    });
    
    $("#courseChange li:has(.layer) .layer").mouseleave(function() {
        $("#courseChange .layer").css("left","-99999px");
    });
    
    $("#courseChange").mouseleave(function() {
        $("#courseChange .layer").css("left","-99999px");
    });
    
};
/**
 * Course change
 */
function courseChangeInitIE6() {
    
    var courseChangeWidth = 100;
    
    $("#courseChange li:has(.layer)").each(function() {
        $(this).find(".layer").wrapInner('<div class="wrapper">&nbsp;</div');
        $(this).find(".wrapper").prepend('<div class="topRight">&nbsp;</div').
        append('<div class="bottomRight">&nbsp;</div');
        
        var link = $(this).children("a").attr("href");
        var name = $(this).children("a").text();
        $(this).find(".wrapper").before('<div class="tab"><a href="' + link + '"><span>' + name +'</span></a></div>');
    });
    
    $("#courseChange .wrapper").each(function() {
        var wrapperWidth = 100;
        var wrapperHeight = $(this).innerHeight() + $(this).parent().find(".tab").height() - 5;
        
        $(this).css({"width":wrapperWidth + 20, "height":wrapperHeight});
        $(this).find(".bottomRight").css({"height":wrapperHeight - 20});
    });
    
    $("#courseChange li:has(.layer) a").mouseenter(function() {
        $(this).siblings(".layer").css("left","-1px");
    });
    
    $("#courseChange li:has(.layer) .layer").mouseleave(function() {
        $("#courseChange .layer").css("left","-99999px");
    });
    
    $("#courseChange").mouseleave(function() {
        $("#courseChange .layer").css("left","-99999px");
    });
    
    $("#courseChange>ul>li").each(function() {
        courseChangeWidth += $(this).outerWidth();
    });
    
    $("#courseChange").css("width", courseChangeWidth);
    
};

/**
 * Meta navigation
 */
function metaNavInit() {
    
    $("#metaNav li:has(.layer)").each(function() {
        $(this).find(".layer").wrapInner('<div class="wrapper">&nbsp;</div');
        $(this).find(".wrapper").prepend('<div class="topRight">&nbsp;</div').
        append('<div class="bottomRight">&nbsp;</div');
        
        var link = $(this).children("a").attr("href");
        var name = $(this).children("a").text();
        $(this).find(".wrapper").before('<div class="tab"><a href="' + link + '"><span>' + name +'</span></a></div>');
        //$(this).find(".tab").css("width",$(this).find(".tab").width());
    });
    
    $("#metaNav .wrapper").each(function() {
        var wrapperWidth = $(this).width();
        var wrapperHeight = $(this).innerHeight() + $(this).parent().find(".tab").height() - 5;
        
        $(this).css({"width":wrapperWidth + 20, "height":wrapperHeight});
        $(this).find(".bottomRight").css({"height":wrapperHeight - 20});
    });
    
    $("#metaNav li:has(.layer) a").mouseenter(function() {
        $(this).siblings(".layer").css("left","-1px");
    });
    
    $("#metaNav li:has(.layer) .layer").mouseleave(function() {
        $("#metaNav .layer").css("left","-99999px");
    });
    
    $("#metaNav").mouseleave(function() {
        $("#metaNav .layer").css("left","-99999px");
    });
    
};

/**
 * Meta navigation
 */
function metaNavInitIE6() {
    
    var metaNavWidth = 20;
    
    $("#metaNav li:has(.layer)").each(function() {
        $(this).find(".layer").wrapInner('<div class="wrapper">&nbsp;</div');
        $(this).find(".wrapper").prepend('<div class="topRight">&nbsp;</div').
        append('<div class="bottomRight">&nbsp;</div');
        
        var link = $(this).children("a").attr("href");
        var name = $(this).children("a").text();
        $(this).find(".wrapper").before('<div class="tab"><a href="' + link + '"><span>' + name +'</span></a></div>');
    });
    
    $("#metaNav .wrapper").each(function() {
        var wrapperWidth = $(this).width();
        var wrapperHeight = $(this).innerHeight() + $(this).parent().find(".tab").height() - 5;
        
        $(this).css({"width":wrapperWidth + 20, "height":wrapperHeight});
        $(this).find(".bottomRight").css({"height":wrapperHeight - 20});
    });
    
    $("#metaNav li:has(.layer) a").mouseenter(function() {
        $(this).siblings(".layer").css("left","-1px");
    });
    
    $("#metaNav li:has(.layer) .layer").mouseleave(function() {
        $("#metaNav .layer").css("left","-99999px");
    });
    
    $("#metaNav").mouseleave(function() {
        $("#metaNav .layer").css("left","-99999px");
    });
    
    $("#metaNav>ul>li").each(function() {
        metaNavWidth += $(this).outerWidth();
    });
    
    $("#metaNav").css("width", metaNavWidth);
    
};
 
/**
 * Main navigation
 */
var bgSubSeparatorImage;
function mainNavInitIE6() {
    
    /* ---------->>> Set Interaction <<<-----------*/
    
    $("#mainNav ul:first-child>li>a").mouseenter(function() {
        $("#mainNav .layer").css("left","-99999px");
        $(this).siblings(".layer").css("left","-3px");    
    });
    
    $("#mainNav .layer").mouseleave(function() {
        $("#mainNav .layer").css("left","-99999px");
        $(this).find("a").removeClass("hoverIE");
        $(this).find(".level2 ul").hide();
    });
    
    $("#mainNav").mouseleave(function() {
        $("#mainNav .layer").css("left","-99999px");
    });
    
    $('.level2').wrap('<div class="innerWrapper" />');
    $('.innerWrapper').wrap('<div class="outerWrapper" />');                        
    $('<div class="top">&nbsp;</div>').insertBefore('.level2');    
    
    
    /* ---------->>> Build navigation <<<-----------*/
    
    var lastCatName = $(".level1>li:last a:first").text();
    var completeCatWidth = 0;
    
    $(".level1>li").each(function() {
        completeCatWidth += $(this).width();
    });
    
    bgSubSeparatorImage = $(".level2").css("background-image");
    //$(".level2").css("background","none");
    //$(".level3").css("background","none");
    
    // Disable border of level2, if no sub level is inside.
    $(".level2:not(:has(.level3))").css("background","none");
    $(".level2:not(:has(.level4))").find(".level3").css("background","none");
    
    
    $("#mainNav .level1>li .level2").each(function() {
        var layerHeight;
        var layerWidth;
        
        var level2Width = 0;
        var level3Width = 0;
        var level4Width = 0;
        
        layerHeight = $(this).outerHeight();
        level2Width = $(this).outerWidth();
        $(this).css("width",level2Width);
        
        // Search every ul inside this element and get the heighest
        $(this).children().find("ul").each(function() {
            setHeight($(this).outerHeight());
        });
        
        // Set every ul element inside this element to the heighest outer height
        $(this).children().find("ul").each(function() {
            $(this).css("height",layerHeight - 20);
        });
        $(this).css("height",layerHeight - 20);
        
        // Set positon of level3 and level4 to the broadest inner element and get also the broadest width of it.
        $(this).children().find(".level3").each(function() {
            $(this).prev().addClass("ieSub");
            setBiggestL3Width($(this).outerWidth());
            $(this).css({"left":level2Width});
            
            $(this).children().find(".level4").each(function() {
                $(this).prev().addClass("ieSub");
                setBiggestL4Width($(this).outerWidth());
                $(this).css({"left": $(this).parents(".level3").outerWidth()});
            });
            
        });
        
        // Set the width of each ul like the broadest element
        $(this).children().find(".level3").each(function() {
            $(this).css("width",$(this).outerWidth());
        });
        
        $(this).children().find(".level4").each(function() {
            $(this).css("width",$(this).outerWidth());
        });
        
        // Short function to get the biggest outer height and outer width inside a layer
        function setHeight(height) {
            if (layerHeight < height) {
                layerHeight = height + 20;
            }
        }
        
        function setBiggestL2Width(width) {
            if(level2Width < width) {
                level2Width = width;
            }
        }
        function setBiggestL3Width(width) {
            if(level3Width < width) {
                level3Width = width;
            }
        }
        
        function setBiggestL4Width(width) {
            if(level4Width < width) {
                level4Width = width;
            }
        }
        
        layerWidth = level2Width + 4;
        
        // Set correct wrapper measures.
        $(this).parents(".layer").find(".outerWrapper").css({"width":layerWidth - 10, "height":layerHeight});
        $(this).parents(".layer").find(".innerWrapper").css({"width":layerWidth - 10, "height":layerHeight});
        $(this).parents(".layer").find(".innerWrapper .top").css("width",layerWidth);
        
        // Set last category to the right
        if($(this).parents(".layer").prev().text() == lastCatName) {
            var layer = $(this).parents(".layer");
            var top = $(this).parents(".layer").find(".top");
            var position = -layerWidth + $(this).parents(".level1>li").width() + (974 - completeCatWidth);
            
            $('<div class="topLeft">&nbsp;</div>').insertBefore(top);
            layer.find(".top").css({"margin":"-10px 0 0 0"});
            layer.find(".tab a span").css("height","23px");
            layer.find(".outerWrapper").css("left", position);
            
            $(this).children().find(".level3").each(function() {
                $(this).css({"left":-$(this).outerWidth()});
                $(this).children().find(".level4").each(function() {
                    //$(this).prev().addClass("sub");
                    $(this).css({"width": $(this).outerWidth()});
                
                });
                
            });
        }
    
        // Set correct wrapper measures.
        $(this).parents(".layer").find(".outerWrapper").css({"height":layerHeight});
        $(this).parents(".layer").find(".innerWrapper").css({"height":layerHeight});
        
        $(".level3").hide();
        $(".level4").hide();
    
    });


    
    /* ---------->>> Show sub level <<<-----------*/
    
    $(".level1 a").parent().mouseenter(function() {
        
        var layerWidth;
        
        var level2Width;
        var level3Width;
        var level4Width;
        
        $(this).siblings().find("a").removeClass("hoverIE");
        
        // Level1
        if($(this).parent().is(".level1")) {
            level2Width = parseInt($(this).find(".level2").css("width"));
            layerWidth = level2Width;
            
            $(".level2").css("background","none");
            $(".level3").css("background","none");
            $(".level4").css("background","none");
            
            if($(this).find(".layer").find("cufontext").html() == lastCatName) {
                
                var position = -layerWidth + $(this).width() + (974 - completeCatWidth);
                var layer = $(this).find(".layer");
                
                    layer.find(".outerWrapper").css("left",position);
                    layer.find(".level2").css("left",5);
                
            }
            
        }
        
        // Level2
        if($(this).parent().is(".level2")) {
            
            $(".level3").hide();
            $(".level4").hide();
            
            $(this).children("ul").show();
            
            if($(this).find("ul").hasClass("level3")) {
                
                $(".level2").css({"background-image":bgSubSeparatorImage,"background-repeat":"repeat-y", "background-position":"top right"});
                level2Width = $(this).parent().outerWidth();
                level3Width = $(this).find(".level3").outerWidth();
                $(this).children("a").addClass("hoverIE");
                
                layerWidth = level2Width + level3Width;
                
                if($(this).parents(".layer").find("cufontext").html() == lastCatName) {
                    
                    $(".level2").css({"background-image":bgSubSeparatorImage,"background-repeat":"repeat-y", "background-position":"top left"});
                    
                    var position = -layerWidth + $(this).parents(".level1>li").width() + (974 - completeCatWidth);
                    var layer = $(this).parents(".layer");
                    
                    layer.find(".outerWrapper").css("left",position);
                    layer.find(".level2").css("left",level3Width+5);
                    
                }
    
            } else {
                
                $(".level2").css("background","none");
                level2Width = $(this).parent().outerWidth();
                layerWidth = level2Width;
                
                if($(this).parents(".layer").find("cufontext").html() == lastCatName) {
                    
                    var position = -layerWidth + $(this).parents(".level1>li").width() + (974 - completeCatWidth);
                    var layer = $(this).parents(".layer");
                    
                        layer.find(".outerWrapper").css("left",position);
                        layer.find(".level2").css("left",5);
                    
                }
                
            }
        
        }
        
        if($(this).parent().is(".level3")) {
            
            if($(this).find("ul").hasClass("level4")) {
                
                $(".level3").css({"background-image":bgSubSeparatorImage,"background-repeat":"repeat-y", "background-position":"top right"});
                $(this).children("a").addClass("hoverIE");
                $(this).children("ul").show();
                level2Width = $(this).parents(".level2").outerWidth();
                level3Width = $(this).parents(".level3").outerWidth();
                level4Width = $(this).find(".level4").outerWidth();
                
                layerWidth = level2Width + level3Width + level4Width;
            
            } else {
                
                level2Width = $(this).parents(".level2").outerWidth();
                level3Width = $(this).parents(".level3").outerWidth();
                
                layerWidth = level2Width + level3Width; 
                $(".level3").css("background","none");
                $(".level4").hide();
            }
        }
        
        // Set background layer
        if($(this).parent().is(".level1")) {
            
            $(this).find(".layer").find(".outerWrapper").css({"width":layerWidth - 10});
            $(this).find(".layer").find(".innerWrapper").css({"width":layerWidth - 10});
            $(this).find(".layer").find(".innerWrapper .top").css("width",layerWidth);
            
            if ($(this).find(".layer").find("cufontext").html() == lastCatName) {
                $(this).find(".layer").find(".innerWrapper .top").css("width",layerWidth);
            }
            
        } else {
            
            $(this).parents(".layer").find(".outerWrapper").css({"width":layerWidth - 10});
            $(this).parents(".layer").find(".innerWrapper").css({"width":layerWidth - 10});
            $(this).parents(".layer").find(".innerWrapper .top").css("width",layerWidth);
            
            if ($(this).parents(".layer").find("cufontext").html() == lastCatName) {
                $(this).parents(".layer").find(".innerWrapper .top").css("width",layerWidth);
            }
        }
        
    });
    
}
function mainNavInit() {
    
    var lastCatName = $(".level1>li:last a:first").text();
    var completeCatWidth = 0;
    
    // Calculates the width of the inner main categorys.
    $(".level1>li").each(function() {
        completeCatWidth += $(this).width();
    });
    
    bgSubSeparatorImage = $(".level2").css("background-image");
    $(".level2").css("background","none");
    $(".level3").css("background","none");
    
    $("#mainNav ul:first-child>li>a").mouseenter(function() {
        $("#mainNav .layer").css("left","-99999px");
        $(this).siblings(".layer").css("left","-3px");
        $("#mainNav ul:first-child>li").css("z-index","2");
        $(this).parents("li").css("z-index","3");
        
        if($.browser.msie && $.browser.version.substr(0,1) < 7) {
            $(this).parents().find(".layer").show();
        }
        
    });
    
    $("#mainNav .layer").mouseleave(function() {
        $("#mainNav .layer").css("left","-99999px");
        $(this).find("a").removeClass("hover");
        $(this).find(".level2 ul").hide();
        
        if($.browser.msie && $.browser.version.substr(0,1) < 7) { // IE6
            $(this).parents().find(".layer").hide();
        }
    });
    
    $("#mainNav").mouseleave(function() {
        $("#mainNav .layer").css("left","-99999px");
        if($.browser.msie && $.browser.version.substr(0,1) < 7) { // IE6
            $(this).parents().find(".layer").hide();
        }
    });
    //$("#mainNav .level1>li.mainNavAbout").find("ul").parent().next().css("margin-top","-15px");
    
    $('.level2').wrap('<div class="innerWrapper" />');
    $('.innerWrapper').wrap('<div class="outerWrapper" />');                        
    $('<div class="top">&nbsp;</div>').insertBefore('.level2');
        
    
    $("#mainNav .level1>li .level2").each(function() {
        
        var layerHeight;
        var layerWidth;
        
        var level2Width = 0;
        var level3Width = 0;
        var level4Width = 0;
        
        layerHeight = $(this).outerHeight() + 20;
        level2Width = $(this).outerWidth();
        $(this).css("width",level2Width);
        
        // Search every ul inside this element and get the heighest
        $(this).children().find("ul").each(function() {
            setHeight($(this).outerHeight());
        });
        
        // Set every ul element inside this element to the heighest outer height
        $(this).children().find("ul").each(function() {
            $(this).css("height",layerHeight - 20);
        });
        $(this).css("height",layerHeight - 20);
        
        // Set positon of level3 and level4 to the broadest inner element and get also the broadest width of it.
        $(this).children().find(".level3").each(function() {
            $(this).prev().addClass("sub");
            setBiggestL3Width($(this).outerWidth());
            $(this).css({"left":level2Width});
            
            $(this).children().find(".level4").each(function() {
                $(this).prev().addClass("sub");
                $(this).css({"left": $(this).parents(".level3").outerWidth()});
            });
            
        });
        
        
        // Set the width of each ul like the broadest element
        $(this).children().find(".level3").each(function() {
            $(this).css("width",$(this).outerWidth());
        });
        
        $(this).children().find(".level4").each(function() {
            //$(this).css("width",$(this).outerWidth());
        });
        
        // Short function to get the biggest outer height and outer width inside a layer
        function setHeight(height) {
            if (layerHeight < height) {
                layerHeight = height + 20;
            }
        }
        
        function setBiggestL2Width(width) {
            if(level2Width < width) {
                level2Width = width;
            }
        }
        function setBiggestL3Width(width) {
            if(level3Width < width) {
                level3Width = width;
            }
        }
        
        function setBiggestL4Width(width) {
            if(level4Width < width) {
                level4Width = width;
            }
        }
        
        layerWidth = level2Width + 4; /* + level3Width + level4Width + 4; */
        
        // Set last category to the right
        if($(this).parents(".layer").prev().text() == lastCatName) {
            var layer = $(this).parents(".layer");
            var top = $(this).parents(".layer").find(".top");
            var position = -layerWidth + $(this).parents(".level1>li").width() + (974 - completeCatWidth);
            
            $('<div class="topLeft">&nbsp;</div>').insertBefore(top);
            layer.find(".top").css({"margin":"-10px 0 0 7px"});
            layer.find(".tab a span").css("height","23px");
            layer.find(".outerWrapper").css("left", position);
            layer.find(".outerWrapper").css({"margin":"0px 0 0 -6px"});

            
            $(this).children().find(".level3").each(function() {
                $(this).css({"left":-$(this).outerWidth()});
                $(this).children().find(".level4").each(function() {
                    //$(this).prev().addClass("sub");
                    $(this).css({"width": $(this).outerWidth()});
                
                });
                
            });
        }
        
        // Set correct wrapper measures.
        $(this).parents(".layer").find(".outerWrapper").css({"height":layerHeight});
        $(this).parents(".layer").find(".innerWrapper").css({"height":layerHeight});
        
        $(".level3").hide();
        $(".level4").hide();
    
    });
    
    
    $(".level1 a").parent().mouseenter(function() {
        
        var layerWidth;
        
        var level2Width;
        var level3Width;
        var level4Width;
        
        $(this).siblings().find("a").removeClass("hover");
        
        // Level1
        if($(this).parent().is(".level1")) {
            level2Width = parseInt($(this).find(".level2").css("width"));
            layerWidth = level2Width;
            
            $(".level2").css("background","none");
            $(".level3").css("background","none");
            $(".level4").css("background","none");
            
            if($(this).find(".layer").find("cufontext").html() == lastCatName) {
                
                var position = -layerWidth + $(this).width() + (974 - completeCatWidth);
                var layer = $(this).find(".layer");
                
                    layer.find(".outerWrapper").css("left",position-4);
                    layer.find(".level2").css("left",5);
                
            }
            
        }
        
        // Level2
        if($(this).parent().is(".level2")) {
            
            $(".level3").hide();
            $(".level4").hide();
            
            $(this).children("a").addClass("hover");
            $(this).children("ul").show();
            
            if($(this).find("ul").hasClass("level3")) {
                
                $(".level2").css({"background-image":bgSubSeparatorImage,"background-repeat":"repeat-y", "background-position":"top right"});
                level2Width = $(this).parent().outerWidth();
                level3Width = $(this).find(".level3").outerWidth();
                
                layerWidth = level2Width + level3Width;
                
                if($(this).parents(".layer").find("cufontext").html() == lastCatName) {
                    
                    $(".level2").css({"background-image":bgSubSeparatorImage,"background-repeat":"repeat-y", "background-position":"top left"});
                    
                    var position = -layerWidth + $(this).parents(".level1>li").width() + (974 - completeCatWidth);
                    var layer = $(this).parents(".layer");
                    
                    layer.find(".outerWrapper").css("left",position-4);
                    layer.find(".level2").css("left",level3Width+5);
                    
                }
    
            } else {
                
                $(".level2").css("background","none");
                level2Width = $(this).parent().outerWidth();
                layerWidth = level2Width;
                
                if($(this).parents(".layer").find("cufontext").html() == lastCatName) {
                    
                    var position = -layerWidth + $(this).parents(".level1>li").width() + (974 - completeCatWidth);
                    var layer = $(this).parents(".layer");
                    
                        layer.find(".outerWrapper").css("left",position-4);
                        layer.find(".level2").css("left",5);
                    
                }
                
            }
        
        }
        
        // Level3
        if($(this).parent().is(".level3")) {
            
            if($(this).find("ul").hasClass("level4")) {
                
                $(".level3").css({"background-image":bgSubSeparatorImage,"background-repeat":"repeat-y", "background-position":"top right"});
                $(this).children("a").addClass("hover");
                $(this).children("ul").show();
                level2Width = $(this).parents(".level2").outerWidth();
                level3Width = $(this).parents(".level3").outerWidth();
                level4Width = $(this).find(".level4").outerWidth();
                
                layerWidth = level2Width + level3Width + level4Width;
            
            } else {
                
                level2Width = $(this).parents(".level2").outerWidth();
                level3Width = $(this).parents(".level3").outerWidth();
                
                layerWidth = level2Width + level3Width;    
                $(".level3").css("background","none");
                $(".level4").hide();
            }
        }
        
        // Set background layer
        if($(this).parent().is(".level1")) {
            
            $(this).find(".layer").find(".outerWrapper").css({"width":layerWidth + 18});
            $(this).find(".layer").find(".innerWrapper").css({"width":layerWidth-5});
            $(this).find(".layer").find(".innerWrapper .top").css("width",layerWidth + 19);
            
            if ($(this).find(".layer").find("cufontext").html() == lastCatName) {
                $(this).find(".layer").find(".innerWrapper .top").css("width",layerWidth + 14);
            }
            
        } else {
            
            $(this).parents(".layer").find(".outerWrapper").css({"width":layerWidth + 18});
            $(this).parents(".layer").find(".innerWrapper").css({"width":layerWidth-5});
            $(this).parents(".layer").find(".innerWrapper .top").css("width",layerWidth + 19);
            
            if ($(this).parents(".layer").find("cufontext").html() == lastCatName) {
                $(this).parents(".layer").find(".innerWrapper .top").css("width",layerWidth + 14);
            }
        }
    });
    
};

/**
 * Overview 4 Btn Teaser 
 */
 function initOverview4BtnTeaser() {
         
    $('<div class="effect">&nbsp;</div>').insertBefore(".overview4BtnTeaser .btnBox a");
    $(".overview4BtnTeaser .btnBox").css("cursor","pointer");
    
    $(".overview4BtnTeaser .btnBox").bind("mouseenter",function() {
        if($.support.opacity) {
            $(this).find(".effect").stop(true, true).fadeOut(800);
        } else {
            $(this).find(".effect").hide();
        }
    }).bind("mouseleave",function() {
        if($.support.opacity) {
            $(this).find(".effect").stop(true, true).fadeIn(800);
        } else {
            $(this).find(".effect").show();
        }
    });
};
/**
 * Overview 4 Btn Teaser Small
 */
 function initOverview4BtnTeaserSmall() {
         
    $('<div class="effect">&nbsp;</div>').insertBefore(".overview4BtnTeaserSmall .btnBox a");
    $(".overview4BtnTeaserSmall .btnBox").css("cursor","pointer");
    
    $(".overview4BtnTeaserSmall .btnBox").bind("mouseenter",function() {
        if($.support.opacity) {
            $(this).find(".effect").stop(true, true).fadeOut();
        } else {
            $(this).find(".effect").hide();
        }
    }).bind("mouseleave",function() {
        if($.support.opacity) {
            $(this).find(".effect").stop(true, true).fadeIn();
        } else {
            $(this).find(".effect").show();
        }
    });
};

/**
 * Three column teaser
 */
function initThreeColumnTeaser() {
    
    $(".threeColumnTeaser .img a").prepend('<div class="effect">&nbsp;</div>');
    
    $(".threeColumnTeaser a").bind("mouseenter",function() {
        hideEffect($(this));
    }).bind("mouseleave",function() {
        showEffect($(this));
    });
    
    function hideEffect(object) {
        if($.support.opacity) {
            object.parents(".teaserBox").find(".effect").stop(true, true).fadeOut(800);
        } else {
            object.parents(".teaserBox").find(".effect").hide();
        }
    }
    
    function showEffect(object) {
        if($.support.opacity) {
            object.parents(".teaserBox").find(".effect").stop(true, true).fadeIn(800);
        } else {
            object.parents(".teaserBox").find(".effect").show();
        }
    }
}
 
/**
 * Three column teaser Carrer
 */
function initThreeColumnTeaserCareer() {
    
    $(".threeColumnTeaserCareer .img a").prepend('<div class="effect">&nbsp;</div>');
    
    $(".threeColumnTeaserCareer a").bind("mouseenter",function() {
        hideEffect($(this));
    }).bind("mouseleave",function() {
        showEffect($(this));
    });
    
    function hideEffect(object) {
        if($.support.opacity) {
            object.parents(".teaserBox").find(".effect").stop(true, true).fadeOut(800);
        } else {
            object.parents(".teaserBox").find(".effect").hide();
        }
    }
    
    function showEffect(object) {
        if($.support.opacity) {
            object.parents(".teaserBox").find(".effect").stop(true, true).fadeIn(800);
        } else {
            object.parents(".teaserBox").find(".effect").show();
        }
    }
}
/**
 * IndustryBox Effect
 */
function initIndustryBox() {
    
    $(".industrybox .img a").prepend('<div class="effect">&nbsp;</div>');
    
    $(".industrybox a").bind("mouseenter",function() {
        hideEffect($(this));
    }).bind("mouseleave",function() {
        showEffect($(this));
    });
    
    function hideEffect(object) {
        if($.support.opacity) {
            object.parents(".teaserBox").find(".effect").stop(true, true).fadeOut(800);
        } else {
            object.parents(".teaserBox").find(".effect").hide();
        }
    }
    
    function showEffect(object) {
        if($.support.opacity) {
            object.parents(".teaserBox").find(".effect").stop(true, true).fadeIn(800);
        } else {
            object.parents(".teaserBox").find(".effect").show();
        }
    }
}
/**
 * InvestorBox effect
 */
function initInvestorsBox() {
    
    $(".investorBox .img a").prepend('<div class="effect">&nbsp;</div>');
    
    $(".investorBox a").bind("mouseenter",function() {
        hideEffect($(this));
    }).bind("mouseleave",function() {
        showEffect($(this));
    });
    
    function hideEffect(object) {
        if($.support.opacity) {
            object.parents(".teaserBox").find(".effect").stop(true, true).fadeOut(800);
        } else {
            object.parents(".teaserBox").find(".effect").hide();
        }
    }
    
    function showEffect(object) {
        if($.support.opacity) {
            object.parents(".teaserBox").find(".effect").stop(true, true).fadeIn(800);
        } else {
            object.parents(".teaserBox").find(".effect").show();
        }
    }
}
 
/**
 * Location button
 */
 function initLocationButtons() {
         
    $('<div class="effect">&nbsp;</div>').insertBefore(".locationButtons .btnBox a");
    $(".locationButtons .btnBox").css("cursor","pointer");
    $(".locationButtons .btnBox").mousedown(function() {
    var btnName = $(this).find("a").attr("href").substr(1);
        $(this).find("a").trigger('click');
        callFlashLocation(btnName);
    });
    
    $(".locationButtons .btnBox").bind("mouseenter",function() {
        if($.support.opacity) {
            $(this).find(".effect").stop(true, true).fadeOut(800);
        } else {
            $(this).find(".effect").hide();
        }
    }).bind("mouseleave",function() {
        if($.support.opacity) {
            $(this).find(".effect").stop(true, true).fadeIn(800);
        } else {
            $(this).find(".effect").show();
        }
    });
};
/**
 * Courses button
 */
 function initCoursesButtons() {
         
    $('<div class="effect">&nbsp;</div>').insertBefore(".coursesButtons .btnBox a");
    $(".coursesButtons .btnBox").css("cursor","pointer");
    $(".coursesButtons .btnBox").mousedown(function() {
    var btnName = $(this).find("a").attr("href").substr(1);
        $(this).find("a").trigger('click');
        callFlashLocation(btnName);
    });
    
    $(".coursesButtons .btnBox").bind("mouseenter",function() {
        if($.support.opacity) {
            $(this).find(".effect").stop(true, true).fadeOut(800);
        } else {
            $(this).find(".effect").hide();
        }
    }).bind("mouseleave",function() {
        if($.support.opacity) {
            $(this).find(".effect").stop(true, true).fadeIn(800);
        } else {
            $(this).find(".effect").show();
        }
    });
};

/**
 * Study button
 */
 function initStudyButtons() {
         
    $('<div class="effect">&nbsp;</div>').insertBefore(".studyButtons .btnBox .top a");
    $(".studyButtons .btnBox").css("cursor","pointer");
    $(".studyButtons .btnBox").mousedown(function() {
    var btnName = $(this).find("a").attr("href").substr(1);
        $(this).find("a").trigger('click');
        callFlashLocation(btnName);
    });
    
    $(".studyButtons .btnBox").bind("mouseenter",function() {
        if($.support.opacity) {
            $(this).find(".effect").stop(true, true).fadeOut(800);
        } else {
            $(this).find(".effect").hide();
        }
    }).bind("mouseleave",function() {
        if($.support.opacity) {
            $(this).find(".effect").stop(true, true).fadeIn(800);
        } else {
            $(this).find(".effect").show();
        }
    });
};


/**
 * ExternalInterface call from Flash
 */
function callLocation(location) {
    switch(location) {
        case "overview":
            //$("h2 span").fadeOut(100, function() {$(this).html("Overview").fadeIn(500)});        
            $(".locationButtons").idTabs("overview");
            break;
        case "cairo_btn":
            //$("h2 span").fadeOut(100, function() {$(this).html("SQS Egypt: Excellent background in banking, telco, automotive, avionic and logisiticsSQS Egypt: Excellent background in banking, telco, automotive, avionic and logisitics").fadeIn(500)});        
            $(".locationButtons").idTabs("cairo");
            break;
        case "pune_btn":
            //$("h2 span").fadeOut(100, function() {$(this).html("SQS India: Wide domain knowledge, especially in media, finance, healthcare and gaming").fadeIn(500)});        
            $(".locationButtons").idTabs("pune");
            break;            
        case "durban_btn":
            //$("h2 span").fadeOut(100, function() {$(this).html("SQS South Africa: Wide domain knowledge especially in finance, SAP, telco & online gambling").fadeIn(500)});        
            $(".locationButtons").idTabs("durban");
            break;
        case "goerlitz_btn":
            //$("h2 span").fadeOut(100, function() {$(this).html("SQS South Africa: Wide domain knowledge especially in finance, SAP, telco & online gambling").fadeIn(500)});        
            $(".locationButtons").idTabs("goerlitz");
            break; 
    }
}
function callFlashLocation(btn) {
    $('#flashMap').each(function() {
        this.callLocationButton(btn);
    });
}

function cssInit() {
    $(".s2cBox").css("margin","13px 12px 0 1px");
    $(".s2cBox.right").css("margin","13px 0 0 1px");
    }
