/*root*/

var HugoBoss = {

    //initialize
    init: function(){
    
        $('body').addClass('js');
        
        //flash player version needed
        HugoBoss.flash.version = '10.0.0';
        
        HugoBoss.utils.init();
        
        //check for browser and flash player/version
        if (HugoBoss.utils.browserAndVersion() === 'ie6') {
            HugoBoss.utils.showErrorSceen('browser');
            
        }
        else 
            if (!swfobject.hasFlashPlayerVersion(HugoBoss.flash.version)) {
            
                HugoBoss.utils.showErrorSceen('flash');
                
            }
            else {
            
                HugoBoss.flash.init();
                HugoBoss.events.init();
                
            }
        
    },
    
    //helper
    utils: {
    
        //initialize helper
        init: function(){
        
            HugoBoss.utils.setInputField('search');
            HugoBoss.utils.setInputField('newsletter');
            HugoBoss.utils.setBrowserSpecs();
            HugoBoss.utils.clearNoScript();
            HugoBoss.utils.initSoundButton();
            HugoBoss.utils.initShoppingCart();
            
        },
        
        getTimestamp: function(){
        
            var timestamp = new Date();
            return timestamp.getTime();
            
        },
        
        getHash: function(){
        
            var tempHash = window.location.hash;
            var hash = tempHash.substring(1);
            
            return hash;
        },
        
        getFileName: function(){
        
            var tempHref = window.location.href;
            var lastSlash = tempHref.lastIndexOf('/');
            var fileName = tempHref.substring(lastSlash + 1);
            
            return fileName;
        },
        
        //return browser and version
        browserAndVersion: function(){
        
            if ($.browser.msie && $.browser.version <= 6) {
                return 'ie6';
            }
            else 
                if ($.browser.msie && $.browser.version > 6 && $.browser.version < 8) {
                    return 'ie7';
                }
                else 
                    if ($.browser.msie && $.browser.version > 7 && $.browser.version < 9) {
                        return 'ie8';
                    }
                    else 
                        if ($.browser.opera) {
                            return 'opX';
                        }
                        else {
                            return 'zz';
                        }
            
        },
        
        //info text in searchfield is set/unset via title-tag and highlighted
        setInputField: function(input){
        
            var $infoTextTemp = $('#searchInput').add('#newsletterInput');
            
            $infoTextTemp.unbind('focus', 'blur').bind('focus', function(){
            
                if ($(this)[0].title) {
                    if ($(this).val() === $(this)[0].title) {
                        $(this).val('');
                    }
                }
                
                $(this).addClass('active');
                $(this).parent('div').addClass('active');
                
            }).bind('blur', function(){
            
                if ($(this)[0].title) {
                    if ($(this).val() === '') {
                        $(this).val($(this)[0].title);
                    }
                }
                
                $(this).removeClass('active');
                $(this).parent('div').removeClass('active');
                
            }).blur();
            
        },
        
        setBrowserSpecs: function(){
        
            //ie specifics
            if ($.browser.msie && $('#outerWrapper').length !== 0) {
            
                if ($('#outerWrapper').width() < 1004) {
                    $('#outerWrapper').css({
                        overflowX: 'auto'
                    });
                }
                else {
                    $('#outerWrapper').css({
                        overflowX: 'hidden'
                    });
                }
                
                if ($('#header').length !== 0) {
                    $('#header').css({
                        width: '100%'
                    });
                }
                
            }
            
            //opera specifics
            if ($.browser.opera) {
            
                $('#header').css({
                    left: '-8px'
                });
                
                $('#outerWrapper').css({
                    /*position: 'fixed',*/
                    width: '100%',
                    top: '0px',
                    left: '0px'
                });
                
            }
            
        },
        
        //cookie handling
        setCookie: function(name, value){
        
            var arguments = HugoBoss.utils.setCookie.arguments;
            var aLenght = arguments.length;
            
            var cookie = name + '=' + escape(value);
            
            if (aLenght > 2) {
                var expireDate = HugoBoss.utils.setExpireDate(arguments[2]);
                cookie += '; expires=' + expireDate.toGMTString();
            }
            if (aLenght > 3) {
                cookie += '; path=' + arguments[3];
            }
            if (aLenght > 4) {
                cookie += '; domain=' + arguments[4];
            }
            if (aLenght > 5) {
                cookie += '; secure=' + arguments[5];
            }
            
            document.cookie = cookie;
            
        },
        
        getCookie: function(name){
        
            var arguments = name + '=';
            var aLength = arguments.length;
            var cLength = document.cookie.length;
            
            var i = 0;
            
            while (i < cLength) {
            
                var j = i + aLength;
                
                if (document.cookie.substring(i, j) === arguments) {
                
                    var endstr = document.cookie.indexOf(";", j);
                    
                    if (endstr == -1) {
                        endstr = document.cookie.length;
                    }
                    
                    return unescape(document.cookie.substring(j, endstr));
                    
                }
                
                i = document.cookie.indexOf("", i) + 1;
                
                if (i == 0) {
                
                    break;
                    
                }
                
            }
            
            return null;
            
        },
        
        setExpireDate: function(days){
        
            var expireDate = new Date();
            var livetime = expireDate.getTime() + (days * 24 * 60 * 60 * 1000);
            
            expireDate.setTime(livetime);
            
            return expireDate;
            
        },
        
        //sound button entsprechend cookie laden
        initSoundButton: function(){
        
            if (!HugoBoss.utils.getCookie('sound')) {
            
                HugoBoss.utils.setCookie('sound', 'true', 2, '/');
                HugoBoss.utils.setSoundButton('on');
                
            }
            else 
                if (HugoBoss.utils.getCookie('sound') === 'true') {
                
                    HugoBoss.utils.setSoundButton('on');
                    
                }
                else {
                
                    HugoBoss.utils.setSoundButton('off');
                    
                }
            
            $('#soundOff').add('#soundOn').css({
                visibility: 'visible'
            });
            
        },
        
        //sound button entsprechend cookie laden
        soundButtonClick: function(){
        
            if (HugoBoss.utils.getCookie('sound') === 'true') {
            
                HugoBoss.utils.setCookie('sound', 'false', 2, '/');
                HugoBoss.utils.setSoundButton('off');
                
            }
            else {
            
                HugoBoss.utils.setCookie('sound', 'true', 2, '/');
                HugoBoss.utils.setSoundButton('on');
                
            }
            
        },
        
        //sound state on/off anzeigen
        setSoundButton: function(state){
        
            switch (state) {
                case 'on':
                    
                    $('#soundOff').css({
                        display: 'none'
                    });
                    $('#soundOn').css({
                        display: 'block'
                    });
                    
                    break;
                case 'off':
                    
                    $('#soundOff').css({
                        display: 'block'
                    });
                    $('#soundOn').css({
                        display: 'none'
                    });
                    
                    break;
            }
            
            
            $('div.flash').children('object').each(function(){
            
                try {
                    //function inside flash
                    this.soundClickEvent(state);
                } 
                catch (e) {
                    //could not connect to flash movie (maybe not loaded jet)
                    //return false;
                }
                
            });
            
        },
        
        
        //set shopping cart
        initShoppingCart: function(){
        
            if (!HugoBoss.utils.getCookie('basketinfo')) {
            
                $('#headerNavCart').remove();
                
            }
            else {
            
                var cartString = unescape(HugoBoss.utils.getCookie('basketinfo'));
                var cartObject = eval('(' + cartString + ')');
                
                if (cartObject.items === 0) {
                
                    $('#headerNavCart').remove();
                    
                }
                else {
                
                    var articleNaming = 'Articles'
                    if (cartObject.items === 1) {
                        articleNaming = 'Article'
                    }
                    
                    var content = '<div id="headerNavCart">';
                    content += '<a href="' + cartObject.url + '" target="_self">';
                    content += '<span>Shopping bag</span>';
                    content += '<br/>';
                    content += cartObject.items + ' ' + articleNaming + ', ' + cartObject.subtotal;
                    content += '</a>';
                    content += '</div>';
                    
                    $(content).insertAfter('#headerNavLogo');
                    
                }
                
            }
            
        },
        
        //debug helper returning console.log or alerts
        debug: function(){
        
            var location = window.location + '';
            
            if (location.indexOf('preview') !== -1) {
            
                var debugMode = true;
                var debugModeAlert = false;
                
                if (debugMode) {
                
                    var debugString = '';
                    var i = HugoBoss.utils.debug.arguments.length;
                    
                    do {
                        i--;
                        debugString += i + 1 + '. ' + HugoBoss.utils.debug.arguments[i] + '\n';
                    }
                    while (i > 0);
                    
                    if ($.browser.mozilla) {
                    
                        try {
                            console.log(debugString);
                        } 
                        catch (e) {
                        
                        }
                    }
                    else 
                        if (debugModeAlert) {
                            window.alert(debugString);
                        }
                }
                
            }
            
        },
        
        //change location
        changeLocation: function(){
        
            window.location = HugoBoss.utils.newLocation;
            
        },
        
        clearNoScript: function(){
        
            $('div.noscript').remove();
            $('noscript').remove();
            
        },
        
        showErrorSceen: function(reason){
        
            $('#headerNavSub').find('span.preview').add('#leftNav').add('#leftNavHeader').add('#rightContent').add('#onlineStoreTeaser').add('#lifestyleTeaser').add('#socialLinks').add('abdeckerFooter').remove();
            
            if ($('#changeCountry').length !== 0) {
            
                var content = '<div id="headerNav">';
                content += '<div id="headerNavLogo">';
                content += '<a href="/">';
                content += '<img src="/style/img/_shared.headerNav.logo.gif" alt="HUGO BOSS" title="HUGO BOSS" />';
                content += '</a>';
                content += '</div>';
                content += '</div>';
                
                $('#content').html(content);
                
            }
            
            $('body').css({
                background: '#ffffff'
            }).removeClass('js');
            
            $('#content').css({
                minHeight: '545px',
                height: '545px',
                background: '#ffffff'
            });
            
            $('#backgroundImg').add('#innerContent').remove();
            
            $('#headerNav').css({
                background: 'url(/style/img/error.headerNav.bg.gif)'
            });
            
            var errorHTML = '<div id="warning">';
            
            switch (reason) {
                case 'flash':
                    errorHTML += errorContent.flash.message + '<br />';
                    errorHTML += '<a href="' + errorContent.flash.url + '">' + errorContent.flash.link + '</a>';
                    break;
                case 'browser':
                    errorHTML += errorContent.browser.message + '<br />';
                    errorHTML += '<a href="' + errorContent.browser.url1 + '">' + errorContent.browser.link1 + '</a>';
                    errorHTML += '<a href="' + errorContent.browser.url2 + '">' + errorContent.browser.link2 + '</a>';
                    break;
            }
            errorHTML += '</div>';
            errorHTML += '<div id="errorImage"></div>';
            
            $('#headerNav').append(errorHTML);
            
        },
        
        //layer für datenschutz, nutzungsbedingungen
        showLayer: function(target){
        
            $('#' + target).css({
                display: 'block'
            });
            
            setTimeout(function(){
            
                $('body').bind('click', function(){
                
                    $('#' + target).css({
                        display: 'none'
                    });
                    
                    $('a.close').unbind('click');
                    $('body').unbind('click');
                    
                });
                
                $('a.close').bind('click', function(){
                
                    $('#' + target).css({
                        display: 'none'
                    });
                    
                    $('body').unbind('click');
                    $('a.close').unbind('click');
                    
                    return false;
                    
                });
                
                $('div.layer').bind('click', function(){
                
                    return false;
                    
                });
                
            }, 100);
            
        }
        
    },
    
    //global events
    events: {
    
        //initialize event handlers
        init: function(){
        
            //resize events
            $(window).resize(function(){
            
                HugoBoss.utils.setBrowserSpecs();
                
                //HugoBoss.flash.updateSize();
                HugoBoss.flash.getOffsetX();
                
                HugoBoss.events.getMousePosition();
                
            });
            
            //click event
            $('a').live('click', function(){
            
                HugoBoss.utils.newLocation = $(this).attr('href');
                
                var target = $(this).attr('target');
                var location = window.location + '';
                
                if (target !== '_top' && target !== '_parent' && target !== '_self' && HugoBoss.utils.newLocation.indexOf(location) === -1) {
                
                    if (HugoBoss.utils.newLocation.indexOf('.pdf') !== -1 || HugoBoss.utils.newLocation.indexOf('http://') !== -1 || HugoBoss.utils.newLocation.indexOf('https://') !== -1) {
                    
                        window.open(HugoBoss.utils.newLocation);
                        
                        return false;
                        
                    }
                    
                }
                else 
                    if ($('div.flash').length !== 0) {
                    
                    
                        if (!HugoBoss.flash.readyCounter || !HugoBoss.flash.loadedCounter) {
                        
                            return true;
                            
                        }
                        else {
                        
                            //fade out flash content, flash movie will return true and set the link free if content is faded out
                            HugoBoss.flash.fadeOut();
                            
                        }
                        return false;
                        
                    }
                    else {
                    
                        //no flash to fade out, link is executed
                        return true;
                        
                    }
                
            });
            
            $('a.videoLink').live('click', function(){
            
                var videoAliasTemp = $(this).attr('hash');
                var videoAlias = videoAliasTemp.substring(1);
                
                HugoBoss.flash.showVideoLayer(videoAlias);
                
                return false;
                
            });
            
            
            $('#newsletterSubmit').live('click', function(){
            
                if ($('#newsletterInput').attr('title') === $('#newsletterInput').attr('value')) {
                
                    $('#newsletterInput').attr('value', '');
                    
                }
                
                $('#newsletterForm').submit();
                
            });
            
            $('#searchSubmit').live('click', function(){
            
                if ($('#searchInput').attr('title') === $('#searchInput').attr('value')) {
                
                    $('#searchInput').attr('value', '');
                    
                }
                
                $('#searchForm').submit();
                
            });
            
            //Footer Sound 
            $('#footerSound').children('a').bind('click', function(){
            
                HugoBoss.utils.soundButtonClick();
                return false;
                
            });
            
            //Webtrack Events
            $('#onlineStoreTeaser').find('a').bind('click', function(){
            
                var imagePath = $(this).css('backgroundImage');
                var image = imagePath.substring(imagePath.lastIndexOf('/') + 1, imagePath.lastIndexOf('.'));
                
                HugoBoss.flash.analytics('extLink.' + image, 'click');
                
            });
            
            $('#lifestyleTeaser').find('a').bind('click', function(){
            
                var imagePath = $(this).css('backgroundImage');
                var image = imagePath.substring(imagePath.lastIndexOf('/') + 1, imagePath.lastIndexOf('.'));
                
                HugoBoss.flash.analytics('tc.' + image, 'click');
                
            });
            
            $('#socialLinks').add('div.leftNavIcons').find('a').bind('click', function(){
            
                var className = $(this).attr('class');
                var id;
                switch (className) {
                    case 'iPhoneApp':
                        id = 'IPHONE_APP';
                        break;
                    case 'youTube':
                        id = 'YOUTUBE';
                        break;
                    case 'facebook':
                        id = 'FB_FANPAGE';
                        break;
                    case 'twitter':
                        id = 'TWITTER';
                        break;
                }
                
                HugoBoss.flash.analytics('extLink.' + id, 'click');
                
            });
            
            HugoBoss.events.mouseOverPreview = false;
            HugoBoss.events.mouseOverLink = false;
            
            $('#headerNavSub span.preview').hover(function(){
            
                var target = $(this);
                
                HugoBoss.events.mouseOverPreview = true;
                if (HugoBoss.events.timeout) {
                    window.clearTimeout(HugoBoss.events.timeout);
                }
                HugoBoss.events.fadeOutHeaderNav(target);
                
                
            }, function(){
            
                var target = $(this);
                var parent = $(this).parent().children('a');
                
                parent.hover(function(){
                
                    var target = $(this);
                    
                    parent.unbind('mouseenter');
                    
                    HugoBoss.events.mouseOverLink = true;
                    if (HugoBoss.events.timeout) {
                        window.clearTimeout(HugoBoss.events.timeout);
                    }
                    HugoBoss.events.fadeOutHeaderNav(target);
                    
                }, function(){
                
                    parent.unbind('mouseleave');
                    
                    HugoBoss.events.mouseOverLink = false;
                    if (HugoBoss.events.timeout) {
                        window.clearTimeout(HugoBoss.events.timeout);
                    }
                    HugoBoss.events.fadeOutHeaderNav(target);
                    
                });
                
                if (!HugoBoss.events.timeout) {
                    HugoBoss.events.timeout = null;
                }
                
                if (HugoBoss.events.timeout) {
                    window.clearTimeout(HugoBoss.events.timeout);
                }
                HugoBoss.events.timeout2 = window.setTimeout(function(){
                
                    HugoBoss.events.mouseOverPreview = false;
                    if (HugoBoss.events.timeout) {
                        window.clearTimeout(HugoBoss.events.timeout);
                    }
                    HugoBoss.events.fadeOutHeaderNav(target);
                }, 40);
            });
            
            $('#headerNavSub a').not('.active').not('.previewLink').hoverIntent(function(){
            
                var parent = $(this);
                var target = $(this).parent().children('span.preview');
                
                HugoBoss.events.mouseOverLink = true;
                if (HugoBoss.events.timeout) {
                    window.clearTimeout(HugoBoss.events.timeout);
                }
                HugoBoss.events.fadeOutHeaderNav(target);
                
                $('span.preview').css({
                    display: 'none'
                });
                
                target.css({
                    display: 'block'
                });
                
                target.stop().animate({
                    opacity: 1
                }, {
                    duration: 300,
                    complete: function(){
                    
                        parent.addClass('mouseOver');
                        
                    }
                    
                });
                
            }, function(){
            
                var target = $(this).parent().children('span.preview');
                
                HugoBoss.events.mouseOverLink = false;
                if (HugoBoss.events.timeout) {
                    window.clearTimeout(HugoBoss.events.timeout);
                }
                HugoBoss.events.fadeOutHeaderNav(target);
                
            });
            
            HugoBoss.events.getMousePosition();
            
        },
        
        fadeOutHeaderNav: function(ref){
        
            if (!HugoBoss.events.timeout) {
                HugoBoss.events.timeout = null;
            }
            
            if (HugoBoss.events.timeout) {
                window.clearTimeout(HugoBoss.events.timeout);
            }
            
            if (!HugoBoss.events.mouseOverLink) {
            
                var timer = 0;
                
                if (!HugoBoss.events.mouseOverPreview) {
                    timer = 0;
                }
                else {
                    timer = 2000;
                }
                
                HugoBoss.events.timeout = window.setTimeout(function(){
                
                    var parent = ref.parent().children('a');
                    var target = ref;
                    
                    if (parent.hasClass('mouseOver')) {
                    
                        parent.removeClass('mouseOver');
                        
                        target.stop().animate({
                            opacity: 0
                        }, {
                            duration: 150,
                            complete: function(){
                            
                                target.css({
                                    display: 'none'
                                });
                                
                            }
                            
                        });
                        
                    }
                    else {
                    
                        target.stop().animate({
                            opacity: 0
                        }, {
                            duration: 50,
                            complete: function(){
                            
                                target.css({
                                    display: 'none'
                                });
                                
                            }
                            
                        });
                        
                    }
                    
                }, timer);
                
            }
            
        },
        
        getMousePosition: function(){
        
            //catch scroll event to enable highlighting in flash
            $('#outerWrapper').bind('scroll', function(){
            
                if ($('#moduleFlashSwf').length !== 0) {
                
                    if (HugoBoss.events.mouseX === undefined) {
                        HugoBoss.events.mouseX = 0;
                    }
                    if (HugoBoss.events.mouseY === undefined) {
                        HugoBoss.events.mouseY = 0;
                    }
                    
                    var offsetModuleX = $('#moduleFlashSwf').offset().left;
                    var mouseX = HugoBoss.events.mouseX;
                    var offsetModuleY = $('#moduleFlashSwf').offset().top * -1;
                    var mouseY = offsetModuleY + HugoBoss.events.mouseY;
                    
                    $('div.flash').find('object').each(function(){
                    
                        try {
                            //function inside flash
                            this.scrollOffset(offsetModuleY, offsetModuleX);
                            this.scrollContent(mouseX, mouseY);
                        } 
                        catch (e) {
                            //could not connect to flash movie (maybe not loaded jet)
                            //return false;
                        }
                        
                    });
                    
                }
                
                if (HugoBoss.startpage) {
                
                    var offsetContentY = $('#content').offset().top;
                    HugoBoss.startpage.utils.fadeFooter(offsetContentY);
                    
                }
                
            });
            
            //emag article 
            $('#outerWrapper').bind('scroll', function(){
            
                if ($('#articleFlashSwf').length !== 0) {
                
                    if (HugoBoss.events.mouseX === undefined) {
                        HugoBoss.events.mouseX = 0;
                    }
                    if (HugoBoss.events.mouseY === undefined) {
                        HugoBoss.events.mouseY = 0;
                    }
                    
                    var offsetModuleX = $('#articleFlashSwf').offset().left;
                    var mouseX = HugoBoss.events.mouseX;
                    var offsetModuleY = $('#articleFlashSwf').offset().top * -1;
                    var mouseY = offsetModuleY + HugoBoss.events.mouseY;
                    
                    $('div.flash').find('object').each(function(){
                    
                        try {
                            //function inside flash
                            this.scrollOffset(offsetModuleY, offsetModuleX);
                            this.scrollContent(mouseX, mouseY);
                        } 
                        catch (e) {
                            //could not connect to flash movie (maybe not loaded jet)
                            //return false;
                        }
                        
                    });
                    
                }
                
            });
            
            //catch mouse position to enable highlighting in flash (while/after scrolling)
            $('#outerWrapper').bind('mousemove', function(e){
                HugoBoss.events.mouseX = e.pageX;
                HugoBoss.events.mouseY = e.pageY;
            });
            
        }
        
    },
    
    //flash communication & control
    flash: {
    
        //init flash functions
        init: function(){
        
            HugoBoss.flash.scrollToTop();
            HugoBoss.flash.prepareFlashContent();
            
        },
        
        //prepare html and flash content
        prepareFlashContent: function(){
        
            if (flashContent.background && $('div.backgroundScroll').length !== 0) {
            
                var id = 'backgroundScrollFlash';
                
                $('div.backgroundScroll').addClass('flash').append('<div id="' + id + '"></div>');
                
                var swfObjectData = {
                    source: flashContent.background.source,
                    id: id,
                    width: '100%',
                    height: '100%',
                    center: true,
                    flashvars: flashContent.background.flashvars,
                    params: flashContent.background.params
                };
                
                HugoBoss.flash.initSwfObject(swfObjectData);
            }
            
            if (flashContent.background && $('div.backgroundFixed').length !== 0) {
            
                var id = 'backgroundFixedFlash';
                
                $('div.backgroundFixed').addClass('flash').append('<div id="' + id + '"></div>');
                
                var swfObjectData = {
                    source: flashContent.background.source,
                    id: id,
                    width: '100%',
                    height: '100%',
                    center: true,
                    flashvars: flashContent.background.flashvars,
                    params: flashContent.background.params
                };
                
                HugoBoss.flash.initSwfObject(swfObjectData);
            }
            
            if (flashContent.module && $('div.module').length !== 0) {
            
                var id = 'moduleFlash';
                
                $('div.module').addClass('flash').append('<div id="' + id + '"></div>');
                
                var width;
                if (!flashContent.module.width) {
                    var width = '100%';
                }
                else {
                    var width = flashContent.module.width;
                }
                
                var height;
                if (!flashContent.module.height) {
                    var height = '100%';
                }
                else {
                    var height = flashContent.module.height;
                }
                
                var center;
                if (!flashContent.module.center) {
                    var center = false;
                }
                else {
                    var center = true;
                }
                
                if (!flashContent.module.flashvars) {
                    flashContent.module.flashvars = {};
                }
                
                flashContent.module.flashvars.stageHeight = $('body').height();
                flashContent.module.flashvars.stageWidth = $('#content').width();
                
                var swfObjectData = {
                    source: flashContent.module.source,
                    id: id,
                    width: width,
                    height: height,
                    center: center,
                    flashvars: flashContent.module.flashvars,
                    params: flashContent.module.params
                };
                
                HugoBoss.flash.initSwfObject(swfObjectData);
                
            }
            
            if (flashContent.teaser && $('div.teaser').length !== 0) {
            
                var id = 'teaserFlash';
                
                $('div.teaser').addClass('flash').append('<div id="' + id + '"></div>');
                
                var width;
                if (!flashContent.teaser.width) {
                    var width = '100%';
                }
                else {
                    var width = flashContent.teaser.width;
                }
                
                if (!flashContent.teaser.flashvars) {
                    flashContent.teaser.flashvars = {};
                }
                
                flashContent.teaser.flashvars.stageHeight = $('body').height();
                flashContent.teaser.flashvars.stageWidth = $('#content').width();
                
                var swfObjectData = {
                    source: flashContent.teaser.source,
                    id: id,
                    width: width,
                    height: '295',
                    center: true,
                    flashvars: flashContent.teaser.flashvars,
                    params: flashContent.teaser.params
                };
                
                HugoBoss.flash.initSwfObject(swfObjectData);
                
            }
            
        },
        
        //init swfobject  
        initSwfObject: function(data){
        
            if (!data.source) {
                data.source = '';
            }
            
            if (!data.id) {
                data.id = '';
            }
            
            if (!data.width) {
                data.width = '100%';
            }
            
            if (!data.height) {
                data.height = '100%';
            }
            else {
                //TODO: mac ff flashplayer bug
                if ($.os.mac && $.browser.mozilla) { // 
                    var height = data.height + ' ';
                    if (height.indexOf('%') === -1) {
                        data.height = parseInt(height) + 1;
                    }
                    var width = data.width + ' ';
                    if (width.indexOf('%') === -1) {
                        data.width = parseInt(width) + 1;
                    }
                }
            }
            
            if (!data.version) {
                data.version = HugoBoss.flash.version;
            }
            
            if (!data.expressInstall) {
                data.expressInstall = null;
            }
            
            if (!data.flashvars) {
                data.flashvars = {};
            }
            
            if (!data.flashvars.moduleCSS) {
                data.flashvars.moduleCSS = flashContent.moduleCSS;
            }
            if (!data.flashvars.moduleXML) {
                data.flashvars.moduleXML = flashContent.moduleXML;
            }
            if (!data.flashvars.layoutXML) {
                data.flashvars.layoutXML = flashContent.layoutXML;
            }
            data.flashvars.lcKEY = flashContent.lcKEY;
            
            if (HugoBoss.utils.getCookie('sound') === 'true') {
                data.flashvars.soundState = 'on';
            }
            else {
                data.flashvars.soundState = 'off';
            }
            
            if (!data.params) {
                data.params = {
                    wmode: 'transparent', //opaque
                    allowScriptAccess: 'always',
                    menu: false
                };
            }
            else {
                if (!data.params.wmode) {
                    data.params.wmode = 'transparent'; //opaque
                }
                if (!data.params.allowScriptAccess) {
                    data.params.allowScriptAccess = 'always';
                }
                if (!data.params.menu) {
                    data.params.menu = false;
                }
            }
            
            if (!data.attributes) {
                data.attributes = {};
                data.attributes.id = data.id + 'Swf';
            }
            else 
                if (!data.attributes.id) {
                    data.attributes.id = data.id + 'Swf';
                }
            
            if (!data.callback) {
                data.callback = null;
            }
            
            swfobject.embedSWF(data.source, data.id, data.width, data.height, data.version, data.expressInstall, data.flashvars, data.params, data.attributes, data.callback);
            
            //TODO: mac ff flashplayer bug
            if ($.os.mac && $.browser.mozilla) { //
                swfobject.createCSS('#' + data.attributes.id, 'margin-top:-1px; margin-left:-1px;', null, true);
                
            }
            
            var height = data.height + ' ';
            if (height.indexOf('%') !== -1) {
            
                HugoBoss.flash.setHeight();
                
            }
            
            if (data.id === 'moduleFlash') {
            
                HugoBoss.flash.initSwfMacMousewheel('moduleFlashSwf');
                
            }
            
            var width = data.width + ' ';
            if (data.center && width.indexOf('%') === -1) {
            
                var marginLeft = Math.ceil(width / 2);
                swfobject.createCSS('#' + data.attributes.id, 'left:50%; margin-left:-' + marginLeft + 'px; position:absolute;', null, true);
                
            }
        },
        
        //scroll to top
        scrollToTop: function(duration){
        
            if (!duration || duration == 'undefined') {
                duration = 0;
            }
            
            $('#outerWrapper').scrollTo(0, duration);
            
        },
        
        //scroll to position
        scrollToPosition: function(position, duration){
        
            if (!position || position == 'undefined') {
                position = 0;
            }
            
            if (!duration || duration == 'undefined') {
                duration = 0;
            }
            
            $('#outerWrapper').scrollTo(position, duration);
            
        },
        
        //set flash 100% height
        setHeight: function(){
        
            if ($.browser.chrome || $.browser.safari) {
            
                var height = $('#content').height();
                
                swfobject.createCSS('#moduleFlashSwf', 'height:' + height + 'px;', null, true);
                swfobject.createCSS('#backgroundScrollFlashSwf', 'height:' + height + 'px;', null, true);
                
            }
            
        },
        
        //init swf mac mousewheel
        initSwfMacMousewheel: function(target){
        
            try {
            
                swfmacmousewheel.registerObject(target);
                
            } 
            catch (e) {
                //return false;
            }
            
        },
        
        //show/hide background which is not needed
        setBackground: function(fixed){
        
            if (!fixed) {
                $('div.backgroundFixed').children('object').css({
                    display: 'none'
                });
            }
            else {
                $('div.backgroundScroll').children('object').css({
                    display: 'none'
                });
            }
            
        },
        
        //hide Teaser
        hideTeaser: function(){
        
            $('#footer').css({
                height: '100px',
                marginTop: '-100px'
            }).children('div.teaser').css({
                display: 'none'
            });
            
        },
        
        //set to height other than 100%
        setFlashHeight: function(target, height){
        
            swfobject.createCSS('#' + target + 'FlashSwf', 'height:' + height + 'px;', null, true);
            
            var moduleHeight;
            var teaserHeight;
            var footerHeight;
            
            switch (target) {
                case 'teaser':
                    
                    moduleHeight = $('div.module').height();
                    teaserHeight = height;
                    footerHeight = teaserHeight + 100;
                    
                    $('div.teaser').css({
                        height: height + 'px'
                    });
                    
                    $('#footerNavInner').css({
                        marginTop: '50px'
                    });
                    
                    $('#footer').css({
                        height: footerHeight + 'px',
                        marginTop: '-' + footerHeight + 'px'
                    });
                    
                    if ($('#footer .teaser').length !== 0) {
                    
                        $('#footer .teaser').css({
                            visibility: 'visible'
                        });
                        
                    }
                    
                    break;
                case 'module':
                    
                    moduleHeight = height;
                    teaserHeight = $('div.teaser').height();
                    footerHeight = teaserHeight + 100;
                    
                    $('div.module').css({
                        height: height + 'px'
                    });
                    
                    break;
            }
            
            $('div.flash').find('object').each(function(){
            
                try {
                    //function inside flash
                    this.setModuleHeight(moduleHeight);
                } 
                catch (e) {
                    //could not connect to flash movie (maybe not loaded jet)
                    //return false;
                }
                
            });
            
            var contentHeight = moduleHeight + footerHeight;
            
            HugoBoss.flash.positionTeaser(contentHeight);
            
        },
        
        //change teaser position for pv 
        positionTeaser: function(posY){
        
            $('#content').css({
                minHeight: posY + 'px'
            });
            
            if ($('#innerContent').length !== 0) {
            
                $('#innerContent').css({
                    height: posY + 'px'
                });
                
            }
            
            HugoBoss.flash.setHeight();
            
            if ($('#footer .teaser').length !== 0) {
            
                $('#footer .teaser').css({
                    visibility: 'visible'
                });
                
            }
            
            //HugoBoss.flash.updateSize();
        
        },
        
        //update size of flash movie (after resize)
        updateSize: function(){
        
            var height = $('body').height();
            var width = $('#content').width();
            
            //external interface call to flash movies 
            $('div.flash').children('object').each(function(){
            
                try {
                    //function inside flash
                    this.setStageHeight(height);
                    this.setStageWidth(width);
                } 
                catch (e) {
                    //could not connect to flash movie (maybe not loaded jet)
                    //return false;
                }
                
            });
            
        },
        
        hbTvPlayVideo: function(id){
        
            $('div.backgroundScroll').find('object').each(function(){
            
                try {
                    //function inside flash
                    this.playVideo(id);
                } 
                catch (e) {
                    //could not connect to flash movie (maybe not loaded jet)
                    //return false;
                }
                
            });
            
        },
        
        showVideoLayer: function(videoAlias){
        
            HugoBoss.flash.scrollToTop(200);
            
            setTimeout(function(){
            
                if ($('#videoLayer').length === 0) {
                
                    var videoLayer = '<div id="videoLayerBg"></div>';
                    videoLayer += '<div id="videoLayer" class="flash"><a href="#close" class="close">' + textContent.close + '</a><div id="videoLayerFlash"></div></div>';
                    
                    $('#outerWrapper').append(videoLayer);
                    
                    $('#videoLayerBg').css({
                        opacity: 0
                    }).animate({
                        opacity: 0.9
                    }, {
                        duration: 400,
                        complete: function(){
                        
                            var swfObjectData = {
                                source: '/assets/mainLoader.swf',
                                id: 'videoLayerFlash',
                                width: '765',
                                height: '432',
                                center: true,
                                flashvars: {
                                    stageWidth: '765',
                                    stageHeight: '432',
                                    moduleCSS: '/style/style.emag.hbTV.css',
                                    moduleXML: path + 'emag/hbTV/data/overlayPlayer.xml',
                                    layoutXML: '',
                                    videoAlias: videoAlias
                                },
                                params: {
                                    wmode: 'opaque',
                                    bgColor: '#000000',
                                    allowFullscreen: true
                                },
                                attributes: {
                                    id: 'videoLayerFlashSwf'
                                }
                            };
                            
                            HugoBoss.flash.initSwfObject(swfObjectData);
                            
                            $('#videoLayer').css({
                                display: 'block'
                            });
                            
                            $('#videoLayerBg').add('#videoLayer a.close').bind('click', function(){
                            
                                $('#videoLayer').add('#videoLayerBg').css({
                                    display: 'none'
                                });
                                
                                return false;
                                
                            });
                            
                            $('#videoLayer').bind('click', function(){
                            
                                return false;
                                
                            });
                            
                        }
                        
                    });
                    
                }
                else {
                
                    $('#videoLayerBg').css({
                        display: 'block',
                        opacity: 0
                    }).animate({
                        opacity: 0.9
                    }, {
                        duration: 400,
                        complete: function(){
                        
                            var swfObjectData = {
                                source: '/assets/mainLoader.swf',
                                id: 'videoLayerFlashSwf',
                                width: '765',
                                height: '432',
                                center: true,
                                flashvars: {
                                    stageWidth: '765',
                                    stageHeight: '432',
                                    moduleCSS: '/style/style.emag.hbTV.css',
                                    moduleXML: path + 'emag/hbTV/data/overlayPlayer.xml',
                                    layoutXML: '',
                                    videoAlias: videoAlias
                                },
                                params: {
                                    wmode: 'opaque',
                                    bgColor: '#000000',
                                    allowFullscreen: true
                                },
                                attributes: {
                                    id: 'videoLayerFlashSwf'
                                }
                            };
                            
                            HugoBoss.flash.initSwfObject(swfObjectData);
                            
                            $('#videoLayer').css({
                                display: 'block'
                            });
                            
                        }
                        
                    });
                    
                }
                
            }, 250);
            
        },
        
        setTo100Percent: function(){
        
            if ($('#content').length !== 0) {
            
                $('#content').css({
                    minHeight: '100%'
                });
                
                swfobject.createCSS('#moduleFlashSwf', 'height: 100%;', null, true);
                
            }
            
            HugoBoss.flash.updateSize();
            
        },
        
        analytics: function(klickname, clicktype){
        
            var target = webtrekk.contentId + '.' + klickname;
            
            wt_sendinfo(target, clicktype);
            
        },
        
        analyticsMedia: function(media_id, player_action, clip_position, clip_length, media_group){
        
            wt_sendinfo_media(media_id, player_action, clip_position, clip_length, media_group);
            
        },
        
        getTracksMenuHeight: function(){
        
            //height nav left  + height my account navi
            var height = $('#leftNav').height(); // + 155
            return height;
            
        },
        
        getOffsetX: function(){
        
            var offsetX;
            
            if ($('#teaserFlashSwf').length !== 0) {
            
                offsetX = $('#teaserFlashSwf').offset().left;
                
            }
            else 
                if ($('#moduleFlashSwf').length !== 0) {
                
                    offsetX = $('#moduleFlashSwf').offset().left;
                    
                }
            
            if (offsetX !== 'undefined') {
            
                $('div.flash').find('object').each(function(){
                
                    try {
                        //function inside flash
                        this.setOffsetX(offsetX);
                    } 
                    catch (e) {
                        //could not connect to flash movie (maybe not loaded jet)
                        //return false;
                    }
                    
                });
                
            }
            
        },
        
        //force fade in if flash callback 'loaded' takes more than 8 seconds
        fadeInTimeout: function(){
        
            clearTimeout(HugoBoss.flash.timeout);
            
            HugoBoss.flash.timeout = window.setTimeout(function(){
            
                HugoBoss.flash.fadeIn();
                
            }, 8000);
            
        },
        
        //force page change if flash callback 'fadedOut' takes more than 4 seconds
        fadeOutTimeout: function(){
        
            clearTimeout(HugoBoss.flash.timeout);
            
            HugoBoss.flash.timeout = window.setTimeout(function(){
            
                HugoBoss.utils.changeLocation();
                
            }, 4000);
            
        },
        
        //external interface callback from flash if movie is ready (added to stage)
        ready: function(){
        
            //count flash movies, which are ready
            if (!HugoBoss.flash.readyCounter) {
                HugoBoss.flash.readyCounter = 1;
            }
            else {
                HugoBoss.flash.readyCounter += 1;
            }
            
            HugoBoss.flash.fadeInTimeout();
            
        },
        
        //external interface callback from flash if movie content is loaded and ready to fade in
        loaded: function(){
        
            //count flash movies, whose content is loaded
            if (!HugoBoss.flash.loadedCounter) {
                HugoBoss.flash.loadedCounter = 1;
            }
            else {
                HugoBoss.flash.loadedCounter += 1;
            }
            
            //init fade in if ready & loaded counters are the same
            if (HugoBoss.flash.readyCounter === HugoBoss.flash.loadedCounter) {
            
                HugoBoss.flash.fadeIn();
                
            }
        },
        
        //fade in flash content
        fadeIn: function(){
        
            clearTimeout(HugoBoss.flash.timeout);
            
            //external interface call to flash movies to fade in
            $('div.flash').children('object').each(function(){
            
                try {
                    //function inside flash
                    this.fadeIn();
                } 
                catch (e) {
                    //could not connect to flash movie (maybe not loaded jet)
                    //return false;
                }
                
            });
            
        },
        
        //fade out flash content
        fadeOut: function(){
        
            HugoBoss.flash.fadeOutTimeout();
            
            //external interface call to flash movies to fade out
            $('div.flash').children('object').each(function(){
            
                try {
                    //function inside flash
                    this.fadeOut();
                } 
                catch (e) {
                    //could not connect to flash movie (maybe not loaded jet)
                    //return false;
                }
                
            });
            
        },
        
        //external interface callback from flash if movie content is faded out
        fadedOut: function(){
        
            //count flash movies, which are faded out
            if (!HugoBoss.flash.fadedOutCounter) {
                HugoBoss.flash.fadedOutCounter = 1;
            }
            else {
                HugoBoss.flash.fadedOutCounter += 1;
            }
            
            //init change page if faded out and loaded counters are the same
            if (HugoBoss.flash.fadedOutCounter === HugoBoss.flash.loadedCounter) {
            
                clearTimeout(HugoBoss.flash.fadeOutTimeout);
                HugoBoss.utils.changeLocation();
                
            }
            
        }
        
    }

};


//initialize all
$(document).ready(function(){

    HugoBoss.init();
    
});


// *****************
// Footer Navigation
// *****************

$(document).ready(function(){
	
	countrySelection();	
	
});

var countrySelection = function(){
		document.getElementById("changeCountries").onmouseover =  function(){
				document.getElementById("arrow_country").style.right = "16px";
				document.getElementById("country_box_open").style.display = "block";
		}
		document.getElementById("changeCountries").onmouseout =  function(){
				document.getElementById("country_box_open").style.display = "none";
		}
}

// ------------------------------------------------------------------------------------
/*
$(document).ready(function(){
	
	countrySelection();	
	
});

var countrySelection = function(){
		$("changeCountries").onmouseover(function(){
				$("arrow_country").css("right","16px");
				$("country_box_open").css("display", "block");
		});
		$("changeCountries").onmouseout(function(){
				$("country_box_open").css("display", "none");
		});
}*/
		
