﻿$(function () {
    // dynamic loading client script for searchpart_view
    $('<script src="/ManageSite/js/searchbarpart_view.js" type="text/javascript"/>').appendTo('body');

    // Header Quick Panel Feature
    /////////////////////////////////////////////////////////////////
    $(".headerLinks > li").mouseenter(function () {
        if (!$(this).hasClass('moving')) {
            $(this).addClass('moving');
            $(this).find('.dropdown_panel').slideDown(100, function () { $(this).parent('li').removeClass('moving'); });
        }
    });
    $("div.dropdown_panel").mouseleave(function () {
        $(this).hide();
    });

    // Footer Quick Panel Feature
    /////////////////////////////////////////////////////////////////
    $('.footer .menu > li ul').hide();
    $('.footer .menu > li').mouseenter(function () {
        $('.footer .menu > li.selected').removeClass('selected');
        $(this).addClass('selected');
        setTimeout(function () {
            $('.footer .menu > li').not('.selected').find('ul').slideUp(100);
            $('.footer .menu > li.selected ul').slideDown(100);
        }, 200);

    });
    $('.footer .menu > li').mouseleave(function () {
        $(this).removeClass('selected');
        setTimeout(function () {
            $('.footer .menu > li').not('.selected').find('ul').slideUp(100);
        }, 200);
    });


    // Hide all popup when body be clicked
    /////////////////////////////////////////////////////////////////
    $("body").click(function () {
        $("div.dropdown_panel, #multi_search_bar .pnl, .footer .menu > li").trigger('mouseleave');
    });

    // AspNet Grid View Action mene default action setup
    /////////////////////////////////////////////////////////////////
    $('.actionmenu .preSelected').each(function () {
        $(this).prependTo($(this).parent());
    });

    // What is this ? general function
    /////////////////////////////////////////////////////////////////
    var popups = [];
    $('.whatisthis > a').click(function () {
        if (!$(this).attr('dialog_index')) {
            var pop = popups.length;
            popups[pop] = $(this).parent('.whatisthis').children('div').css({
                'padding': '10px',
                'line-height': '2em'
            }).dialog({
                width: 500,
                closeText: "",
                modal: true
            });
            $(this).attr('dialog_index', pop);
        } else {
            popups[$(this).attr('dialog_index')].dialog('open');
        }

        return false;
    });

});




