
$(document).ready(function () {



    ////////////////////////////////////////////////fade btns
    $('.fadeThis').append('<span class="hover"></span>').each(function () {
        var $span = $('> span.hover', this).css('opacity', 0);



        $(this).hover(function () {
            $span.stop().fadeTo(300, 1);
        }, function () {
            if ($(this).hasClass('.active')) {
                //do nothing
            } else {
                $span.stop().fadeTo(300, 0);
            }
        });
    });


    ////////////////////////////////////////////////////////menu//////////////////////////
    function megaHoverOver() {
        //var ah = $(this).css('left'); //grab left of current LI hoverd
        var ah2 = $(this).find(".subMenu").height(); //grab height of submenu

        //bring current sub top 1
        //$(this).find(".sub2").css('top', 41);
        //$(this).find("#mDivider").css('height', ah2); //adjust main divider to submenu's height
        //$(this).find(".sub2").css('left', ah); //adjust submenu's left position to current LI

        $(this).find(".subMenu").stop().fadeTo('fast', 1).show()
        $(this).find(".subMenu").css("z-index", "9999");


    }

    function megaHoverOut() {

        $(this).find(".subMenu").css("z-index", "9998");
        $(this).find(".subMenu").stop().fadeTo('fast', 0, function () {
            $(this).hide();
        });

    }


    var config = {
        sensitivity: 1, // number = sensitivity threshold (must be 1 or higher)    
        interval: 10, // 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)    
    };

    $("ul#navUL li .subMenu").css({ 'opacity': '0' });
    $("ul#navUL li .subMenu").css({ 'display': 'none' });
    $("ul#navUL li").hoverIntent(config);

    /////////////////anchor slide
    $(".scroll").click(function (event) {
        //prevent the default action for the click event
        event.preventDefault();

        //get the full url - like mysitecom/index.htm#home
        var full_url = this.href;

        //split the url by # and get the anchor target name - home in mysitecom/index.htm#home
        var parts = full_url.split("#");
        var trgt = parts[1];

        //get the top offset of the target anchor
        var target_offset = $("#" + trgt).offset();
        var target_top = target_offset.top;

        //goto that anchor by setting the body scroll top to anchor top
        $('html, body').animate({ scrollTop: target_top }, 500);
    });


    // Quote Form - Added my MJE
    $('#divInterestedCommercial').hide();

    $('#dropResCom').change(function () {
        if( $('#dropResCom').val() == "Residential" )
        {
            $('#divInterestedCommercial').hide();
            $('#divInterested').show();
        } else {
            $('#divInterestedCommercial').show();
            $('#divInterested').hide();
        }
    });

});

