// Función de inicialización común a todas las páginas del sitio
function common_init() {
	// Si está cargado el fichero para hacer las esquineas redondeadas, se inicializa
	if (typeof(roundrect_init) !== "undefined")
		roundrect_init();
	
	// Rollover para los botones de la página
	buttons_init();
}

// Rollover para los botones de la página.
// Se peude llamar de forma aislada y en cualquier momento, por eso existe la función y no se mete dentro de common_init();
function buttons_init() {
	function over() {
		//$(this).find(".unsel").hide();
		$(this).find(".sel").show();
	}
	
	function out() {
		//$(this).find(".unsel").show();
		$(this).find(".sel").hide();
	}
	
	$(".button .sel").hide();
	$(".button").hover(over, out);
}

// Añadimos la función trim a los strings
String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g, '');
}

// Añadimos la función indexOf a los arrays, para aquellos navegadores que no lo tienen (IE, por supuesto)
if (!Array.prototype.indexOf) {
	Array.prototype.indexOf = function(elt /*, from*/) {
		var len = this.length;
		
		var from = Number(arguments[1]) || 0;
		from = (from < 0)? Math.ceil(from): Math.floor(from);
		if (from < 0)
			from += len;
		
		for (; from < len; from++) {
			if (from in this && this[from] === elt)
				return from;
		}
		
		return -1;
	};
}

// Código necesario para que no se muestre el destino de cada enlace en la barra de estado cuando pasemos el ratón por encima.
function hidestatus() {
	window.status = '';
	return true;
}

if (document.layers)
	document.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT);

document.onmouseover = hidestatus;
document.onmouseout  = hidestatus;
