$(document).ready( function() {
    $('a.adminFooter').click( function() {
        $.modal('<iframe src="' + site_url + '/back/dashboard" height="768" width="100%" style="border:0">', {
                containerCss:{
                        backgroundColor:"#fff",
                        borderColor:"#fff",
                        height: 768,
                        padding:0,
                        width:1024			
                },
                opacity:80,
                overlayCss: {backgroundColor:"#424649"}
        });
        return false;
    });

    $('a.editar').live("click", function() {
	$.modal.close();
	var url = $(this).attr("href");
        $.modal('<iframe src="' + url + '" height="768" width="100%" style="border:0">', {
                containerCss:{
                        backgroundColor:"#fff",
                        borderColor:"#fff",
                        height: 768,
                        padding:0,
                        width:1024
                },
                opacity:80,
                overlayCss: {backgroundColor:"#424649"},
		onClose: function() { $.modal.close();relacionar(filtro_tipo,relacionados,cantidad,bloque); }
        });
        return false;
    });

    $("a.adjuntos_modal_close").live("click", function() {
	$.modal.close();
	relacionar(filtro_tipo,relacionados,cantidad,bloque);
    });

//    ver_header();
    mostrar_ranking('mas-noticias');
});

function limpiar_textbox(id, palabra)
{
    if ($("#" + id).val() == palabra)
    {
        $("#" + id).val("");
    }
}
function restore_textbox(id, palabra)
{
    if ($("#" + id).val() == "")
    {
        $("#" + id).val(palabra);
    }
}

function mostrar_ranking(div){
    $('#mas-comentadas').hide();
    $('#mas-vistas').hide();
    $('#mas-noticias').hide();
    $('#link-mas-comentadas').removeAttr('class');
    $('#link-mas-vistas').removeAttr('class');
    $('#link-mas-noticias').removeAttr('class');

    $('#link-'+div).addClass('on');
    $('#'+div).show();
    
}

function preview_nota_modal( nota ) {
    $("#submodal").html('<div><img src="'+ site_url +'application/templates/modal/images/ajax-loader.gif" width="32" height="32"/></div>');
	$.ajax({
	    url: site_url + 'backend/notas/preview/' + nota + '/true',
	    type: "post",
	    data: "",
	    success: function(data) {
		$("#submodal").html(data);
		return false;
	    }
	});
}

function ver_header(){
    $.ajax({
        
	    url: site_url + 'main/ver_header',
	    type: "post",
	    data: "",
	    success: function(text) {
		$('#header-ajax').html(text);
	    }
    });

     $.ajax({
	    url: site_url + 'main/ver_errores',
	    type: "get",
	    success: function(text) {		
		if (text != "") {
		    $("#mensaje_error").html(text);
		    $("#barra_frontend").show();
		}
	    }
    });
}
