function block(action){
    //action Block
    switch(action){
        case 1: //UnBlock Total
            $.unblockUI();
            break;
        case 2: //Block Total
            $.blockUI({
                message:null,
                overlayCSS: {
                    backgroundColor: '#000',
                    opacity:'0.1'
                }
            });
            break
        case 3: //Block Loader
            $.blockUI({
                message: $('#loader'),
                overlayCSS: {
                    backgroundColor: '#000',
                    opacity:'0.1'
                },
                css:{
                    border:'none',
                    width: '100px',
                    top:  ($(window).height() - 100) /2 + 'px',
                    left: ($(window).width() - 100) /2 + 'px',
                    cursor:'wait'
                }
            });
            break;
    }
}

function innerBlock(div,action){
    switch(action){
        case 1://UnBlock div
            $(div).unblock();
            break;
        case 2: //Block div
            $(div).block({
                message: $('#loader'),
                overlayCSS: {
                    backgroundColor: '#EBE9ED',
                    opacity:'1.0'
                },
                css:{
                    border:'none',
                    width: '100px',
                    top:  ($(window).height() - 100) /2 + 'px',
                    left: ($(window).width() - 100) /2 + 'px',
                    cursor:'wait'
                }
            });
            break;
    }
}

function dialogWarning(title,message){
    $('#dialog_warning').dialog('destroy');
    $("#dialog_warning").dialog({
        title:title,
        bgiframe: true,
        modal: true,
        autoOpen: false,
        resizable:false,
        width:450,
        minHeight:180,
        overlay: {
            backgroundColor: '#000',
            opacity: 0.1
        },
        open: function(){
            $("#message_warning").html(message);
        },
        buttons: {
            Aceptar: function() {
                $(this).dialog('close');
            }
        }
    });
    $('#dialog_warning').dialog('open');
}

function dialogExecute(title,question,message){
    $('#dialog_execute').dialog('destroy');
    $("#dialog_execute").dialog({
        title:title,
        bgiframe: true,
        modal: true,
        autoOpen: false,
        resizable:false,
        width:280,
        minHeight:180,
        overlay: {
            backgroundColor: '#000',
            opacity: 0.1
        },
        open:function(){
            $("#question_execute").html(question);
            $("#message_execute").html(message)
        },
        buttons: {
            Cancelar: function() {
                $(this).dialog('close');
            },
            Aceptar: function() {
                afterCall();
                $(this).dialog('close');
            }
        }
    });
    $('#dialog_execute').dialog('open');
}

function redirect(url){
    location.href=url;
}

function showModal(mensaje){

    var html='<div id="contenidoModal">' +
    '<div id="cuerpoModal">'+mensaje+'</div>'+
    '<div id="botonModal">'+
    '<img border="0" width="90" height="27" alt="Aceptar" src="public/media/images/aceptarpopup.png"/>'+
    '</div>'+
    '</div>';

    if($("#modal").length>0){
        $("#modal").remove();
    }

    $("body").append('<div align="center" id="modal">'+html+'</div>');

    if($.browser.msie&&$.browser.version=='6.0'){
        $("#modal").addClass("select-free").append("<iframe></iframe>");
    }

    $("#modal").show();
    $("img[src$=.png]").ifixpng();
    $("#contenidoModal").ifixpng();

    $("#botonModal").click(function(){
        $("#modal").hide();
    });
}

