/**
 * FUNCIONES GENERALES DEL PORTAL
 *
 **/

	$(document).ready(function(){

		// Convierte los title (títulos) de los
		// siguientes tags en tooltips
		//$('a, img, .title').tooltip({ 
		$("a, img, .title").tooltip({ 
		    track: true, 
		    delay: 0, 
		    showURL: false, 
		    showBody: " - ", 
		    fade: 250 
		});	

		// Los enlaces con clase ventana_modal
		// abren en una ventana modal el contenido
		// remoto que indica su href
		$('a.ventana_modal').click(function() {
			var url = this.href;
			var titulo = this.name;
			var dialog = $('<div style="display:hidden"></div>').appendTo('body');
			// Carga el contenido remoto
			dialog.load(
				url, 
				{},
				function (responseText, textStatus, XMLHttpRequest) {
					dialog.dialog({
						resizable: true,
						modal: true,
						width: 600,
						height: 400,
						title: titulo,
						draggable: true,
						buttons: {
							"Cerrar": function() { $(this).dialog("close"); }
						}
					});
				}
			);
			// Evita que el navegador siga el enlace
			return false;
		});

	});




/**
 * function trim
 *
 * Elimina los espacios en blanco inciales y finales
 *
 * @access public
 * @return string
 * @since 17/07/2009
 **/
function trim( str ){
	return str.replace(/^(\s|\&nbsp;)*|(\s|\&nbsp;)*$/g,"");
}



/**
 * function agrega_a_favoritos
 *
 * Agrega a favoritos del navegador la url
 * indicada con el título que se especifique.
 *
 * @access public
 * @return string
 * @since 19/12/2010
 **/
function agrega_a_favoritos( url, title ){
	
		// Para Marcadores de Mozilla Firefox
        if (window.sidebar) {
                window.sidebar.addPanel(title, url,"");
				
        // Para Favoritos de IE
		} else if( window.external || document.all) {
                window.external.AddFavorite( url, title );
				
		// Para Favoritos de Opera
        } else if(window.opera) {
                $("a.jQueryBookmark").attr("href",url);
                $("a.jQueryBookmark").attr("title",title);
                $("a.jQueryBookmark").attr("rel","sidebar");
		
		// Para otros navegadores
        } else {
                 alert('Su navegador no soporta esta acción.');
                 return false;
        }
}
