function ajaxCompleteCallback(event, XMLHttpRequest, ajaxOptions) {
    if (ajaxOptions.url.indexOf('/Content/lang/') == -1) {
        initTasks();
    }
}

function initTasks() {
    $('.desktopmodules_coremodules_mvc_mvcmodule_ascx button,.desktopmodules_coremodules_mvc_mvcmodule_ascx  submit,.desktopmodules_coremodules_mvc_mvcmodule_ascx  input[type=button],.desktopmodules_coremodules_mvc_mvcmodule_ascx   input[type=submit]')
            .addClass('ui-state-default')
            .addClass('ui-corner-all')
            .hover(function () { $(this).addClass('ui-state-hover'); }, function () { $(this).removeClass('ui-state-hover'); });

    $(".desktopmodules_coremodules_mvc_mvcmodule_ascx li.ui-widget-content")
        .css("border", 0)
        .hover(function () { $(this).addClass('ui-state-hover'); }, function () { $(this).removeClass('ui-state-hover'); });

    $('.desktopmodules_coremodules_mvc_mvcmodule_ascx .ui-datepicker-trigger').css('vertical-align', 'top');
    $(".desktopmodules_coremodules_mvc_mvcmodule_ascx tr.hoverable").hover(function () { $(this).addClass('ui-state-hover'); }, function () { $(this).removeClass('ui-state-hover'); });

    $(".desktopmodules_coremodules_mvc_mvcmodule_ascx .ui-tabs ul li").css("list-style-type", "none");

    var opts = { language: "es", pathPrefix: "/Content/lang" };
    $("[rel*=localize]").localize("general", opts);

    var errors = $('.desktopmodules_coremodules_mvc_mvcmodule_ascx .spnError');
    $.each(errors, function (i, item) {
        if ($(item).html() == '&nbsp;') {
            $(item).html('');
        }
    });

}

$(document).ready(function () {
    $('#switcher').themeswitcher();
    $(document).bind('click', function () {
        $("[adv='adv']").hide('slow');
        $(document.body).unbind('click', '');
    });



    $('._timeEntry').timeEntry({ spinnerImage: '', show24Hours: true, defaultTime: new Date(0, 0, 0, 0, 0) });
    initTasks();
    $('#loading').loading({ onAjax: true, img: '', text: 'Cargando...' });

    $.ajaxSetup({
        timeout: 50000
    });

    $(document).ajaxComplete(ajaxCompleteCallback);

    if (document.getElementById('superPrincipalMenu') == null) {
        var s = $('<div id="superPrincipalMenu">');
        $(s).appendTo('div:first');

    }
});
