// JavaScript Document

function enviar_over(elemento)
{	elemento.style.backgroundImage='url(img/yellow_mail_send.png)';
	elemento.style.backgroundRepeat='no-repeat';
	elemento.style.backgroundPosition='top';
}

function enviar_out(elemento)
{	elemento.style.backgroundImage='url(img/mail_send.png)';
	elemento.style.backgroundRepeat='no-repeat';
	elemento.style.backgroundPosition='top';
}

function enviar_car_over(elemento)
{	elemento.style.backgroundImage='url(../../img/yellow_mail_send.png)';
	elemento.style.backgroundRepeat='no-repeat';
	elemento.style.backgroundPosition='top';
}

function enviar_car_out(elemento)
{	elemento.style.backgroundImage='url(../../img/mail_send.png)';
	elemento.style.backgroundRepeat='no-repeat';
	elemento.style.backgroundPosition='top';
}

function enviar_add_over(elemento)
{	elemento.style.backgroundImage='url(../img/save_over.png)';
	elemento.style.backgroundRepeat='no-repeat';
	elemento.style.backgroundPosition='top';
}

function enviar_add_out(elemento)
{	elemento.style.backgroundImage='url(../img/save.png)';
	elemento.style.backgroundRepeat='no-repeat';
	elemento.style.backgroundPosition='top';
}

function switchImage(imgName, imgSrc) 
{
  if (document.images)
  {
    if (imgSrc != "none")
    {
      document.images[imgName].src = imgSrc;
    }
  }
}

function onlyNumbersDano(evt)
{	var keyPressed = (evt.which) ? evt.which : event.keyCode
	return !(keyPressed > 31 && (keyPressed < 48 || keyPressed > 57));
}

function foco(elemento)
{	if(elemento.value!="")
	{elemento.style.color='#003844';}
	if((((elemento.value=="Nombre")||(elemento.value=="E-mail"))||(elemento.value=="Escriba su mensaje aqui..."))||(elemento.value=="Teléfono"))
	{elemento.value=""}
}

function no_foco_nombre(elemento)
{	if(elemento.value=="")
	{	elemento.value='Nombre';
	}
}

function no_foco_email(elemento)
{	if(elemento.value=="")
	{	elemento.value='E-mail';
	}
}

function no_foco_phone(elemento)
{	if(elemento.value=="")
	{	elemento.value='Teléfono';
	}
}

function no_foco_mensaje(elemento)
{	if(elemento.value=="")
	{	elemento.value='Escriba su mensaje aqui...';
	}
}

function comprobacion_contactar()
{var nombre = false;
var email = false;
var seguridad = true;
var mensaje = false;

	if((document.frmcontact.nombre.value!="")&&(document.frmcontact.nombre.value!="Nombre"))
	{	document.frmcontact.nombre.style.color='#003844';
		nombre = true;}
	else
	{document.frmcontact.nombre.style.color='#FF6600';
	document.frmcontact.nombre.value='Nombre';
	nombre = false;}
	
	//Comprobacion del email
	if((document.frmcontact.email.value=="")||(document.frmcontact.email.value=="E-mail"))
	{	document.frmcontact.email.style.color='#FF6600';
		document.frmcontact.email.value='E-mail';
		email = false;
	}
	else
	{	if(document.frmcontact.email.value.indexOf("@")>1)
		{	if(document.frmcontact.email.value.length==document.frmcontact.email.value.indexOf("@"))
			{	document.frmcontact.email.style.color='#FF6600';
				document.frmcontact.email.value='E-mail';
				email = false;
			}
			else
			{	document.frmcontact.email.style.color='#003844';
				email = true;
			}
		}
		else
		{	document.frmcontact.email.style.color='#FF6600';
			document.frmcontact.email.value='E-mail';
			email = false;
		}
	}
	
	if(document.frmcontact.comments.value!="")
	{	if(document.frmcontact.comments.value=="Escriba su mensaje aqui...")
		{document.frmcontact.comments.style.color='#FF6600';
		document.frmcontact.comments.value='Escriba su mensaje aqui...';
		mensaje = false;}
		else
		{document.frmcontact.comments.style.color='#003844';
		mensaje = true;}
	}
	else
	{document.frmcontact.comments.style.color='#FF6600';
	document.frmcontact.comments.value='Escriba su mensaje aqui...';
	mensaje = false;}
	
	if(document.frmcontact.num_seguridad.value!="")
	{document.frmcontact.num_seguridad.style.color='#003844';
	seguridad = true;
	}
	else
	{document.frmcontact.num_seguridad.style.color='#FF6600';
	document.frmcontact.num_seguridad.value='';
	seguridad = false;
	}
	
	if(nombre==true)
	{	if(email==true)
		{	if(seguridad==true)
			{	if(mensaje==true)
				{document.frmcontact.submit();}
			}
		}
	}
}

function comprobacion_admin()
{var usu = false;
var pass = false;
var pass_2 = false;
	
	if((document.frmadmin.usu.value!="")&&(document.frmadmin.usu.value!="Obligatorio"))
	{	document.frmadmin.usu.style.color='#003844';
		usu = true;
	}
	else
	{	document.frmadmin.usu.style.color='#FF6600';
		document.frmadmin.usu.value='Obligatorio';
		usu = false;
	}
	
	if(document.frmadmin.password.value!="")
	{	document.frmadmin.password.style.color='#003844';
		pass = true;
	}
	else
	{	document.frmadmin.password.style.color='#FF6600';
		pass = false;
	}
	
	if(document.frmadmin.password_2.value!="")
	{	if(document.frmadmin.password_2.value==document.frmadmin.password.value)
		{	document.frmadmin.password_2.style.color='#003844';
			pass_2 = true;
		}
		else
		{	document.frmadmin.password_2.style.color='#FF6600';
			pass_2 = false;
		}
	}
	else
	{	document.frmadmin.password_2.style.color='#FF6600';
		pass_2 = false;
	}
	
	if((document.frmadmin.password_2.value=="")&&(document.frmadmin.password.value==""))
	{	document.frmadmin.password_2.style.color='#003844';
		document.frmadmin.password.style.color='#003844';
		pass = true;
		pass_2 = true;
	}
	
	if(usu==true)
	{	if(pass==true)
		{	if(pass_2==true)
			{	document.frmadmin.submit();}
		}
	}
}

function comprobar_cambio()
{	if(document.frmadd_coches.cambio.value=="Manual")
	{	document.frmadd_coches.velocidades.disabled=false;
	}
	else
	{	document.frmadd_coches.velocidades.disabled=true;
	}
}

function liberar_file_sigiente()
{	if(document.frmadd_coches.file_1.value!="")
	{document.frmadd_coches.file_2.disabled=false;
	}
	else
	{document.frmadd_coches.file_2.disabled=true;
	}
	
	if(document.frmadd_coches.file_2.value!="")
	{document.frmadd_coches.file_3.disabled=false;
	}
	else
	{document.frmadd_coches.file_3.disabled=true;
	}
	
	if(document.frmadd_coches.file_3.value!="")
	{document.frmadd_coches.file_4.disabled=false;
	}
	else
	{document.frmadd_coches.file_4.disabled=true;
	}
	
	if(document.frmadd_coches.file_4.value!="")
	{document.frmadd_coches.file_5.disabled=false;
	}
	else
	{document.frmadd_coches.file_5.disabled=true;
	}
	
	if(document.frmadd_coches.file_5.value!="")
	{document.frmadd_coches.file_6.disabled=false;
	}
	else
	{document.frmadd_coches.file_6.disabled=true;
	}
	
	if(document.frmadd_coches.file_6.value!="")
	{document.frmadd_coches.file_7.disabled=false;
	}
	else
	{document.frmadd_coches.file_7.disabled=true;
	}
	
	if(document.frmadd_coches.file_7.value!="")
	{document.frmadd_coches.file_8.disabled=false;
	}
	else
	{document.frmadd_coches.file_8.disabled=true;
	}
}

function comprobacion_add_coche()
{var marca = false;
var modelo = false;
var precio = false;
var combustible = false;
var matriculacion = false;
	
	if(document.frmadd_coches.marca.value!="")
	{	document.getElementById('error_marca').style.display = 'none';
		marca = true;
	}
	else
	{	document.getElementById('error_marca').style.display = 'block';
		marca = false;
	}
	
	if(document.frmadd_coches.modelo.value!="")
	{	document.getElementById('error_modelo').style.display = 'none';
		modelo = true;
	}
	else
	{	document.getElementById('error_modelo').style.display = 'block';
		modelo = false;
	}
	
	if(document.frmadd_coches.precio.value!="")
	{	document.getElementById('error_precio').style.display = 'none';
		precio = true;
	}
	else
	{	document.getElementById('error_precio').style.display = 'block';
		precio = false;
	}
	
	if(document.frmadd_coches.combustible.value!="")
	{	document.getElementById('error_combustible').style.display = 'none';
		combustible = true;
	}
	else
	{	document.getElementById('error_combustible').style.display = 'block';
		combustible = false;
	}
	
	if(document.frmadd_coches.matriculacion.value!="")
	{	document.getElementById('error_matriculacion').style.display = 'none';
		matriculacion = true;
	}
	else
	{	document.getElementById('error_matriculacion').style.display = 'block';
		matriculacion = false;
	}
	
	if(marca==true)
	{	if(modelo==true)
		{	if(precio==true)
			{	if(combustible==true)
				{	if(matriculacion==true)
					{document.frmadd_coches.submit();}
				}
			}
		}
	}
}
