
function ver(id){
	document.getElementById(id).style.left="-10px";
	document.getElementById(id).style.top="16px";	
}

function noVer(id){
	document.getElementById(id).style.left="-100000px";
}


/* Cambiar color del texto de colorido */
function cambiotextoColor(color){
borrarColores();
document.getElementById(color).className="activo";
}


/* Poner todos los botones de colorido a off */
function borrarColores(){
	for(i=0;i<document.getElementById("losColores").getElementsByTagName('a').length;i++) {
		if (document.getElementById("losColores").getElementsByTagName('a')[i].className.indexOf('activo') != -1)
			document.getElementById("losColores").getElementsByTagName('a')[i].className="textoColores";
	}
}


/* pasar el color seleccionado para luego trabajar con ellos */
function cambioColor(url){
setColor(url);
document.getElementById("imagenCoche").src="img/subnivel/coches/vista1"+url+".jpg";
colocarVistas();
document.getElementById("vista1").src="img/subnivel/vista1_off.jpg";
document.getElementById("tresPuertas").selected="selected";
carroceria("tresPuertas");
}

var color;
/* recoger color y asignarlo a una variable */
function setColor(elColor){
color=elColor;
}

/* retorno de la variable color */
function getColor(){
return color;
}

/* mostrar imagen correspondiente y poner los botones de vistas como corresponde */
function verVistas(vista){
var imagen= getColor();
	if(imagen){
		colocarVistas();
		document.getElementById(vista).src="img/subnivel/"+vista+"_off.jpg";
		document.getElementById("imagenCoche").src="img/subnivel/coches/"+vista+imagen+".jpg";
		}
}

/* Poner todos los botones de vistas a off */
function colocarVistas(){
for(i=1;i<document.getElementById("lavista1").getElementsByTagName('img').length;i++) {
/*		alert(document.getElementById("lavista1").getElementsByTagName('img')[i].id);*/
		document.getElementById("lavista1").getElementsByTagName('img')[i-1].src="img/subnivel/vista"+i+".jpg";
	}
		document.getElementById("lavista1").getElementsByTagName('img')[i-1].src="img/subnivel/vista"+i+".jpg";
for(i=1;i<document.getElementById("lavista2").getElementsByTagName('img').length;i++) {
/*		alert(document.getElementById("lavista2").getElementsByTagName('img')[i-1].id);*/
		document.getElementById("lavista2").getElementsByTagName('img')[i-1].src="img/subnivel/vista"+i+".jpg";
	}
	document.getElementById("lavista2").getElementsByTagName('img')[i-1].src="img/subnivel/vista"+i+".jpg";	

}

function carroceria(tipo){
	tioCarroceria();
	document.getElementById(tipo).className="si";
	var imagen= getColor();
	if(tipo=="tresPuertas")
	{
		document.getElementById("lavista1").style.display="block";
		document.getElementById("lavista2").style.display="none";
		if(imagen){
			document.getElementById("imagenCoche").src="img/subnivel/coches/vista1"+imagen+".jpg";	
			colocarVistas();		
			document.getElementById("vista1").src="img/subnivel/vista1_off.jpg";				
		}
	}else{
		document.getElementById("lavista2").style.display="block";
		document.getElementById("lavista1").style.display="none";
		if(imagen){
			document.getElementById("imagenCoche").src="img/subnivel/coches/vista4"+imagen+".jpg";		
			colocarVistas();
			for(i=0;i<document.getElementById("lavista2").getElementsByTagName('img').length;i++) {
				if(i==0){			
				numVista=document.getElementById("lavista2").getElementsByTagName('img')[0].id;
				document.getElementById(numVista).src="img/subnivel/"+numVista+"_off.jpg";
				}
			}
		}	
	}
}

function tioCarroceria(){
document.getElementById("tresPuertas").className="no";
document.getElementById("cincoPuertas").className="no";
}

function verSelect(disp){
//document.getElementById("eleccion").style.display=disp;					
for (i=0;i<document.getElementsByTagName("select").length;i++){
	document.getElementsByTagName("select")[i].style.visibility=disp;
	}
}

function contrasegnaOlvidada() {
	if (document.getElementById('contrasenyaOlvidada').style.visibility != 'visible')
		document.getElementById('contrasenyaOlvidada').style.visibility = 'visible';
	else {
		if (document.getElementById('email3').value == ''){
			alert('Debe rellenar el campo de Dirección e-mail para poder continuar');
		}else if(isEmail(document.getElementById('email3').value) == false){
			alert ('El e-mail que ha introducido no es correcto');
		}
		else
			document.getElementById('contrasenyaOlvidada').style.visibility = 'hidden';
	}
}

function contrasegnaOlvidada2(){
			document.getElementById('contrasenyaOlvidada').style.visibility = 'hidden';
}


function condicionesLegales() {
	if (document.getElementById('condiciones').style.visibility != 'visible') {
		if ((document.getElementById('email1').value == '') || (document.getElementById('contrasenya1').value == '') || (document.getElementById('confirmaContrasenya1').value == '')){
			alert('Debe rellenar todos los campos para poder continuar');
		}else if(isEmail(document.getElementById('email1').value) == false){
			alert ('El e-mail que ha introducido no es correcto');
		}	
		else
			document.getElementById('condiciones').style.visibility = 'visible';
	} else {
		document.getElementById('condiciones').style.visibility = 'hidden';
		document.getElementById('condicionesScroll').style.visibility = 'hidden';
	}
}

function aceptarCondicionesLegales(){
/*	if(document.getElement)*/
	var elegir=0
	for(i=0;i<document.getElementsByTagName('input').length;i++) {
		if (document.getElementsByTagName('input')[i].checked) {
			elegir=1;
		}
	}
	
	if (elegir!=0)
	condicionesLegales()
	else
	alert("Debe seleccionar una de las opciones")
	
}

function compruebaContrasenya() {
	if ((document.getElementById('email2').value == '') || (document.getElementById('contrasenya2').value == '')){
		alert('Debe rellenar todos los campos para poder continuar');
	}else if(isEmail(document.getElementById('email2').value) == false){
			alert ('El e-mail que ha introducido no es correcto');
		}	
		
}

function contactoFoto(elId){
	document.getElementById(elId).src="img/contacto/"+elId+"Bis.jpg";
}

function contactoSinFoto(elId){
	document.getElementById(elId).src="img/contacto/"+elId+".jpg";
}

function compruebaModificacion() {
	
	if (document.getElementById('email').value == '')	{
		alert('Debe rellenar el campo email');
		}else if(isEmail(document.getElementById('email').value) == false){
			alert ('El e-mail que ha introducido no es correcto');
		}	
}

function comparaVersiones() {
	var seleccionados = 0;
	for(i=0;i<document.getElementsByTagName('input').length;i++) {
		if ((document.getElementsByTagName('input')[i].type == "checkbox") && (document.getElementsByTagName('input')[i].checked)) {
			seleccionados++;
		}
	}
	if (seleccionados != 2)
		alert('Debe seleccionar dos versiones para poder ver la comparación');
	else
	window.open('ventanaComparativa.html','','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,screenX=1,screenY=1,top=400,left=200,width=705,height=142');	
}

function compruebaSolicitud() {
	
	var seleccionados = 0;
	for(i=0;i<document.getElementsByTagName('input').length;i++) {
		if ((document.getElementsByTagName('input')[i].type == "checkbox") && (document.getElementsByTagName('input')[i].checked)) {
			seleccionados++;
		}
	}
	if (seleccionados < 1)
		alert('Debe elegir un modelo para solicitar el catálogo');
	else {
		if ((document.getElementById('nombre').value == '') || (document.getElementById('apellidos').value == '') || (document.getElementById('direccion').value == '') 
		|| (document.getElementById('numero').value == '') || (document.getElementById('piso').value == '') || (document.getElementById('provincia').value == '')
		|| (document.getElementById('cp').value == '') || (document.getElementById('poblacion').value == '') || (document.getElementById('email').value == '')){
			alert('Debe rellenar todos los campos para poder continuar');
			}else if(isNaN(document.getElementById('numero').value)){
				alert ('El Nº que ha introducido no es correcto');
			}else if(isNaN(document.getElementById('cp').value)){
				alert ('El C.P. que ha introducido no es correcto');
			}else if(isEmail(document.getElementById('email').value) == false){
				alert ('El e-mail que ha introducido no es correcto');
			}
	}		
}

function rolloverGama(cual,porCual) {
	document.getElementById(cual).src = porCual;
}

function compruebaNewsletter() {
	if (document.getElementById('confirmacion').style.visibility != 'visible') {
		if ((document.getElementById('nombre').value == '')||(document.getElementById('apellidos').value == '')||(document.getElementById('email').value == ''))
		{
			alert('Debe rellenar todos los campos para poder continuar');
		}else if(isEmail(document.getElementById('email').value) == false){
			alert ('El e-mail que ha introducido no es correcto');
		}else{
			document.getElementById('confirmacion').style.visibility = 'visible'		
		}
	}else{
			document.getElementById('confirmacion').style.visibility = 'hidden'
	}
}

function isEmail(str) {
	var result = false
	var theStr = new String(str)
	var index = theStr.indexOf("@");
	if (index > 0) {
		var pindex = theStr.indexOf(".",index);
		if ((pindex > index+1) && (theStr.length > pindex+1))
			result = true;
	}
	return result;
}


function compruebalimpiar(){
for (i=0;i<document.getElementsByTagName("input").length;i++){
	document.getElementsByTagName("input")[i].value="";
	}
}

function compruebalimpiarAreas(){
for (i=0;i<document.getElementsByTagName("textarea").length;i++){
	document.getElementsByTagName("textarea")[i].value="";
	}
}


function compruebaPruebaCitroen() {
	
		if ((document.getElementById('nombre').value == '') || (document.getElementById('apellidos').value == '') || (document.getElementById('direccion').value == '') 
		|| (document.getElementById('numero').value == '') || (document.getElementById('piso').value == '') || (document.getElementById('provincia').value == '')|| (document.getElementById('poblacion').value == '')
		|| (document.getElementById('cp').value == '') || (document.getElementById('telefono').value == '')|| (document.getElementById('carnet').value == '')|| (document.getElementById('validez').value == '') || (document.getElementById('email').value == '')){
			alert('Debe rellenar todos los campos para poder continuar');
			}else if(isNaN(document.getElementById('numero').value)){
				alert ('El Nº que ha introducido no es correcto');
			}else if(isNaN(document.getElementById('cp').value)){
				alert ('El C.P. que ha introducido no es correcto');
			}else if((isNaN(document.getElementById('telefono').value))||(document.getElementById('telefono').value.length<9)){
				alert ('El telefono que ha introducido no es correcto');
			}else if(isEmail(document.getElementById('email').value) == false){
				alert ('El e-mail que ha introducido no es correcto');
			}else{
				location.href="elijeConcesioinario.html";
			}
}

function valorConcesionario(valor){
	if (valor!=0)
		document.getElementById("concesionarios").style.display="block";
	else
		document.getElementById("concesionarios").style.display="none";
}


function compruebaConcesionario(){
var eleccion=0;
for (i=0;i<document.getElementsByTagName("input").length;i++){
	if(document.getElementsByTagName("input")[i].type=="radio")
		if(document.getElementsByTagName("input")[i].checked)
			eleccion=1;	
	}
	
if(eleccion==0)
	alert("debes seleccionar un concesionario")
else	
	verAgradecimientoPruebaCitroen();	
}

function verAgradecimientoPruebaCitroen(){
	if(document.getElementById("data").style.visibility!="hidden"){
		document.getElementById("data").style.visibility="hidden";
		document.getElementById("agradecimiento").style.visibility="visible";	
	}else{
		document.getElementById("data").style.visibility="visible";
		document.getElementById("agradecimiento").style.visibility="hidden";
	}
}

function comprobarOpinion(){
	if(document.getElementById("agradecimientoOpinion").style.visibility!="visible"){
		if ((document.getElementById('nombre').value == '') || (document.getElementById('apellidos').value == '')|| (document.getElementById('email').value == '')){
				alert('Debe rellenar todos los campos para poder continuar');	
		}else if(isEmail(document.getElementById('email').value) == false){
				alert ('El e-mail que ha introducido no es correcto');
		}else
			document.getElementById("agradecimientoOpinion").style.visibility="visible";
		
	}else{
		document.getElementById("agradecimientoOpinion").style.visibility="visible";
	}
		
}

function verAgradecimientoOpinion(){
	if(document.getElementById("agradecimientoOpinion").style.visibility!="visible"){
		document.getElementById("agradecimientoOpinion").style.visibility="visible";	
	}else{
		document.getElementById("agradecimientoOpinion").style.visibility="hidden";
	}
}


function compruebaAtencionCliente() {
	if(document.getElementById("agradecimientoAtencionCliente").style.visibility!="visible"){
		if ((document.getElementById('nombre').value == '') || (document.getElementById('apellidos').value == '') || (document.getElementById('direccion').value == '') 
		|| (document.getElementById('numero').value == '') || (document.getElementById('piso').value == '') || (document.getElementById('provincia').value == '')|| (document.getElementById('poblacion').value == '')
		|| (document.getElementById('cp').value == '') || (document.getElementById('email').value == '')|| (document.getElementById('matricula').value == '')|| (document.getElementById('fecha').value == '') || (document.getElementById('chasis').value == '')|| (document.getElementById('concesionario').value == '')|| (document.getElementById('observaciones').value == '')){
			alert('Debe rellenar todos los campos para poder continuar');
   	}else if(isNaN(document.getElementById('numero').value)){
				alert ('El Nº que ha introducido no es correcto');
		}else if(isNaN(document.getElementById('cp').value)){
				alert ('El C.P. que ha introducido no es correcto');
		}else if(isEmail(document.getElementById('email').value) == false){
				alert ('El e-mail que ha introducido no es correcto');
		}else{
				document.getElementById("agradecimientoAtencionCliente").style.visibility="visible";
		}
	}else{
		document.getElementById("agradecimientoAtencionCliente").style.visibility="hidden"
	}		
}

/* Funciones Pop-up Precios y equipamientos */


function abreSerie(){
	window.open('ventanaSerie.html','','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,screenX=1,screenY=1,top=400,left=400,width=505,height=232');

}

function abreOpcional(){
	window.open('ventanaOpcional.html','','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,screenX=1,screenY=1,top=400,left=400,width=505,height=117');

}

function abreCaracteristicas(){
	window.open('ventanaCaracteristicas.html','','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,screenX=1,screenY=1,top=400,left=400,width=505,height=262');

}

function abreAyuda(){
	window.open('ventanaAyuda.html','','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,screenX=1,screenY=1,top=350,left=500,width=420,height=293');
}

function abreEnElMundo(){
	window.open('ventanaEnElMundo.html','','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,screenX=1,screenY=1,top=350,left=400,width=452,height=243');

}

function verPop(){
	if(document.getElementById("inicial").style.display!="none")
	{
		document.getElementById("verCaracteristicas").style.display="block";
		document.getElementById("inicial").style.display="none";
	}else{
		document.getElementById("verCaracteristicas").style.display="none";
		document.getElementById("inicial").style.display="block";
	}
}

function tomarDesplegable(desplegable){
	if(document.getElementById(desplegable).style.display!="block")
		document.getElementById(desplegable).style.display="block";
	else
		document.getElementById(desplegable).style.display="none";

}



function capaFT(name){
		document.getElementById(name).getElementsByTagName('ul')[0].className="seve";
		document.getElementById(name).getElementsByTagName('a')[0].className="activo"
}

function sinCapaFT(name){
			document.getElementById(name).getElementsByTagName('ul')[0].className="";
			document.getElementById(name).getElementsByTagName('a')[0].className=""
}

