
/*startpage*/

HugoBoss.startpage = {

    //initialize startpage 
    init: function(){
    
        HugoBoss.startpage.events.init();
        HugoBoss.startpage.utils.fadeFooter(0);
        
    },
    
    events: {
    
        init: function(){
        
            var height = $('#footer').height() - 51;
            
            $('#abdeckerFooter').css({
                height: height + 'px',
                opacity: 0.7
            });
            
            $('#onlineStoreTeaser .teaser1').hoverIntent(function(){
            
                var on = $(this).children('.on');
                var off = $(this).children('.off');
                HugoBoss.startpage.utils.onlineStoreTeaserEnter(on, off);
                
                
            }, function(){
            
                var on = $(this).children('.on');
                var off = $(this).children('.off');
                HugoBoss.startpage.utils.onlineStoreTeaserLeave(on, off);
                
            });
            
            $('#onlineStoreTeaser .teaser2').hoverIntent(function(){
            
                var on = $(this).children('.on');
                var off = $(this).children('.off');
                HugoBoss.startpage.utils.onlineStoreTeaserEnter(on, off);
                
                
            }, function(){
            
                var on = $(this).children('.on');
                var off = $(this).children('.off');
                HugoBoss.startpage.utils.onlineStoreTeaserLeave(on, off);
                
            });
                        
			$('#onlineStoreTeaser .teaser3').hoverIntent(function(){
            
                var on = $(this).children('.on');
                var off = $(this).children('.off');
                HugoBoss.startpage.utils.onlineStoreTeaserEnter(on, off);
                
                
            }, function(){
            
                var on = $(this).children('.on');
                var off = $(this).children('.off');
                HugoBoss.startpage.utils.onlineStoreTeaserLeave(on, off);
                
            });
            
			$('#onlineStoreTeaser .teaser4').hoverIntent(function(){
            
                var on = $(this).children('.on');
                var off = $(this).children('.off');
                HugoBoss.startpage.utils.onlineStoreTeaserEnter(on, off);
                
                
            }, function(){
            
                var on = $(this).children('.on');
                var off = $(this).children('.off');
                HugoBoss.startpage.utils.onlineStoreTeaserLeave(on, off);
                
            });
			
            $('#lifestyleTeaser .teaser1').hoverIntent(function(){
            
                var on = $(this).children('.on');
                HugoBoss.startpage.utils.livestyleTeaserEnter(on);
                
                
            }, function(){
            
                var on = $(this).children('.on');
                HugoBoss.startpage.utils.livestyleTeaserLeave(on);
                
            });
            
            $('#lifestyleTeaser .teaser2').hoverIntent(function(){
            
                var on = $(this).children('.on');
                HugoBoss.startpage.utils.livestyleTeaserEnter(on);
                
                
            }, function(){
            
                var on = $(this).children('.on');
                HugoBoss.startpage.utils.livestyleTeaserLeave(on);
                
            });
            
        }
        
    },
    
    utils: {
    
        livestyleTeaserEnter: function(on){
        
            if (HugoBoss.utils.browserAndVersion() === 'ie8' || HugoBoss.utils.browserAndVersion() === 'ie7') {
            
                on.stop().css({
                    display: 'block'
                });
                
            }
            else {
            
                on.stop().css({
                    opacity: 0,
                    display: 'block'
                }).animate({
                    opacity: 1
                }, {
                    duration: 300
                });
                
            }
            
        },
        
        livestyleTeaserLeave: function(on){
        
            if (HugoBoss.utils.browserAndVersion() === 'ie8' || HugoBoss.utils.browserAndVersion() === 'ie7') {
            
                on.stop().css({
                    display: 'none'
                });
                
            }
            else {
            
                on.stop().css({
                    opacity: 1,
                    display: 'block'
                }).animate({
                    opacity: 0
                }, {
                    duration: 150
                });
                
            }
            
        },
        
        onlineStoreTeaserEnter: function(on, off){
        
            if (HugoBoss.utils.browserAndVersion() === 'ie8' || HugoBoss.utils.browserAndVersion() === 'ie7') {
            
                off.css({
                    display: 'none'
                });
                
                on.css({
                    display: 'block'
                });
                
            }
            else {
            
                on.stop();
                off.stop();
                
                off.animate({
                    opacity: 0
                }, {
                    duration: 200,
                    complete: function(){
                    
                        off.css({
                            display: 'none'
                        });
                        
                        on.css({
                            opacity: 0,
                            display: 'block'
                        }).animate({
                            opacity: 1
                        }, {
                            duration: 100
                        });
                        
                    }
                    
                });
                
            }
            
        },
        				
        onlineStoreTeaserLeave: function(on, off){
        
            if (HugoBoss.utils.browserAndVersion() === 'ie8' || HugoBoss.utils.browserAndVersion() === 'ie7') {
            
                off.css({
                    display: 'block'
                });
                
                on.css({
                    display: 'none'
                });
                
            }
            else {
            
                on.stop();
                off.stop();
                
                on.animate({
                    opacity: 0
                }, {
                    duration: 200,
                    complete: function(){
                    
                        on.css({
                            display: 'none'
                        });
                        
                        off.css({
                            opacity: 0,
                            display: 'block'
                        }).animate({
                            opacity: 1
                        }, {
                            duration: 100
                        });
                        
                    }
                    
                });
                
            }
            
        },
        
        footerFadeIn: function(){
        
            var target = $('#abdeckerFooter');
            
            target.stop().animate({
                opacity: 0
            }, {
                duration: 400,
                complete: function(){
                
                    target.css({
                        display: 'none'
                    });
                    
                }
                
            });
            
        },
        
        footerFadeOut: function(){
        
            var target = $('#abdeckerFooter');
            
            target.stop().css({
                display: 'block'
            }).animate({
                opacity: 0.7
            }, {
                duration: 400
            
            });
            
        },
        
        fadeFooter: function(offsetContentY){
        
            if (offsetContentY < -300) {
            
                HugoBoss.startpage.utils.footerFadeIn();
                HugoBoss.startpage.utils.footerScroll = true;
                
            }
            else {
            
                $('#footer').hoverIntent(function(){
                
                    HugoBoss.startpage.utils.footerFadeIn();
                    HugoBoss.startpage.utils.footerHover = true;
                    
                }, function(){
                
                    HugoBoss.startpage.utils.footerHover = false;
                    
                    if (!HugoBoss.startpage.utils.footerScroll) {
                        HugoBoss.startpage.utils.footerFadeOut();
                    }
                    
                });
                
                HugoBoss.startpage.utils.footerScroll = false;
                
                if (!HugoBoss.startpage.utils.footerHover) {
                    HugoBoss.startpage.utils.footerFadeOut();
                }
                
            }
            
        }
        
    }

};


//initialize all
$(document).ready(function(){

    HugoBoss.startpage.init();
    
});
