// Etiquetas HTML No Permitidas
EtiquetasNoPerm = new Array ('<!','<a','<abbr','<acronym','<address','<applet','<area','<b','<base','<basefont','<bdo','<big','<blockquote','<body','<br','<button','<caption','<center','<cite','<code','<col','<colgroup','<dd','<del','<dir','<div','<dfn','<dl','<dt','<em','<fieldset','<font','<form','<frame','<frameset','<h','<head','<hr','<html','<iframe','<i','<img','<input','<ins','<isindex','<kbd','<label','<legend','<li','<link','<map','<menu','<meta','<noframes','<noscript','<object','<ol','<optgroup','<option','<p','<param','<pre','<q','<s','<samp','<script','<select','<small','<span','<strike','<strong','<style','<sub','<sup','<table','<tbody','<td','<textarea','<tfoot','<th','<thead','<title','<tr','<tt','<u','<ul','<var','<xmp');
// Etiquetas HTML Permitidas
//EtiquetasPerm = new Array ('<b','<i');

// -----------------------------------------------------------------

// --------------------------
// 		Quita Etiquetas
// --------------------------
// Quita las Etiquetas no Permitidas
// - Entrada: Texto de Origen
// -  Salida: Texto con las Etiquetas no Permitidas separadas
function EtiqNoPermitidas (Origen) {
	var TextoLeido = Origen.value; // Texto de Origen
	// Quitamos las Etiquetas NO permitidas
	for (i=0; i<EtiquetasNoPerm.length; i++) {
		var ExpReg = new RegExp(EtiquetasNoPerm[i], 'g'); // Expreción regular con búsqueda global (g) con las Etiquetas <p ...
		TextoLeido = TextoLeido.replace(ExpReg,'< ' + EtiquetasNoPerm[i].replace('<',''));
		var ExpReg1 = new RegExp(EtiquetasNoPerm[i] + '>', 'g'); // Expreción regular con búsqueda global (g) con las Etiquetas <p>
		TextoLeido = TextoLeido.replace(ExpReg1,'< ' + EtiquetasNoPerm[i].replace('<','') + '>');
	}
	// Devuelve el Texto leido correctamente tras reemplazar los saltos de línea
	return TextoLeido; // return TextoLeido.replace(/\n\n/g,'<br />');
}

// --------------------------
// 		Tomar AJAX
// --------------------------
// Toma el Controlador de AJAX
// - Entrada: ...
// -  Salida: El Controlador de AJAX
function TomarAJAX() {
	var xmlHttp=null;
	try {
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e) {
		// Internet Explorer
		try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) {
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}

// --------------------------
// 	       Ver Foto
// --------------------------
// Muestra la Foto sobre la página
// - Entrada: Foto Actual
// -  Salida: Muestra la Imagen
function VerFoto(FotoActual, Ancho){
	// Si hay un Vídeo Mostrándose
	if(document.getElementById('BloqueVideos'))
		document.getElementById('BloqueVideos').style.visibility = 'hidden';
	var allSpanTags = new Array();
	// Obtenemos todos los Tags HTML span (Para TODOS poner un "*")
	var allSpanTags = document.getElementsByTagName("span");
	// Recorremos los tags
	for (i=0; i<allSpanTags.length; i++) {
		// Si tiene la Class de Flash
		if (allSpanTags[i].className == "Flash") {
			allSpanTags[i].style.visibility = 'hidden';
		}
	}
		
	document.getElementById('Luz').style.display='block';
	document.getElementById('Fondo').style.display='block';
	document.getElementById('FotoActual').src = FotoActual; // Mostramos la Foto
	// Posición del Scroll
	var ScrollTop = document.body.scrollTop;
	if (ScrollTop == 0) {
		if (window.pageYOffset)
			ScrollTop = window.pageYOffset;
		else
			ScrollTop = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
	}
	document.getElementById('Fondo').style.marginTop = ScrollTop +'px';
	document.getElementById('Luz').style.marginTop = (ScrollTop+20) +'px';
	document.getElementById('Luz').style.maxWidth = Ancho +'px';
	// Lo centramos
	document.getElementById('Luz').style.marginLeft = (document.documentElement.clientWidth - (Ancho+(document.getElementById('Luz').style.padding*2)))/2+'px';
	// RECORDAR
	// (NECESARIO INCLUIR FUNCIÓN: window.scroll y DIVs en el fichero) y acciones en "body onresize"
}
function CerrarFoto() {
	document.getElementById('FotoActual').src = 'diseno/img/Cargando.gif';
	document.getElementById('Luz').style.display = 'none';
	document.getElementById('Fondo').style.display = 'none';
	if(document.getElementById('BloqueVideos')) // Si hay que mostrar de nuevo el Vídeo
		document.getElementById('BloqueVideos').style.visibility = 'visible';
	var allSpanTags = new Array();
	// Obtenemos todos los Tags HTML span (Para TODOS poner un "*")
	var allSpanTags = document.getElementsByTagName("span");
	// Recorremos los tags
	for (i=0; i<allSpanTags.length; i++) {
		// Si tiene la Class de Flash
		if (allSpanTags[i].className == "Flash") {
			allSpanTags[i].style.visibility = 'visible';
		}
	}
}

// --------------------------
// 	       Ver Vídeo
// --------------------------
// Muestra el Vídeo sobre la página
// - Entrada: Vídeo Actual
// -  Salida: Muestra la Imagen
function VerVideo(Codigo, Ancho){
	document.getElementById('Luz').style.display='block';
	document.getElementById('Fondo').style.display='block';
	document.getElementById('VideoActual').innerHTML = Codigo; // Mostramos la Foto
	// Posición del Scroll
	var ScrollTop = document.body.scrollTop;
	if (ScrollTop == 0) {
		if (window.pageYOffset)
			ScrollTop = window.pageYOffset;
		else
			ScrollTop = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
	}
	document.getElementById('Fondo').style.marginTop = ScrollTop +'px';
	document.getElementById('Luz').style.marginTop = (ScrollTop+20) +'px';
	// Lo centramos
	document.getElementById('Luz').style.marginLeft = (document.documentElement.clientWidth - (Ancho+(document.getElementById('Luz').style.padding*2)))/2+'px';
	// RECORDAR
	// (NECESARIO INCLUIR FUNCIÓN: window.scroll y DIVs en el fichero) y acciones en "body onresize"
}

// --------------------------
// 	  Selecciona una Option
// --------------------------
// Selecciona la Option de un Select que tenga el valor indicado
// - Entrada: Select y Valor
// -  Salida: Selecciona la Option correspondiente
function SelOption (Select, Valor) {
	for (i=0; i<Select.options.length; i++) {
		if (Select.options[i].value == Valor) // Si es la Elegida
			Select.selectedIndex = i;
	}
}

// --------------------------
// 	      Intersticial
// --------------------------
function MostrarWeb() {
	document.getElementById('Intersticial').style.display = 'none';
	document.getElementById('Web').style.display = 'block';
}
function Intersticial() {
	document.getElementById('Intersticial').style.display = 'block';
	document.getElementById('Web').style.display = 'none';
	var t = setTimeout("MostrarWeb();",7000);
}

// --------------------------
// 	      Favoritos
// --------------------------
function Favoritos() {
	url = "http://www.motor2000.net";
	var titulo = "Motor 2000"; 
	var ns = "Para poner la web de Motor 2000 en tus Marcadores,\nacepta esta ventana y luego pulsa: [ Ctrl + D ]"; 
	var op = "Para poner la web de Motor 2000 en tus Preferidos de Opera, acepta esta ventana y luego pulsa: [ Ctrl + D ]";
	if (navigator.userAgent.indexOf("Opera")!=-1)
		alert (op)
	else
	{
		if (navigator.appName == "Netscape")
			alert (ns)
		else
			window.external.AddFavorite(url, titulo);
	}
}

// --------------------------
// 	      ARREGLO PNG
// --------------------------
function PNGs(){
	var arVersion = navigator.appVersion.split("MSIE")
	var version = parseFloat(arVersion[1])
	
	if ((version < 7) && (version >= 5.5) && (document.body.filters)) 
	{
	   for(var i=0; i<document.images.length; i++)
	   {
		  var img = document.images[i]
		  var imgName = img.src.toUpperCase()
		  if (imgName.substring(imgName.length-3, imgName.length) == "PNG") // Si es PNG
		  {
			 var imgID = (img.id) ? "id='" + img.id + "' " : ""
			 var imgClass = (img.className) ? "class='" + img.className + "' " : ""
			 var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
			 var imgStyle = "display: inline-block;" + img.style.cssText
			 imgStyle = "vertical-align: middle;" + imgStyle
			 //if (img.align == "left") imgStyle = "float:left;" + imgStyle
			 //if (img.align == "right") imgStyle = "float:right;" + imgStyle
			 if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
			 var strNewHTML = "<span " + imgID + imgClass + imgTitle
			 + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
			 + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
			 + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
			 img.outerHTML = strNewHTML
			 i = i-1
		  }
	   }
	   if (document.getElementById('ContWeb')) // Si es con Contenido Web
	      document.getElementById('ContWeb').style.backgroundImage = "url(diseno/img/Fondo.jpg)";
	}
}
