/**
 * $Id: [project name].js [yyyy-mm-dd] $
 *
 * @author [Developer Name]
 * @copyright Copyright (c) [yyyy], Trapeze, All rights reserved.
 *
 * Dependencies:
 *      jQuery 1.3.1        (http://www.jquery.com),
 */

$.namespace("trapeze.bfg");

trapeze.bfg = $.Class.extend({
    set_cufon_fonts : function() {
        Cufon.replace('#ContextBar li a, #ContextBar p', { 
                fontFamily: 'tradegothic-condensed',
                hover: false,
                textShadow: '#662804 -1px 1px'
        });
        
        $('#MainNavigation > li > a').css('font-size', '13px');
        Cufon.replace('#MainNavigation > li > a', { 
                fontFamily: 'tradegothic-condensed',
                hover: false,
                textShadow: '#762f02 -1px 1px'
        });
        
        $('#SubNavigation > li > a').css('font-size', '11px');
        Cufon.replace('#SubNavigation > li > a', { 
                fontFamily: 'tradegothic-condensed',
                hover: false,
                textShadow: '#311102 -1px 1px'
        });
        
        $('#LocationNavigation > li > a').css('font-size', '14px');
        Cufon.replace('#LocationNavigation > li > a', { 
                fontFamily: 'tradegothic-condensed',
                hover: false
        });
        
        Cufon.replace('h1, h2, , h3.greater, #SectionNavigation, .custom-font, .close-btn a', { 
                fontFamily: 'tradegothic-condensed',
                hover: false
        });

        Cufon.replace('.content-slider .message p', { 
                fontFamily: 'tradegothic-condensed',
                hover: false
        });
        
    },
    
    set_home_animation : function() {
        //Fix Home Flash Animation Position
        //TODO implement this fix whenever the subnavigatio opens
        $('#HomeBadge').css('padding-top', $('#SubNavigation').height() + 'px');
    },
    
    slide_sub_navigation : function() {
        //TODO - $("#SubNavigation").css("display","none");
    },

    hover_menus : function() {   
        $("#MainNavigation").add($("#SubNavigation")).addClass("hover-menu"); 
        $(".hover-menu li").hover(
            function() {
                $(this).addClass("active-state");
            },
            function() {
                $(this).removeClass("active-state");
            }
        );   
    },

    close_locations : function() {
        var closeLink = '<div class="close-btn"><a href="javascript:void(0);">close</a></div>';
        if ($("#LocationBar").length > 0){
            var jCloseContainer = $("#LocationBar");
            jCloseContainer.find(".inner-wrapper").append(trapeze.render_template(closeLink, {}));
            jCloseContainer.find('.close-btn a').click(function(){
                jCloseContainer.slideUp({
                    duration: 800, 
                    easing: 'easeOutExpo' 
                });
            });
        }
    },
    
    style_hr : function() {
        $("body").find("hr").wrap('<div class="hr"></div>').each(function() {
            $(this).parent().addClass($(this).attr("class"));
        });
    },

    print_page : function() {
        var printLink = '<a class="print-link" href="javascript:void(0);">print this page</a>';
        $(".section-detail").prepend(trapeze.render_template(printLink, {}));        
        $("a.print-link").click(function(){
            window.print();
        });
    },
    
    submit_form : function() {
        $("form .js-submit").change(function(){
            $(this).parents("form").submit();
        });
    },
    
    init : function() {
        var page = $('body').attr('class');
        //page = page.match(/(\w+-page)/);
        //page = (page.indexOf(' ') > 0) ? page.slice(0,page.indexOf(' ')) : page;
        switch(page) {
            case 'home-page':
                //this.show_home_flash();
                //this.set_home_animation();
                break;
            case 'behind-the-scenes-fish-detail-page':
                this.print_page();
                break;
            case 'behind-the-scenes-recipe-detail-page':
                this.print_page();
                break;
            case 'about-page':
                //Code to be executed on the about page
                break;
            default:
                //Code to be executed on any page, but the pages listed above.
        }

        // Code to be executed on every page
         //this.slide_sub_navigation();
         this.hover_menus();
         this.close_locations();
         this.style_hr();
         this.set_cufon_fonts();
         this.submit_form();
    }
});

$(function() {
    new trapeze.bfg();
});
