var $j = jQuery.noConflict();

function confirmarSalida(event) {
    event.preventDefault();
    var urlActual = event.target.href;
    // Vemos si es IE 6, mostramos confirm
    if (ie6) {
        // Si dicen que si, salimos
        if (confirm('Desea abandonar el sitio')) {
            window.location.href=urlActual;
        }
    } else {
        // Si no es IE 6, mostramos el dialogo normal
        $j('#confirmacionPopUp').dialog('open');
        $j("#linkc").attr({
            href: urlActual
        });
    }
}

$j(document).ready(function () {

    //window.ie6 = $j.support.htmlSerialize && !($j.support.objectAll);
    ie6 = $j.browser.msie && $j.browser.version.substr(0,1)=="6";
    
    $j("a[rel=external]").click(function(event) {
        confirmarSalida(event);
    });
    
    if (ie6) {
        $j('#dialog').remove();
        $j('#confirmacionPopUp').remove();
        $j('#dialogSNM').remove();
    } else {
        /* *-* Dialogos *-* */
        // Dialog COIM
        $j("#dialog").dialog({
            autoOpen: false,
            bgiframe: true,
            draggable: false,
            modal: true,
            resizable: false,
            minHeight: 300,
            minWidth: 350,
            height: 320,
            width: 360
        });
        // Dialog Abandonar Sitio
        $j("#confirmacionPopUp").dialog({
            autoOpen: false,
            bgiframe: true,
            draggable: false,
            modal: true,
            resizable: false,
            closeOnEscape: true,
            height: 150,
            width: 300
        });

    }
    /* *-* Paginador *-* */
    $j('#pager').css("font-family" , "verdana");
    $j('#pager').pager('div.page');
    $j("#nav").css({
        "font-size" : "10px",
        "padding-top" : "5px",
        "font-weight" : "bolder"
    });
    /* *-* Paginador termina aqui. *-* */

    $j('#secretarias-tooltip td').click(function(event){
        event.target.href = $j("a.cursor", this).attr("href");
        confirmarSalida(event);
    });

    $j('#secretarias-tooltip td').tooltip({
      delay:0,
      bodyHandler: function() {
        var idSecretaria = $j(this).attr('id');
        var image = $j("<div id=banner_"+idSecretaria+"></div>");
        return image;
      }
    });
    /* *-* Tooltip de Secretarias termina aqui. *-* */    

});

