
$(function() {
    $('.ui-state-default').live('mouseover', function() {
        $(this).addClass('ui-state-hover');
    });
    
    $('.ui-state-default').live('mouseout', function() {
        $(this).removeClass('ui-state-hover');
    });

    $('.grid-table tr').live('mouseover', function() {
        $(this).addClass('hover');
    });
    
    $('.grid-table tr').live('mouseout', function() {
        $(this).removeClass('hover');
    });
    
    $(document).ajaxStart(function() {
        showAjaxLoader();
    });

    $(document).ajaxComplete(function() {
        hideAjaxLoader();
    });
});

function submitForm(formId, action) {
    var form = $('#' + formId);
    if (form) {
        form.append('<input type="hidden" name="' + action + '" value="' + action + '" />');
        form.submit();
    }
}

function showAjaxLoader() {
    $("#ajax-loader").dialog({
        bgiframe: false,
        minHeight: 50,
        width: 200,
        modal: true,
        title: false,
        draggable: false,
        stack: true,
        resizable: false,
        autoOpen: false,
        closeOnEscape: true,
        dialogClass: 'ajax-loader'
    });
    $("#ajax-loader").dialog('open');
    $('.ui-widget-overlay').css('opacity', 0.1);
}

function hideAjaxLoader() {
    $("#ajax-loader").dialog('close');
}
