
if (!bt) var bt = {};
if (!bt.Global) bt.Global = {};


(function(o, $) {

    o.pageLoad = function() {

        //setup text box hints
        wireUpDisplayTextboxes();

        //png images transparency fix
        //$("#header").pngFix();
		$(document).pngFix();
        /*cufon used for headings replacement with Clarendon font*/
        replaceCufonText();

        //setup mega menu
        var megaConfig = {
            interval: 50,
            sensitivity: 4,
            over: addMega,
            timeout: 50,
            out: removeMega
        };

        //use  non-hoverIntent solution for IE6 & page containing #flashFeature
        //test for flashFeature: $('#flashFeature').length > 0
        //test for IE6: $.browser.msie && $.browser.version.substr(0, 1) < 7
        if ($('#flashFeature').length > 0) { // $.browser.msie && $.browser.version.substr(0, 1) < 7 && 
            //jQuery solution for megamenu hovering class switch
            $("li.menu-item").mouseover(function() {
                $(this).addClass("hovering");
            });
            $("li.menu-item").mouseout(function() {
                $(this).removeClass("hovering");
            });
        } else $("li.menu-item").hoverIntent(megaConfig); //use hoverIntent in any other case      

        /*IE 6 li:hover background menu fix*/
        $('#leftNav li').mouseover(function() {
            $(this).addClass('shover');
        });
        $('#leftNav li').mouseout(function() {
            $(this).removeClass('shover');
        });

        setupHomePage();
    };


    // displays hint text on any input element with the 'title' attribute set
    function wireUpDisplayTextboxes() {
        var el = $('input[Title]');

        // show the display text
        el.each(function(i) {
            $(this).attr('value', $(this).attr('title'));
        });

        // enable the blur & focus
        el.focus(function() {
            if ($(this).attr('value') == $(this).attr('title')) {
                $(this).attr('value', '');
            }
            $(this).addClass('on');
        }).blur(function() {
            if ($(this).attr('value') == '') {
                $(this).attr('value', $(this).attr('title'));
                $(this).removeClass('on');
            }
        });
    }

    function replaceCufonText() {
        //console.log('start Cufon');
        Cufon.replace('h1');
        Cufon.replace('h2');
//        Cufon.replace('h2');		
        Cufon.replace('h3.cufon');
        // console.log('end Cufon');
    }

    function setupHomePage() {
        //flash on the first page
        flashvars = {
            movieURL: "/lib/swf/afeature.swf",
            xmlURL: "/lib/swf/data.xml"
        };
        params = {
            wmode: 'transparent',
            bgcolor: '#FFFFFF',
            scale: 'noborder',
            salign: '',
            quality: 'best',
            menu: 'false',
            allowscriptaccess: 'always',
            swliveconnect: 'true',
            allowFullScreen: 'true'
        };
        attributes = {};

        var playerVersion = swfobject.getFlashPlayerVersion();
        if (playerVersion.major >= 7) {
            //$('#smallPromos').hide();
            //$('#home #content .innerContent').attr('style', 'background-image: none');
            swfobject.embedSWF("/lib/swf/shell.swf", "flashFeature", "1200", "300", "9.0.115.0", "/lib/swf/expressInstall.swf", flashvars, params, attributes);
        } else {
            //$('div#afeature').attr('style', 'height: 300px; width: 1200px; margin-top: 20px; position: relative; left: 125px;');
        }
    }

    function addMega() {
        $(this).addClass("hovering");
    }

    function removeMega() {
        $(this).removeClass("hovering");
    }


})(bt.Global, jQuery);

jQuery(bt.Global.pageLoad);

