$(document).ready(function () {

    $("#quickSearchForm").submit(function (e) {
        e.preventDefault();
        var searchTerms = $("#quicksearchquery").val();
        if (searchTerms) {
            location.href = '/Search/?quicksearchquery=' + searchTerms;
        }
    });

    var imgSrc = "";
    var imgOrg = "";

    if ($("html").hasClass("no-touch")) {
        $("div.badge a").mouseover(function (event) {
            var imgSrc = $(this).attr("rel");
            $(this).children().attr("src", imgSrc).css('cursor', 'pointer');
            $(this).next().css('display', 'block');
        }).mouseleave(function () {
            var imgOrg = $(this).children().attr("rel");
            $(this).children().attr("src", imgOrg);
            $(this).next().css('display', 'none');
        });
    }

    if ($("html").hasClass("no-touch")) {
        $("#consultancyModel ul li").mouseover(function () {
            $("#consultancyModel").css('backgroundPosition', '80%' + $(this).attr("class"));
            $(this).children(".note").css('display', 'block');
        }).mouseout(function () {
            $("#consultancyModel").css('backgroundPosition', '80% 0');
            $(this).children(".note").css('display', 'none');
        });
    }

    $("nav.mobile a").toggle(function () {
        $("header nav").css('display', 'block');
    }, function () {
        $("header nav").css('display', 'none');
        $("nav.mobile").css('display', 'block');
    });

    if ($("html").hasClass("no-touch")) {
        $(window).resize(function () {
            var ww = $(window).width();
            if (ww > 767) {
                $("header nav").css('display', 'block');
            }
            if (ww < 766) {
                $("header nav").css('display', 'none');
            }
        });
    }

});
