var xhr;
var xhr2;
var xhr3;
var desplegado;
var busqGuardada;
var cargado = true;
var timerID = 0;
var idImpCoche;

function inicializarBusqueda(){
	// Funcion que cargara el buscador de inicio
	refrescarBuscador();
	comprobarBusquedaInicial();
}
function refrescarBuscador(){
	// En el caso de navegadores normales... Firefox, etc...
    if (window.XMLHttpRequest) {
        xhr = new XMLHttpRequest();
    }
    // Para el caso de MS Explorer
    else
        if (window.ActiveXObject) {
            xhr = new ActiveXObject("Microsoft.XMLHTTP");
        }
    // Direcciï¿½n donde se encuentra el servlet que valida el nombre de usuario
    var url = "getbuscador.php";
    // Se establece el callback, y se indica que la llamada es asï¿½ncrona
    xhr.onreadystatechange = listarBuscador;
    xhr.open("GET", url, true);
    xhr.send(null);
}
function listarBuscador(){
	if (xhr.readyState == 4 && xhr.status == 200) {
		// Se obtiene la representacion DOM de la lista de usuarios
		var dom = xhr.responseXML;
		// Se obtiene una lista con los nodos <usuario>
        //var coche = dom.getElementsByTagName("coche");
		//alert (coche.length);
		//alert (coche[0].childNodes.length);
		var marca = dom.getElementsByTagName("marca");
		var buscador = document.getElementById("buscador");
		buscador.innerHTML = "";
		var lista="";
		if (marca.length > 0) {
			lista="<select id=\"marca\" name=\"marca\"><option value=\"TODAS\">TODAS</option>";
			for (var i=0;i<marca.length;i++){
				lista+="<option value=\""+marca[i].firstChild.nodeValue+"\">"+marca[i].firstChild.nodeValue+"</option>";
			}
			lista+="</select>";
		}
		var texto1="";
		texto1 = "<form method=\"post\" name=\"formulario\"" +
                 "onsubmit=\"return comprobarBusqueda()\;\"><table border='0' width='100%'><tr><td>" +
			"Marca" +
			"</td><td>" +
			lista +
			"</td></tr><tr><td>" +
			"Precio entre" +
			"</td><td>" +
			"<input size=6 maxlength=6 type=\"text\" id=\"precio1\" name=\"precio1\"> Y <input size=6 maxlength=6 type=\"text\" id=\"precio2\" name=\"precio2\">" +
			//"</td></tr><tr><td>" +
			//"A&ntilde;o entre" +
			//"</td><td>" +
			//"<input size=6 maxlength=4 type=\"text\" id=\"ano1\" name=\"ano1\"> Y <input size=6 maxlength=4 type=\"text\" id=\"ano2\" name=\"ano2\">" +
			//"</td></tr><tr><td>" +
			//"Kil&oacute;metros entre" +
			//"</td><td>" +
			//"<input maxlength=6 size=6 type=\"text\" id=\"kms1\" name=\"kms1\"> Y <input maxlength=6 size=6 type=\"text\" id=\"kms2\" name=\"kms2\">" +
			//"</td></tr><tr><td>" +
			//"Color" +
			//"</td><td>" +
			//"<input type=\"text\" id=\"color\" name=\"color\">" +
			"</td></tr><tr><td>" +
			"</td><td>" +
			"<input type=\"submit\" name=\"Enviar\" value=\"Enviar\">" +
			"<input type=\"reset\" name=\"Limpiar\" value=\"Limpiar\">" +
			"</td></tr></table></form>";
			buscador.innerHTML += texto1 ;
	}
}

function comprobarBusquedaInicial(){
	var marca = "TODAS";
    var precio1 = "";
	var precio2 = "";
	var ano1 = "";
	var ano2 = "";
    var kms1 = "";
    var kms2 = "";
	var color = "";

    var params = "marca=" + escape(marca) + "&precio1=" + escape(precio1) +
                   "&precio2=" + escape(precio2) + "&ano1=" + escape(ano1) +
				   "&ano2=" + escape(ano2) + "&kms1=" + escape(kms1) +
				   "&kms2=" + escape(kms2) + "&color=" + escape(color) ;
    if (window.XMLHttpRequest) {
        xhr2 = new XMLHttpRequest();
    }
    // Para el caso de MS Explorer
    else
        if (window.ActiveXObject) {
            xhr2 = new ActiveXObject("Microsoft.XMLHTTP");
        }
				 	
	  url="busqueda.php"; 
    xhr2.onreadystatechange = resultadoBusqueda;
	
    xhr2.open("POST", url, true);
    xhr2.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xhr2.setRequestHeader("Content-length", params.length);
    xhr2.setRequestHeader("Connection", "close");
    xhr2.send(params);
	return false;
}

function comprobarBusqueda(){
	var marca = document.getElementById("marca").value;
    var precio1 = document.getElementById("precio1").value;
	var precio2 = document.getElementById("precio2").value;
	var ano1 = "";//document.getElementById("ano1").value;
	var ano2 = "";//document.getElementById("ano2").value;
    var kms1 = "";//document.getElementById("kms1").value;
    var kms2 = "";//document.getElementById("kms2").value;
	var color = "";//document.getElementById("color").value;

    var params = "marca=" + escape(marca) + "&precio1=" + escape(precio1) +
                   "&precio2=" + escape(precio2) + "&ano1=" + escape(ano1) +
				   "&ano2=" + escape(ano2) + "&kms1=" + escape(kms1) +
				   "&kms2=" + escape(kms2) + "&color=" + escape(color) ;
    if (window.XMLHttpRequest) {
        xhr2 = new XMLHttpRequest();
    }
    // Para el caso de MS Explorer
    else
        if (window.ActiveXObject) {
            xhr2 = new ActiveXObject("Microsoft.XMLHTTP");
        }
				 	
	  url="busqueda.php"; 
    xhr2.onreadystatechange = resultadoBusqueda;
	
    xhr2.open("POST", url, true);
    xhr2.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xhr2.setRequestHeader("Content-length", params.length);
    xhr2.setRequestHeader("Connection", "close");
    xhr2.send(params);
	return false;
}

// Función crearUsuario.
// Función de callback llamada en el caso de crear un usuario.
function resultadoBusqueda() {
    if (xhr2.readyState == 4 && xhr2.status == 200) {
		var dom = xhr2.responseXML;
		var coche = dom.getElementsByTagName("coche");
		if (coche.length>0){
			var tabla = document.getElementById("tabla");
			tabla.innerHTML="";
			var texto ="";
			texto="<table class=\"coches\" border=1 width=\"100%\">"+
			"<thead><th>Modelo</th><th>Marca</th><th>Precio</th><th>A&ntilde;o</th><th>Kms</th></thead>";
			
			for (var i=0;i<coche.length;i++){
				texto += "<tr>";
				if (coche[i].childNodes[0].hasChildNodes()){
					texto += "<td><a style=\"cursor:pointer\" onClick=\"nCoche('" + coche[i].getAttribute('id') + "');return false;\">" + coche[i].childNodes[0].firstChild.nodeValue + "</td>";
				}
				else {
					texto += "<td>&nbsp;</td>";
				}
				if (coche[i].childNodes[1].hasChildNodes()){
					texto += "<td>" + coche[i].childNodes[1].firstChild.nodeValue + "</td>";
				}
				else {
					texto += "<td>&nbsp;</td>";
				}
				if (coche[i].childNodes[2].hasChildNodes()){
					texto += "<td>" + coche[i].childNodes[2].firstChild.nodeValue + " &euro;</td>";
				}
				else {
					texto += "<td>&nbsp;</td>";
				}
				if (coche[i].childNodes[3].hasChildNodes()){
					texto += "<td>" + coche[i].childNodes[3].firstChild.nodeValue + "</td>";
				}
				else {
					texto += "<td>&nbsp;</td>";
				}
				if (coche[i].childNodes[4].hasChildNodes()){
					texto += "<td>" + coche[i].childNodes[4].firstChild.nodeValue + "</td>";
				}
				else {
					texto += "<td>&nbsp;</td>";
				}
				texto += "</tr>";
			}
			texto += "</table>";
			tabla.innerHTML = texto;
		}
    }
}

function recuperarBusqueda(){
	var tabla = document.getElementById("tabla");
	tabla.innerHTML="";
	tabla.innerHTML=busqGuardada;
}

function inicializar(){
    // Se cargan los datos existentes en la tabla*/
	
	refrescarMarcas();
	refrescarInicial();
	bubble('about',     170, 180, { delay:0.2, duration:1.1 });
	bubble('ref',       470,240, { delay:0.5, duration:1.1 });
	bubble('docs',      770,300, { delay:1.1, duration:1.1 });
	$('liuno').appear({delay:3,duration:2});
	$('lidos').appear({delay:4,duration:2});
	$('litres').appear({delay:5,duration:2});
	$('licuatro').appear({delay:6,duration:2});
	$('licinco').appear({delay:7,duration:2});
	$('liseis').appear({delay:8,duration:2});
	$('lisiete').appear({delay:9,duration:2});
	$('liocho').appear({delay:10,duration:2});
	//desaparecer('about', { delay:5, duration:3 });
		setTimeout("desaparecer('about');",2000);
		setTimeout("desaparecer('ref');",2500);
		setTimeout("desaparecer('docs');",3000);
}

// Funciï¿½n refrescar().
// Obtiene la lista XML con los datos de los usuarios a travï¿½s de una llamada AJAX.
// Una vez la recibe, llama a la funciï¿½n pintarTabla para repoblar la tabla.
function refrescarMarcas(){
	// En el caso de navegadores normales... Firefox, etc...
    if (window.XMLHttpRequest) {
        xhr = new XMLHttpRequest();
    }
    // Para el caso de MS Explorer
    else
        if (window.ActiveXObject) {
            xhr = new ActiveXObject("Microsoft.XMLHTTP");
        }
    // Direcciï¿½n donde se encuentra el servlet que valida el nombre de usuario
    var url = "getmarcas.php";
    // Se establece el callback, y se indica que la llamada es asï¿½ncrona
    xhr.onreadystatechange = listarMarcas;
    xhr.open("GET", url, true);
    xhr.send(null);
}

function refrescarInicial(){
	// En el caso de navegadores normales... Firefox, etc...
    if (window.XMLHttpRequest) {
        xhr2 = new XMLHttpRequest();
    }
    // Para el caso de MS Explorer
    else
        if (window.ActiveXObject) {
            xhr2 = new ActiveXObject("Microsoft.XMLHTTP");
        }
    // Direcciï¿½n donde se encuentra el servlet que valida el nombre de usuario
    var url = "getInicial.php";
    // Se establece el callback, y se indica que la llamada es asï¿½ncrona
    xhr2.onreadystatechange = listarInicial;
    xhr2.open("GET", url, true);
    xhr2.send(null);
}

function listarInicial(){
	if (xhr2.readyState == 4 && xhr2.status == 200) {
		// Se obtiene la representacion DOM de la lista de usuarios
		var dom = xhr2.responseXML;
		// Se obtiene una lista con los nodos <usuario>
        var coche = dom.getElementsByTagName("coche");
		//alert (coche.length);
		//alert (coche[0].childNodes.length);
		var tabla = document.getElementById("tabla");
		tabla.innerHTML = "";
		var texto1="";
		texto1 = "<table border='0' width='100%'><tr><td align='center'>" +
			"<a style=\"cursor:pointer\" onClick=\"nCoche('" + coche[0].childNodes[1].firstChild.nodeValue + "');return false;\"><img src='/imagenes/" + coche[0].childNodes[15].childNodes[0].firstChild.nodeValue + "' width='175'></a>" +
			"</td><td align='center'>" +
			"<a style=\"cursor:pointer\" onClick=\"nCoche('" + coche[1].childNodes[1].firstChild.nodeValue + "');return false;\"><img src='/imagenes/" + coche[1].childNodes[15].childNodes[0].firstChild.nodeValue + "' width='175'></a>" +
			"</td><td align='center'>" +
			"<a style=\"cursor:pointer\" onClick=\"nCoche('" + coche[2].childNodes[1].firstChild.nodeValue + "');return false;\"><img src='/imagenes/" + coche[2].childNodes[15].childNodes[0].firstChild.nodeValue + "' width='175'></a>" +
			"</td></tr>" +
			"<tr><td align='center'>" + 
			coche[0].childNodes[0].firstChild.nodeValue +
			"</td><td align='center'>" +
			coche[1].childNodes[0].firstChild.nodeValue +
			"</td><td align='center'>" +
			coche[2].childNodes[0].firstChild.nodeValue +
			"</td></tr>" +
			"<tr><td align='center'><b>" + 
			coche[0].childNodes[2].firstChild.nodeValue + "&euro;" +
			"</b></td><td align='center'><b>" +
			coche[1].childNodes[2].firstChild.nodeValue + "&euro;" +
			"</b></td><td align='center'><b>" +
			coche[2].childNodes[2].firstChild.nodeValue + "&euro;" +
			"</b></td></tr></table>";
			tabla.innerHTML += texto1 ;
	}
}

function listarInicial2(){
	if (xhr2.readyState == 4 && xhr2.status == 200) {
		// Se obtiene la representacion DOM de la lista de usuarios
		var dom = xhr2.responseXML;
		// Se obtiene una lista con los nodos <usuario>
        var coche = dom.getElementsByTagName("coche");
		//alert (coche.length);
		//alert (coche[0].childNodes.length);
		var tabla = document.getElementById("tabla");
		tabla.innerHTML = "";
		var texto1="";
		texto1="<h2 class='title'>" + coche[0].childNodes[0].firstChild.nodeValue + "</h2>";
		if (coche[0].childNodes[2].hasChildNodes()) {
			texto1 += "<p class='date'>" + coche[0].childNodes[2].firstChild.nodeValue + "</p>";
		}
		texto1 += "<table border='0' ><tr><td><table border='0'>";
		var texto2;
		texto2="";
		if (coche[0].childNodes[1].hasChildNodes()){				
			texto2 += "<tr>" + 
						"<td>Año</td>" +
						"<td>" + coche[0].childNodes[1].firstChild.nodeValue + "</td>" +
						"</tr>";
		}						
		if (coche[0].childNodes[2].hasChildNodes()){				
			texto2 += "<tr>" +
						"<td>Precio</td>" +
						"<td>" + coche[0].childNodes[2].firstChild.nodeValue + "</td>" +
						"</tr>";
		}
		if (coche[0].childNodes[3].hasChildNodes()){				
			texto2 += "<tr>" +
						"<td>Kms</td>" +
						"<td>" + coche[0].childNodes[3].firstChild.nodeValue + "</td>" +
						"</tr>";
		}
		if (coche[0].childNodes[4].hasChildNodes()){				
			texto2 += "<tr>" +
						"<td>Color</td>" +
						"<td>" + coche[0].childNodes[4].firstChild.nodeValue + "</td>" +
						"</tr>";
		}
		if (coche[0].childNodes[5].hasChildNodes()){				
			texto2 += "<tr>" +
						"<td>Aire</td>" +
						"<td>" + coche[0].childNodes[5].firstChild.nodeValue + "</td>" +
						"</tr>";
		}
		if (coche[0].childNodes[6].hasChildNodes()){				
			texto2 += "<tr>" +
						"<td>Climatizador</td>" +
						"<td>" + coche[0].childNodes[6].firstChild.nodeValue + "</td>" +
						"</tr>";
		}
		if (coche[0].childNodes[7].hasChildNodes()){				
			texto2 += "<tr>" +
						"<td>Direcci&oacute;n asistida</td>" +
						"<td>" + coche[0].childNodes[7].firstChild.nodeValue + "</td>" +
						"</tr>";
		}
		if (coche[0].childNodes[8].hasChildNodes()){				
			texto2 += "<tr>" +
						"<td>Airbag</td>" +
						"<td>" + coche[0].childNodes[8].firstChild.nodeValue + "</td>" +
						"</tr>";
		}
		if (coche[0].childNodes[9].hasChildNodes()){				
			texto2 += "<tr>" +
						"<td>ABS</td>" +
						"<td>" + coche[0].childNodes[9].firstChild.nodeValue + "</td>" +
						"</tr>";
		}
		if (coche[0].childNodes[10].hasChildNodes()){				
			texto2 += "<tr>" +
						"<td>Elevalunas el&eacute;ctrico</td>" +
						"<td>" + coche[0].childNodes[10].firstChild.nodeValue + "</td>" +
						"</tr>";
		}
		if (coche[0].childNodes[11].hasChildNodes()){				
			texto2 += "<tr>" +
						"<td>Equipo musical</td>" +
						"<td>" + coche[0].childNodes[11].firstChild.nodeValue + "</td>" +
						"</tr>";
		}
		if (coche[0].childNodes[12].hasChildNodes()){				
			texto2 += "<tr>" +
						"<td>Llantas</td>" +
						"<td>" + coche[0].childNodes[12].firstChild.nodeValue + "</td>" +
						"</tr>";
		}
		if (coche[0].childNodes[13].hasChildNodes()){				
			texto2 += "<tr>" +
						"<td>Alarma</td>" +
						"<td>" + coche[0].childNodes[13].firstChild.nodeValue + "</td>" +
						"</tr>";
		}
		if (coche[0].childNodes[14].hasChildNodes()){				
			texto2 += "<tr>" +
						"<td>Cierre centralizado</td>" +
						"<td>" + coche[0].childNodes[14].firstChild.nodeValue + "</td>" +
						"</tr>";
		}
					var texto="";
					var fotop="";
					if (coche[0].childNodes[15].hasChildNodes()) {
						for (var i = 0; i < coche[0].childNodes[15].childNodes.length; i++) {
							texto += "<td><img width='150' src='/imagenes/" + coche[0].childNodes[15].childNodes[i].firstChild.nodeValue + "' onClick='cambiarImg(\"" + coche[0].childNodes[15].childNodes[i].firstChild.nodeValue + "\");'></td>";
						}
						fotop="<img src='/imagenes/" + coche[0].childNodes[15].childNodes[0].firstChild.nodeValue + "' width='350'>";
					}
						tabla.innerHTML += texto1 + texto2 + "</table></td>" +
						"<td><div id=\"ImgP\">" + fotop + "</div></td>" +
						"</tr></table>" + "<table border='0'><tr>" + texto +
						"</tr></table>";
	}
}

function finCarga(){
	cargado=true;
	clearTimeout(timerID);
}
function cambiarImg(p){
	if (cargado == true) {
		var imgP = document.getElementById("ImgP");
		imgP.style.display = "none";
		imgP.innerHTML = "";
		imgP.innerHTML = "<img src='/imagenes/" + p + "' width='350'>";
		Effect.Grow('ImgP',{
		//Effect.SlideDown('ImgP', {
			duration: 1.5
		});
		cargado=false;
		timerID =  setTimeout("finCarga()",1500);
	}
}

function listarMarcas(){
	if (xhr.readyState == 4 && xhr.status == 200) {
		// Se obtiene la representacion DOM de la lista de usuarios
		var dom = xhr.responseXML;
		// Se obtiene una lista con los nodos <usuario>
		var marca = dom.getElementsByTagName("marca");
		// En el caso de tener usuarios...
		numMenus = marca.length;
		if (marca.length > 0) {
			// Se obtiene una referencia al tbody de la tabla
			var tabla = document.getElementById("menumarcas");

			// y lo primero que se hace es borrar los TR
			// existentes para no duplicarlos. Para ello
			// se indica que el codigo HTML contenido
			// entre las etiquetas de apertura y cierre
			// del tbody es nada (""), luego con eso se borran
			// los <tr> que existiesen.
			tabla.innerHTML = "";
			// Para cada usuario existente...
			for (var i = 0; i < marca.length; i++) {
					var u = marca[i];
					// Se crea el elemento TR de la tabla
					var newMarca = new Element("div");
					newMarca.id=u.firstChild.firstChild.nodeValue;
					newMarca.style.bgcolor="#ffffff"
					newMarca.innerHTML += "<span onClick='desplegar(\"" + newMarca.id + "\");return false;'><h2>" + u.firstChild.firstChild.nodeValue + "</h2></span>";
					var newDiv = new Element("div");
					newDiv.id = "lista" + newMarca.id;
					for (var j=1;j<marca[i].childNodes.length;j++){
						var coche =u.childNodes[j];
						//alert (coche.getAttribute('id'));
						newDiv.innerHTML += "<a style=\"cursor:pointer\" onClick=\"nCoche('" + coche.getAttribute('id') + "');return false;\">" + coche.firstChild.nodeValue + "</a><br/>";
					}
					newDiv.style.display="none";
					newMarca.appendChild(newDiv);
					tabla.appendChild(newMarca);
			}
		}
	}
}

function nCoche(p){
	// En el caso de navegadores normales... Firefox, etc...
	if (window.XMLHttpRequest) {
        xhr3 = new XMLHttpRequest();
    }
    // Para el caso de MS Explorer
    else
        if (window.ActiveXObject) {
            xhr3 = new ActiveXObject("Microsoft.XMLHTTP");
        }
    // Direcciï¿½n donde se encuentra el servlet que valida el nombre de usuario
	var url = "getCoche.php?id=" + p;
	idImpCoche=p;
    // Se establece el callback, y se indica que la llamada es asï¿½ncrona
    xhr3.onreadystatechange = listarCoche;
    xhr3.open("GET", url, true);
    xhr3.send(null);
}

function listarCoche(){
	if (xhr3.readyState == 4 && xhr3.status == 200) {
		// Se obtiene la representacion DOM de la lista de usuarios
		var dom = xhr3.responseXML;
		// Se obtiene una lista con los nodos <usuario>
        var coche = dom.getElementsByTagName("coche");
		//alert (coche.length);
		//alert (coche[0].childNodes.length);
		var marco = document.getElementById("marco1");
		//alert(marco.innerHTML);
		var tabla = document.getElementById("tabla");
		var texto1="";
		if (marco != null) {
			marco.height = 0;
			marco.innerHTML = "";
		}
		else {
			busqGuardada = tabla.innerHTML;
			texto1="<a style=\"cursor:pointer\" onClick=\"recuperarBusqueda()\">Volver a la busqueda anterior</a>";
		}
		tabla.innerHTML = "";
		
		texto1+="<h2 class='title'>" + coche[0].childNodes[0].firstChild.nodeValue + "</h2>";
		if (coche[0].childNodes[2].hasChildNodes()) {
			texto1 += "<p class='date'>" + coche[0].childNodes[2].firstChild.nodeValue + " &euro;</p>";
		}
		texto1 += "<table border='0' ><tr><td><table border='0'>";
		var texto2;
		texto2="";
		if (coche[0].childNodes[1].hasChildNodes()){				
			texto2 += "<tr>" + 
						"<td>A&ntilde;o</td>" +
						"<td>" + coche[0].childNodes[1].firstChild.nodeValue + "</td>" +
						"</tr>";
		}						
		/*if (coche[0].childNodes[2].hasChildNodes()){				
			texto2 += "<tr>" +
						"<td>Precio</td>" +
						"<td>" + coche[0].childNodes[2].firstChild.nodeValue + "</td>" +
						"</tr>";
		}*/
		if (coche[0].childNodes[3].hasChildNodes()){				
			texto2 += "<tr>" +
						"<td>Kms</td>" +
						"<td>" + coche[0].childNodes[3].firstChild.nodeValue + "</td>" +
						"</tr>";
		}
		if (coche[0].childNodes[4].hasChildNodes()){				
			texto2 += "<tr>" +
						"<td>Color</td>" +
						"<td>" + coche[0].childNodes[4].firstChild.nodeValue + "</td>" +
						"</tr>";
		}
		if (coche[0].childNodes[5].hasChildNodes()){
			if (coche[0].childNodes[5].firstChild.nodeValue != "No") {
				texto2 += "<tr>" +
				"<td>Aire</td>" +
				"<td>" +
				//coche[0].childNodes[5].firstChild.nodeValue +
				"</td>" +
				"</tr>";
			}
		}
		if (coche[0].childNodes[6].hasChildNodes()){
			if (coche[0].childNodes[6].firstChild.nodeValue != "No") {
				texto2 += "<tr>" +
				"<td>Climatizador</td>" +
				"<td>" +
				//coche[0].childNodes[6].firstChild.nodeValue +
				"</td>" +
				"</tr>";
			}
						
		}
		if (coche[0].childNodes[7].hasChildNodes()){
			if (coche[0].childNodes[7].firstChild.nodeValue != "No") {
				texto2 += "<tr>" +
				"<td>Direcci&oacute;n asistida</td>" +
				"<td>" +
				//coche[0].childNodes[7].firstChild.nodeValue +
				"</td>" +
				"</tr>";
			}
		}
		if (coche[0].childNodes[8].hasChildNodes()){
			if (coche[0].childNodes[8].firstChild.nodeValue != "No") {
				texto2 += "<tr>" +
				"<td>Airbag</td>" +
				"<td>" +
				//coche[0].childNodes[8].firstChild.nodeValue +
				"</td>" +
				"</tr>";
			}
		}
		if (coche[0].childNodes[9].hasChildNodes()){
			if (coche[0].childNodes[9].firstChild.nodeValue != "No") {
				texto2 += "<tr>" +
				"<td>ABS</td>" +
				"<td>" +
				//coche[0].childNodes[9].firstChild.nodeValue +
				"</td>" +
				"</tr>";
			}
		}
		if (coche[0].childNodes[10].hasChildNodes()){
			if (coche[0].childNodes[10].firstChild.nodeValue != "No") {
				texto2 += "<tr>" +
				"<td>Elevalunas el&eacute;ctrico</td>" +
				"<td>" +
				//coche[0].childNodes[10].firstChild.nodeValue +
				"</td>" +
				"</tr>";
			}
		}
		if (coche[0].childNodes[11].hasChildNodes()){
			if (coche[0].childNodes[11].firstChild.nodeValue != "No") {
				texto2 += "<tr>" +
				"<td>Equipo de m&uacute;sica</td>" +
				"<td>" +
				//coche[0].childNodes[11].firstChild.nodeValue +
				"</td>" +
				"</tr>";
			}
		}
		if (coche[0].childNodes[12].hasChildNodes()){
			if (coche[0].childNodes[12].firstChild.nodeValue != "No") {
				texto2 += "<tr>" +
				"<td>Llantas</td>" +
				"<td>" +
				//coche[0].childNodes[12].firstChild.nodeValue +
				"</td>" +
				"</tr>";
			}
		}
		if (coche[0].childNodes[13].hasChildNodes()){
			if (coche[0].childNodes[13].firstChild.nodeValue != "No") {
				texto2 += "<tr>" +
				"<td>Alarma</td>" +
				"<td>" +
				//coche[0].childNodes[13].firstChild.nodeValue +
				"</td>" +
				"</tr>";
			}
		}
		if (coche[0].childNodes[14].hasChildNodes()){
			if (coche[0].childNodes[14].firstChild.nodeValue != "No") {
				texto2 += "<tr>" +
				"<td>Cierre centralizado</td>" +
				"<td>" +
				//coche[0].childNodes[14].firstChild.nodeValue +
				"</td>" +
				"</tr>";
			}
		}
						var texto="";
						var fotop="";
					var textdiv="";
					var textdiv1="";
					var textdatos1="";
					var textdatos2="";
					if (coche[0].childNodes[16].hasChildNodes()) {
						textdatos1="<tr><td colspan=\"2\">" + coche[0].childNodes[16].firstChild.nodeValue + "</td></tr>";
					}
					if (coche[0].childNodes[17].hasChildNodes()) {
						textdatos2="<tr><td colspan=\"2\">" + coche[0].childNodes[17].firstChild.nodeValue + "</td></tr>";
					}
					if (coche[0].childNodes[15].hasChildNodes()) {
						textdiv="<div id=\"galleryContainer\"> " +
						"<div id=\"arrow_left\"><img src=\"images/arrow_left.gif\"></div>" +
						"<div id=\"arrow_right\"><img src=\"images/arrow_right.gif\"></div>" +
						"<div id=\"theImages\">";
						for (var i = 0; i < coche[0].childNodes[15].childNodes.length; i++) {
							//texto += "<img style=\"cursor:pointer\" width='175' src='/imagenes/" + coche[0].childNodes[15].childNodes[i].firstChild.nodeValue + "' onClick='cambiarImg(\"" + coche[0].childNodes[15].childNodes[i].firstChild.nodeValue + "\");'></td>";
							texto += "<img style=\"cursor:pointer\" width='175' src='/imagenes/" + coche[0].childNodes[15].childNodes[i].firstChild.nodeValue + "' onClick='cambiarImg(\"" + coche[0].childNodes[15].childNodes[i].firstChild.nodeValue + "\");'>";
						}
						textdiv1="<div id=\"slideEnd\"></div>" +
							"</div>" +
							"</div>";
						fotop="<img src='/imagenes/" + coche[0].childNodes[15].childNodes[0].firstChild.nodeValue + "' width='350'>";
					}
						tabla.innerHTML += texto1 + texto2 + "</table></td>" +
						"<td><div id=\"ImgP\">" + fotop + "</div></td>" +
						"</tr>" + textdatos1 + textdatos2 + " </table>" + "<table width='100%' border='0'><tr><td>" + textdiv + texto + textdiv1 +
						"</tr><tr><td><a href=\"mostrarCoche.php?id=" + idImpCoche + "\" target=\"_blank\"><img src=\"/images/imprimir.jpg\" width=\"50\"/></a><br><!--<a href=\"mostrarCoche.php?id=" + idImpCoche + "\" target=\"_blank\">Ficha</a>--></td></tr></table></td>";
	}
	initSlideShow();
}

function desplegar(ident){
	if (desplegado!=null){
		Effect.SlideUp(desplegado);
	}
	if (desplegado != "lista" + ident) {
		desplegado = "lista" + ident;
		Effect.SlideDown("lista" + ident);
	}
	else {
		desplegado=null;
	}
}

function bubble(id,x,y){
        $(id+'-bubble').setStyle({left:x+'px',top:y+'px'});
        new Effect.Scale(id+'-bubble',100, Object.extend({
          beforeStart:function(effect){
            $(effect.element).style.display = 'block';
            $(effect.element).setOpacity(0);
            $$('#'+id+'-bubble p').each(function(p){p.hide()});
          },
          afterUpdate:function(effect){
            $(effect.element).setOpacity(effect.position);
          },
          scaleFrom:0,
          scaleFromCenter:true,
          afterFinish:function(effect){
            $$('#'+id+'-bubble p').each(function(p){
              new Effect.Appear(p,{duration:0.4});
            });
          }
        }, arguments[3] || {}));        
      }

function desaparecer(ident){
	Effect.Fade(ident+'-bubble', { duration: 3.0 });
}
function anadir(p,uni){
    // En el caso de navegadores normales... Firefox, etc...
    if (window.XMLHttpRequest) {
        xhr3 = new XMLHttpRequest();
    }
    // Para el caso de MS Explorer
    else
        if (window.ActiveXObject) {
            xhr3 = new ActiveXObject("Microsoft.XMLHTTP");
        }
    // Direcciï¿½n donde se encuentra el servlet que valida el nombre de usuario
    var url = "comprar";

    // Parï¿½metros a pasar...
    var params = "idProducto=" + escape(p) + "&uniProducto=" + escape(uni);

    // Se establece el callback, y se indica que la llamada es asï¿½ncrona
    xhr3.onreadystatechange = comprar;
    xhr3.open("POST", url, true);
    xhr3.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xhr3.setRequestHeader("Content-length", params.length);
    xhr3.setRequestHeader("Connection", "close");
    xhr3.send(params);

    // Se devuelve un falso para no enviar los datos del formulario
    // como un formulario normal. Ya los hemos enviado mediante AJAX.
}

// Funciï¿½n crearUsuario.
// Funciï¿½n de callback llamada en el caso de crear un usuario.
function comprar() {
    if (xhr3.readyState == 4 && xhr3.status == 200) {
        var resp = xhr3.responseText;
        // Si el usuario se ha creado correctamente,
        // se indica en el DIV creado para tal efecto.
        if(resp=="true")
        {
             // Se refresca la tabla.
            refrescarCarrito();
        }
        else
        {
            alert("No se ha podido a&nacute;adir ese producto");
        }
    }
}

function ver(p){
	// En el caso de navegadores normales... Firefox, etc...
    if (window.XMLHttpRequest) {
        xhr3 = new XMLHttpRequest();
    }
    // Para el caso de MS Explorer
    else
        if (window.ActiveXObject) {
            xhr3 = new ActiveXObject("Microsoft.XMLHTTP");
        }
    // Direcciï¿½n donde se encuentra el servlet que valida el nombre de usuario
    var url = "ver";

    // Parï¿½metros a pasar...
    var params = "idProducto=" + escape(p);

    // Se establece el callback, y se indica que la llamada es asï¿½ncrona
    xhr3.onreadystatechange = verDetalle;
    xhr3.open("POST", url, true);
    xhr3.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xhr3.setRequestHeader("Content-length", params.length);
    xhr3.setRequestHeader("Connection", "close");
    xhr3.send(params);

    // Se devuelve un falso para no enviar los datos del formulario
    // como un formulario normal. Ya los hemos enviado mediante AJAX.
}

// Funciï¿½n crearUsuario.
// Funciï¿½n de callback llamada en el caso de crear un usuario.
function verDetalle() {
    if (xhr3.readyState == 4 && xhr3.status == 200) {
        var dom = xhr3.responseXML;
        // Si el usuario se ha creado correctamente,
        // se indica en el DIV creado para tal efecto.
        var titulo = dom.getElementsByTagName("titulo");
		var tabla = document.getElementById("pdetalle");
		tabla.innerHTML="";
		var descripcion = dom.getElementsByTagName("descripcion");
		if (titulo!=null){
			var pTitulo = document.createElement("h3");
			var pAtributo = document.createAttribute("class");
			pAtributo.value="descripcion";
			pTitulo.setAttributeNode(pAtributo);
			pTitulo.innerHTML = titulo[0].firstChild.nodeValue
			var pDescripcion = document.createElement("p");
			pDescripcion.innerHTML = descripcion[0].firstChild.nodeValue
			tabla.appendChild(pTitulo);
			tabla.appendChild(pDescripcion);
		}

    }
}

function hacerFactura(){
	// En el caso de navegadores normales... Firefox, etc...
    if (window.XMLHttpRequest) {
        xhr = new XMLHttpRequest();
    }
    // Para el caso de MS Explorer
    else
        if (window.ActiveXObject) {
            xhr = new ActiveXObject("Microsoft.XMLHTTP");
        }
    // Direcciï¿½n donde se encuentra el servlet que valida el nombre de usuario
    var url = "crearfactura";

    // Se establece el callback, y se indica que la llamada es asï¿½ncrona
    xhr.onreadystatechange = dibujarFactura;
    xhr.open("GET", url, true);
    xhr.send(null);
}

function dibujarFactura(){
	if (xhr.readyState == 4 && xhr.status == 200) {
	    var dom = xhr.responseXML;
		var contenido = document.getElementById("page-bgcontent");
		contenido.innerHTML="";
		contenido.innerHTML="<h2>Factura</h2>";
		var lineas = dom.getElementsByTagName("linea");
        var tot = dom.getElementsByTagName("total");
        // En el caso de tener usuarios...
        if (lineas.length > 0) {
			var tabla = document.createElement("table");
			//tabla.border="1";
			var thead = document.createElement("thead");
			var thUnidades = document.createElement("th");
			var thProducto = document.createElement("th");
			var thPrecio   = document.createElement("th");
			var thTotal    = document.createElement("th");
			thUnidades.innerHTML = "Unidades";
			thProducto.innerHTML = "Producto";
			thPrecio.innerHTML = "Precio Unitario";
			thTotal.innerHTML = "Precio Total";
			thead.appendChild(thUnidades);
			thead.appendChild(thProducto);
			thead.appendChild(thPrecio);
			thead.appendChild(thTotal);
			tabla.appendChild(thead);
			var tbody = document.createElement("tbody");
			for (var i=0; i<lineas.length;i++) {
                // i es el ï¿½ndice, luego hay que acceder
                // al elemento concreto.
                var u = lineas[i];

                // Se crea el elemento TR de la tabla
                var tr = document.createElement("tr");
                // Se le asigna un identificador al <tr>
                tr.id = "linea"+i;
                // Se crea el TD para el identificador del usuario
                var tdIdentificador = document.createElement("td");
                tdIdentificador.innerHTML =
                           	u.getElementsByTagName("unidades")[0].firstChild.nodeValue;
                var tdProducto = document.createElement("td");
				tdProducto.innerHTML =
							u.getElementsByTagName("producto")[0].firstChild.nodeValue;
                // Se crea el TD para el nombre de usuario
                var tdPrecio = document.createElement("td");
                tdPrecio.innerHTML =
                     u.getElementsByTagName("precio")[0].firstChild.nodeValue;
                var tdTotalU = document.createElement("td");
				tdTotalU.innerHTML =
				     u.getElementsByTagName("preciou")[0].firstChild.nodeValue;
                // Se insertan los TDs en el TR
                tr.appendChild(tdIdentificador);
				tr.appendChild(tdProducto);
                tr.appendChild(tdPrecio);
				tr.appendChild(tdTotalU);

                // Se inserta el TR en la tabla.
                tbody.appendChild(tr);
            }
			var trTotal = document.createElement("tr");
			var atColspan = document.createAttribute("colspan");
			atColspan.value="3";
			var alineamiento = document.createAttribute("align");
			alineamiento.value = "right"
			var tdTotalLabel = document.createElement("td");
			tdTotalLabel.innerHTML="<strong>Total</strong>";
			tdTotalLabel.setAttributeNode(atColspan);
			tdTotalLabel.setAttributeNode(alineamiento);
			var tdTotal = document.createElement("td");
			tdTotal.innerHTML=tot[0].firstChild.nodeValue;
			trTotal.appendChild(tdTotalLabel);
			trTotal.appendChild(tdTotal);
			tbody.appendChild(trTotal);
			tabla.appendChild(tbody);
		}
		contenido.appendChild(tabla);
		contenido.innerHTML += "<a href='index.html'>Volver atras</a>"
	}
}

   	/***********************************************************************************************
	
	Copyright (c) 2005 - Alf Magne Kalleland post@dhtmlgoodies.com
	
	UPDATE LOG:
	
	March, 10th, 2006 : Added support for a message while large image is loading
	
	Get this and other scripts at www.dhtmlgoodies.com
	
	You can use this script freely as long as this copyright message is kept intact.
	
	***********************************************************************************************/ 
   	
	var displayWaitMessage=true;	// Display a please wait message while images are loading?
  	
   		
	var activeImage = false;
	var imageGalleryLeftPos = false;
	var imageGalleryWidth = false;
	var imageGalleryObj = false;
	var maxGalleryXPos = false;
	var slideSpeed = 0;
	var imageGalleryCaptions = new Array();
	function startSlide(e)
	{
		if(document.all)e = event;
		var id = this.id;
		this.getElementsByTagName('IMG')[0].src = 'images/' + this.id + '_over.gif';	
		if(this.id=='arrow_right'){
			slideSpeedMultiply = Math.floor((e.clientX - this.offsetLeft) / 15);
			slideSpeed = -1*slideSpeedMultiply;
			slideSpeed = Math.max(-5,slideSpeed);
		}else{			
			slideSpeedMultiply = 10 - Math.floor((e.clientX - this.offsetLeft) / 15);
			slideSpeed = 1*slideSpeedMultiply;
			slideSpeed = Math.min(10,slideSpeed);
			if(slideSpeed<0)slideSpeed=5;
		}
	}
	
	function releaseSlide()
	{
		var id = this.id;
		this.getElementsByTagName('IMG')[0].src = 'images/' + this.id + '.gif';
		slideSpeed=0;
	}
		
	function gallerySlide()
	{
		if(slideSpeed!=0){
			var leftPos = imageGalleryObj.offsetLeft;
			leftPos = leftPos/1 + slideSpeed;
			if(leftPos>maxGalleryXPos){
				leftPos = maxGalleryXPos;
				slideSpeed = 0;
				
			}
			if(leftPos<minGalleryXPos){
				leftPos = minGalleryXPos;
				slideSpeed=0;
			}
			
			imageGalleryObj.style.left = leftPos + 'px';
		}
		setTimeout('gallerySlide()',20);
		
	}
	
	function showImage()
	{
		if(activeImage){
			activeImage.style.filter = 'alpha(opacity=50)';	
			activeImage.style.opacity = 0.5;
		}	
		this.style.filter = 'alpha(opacity=100)';
		this.style.opacity = 1;	
		activeImage = this;	
	}
	
	function initSlideShow()
	{
		document.getElementById('arrow_left').onmousemove = startSlide;
		document.getElementById('arrow_left').onmouseout = releaseSlide;
		document.getElementById('arrow_right').onmousemove = startSlide;
		document.getElementById('arrow_right').onmouseout = releaseSlide;
		
		imageGalleryObj = document.getElementById('theImages');
		imageGalleryLeftPos = imageGalleryObj.offsetLeft;
		imageGalleryWidth = document.getElementById('galleryContainer').offsetWidth - 80;
		maxGalleryXPos = imageGalleryObj.offsetLeft; 
		minGalleryXPos = imageGalleryWidth - document.getElementById('slideEnd').offsetLeft;
		var slideshowImages = imageGalleryObj.getElementsByTagName('IMG');
		for(var no=0;no<slideshowImages.length;no++){
			slideshowImages[no].onmouseover = showImage;
		}
		
		var divs = imageGalleryObj.getElementsByTagName('DIV');
		for(var no=0;no<divs.length;no++){
			if(divs[no].className=='imageCaption')imageGalleryCaptions[imageGalleryCaptions.length] = divs[no].innerHTML;
		}
		gallerySlide();
	}
	
	function showPreview(imagePath,imageIndex){
		var subImages = document.getElementById('previewPane').getElementsByTagName('IMG');
		if(subImages.length==0){
			var img = document.createElement('IMG');
			document.getElementById('previewPane').appendChild(img);
		}else img = subImages[0];
		
		if(displayWaitMessage){
			document.getElementById('waitMessage').style.display='inline';
		}
		document.getElementById('largeImageCaption').style.display='none';
		img.onload = function() { hideWaitMessageAndShowCaption(imageIndex-1); };
		img.src = imagePath;
		
	}
	function hideWaitMessageAndShowCaption(imageIndex)
	{
		document.getElementById('waitMessage').style.display='none';	
		document.getElementById('largeImageCaption').innerHTML = imageGalleryCaptions[imageIndex];
		document.getElementById('largeImageCaption').style.display='block';
		
	}
	
	function mostrarMapa(mapa){
		if (mapa==1){
			divMap1 = document.getElementById('map1');
			divMap1.innerHTML="";
			//divMap1.innerHTML="<iframe width=\"425\" height=\"350\" frameborder=\"0\" scrolling=\"no\" marginheight=\"0\" marginwidth=\"0\" src=\"http://maps.google.es/maps?f=q&amp;source=s_q&amp;hl=es&amp;geocode=&amp;q=libertad+61+alcobendas&amp;sll=40.396764,-3.713379&amp;sspn=12.22441,18.215332&amp;ie=UTF8&amp;hq=&amp;hnear=Calle+de+la+Libertad,+61,+28100+Alcobendas,+Madrid,+Comunidad+de+Madrid&amp;t=h&amp;z=16&amp;ll=40.538202,-3.636298&amp;output=embed\"></iframe><br /><small><a target=\"otra\" href=\"http://maps.google.es/maps?f=q&amp;source=embed&amp;hl=es&amp;geocode=&amp;q=libertad+61+alcobendas&amp;sll=40.396764,-3.713379&amp;sspn=12.22441,18.215332&amp;ie=UTF8&amp;hq=&amp;hnear=Calle+de+la+Libertad,+61,+28100+Alcobendas,+Madrid,+Comunidad+de+Madrid&amp;t=h&amp;z=16&amp;ll=40.538202,-3.636298\" style=\"color:#0000FF;text-align:left\">Ver mapa m&aacute;s grande</a></small>";
			divMap1.innerHTML="<a onClick=\"ocultarMapa(1)\" style=\"cursor:pointer\" >Cerrar Mapa</a><br /><iframe width=\"425\" height=\"350\" frameborder=\"0\" scrolling=\"no\" marginheight=\"0\" marginwidth=\"0\" src=\"http://maps.google.es/maps?f=q&amp;source=s_q&amp;hl=es&amp;geocode=&amp;q=libertad+61+alcobendas&amp;sll=40.396764,-3.713379&amp;sspn=12.25782,19.555664&amp;ie=UTF8&amp;hq=&amp;hnear=Calle+de+la+Libertad,+61,+28100+Alcobendas,+Madrid,+Comunidad+de+Madrid&amp;z=16&amp;ll=40.53819,-3.636309&amp;output=embed\"></iframe><br /><small><a href=\"http://maps.google.es/maps?f=q&amp;source=embed&amp;hl=es&amp;geocode=&amp;q=libertad+61+alcobendas&amp;sll=40.396764,-3.713379&amp;sspn=12.25782,19.555664&amp;ie=UTF8&amp;hq=&amp;hnear=Calle+de+la+Libertad,+61,+28100+Alcobendas,+Madrid,+Comunidad+de+Madrid&amp;z=16&amp;ll=40.53819,-3.636309\" style=\"color:#0000FF;text-align:left\">Ver mapa m&acute;s grande</a></small>";
		}
		if (mapa==2){
			divMap1 = document.getElementById('map2');
			divMap1.innerHTML="";
			//divMap1.innerHTML="<iframe width=\"425\" height=\"350\" frameborder=\"0\" scrolling=\"no\" marginheight=\"0\" marginwidth=\"0\" src=\"http://maps.google.es/maps?f=q&amp;source=s_q&amp;hl=es&amp;geocode=&amp;q=libertad+61+alcobendas&amp;sll=40.396764,-3.713379&amp;sspn=12.22441,18.215332&amp;ie=UTF8&amp;hq=&amp;hnear=Calle+de+la+Libertad,+61,+28100+Alcobendas,+Madrid,+Comunidad+de+Madrid&amp;t=h&amp;z=16&amp;ll=40.538202,-3.636298&amp;output=embed\"></iframe><br /><small><a target=\"otra\" href=\"http://maps.google.es/maps?f=q&amp;source=embed&amp;hl=es&amp;geocode=&amp;q=libertad+61+alcobendas&amp;sll=40.396764,-3.713379&amp;sspn=12.22441,18.215332&amp;ie=UTF8&amp;hq=&amp;hnear=Calle+de+la+Libertad,+61,+28100+Alcobendas,+Madrid,+Comunidad+de+Madrid&amp;t=h&amp;z=16&amp;ll=40.538202,-3.636298\" style=\"color:#0000FF;text-align:left\">Ver mapa m&aacute;s grande</a></small>";
			divMap1.innerHTML="<a onClick=\"ocultarMapa(2)\" style=\"cursor:pointer\" >Cerrar Mapa</a><br /><iframe width=\"425\" height=\"350\" frameborder=\"0\" scrolling=\"no\" marginheight=\"0\" marginwidth=\"0\" src=\"http://maps.google.es/maps?f=q&amp;source=s_q&amp;hl=es&amp;geocode=&amp;q=san+onofre+19+san+sebastian+de+los+reyes&amp;sll=40.53819,-3.636309&amp;sspn=0.011953,0.019097&amp;ie=UTF8&amp;hq=&amp;hnear=Calle+de+San+Onofre,+19,+28701+San+Sebasti%C3%A1n+de+los+Reyes,+Madrid,+Comunidad+de+Madrid&amp;z=16&amp;ll=40.550452,-3.628514&amp;output=embed\"></iframe><br /><small><a href=\"http://maps.google.es/maps?f=q&amp;source=embed&amp;hl=es&amp;geocode=&amp;q=san+onofre+19+san+sebastian+de+los+reyes&amp;sll=40.53819,-3.636309&amp;sspn=0.011953,0.019097&amp;ie=UTF8&amp;hq=&amp;hnear=Calle+de+San+Onofre,+19,+28701+San+Sebasti%C3%A1n+de+los+Reyes,+Madrid,+Comunidad+de+Madrid&amp;z=16&amp;ll=40.550452,-3.628514\" style=\"color:#0000FF;text-align:left\">Ver mapa m&acute;s grande</a></small>";
		}
	//<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.es/maps?f=q&amp;source=s_q&amp;hl=es&amp;geocode=&amp;q=san+onofre+19+san+sebastian+de+los+reyes&amp;sll=40.396764,-3.713379&amp;sspn=12.342864,19.577637&amp;ie=UTF8&amp;hq=&amp;hnear=Calle+de+San+Onofre,+19,+28701+San+Sebasti%C3%A1n+de+los+Reyes,+Madrid,+Comunidad+de+Madrid&amp;ll=40.550452,-3.628514&amp;spn=0.006016,0.009559&amp;t=h&amp;z=17&amp;output=embed"></iframe><br /><small><a href="http://maps.google.es/maps?f=q&amp;source=embed&amp;hl=es&amp;geocode=&amp;q=san+onofre+19+san+sebastian+de+los+reyes&amp;sll=40.396764,-3.713379&amp;sspn=12.342864,19.577637&amp;ie=UTF8&amp;hq=&amp;hnear=Calle+de+San+Onofre,+19,+28701+San+Sebasti%C3%A1n+de+los+Reyes,+Madrid,+Comunidad+de+Madrid&amp;ll=40.550452,-3.628514&amp;spn=0.006016,0.009559&amp;t=h&amp;z=17" style="color:#0000FF;text-align:left">Ver mapa m&aacute;s grande</a></small>
	}
	
	function ocultarMapa(mapa){
		if (mapa==1){
			divMap1 = document.getElementById('map1');
			divMap1.innerHTML="";
			//divMap1.innerHTML="<iframe width=\"425\" height=\"350\" frameborder=\"0\" scrolling=\"no\" marginheight=\"0\" marginwidth=\"0\" src=\"http://maps.google.es/maps?f=q&amp;source=s_q&amp;hl=es&amp;geocode=&amp;q=libertad+61+alcobendas&amp;sll=40.396764,-3.713379&amp;sspn=12.22441,18.215332&amp;ie=UTF8&amp;hq=&amp;hnear=Calle+de+la+Libertad,+61,+28100+Alcobendas,+Madrid,+Comunidad+de+Madrid&amp;t=h&amp;z=16&amp;ll=40.538202,-3.636298&amp;output=embed\"></iframe><br /><small><a target=\"otra\" href=\"http://maps.google.es/maps?f=q&amp;source=embed&amp;hl=es&amp;geocode=&amp;q=libertad+61+alcobendas&amp;sll=40.396764,-3.713379&amp;sspn=12.22441,18.215332&amp;ie=UTF8&amp;hq=&amp;hnear=Calle+de+la+Libertad,+61,+28100+Alcobendas,+Madrid,+Comunidad+de+Madrid&amp;t=h&amp;z=16&amp;ll=40.538202,-3.636298\" style=\"color:#0000FF;text-align:left\">Ver mapa m&aacute;s grande</a></small>";
			divMap1.innerHTML="<a onClick=\"mostrarMapa(1)\" style=\"cursor:pointer\"><img src=\"images/senal.png\"  width=\"100\"/> <br />Ver mapa</a>";
		}
		if (mapa==2){
			divMap1 = document.getElementById('map2');
			divMap1.innerHTML="";
			//divMap1.innerHTML="<iframe width=\"425\" height=\"350\" frameborder=\"0\" scrolling=\"no\" marginheight=\"0\" marginwidth=\"0\" src=\"http://maps.google.es/maps?f=q&amp;source=s_q&amp;hl=es&amp;geocode=&amp;q=libertad+61+alcobendas&amp;sll=40.396764,-3.713379&amp;sspn=12.22441,18.215332&amp;ie=UTF8&amp;hq=&amp;hnear=Calle+de+la+Libertad,+61,+28100+Alcobendas,+Madrid,+Comunidad+de+Madrid&amp;t=h&amp;z=16&amp;ll=40.538202,-3.636298&amp;output=embed\"></iframe><br /><small><a target=\"otra\" href=\"http://maps.google.es/maps?f=q&amp;source=embed&amp;hl=es&amp;geocode=&amp;q=libertad+61+alcobendas&amp;sll=40.396764,-3.713379&amp;sspn=12.22441,18.215332&amp;ie=UTF8&amp;hq=&amp;hnear=Calle+de+la+Libertad,+61,+28100+Alcobendas,+Madrid,+Comunidad+de+Madrid&amp;t=h&amp;z=16&amp;ll=40.538202,-3.636298\" style=\"color:#0000FF;text-align:left\">Ver mapa m&aacute;s grande</a></small>";
			divMap1.innerHTML="<a onClick=\"mostrarMapa(2)\" style=\"cursor:pointer\"><img src=\"images/senal.png\"   width=\"100\" /> <br />Ver mapa</a>";
		}
	//<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.es/maps?f=q&amp;source=s_q&amp;hl=es&amp;geocode=&amp;q=san+onofre+19+san+sebastian+de+los+reyes&amp;sll=40.396764,-3.713379&amp;sspn=12.342864,19.577637&amp;ie=UTF8&amp;hq=&amp;hnear=Calle+de+San+Onofre,+19,+28701+San+Sebasti%C3%A1n+de+los+Reyes,+Madrid,+Comunidad+de+Madrid&amp;ll=40.550452,-3.628514&amp;spn=0.006016,0.009559&amp;t=h&amp;z=17&amp;output=embed"></iframe><br /><small><a href="http://maps.google.es/maps?f=q&amp;source=embed&amp;hl=es&amp;geocode=&amp;q=san+onofre+19+san+sebastian+de+los+reyes&amp;sll=40.396764,-3.713379&amp;sspn=12.342864,19.577637&amp;ie=UTF8&amp;hq=&amp;hnear=Calle+de+San+Onofre,+19,+28701+San+Sebasti%C3%A1n+de+los+Reyes,+Madrid,+Comunidad+de+Madrid&amp;ll=40.550452,-3.628514&amp;spn=0.006016,0.009559&amp;t=h&amp;z=17" style="color:#0000FF;text-align:left">Ver mapa m&aacute;s grande</a></small>
	}
	
	function enviarEmail(){
		alert("hola");

		return true;
	}

