$(document).ready(function(){

    $('#dialog').dialog({
        autoOpen: false,
        modal: true,
        draggable: true,
        resizable: false,
        close: function() {
            $( '#dialog' ).dialog("option", "title", "");
            $( '#dialog' ).html("");
        }
    });

    $('#verTerminos, .notaEditar, .editar_fuentes').live('mouseover mouseout',function(event) {
        if(event.type == 'mouseover') {
            $(this).addClass('hovering');
        } else {
            $(this).removeClass('hovering');            
        }
    });

    $('.hover').live('mouseover mouseout', function(event){
        var img = '';
        var ext = '';
        var pos = '';
        if (event.type == 'mouseover') {
            $(this).css('cursor','pointer');
            img = $(this).attr('name');
            ext = $(this).attr('src').split(".");
            pos = ext.length - 1;
            $(this).attr("src",root + 'web/img/sitio/' + img + '2.' +ext[pos]);
        } else if (event.type == 'mouseout') {
            img = $(this).attr('name');
            ext = $(this).attr('src').split(".");
            pos = ext.length - 1;
            $(this).attr("src",root + 'web/img/sitio/' + img + '.' +ext[pos]);
        }
    });

    $('#btnRegresar').click(function() {
        history.back();
    });

    $('#selEstado').change(function() {
        $('#selMunicipio').load(root+'recursos/municipios',{idEstado:$(this).attr('value')});
    });

});

// JAVASCRIPT GLOBAL FUNCTIONS

function popUp(title, width, height, content, button) {
    if(button) {
        $('#dialog').dialog( "option", "buttons", {
            Ok: function() {
                $( this ).dialog("close");
            }
        });
    }
    $('#dialog').dialog('option','title','<b>'+title+'</b>');
    $('#dialog').dialog('option','width',width);
    $('#dialog').dialog('option','height',height);
    $('#dialog').html(content);
    $('#dialog').dialog('open');
}

function jBotones()
{
    $(':button, :submit').button();
}

function jFilas()
{
    $('#publicaciones table tr:even, #notas table tr:even, #fuentes table tr:even').css('background-color','#EEEEEE');
}


