/*Sustitucion de imagenes*/
jQuery.fn.jQIR = function(format, path, onload){
	if(!document.images) return this;
	path = path || "";
	this.each(
		function()
		{
			var img = $("<img>"), el = jQuery(this);
			var file;
			var re = /(?:{src\:)(\S+)(?:})/i;
			var m = this.className.match(re);
			if(m){
				file = path + m[1];
			}else{
				file = path + this.id + "." + format;
			}
			jQuery(img).attr(
			{
				src: file,
				alt: el.text()
			}).load(typeof onload == "function" ? onload : function(){} );
			var a = el.find("a");
			var toAppend = a.length ? a.empty().append(img) : img;
			el.empty().append(toAppend);
		}
	)
	return this;
}
function resizeImg(cualImg) {
	var maxwidth = 240;
	var maxheight = 250;
	var imagen = document.getElementById(cualImg);
	if (imagen.width>maxwidth || imagen.height>maxheight) {
		var scale = Math.min((maxwidth/imagen.width),(maxheight/imagen.height), 1 );
		var new_width = Math.floor(scale*imagen.width);
		var new_height = Math.floor(scale*imagen.height);
		imagen.width = new_width;
		imagen.height = new_height;
	}
}
function selector(numero){
	for(x=1; x <= 3; x++){
		if(x == numero){
			document.getElementById("sel_" + x).className = "goshow";
			document.getElementById("link_" + x).className = "selected";
			document.getElementById("li_" + x).className = "selected";
		}else{
			document.getElementById("sel_" + x).className = "noshow";
			document.getElementById("link_" + x).className = null;
			document.getElementById("li_" + x).className = null;
		}
	}
}
function addevento(url, title, tipo){//tipo=favoritos, tipo=home
	version=0
	if (navigator.appVersion.indexOf("MSIE")!=-1){
	temp=navigator.appVersion.split("MSIE")
	version=parseFloat(temp[1])
	}
	if(version == 0){//Firefox, opera,...
		if(tipo == "favoritos"){//aņadimos a favoritos
			alert("Para aņadir esta web a sus favoritos pulsa: [ Ctrl ] + [ D ]");
		}else{//Hacemos pagina de inicio
			alert("Arrastre la URL hasta su carpeta de favoritos");
		}
	}else{//En caso de ser explorer
		if(tipo == "favoritos"){//aņadimos a favoritos
			window.external.AddFavorite(url,title);
		}else{//Hacemos pagina de inicio
			document.getElementById("home").style.behavior='url(#default#homepage)';
			document.getElementById("home").setHomePage(url);
		}
	}
}


