    var subnav_interval=null;
    var dropped=null;
    function drop_nav(id){
        if(dropped){ $(dropped).slideUp('fast'); } 
        dropped= $('#'+id);
        dropped.css('opacity', '0.94');
        dropped.slideDown("fast"); 
        if(subnav_interval){ clearInterval(subnav_interval); }
        subnav_interval=setInterval(function(){ $('#'+id).slideUp('fast'); dropped=null; },(id=="category_subnav")?15000:1600); 
    }
    function init_nav(id){
        $('#'+id).bind("mouseenter",function(e){if(subnav_interval){ clearInterval(subnav_interval); }});
        $('#'+id).bind("mouseleave", function(e){ $(this).slideUp("fast"); dropped=null;});
    }
    function show_whats_new_box () {
        $('#whats_new_popup').css('opacity','0.9');
        $('#whats_new_popup').fadeIn('fast');
    }
    function hide_whats_new_box () {
        $('#whats_new_popup').fadeOut('fast');
    }
    var resizeBg = function(){
        var w = 1280;
        var h = 750;
        var stageHeight = self.innerHeight || document.documentElement.clientHeight || document.body.clientHeight; 
        var stageWidth = self.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; 
        var elem = $('#background-img'); 
        var origHeight = Number(elem.attr('alt'));
        var origWidth = Number(elem.attr('title'));

        var sX = stageWidth/w;
        var sY = stageHeight/h; 
        var sF = null;
        sF = sX;
        if(sY>sX){sF = sY;}         
        elem.attr('name',sF);
        elem.css('width',(origWidth*sF));
        elem.css('height',(origHeight*sF));
        //Tweener.addTween(o, {scaleX:sF, scaleY:sF, time:0, transition: "easeoutexpo"})
    }

    function show_thickbox() {
        tb_show('E-mail Your Friends', '/sendtofriend/send-to-friend/?url=/videos/&KeepThis=true&TB_iframe=true&height=324&width=427', null);
        }
    function show_embedcode(flv) {
        tb_show('Embed this video on your website', '/embedcode/?videopath='+flv, null);
        }
    function setBackgroundSize() {
        jQuery.each(jQuery.browser, function(i) {
          if($.browser.safari){
            $('.wrapper').css('min-height',null);
            $('#bg_hold').css('height',$(document).height() - 28 );
            $('.wrapper').css('min-height',$(document).height());
          }else{
            $('#bg_hold').css('height',$(document).height() - 28 );
          }
        });

    }

    function searchClick(){
        $('#search_link').click();
    }
    function secondSubmit() {
        $('#thankyoutext').submit();
    }

        $(document).ready(function() {
            $('#products_btn').mouseover(
                function(){
                    drop_nav('category_subnav');
                });
            init_nav('category_subnav'); 
            $('#whatsnew_link').click(
                function () {
                    show_whats_new_box();
                }
            );
            $('#close_popup').click(
                function () {
                    hide_whats_new_box();
                }
            );
            $('#team_subnav_container').hover( function() {
                $(this).find('ul').slideDown('fast');
            }, function(){
                $(this).find('ul').hide();
            });

            $('#search_link').toggle(
                function () {
                    $('#search_box_holder').slideDown('fast');
                    $("#search_box").focus();
                    $("#search_box").css('z-index','1500');
                    $('#content').bind("click", searchClick);
                },
                function () {
                    $('#search_box_holder').slideUp('fast');
                    $('#content').unbind("click", searchClick);
                }
            );

            setBackgroundSize();
            $(window).resize(function(){
                setBackgroundSize();
                resizeBg();
            });
            setTimeout('setBackgroundSize();resizeBg();',500);
            $('#headband').css('opacity','0.69');
            $('.bg').css('opacity','0.05');
            $('#foot_left form').ajaxForm({
               target: '#foot_left',
               success: secondSubmit
            }); 
        });
