jQuery(document).ready(function(){
    jQuery("div.multi a, div#destacado a").fancybox({
	'zoomSpeedIn': 600, 
	'zoomSpeedOut': 600, 
	'padding': 1 
    });
		
    $("#dialogo").dialog({
	bgiframe: true,
	autoOpen: false,
	width: 460,
	height: 400,
	modal: true,
	buttons: {
	    'Enviar': function() {
		var destino = $("#agregarComentario").attr('action');
		jQuery.ajax({
		    url: destino,
		    type: "POST",
		    data: jQuery("#agregarComentario").serialize(),
		    cache: false,
		    success: function(html){
			jQuery("#dialogo").html(html);
		    },
		    beforeSend: function(){
			jQuery("#cargador").center(true);
			jQuery("#cargador").show();
		    },
		    complete: function(){
			jQuery("#cargador").hide();
		    }
		});
	    },
	    'Cancelar': function() {
		$(this).dialog('close');
	    }
	},
	close: function() {
	    spag(destinoDefault);
	}
    });
    
});
function agregar(id) {
   $("#dialogo").dialog( 'open' );
}

function spag(destino) {
    jQuery.ajax({
	url: destino,
	type: "GET",
	cache: false,
	success: function(html){
	    jQuery("#articulo-comentarios").html(html);
	},
	beforeSend: function(){
	    jQuery("#cargador").center(true);
	    jQuery("#cargador").show();
	},
	complete: function(){
	    jQuery("#cargador").hide();
	}
    });
    return false;
}