jQuery(document).ready(function () {

    //GOOGLE TRACKING
    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-28400519-1']);
    _gaq.push(['_trackPageview']);

    (function () {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
    })();

    //javascript for random image in footer
    var rand = Math.floor(Math.random() * 4);

    var imgs = ["url(../images/footer/footer_DP10.png)", "url(../images/footer/footer_I12.png)", "url(../images/footer/footer_CR14.png)", "url(../images/footer/footer_MCL1000.png)"];
    var txt = ["../images/footer/footer_DP10_text.png", "../images/footer/footer_I12_text.png", "../images/footer/footer_CR14_text.png", "../images/footer/footer_MCL1000_text.png"];
    var links = ["../two_post/DP10A.aspx", "../two_post/I12.aspx", "../four_post/CR14.aspx", "../motorcycle/1000MCL.aspx"];
    //alert(links[rand] + rand);
    jQuery('#footer_img').attr('src', txt[rand]);
    jQuery('#learnmore_link').attr('href', links[rand]);
    jQuery('#footer_imglink').attr('href', links[rand]);
    jQuery('.footer_image').css('background-image', imgs[rand]);
    
    function megaHoverOver() {
        jQuery(this).find(".sub").stop().fadeTo('fast', 1).show();

        //Calculate width of all ul'sn
        (function (jQuery) {
            jQuery.fn.calcSubWidth = function () {
                rowWidth = 405;
                //rowWidth = 0;
                //Calculate row
                //jQuery(this).find("ul").each(function () { //for each ul...
                //    rowWidth += jQuery(this).width(); //Add each ul's width together
                //});
            };
        })(jQuery);

        if (jQuery(this).find(".row").length > 0) { //If row exists...
            var biggestRow = 0;
            //Calculate each row
            jQuery(this).find(".row").each(function () {
                jQuery(this).calcSubWidth();
                //Find biggest row
                if (rowWidth > biggestRow) {
                    biggestRow = rowWidth;
                }
            });
            //Set width
            jQuery(this).find(".sub").css({ 'width': biggestRow });
            jQuery(this).find(".row:last").css({ 'margin': '0' });

        } else { //If row does not exist...

            jQuery(this).calcSubWidth();
            //Set Width
            jQuery(this).find(".sub").css({ 'width': rowWidth });

        }
    }

    function megaHoverOut() {
        jQuery(this).find(".sub").stop().fadeTo('fast', 0, function () {
            jQuery(this).hide();
        });
    }


    var config = {
        sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)    
        interval: 100, // number = milliseconds for onMouseOver polling interval    
        over: megaHoverOver, // function = onMouseOver callback (REQUIRED)    
        timeout: 500, // number = milliseconds delay before onMouseOut    
        out: megaHoverOut // function = onMouseOut callback (REQUIRED)    
    };

    jQuery("ul#topnav li .sub").css({ 'opacity': '0' });
    jQuery("ul#topnav li").hoverIntent(config);
    jQuery('.quote').hide();
    jQuery('#quote_1').show();
});


       var k = 2;
       function rotate() {
           //alert("k is "+k);
           jQuery('.quote').hide();
           jQuery('#quote_' + k).show();
           if (k == 6)
           { k = 1; }
           else
           { k++; }
           setTimeout("rotate()", 7250)
       }
       rotate()


     
