// JavaScript Document
function faq(id,arr)
{
var part=arr.split("|");
var cant=part.length-1;
for (var i=0; i < cant; i++)
	{
	var control='faq'+part[i];
	document.getElementById(control).style.display='none';	
	}
var control='faq'+id;
document.getElementById(control).style.display='block';	
}
function view_img(img,x)
{
if(x==1)
	{
	document.getElementById('gal').src='../admin/archivos/'+img;	
	}
else
	{
	document.getElementById('gal').src='admin/archivos/'+img;	
	}
}
function ver_submenu()
{
	document.getElementById('submenu').style.display="block";
}
function oculta_submenu()
{
	document.getElementById('submenu').style.display="none";
}
function valida_formularios(modelo,tipo,pag)
{
if(tipo==3)
	{
	if ((document.form1.txt_localidad.value=="")|(document.form1.txt_provincia.value==""))
		{
		var err=1;
		}
	else
		{
		var err=0;
		}
	}
else
	{
	var err=0;
	}
if ((document.form1.txt_apenom.value=="")|(document.form1.txt_telefono.value=="")|(document.form1.txt_email.value=="")|(document.form1.txt_descripcion.value=="")|(err==1))
	{
		alert("Los campos marcados con (*) son obligatorios.")
	}
	else
	{
		q=document.form1.txt_email.value;
		var b=/^[^@\s]+@[^@\.\s]+(\.[^@\.\s]+)+$/;
		if(b.test(q)==false)
		{
			alert ("La dirección de e-mail es incorrecta.")
			document.form1.txt_email.focus();
		}
		else
		{
			document.form1.action='envio_cmd.php?tipo='+tipo+'&mod='+modelo+'&pag='+pag;
			document.form1.submit();
		}
	}
}
function valida_testdrive()
{
	if ((document.form1.txt_apenom.value=="")|(document.form1.txt_telefono.value=="")|(document.form1.txt_email.value=="")|(document.form1.lst_auto.value==0)|(document.form1.lst_lugar.value==0))
	{
		alert("Los campos marcados con (*) son obligatorios.")
	}
	else
	{
		q=document.form1.txt_email.value;
		var b=/^[^@\s]+@[^@\.\s]+(\.[^@\.\s]+)+$/;
		if(b.test(q)==false)
		{
			alert ("La dirección de e-mail es incorrecta.")
			document.form1.txt_email.focus();
		}
		else
		{
			document.form1.submit();
		}
	}
}
function valida_firma()
{
	if ((document.form1.txt_apenom.value=="")|(document.form1.txt_telefono.value=="")|(document.form1.txt_departamento.value=="")|(document.form1.txt_email.value==""))
	{
		alert("Los campos marcados con (*) son obligatorios.")
	}
	else
	{
		q=document.form1.txt_email.value;
		var b=/^[^@\s]+@[^@\.\s]+(\.[^@\.\s]+)+$/;
		if(b.test(q)==false)
		{
			alert ("La dirección de e-mail es incorrecta.")
			document.form1.txt_email.focus();
		}
		else
		{
			document.form1.action='genera_firma_cmd.php'
			document.form1.submit();
		}
	}
}
function valida_registro()
{
if ((document.form1.txt_nombre.value=="")|(document.form1.txt_apellido.value=="")|(document.form1.txt_telefonofijo.value=="")|(document.form1.txt_email.value=="")|(document.form1.txt_clave.value=="")|(document.form1.txt_clave1.value==""))
	{
	alert("Todos los datos (*) son obligatorios.")
	}
else
	{
	if((document.form1.txt_clave.value.length<6)|(document.form1.txt_clave1.value.length<6))
		{
		alert("La contraseña debe tener 6 caracteres")
		}
	else
		{
		if(document.form1.txt_clave.value != document.form1.txt_clave1.value)	
			{
			alert("Las contraseñas no coinciden")
			}
		else
			{
			q=document.form1.txt_email.value;
			var b=/^[^@\s]+@[^@\.\s]+(\.[^@\.\s]+)+$/;
			if(b.test(q)==false)
				{
				alert ("La dirección de email es incorrecta");
				}	
			else
				{
				document.form1.action="registro_cmd.php";
				document.form1.submit();	
				}
			}
		}
	}
}
function limpia_login()
{
	 document.getElementById('usuario').value="";
}
function limpia_clave()
{
	 document.getElementById('clave1').style.display="none";
	 document.getElementById('clave').style.display="block";
	  document.getElementById('clave').focus();
}
function validausu()
{
if ((document.form_usuario.usuario.value=="" )|(document.form_usuario.clave.value==""))
	{
	alert("Debes ingresar el email y la Clave.");
	document.form_usuario.usuario.focus();
	}
else
	{
	document.form_usuario.action="valida.php";
	document.form_usuario.submit();
	}
}
function mensajes2(x)
{
if (x==1){alert("El email indicado ya existe en nuestros registros.");}
if (x==2){alert("El registro concluyó con éxito."+'\n'+"En breve recibirás un email en tu cuenta para confirmar el registro."+'\n'+"Muchas gracias por registrarte en nuestro portal!");}
if (x==3){alert("Enviamos un mensaje a su email con los datos de acceso.");}
if (x==4){alert("El email indicado no se encuentra en nuestros registros.");}
if (x==5){alert("Los datos fueron modificados correctamente.");}
if (x==6){alert("Los datos fueron enviados con éxito.");}
if (x==7){alert("Tu comentario fué enviado con éxito."+'\n'+"En breve revisaremos el contenido del mismo, y procederemos a su publicación."+'\n'+"Muchas gracias!");}
if (x==8){alert("El email indicado ya se encuentra,"+'\n'+"habilitado para recibir nuestro Newsletter.");
}
}
function valida_profile()
{
if ((document.form1.txt_nombre.value=="")|(document.form1.txt_apellido.value=="")|(document.form1.txt_telefonofijo.value=="")|(document.form1.txt_email.value=="")|(document.form1.txt_clave.value=="")|(document.form1.txt_clave1.value==""))
	{
	alert("Todos los datos son obligatorios.")
	}
else
	{
	if((document.form1.txt_clave.value.length<6)|(document.form1.txt_clave1.value.length<6))
		{
		alert("La contraseña debe tener 6 caracteres")
		}
	else
		{
		if(document.form1.txt_clave.value != document.form1.txt_clave1.value)	
			{
			alert("Las contraseñas no coinciden")
			}
		else
			{
			q=document.form1.txt_email.value;
			var b=/^[^@\s]+@[^@\.\s]+(\.[^@\.\s]+)+$/;
			if(b.test(q)==false)
				{
				alert ("La dirección de email es incorrecta");
				}	
			else
				{
				document.form1.action="comandos.php?accion=editprofile";
				document.form1.submit();	
				}
			}
		}
	}
}
function valida_olvide()
{
if (document.form1.txt_email.value=="")
	{
	alert("Debe indicar su email.")
	}
else
	{
	q=document.form1.txt_email.value;
	var b=/^[^@\s]+@[^@\.\s]+(\.[^@\.\s]+)+$/ 
	if(b.test(q)==false)
		{
		alert ("La dirección de email es incorrecta")
		}
	else
		{
			document.form1.action="olvido_cmd.php"
			document.form1.submit();
		}
	}
}
function validate_comentario(pag)
{
var oEditor = FCKeditorAPI.GetInstance('txt_comentario');
valor=oEditor.GetXHTML(true);
if((valor=="")|(valor=="<br />"))
	{
	alert("Debes especificar el comentario que deseas realizar.")
	}
else
	{
	document.form_comentario.action="comandos.php?accion=addcomentarios&pag="+pag;
	document.form_comentario.submit();
	}
}
var map = null;
var geocoder = null;
var lat=0;
var lng=0;
function initialize()
	{
    if (GBrowserIsCompatible())
		{
		if(document.getElementById('m1'))
			{
			var map = new GMap2(document.getElementById('m1'));
			var latlng = new GLatLng(-32.937196,-60.655217);
			map.setCenter(latlng, 15);
			map.setUIToDefault(); 
			var marker = new GMarker(latlng);
			map.addOverlay(marker);
			}
		if(document.getElementById('m2'))
			{
			var map = new GMap2(document.getElementById('m2'));
			var latlng = new GLatLng(-32.935854,-60.696824);
			map.setCenter(latlng, 15);
			map.setUIToDefault(); 
			var marker = new GMarker(latlng);
			map.addOverlay(marker);
			}
		if(document.getElementById('m3'))
			{
			var map = new GMap2(document.getElementById('m3'));
			var latlng = new GLatLng(-31.634708,-60.707295);
			map.setCenter(latlng, 15);
			map.setUIToDefault(); 
			var marker = new GMarker(latlng);
			map.addOverlay(marker);
			}
		if(document.getElementById('m4'))
			{
			var map = new GMap2(document.getElementById('m4'));
			var latlng = new GLatLng(-31.645377,-60.696373);
			map.setCenter(latlng, 15);
			map.setUIToDefault(); 
			var marker = new GMarker(latlng);
			map.addOverlay(marker);
			}
		}
    }
function over(tipo,control,cant)
{
	if(!cant)
	{
	if(tipo==1)
		{
		document.getElementById(control).src="img/"+control+"_o.gif";
		}
	else
		{
		document.getElementById(control).src="img/"+control+".gif";	
		}
	}
else
	{
		if(tipo==1)
		{
		document.getElementById(control+cant).src="img/"+control+"_o.gif";
		}
	else
		{
		document.getElementById(control+cant).src="img/"+control+".gif";	
		}
	}
}
function inicia_promo()
{
var roll = new roll_promo();
setTimeout(roll.start, 500);
}
function roll_promo()
{
this.start = function() {show();}
this.stop = function() {hide();}
function hide()
{
t1 = new Tween(document.getElementById('contentpromo').style,'left',Tween.regularEaseInOut,0,-640,0.8,'px');
t1.start();
t1.onMotionFinished = function()
	{
	var roll = new roll_promo();
	setTimeout(roll.start, 500);
	}
}
function show()
{
var url='admin/includes/duplicado.php?accion=rollautos';
var params = '';
new Ajax.Request(url, {method: 'get', parameters: params, onSuccess: function(transport) {if(transport.responseText.length > 0){document.getElementById('contentpromo').style.visibility = 'visible';document.getElementById('contentpromo').innerHTML=transport.responseText;t1 = new Tween(document.getElementById('contentpromo').style,'left',Tween.elasticEaseOut,200,0,2,'px');t1.start();t1.onMotionFinished = function(){var roll = new roll_promo();setTimeout(roll.stop, 5000);}}}});}
}
function cambiaclase(x,tipo)
{	
var control='div'+x
if(tipo==2)
	{
	document.getElementById(control).className='detalles2';
	}
else
	{
	document.getElementById(control).className='detalles';	
	}
}
function changeimage(x)
{
document.getElementById('principal').src='img/aguarde.gif';	
document.getElementById('principal').src=x;	
//document.getElementById('nombre').innerHTML='<strong>'+nom+'</strong>';
}
function fichas(fic)
{
document.getElementById('imagenes').style.display='none';
if(document.getElementById('crashtest')){document.getElementById('crashtest').style.display='none';}
document.getElementById('comentarios').style.display='none';
if(document.getElementById('video')){document.getElementById('video').style.display='none';}
document.getElementById('masinfo').style.display='none';
document.getElementById(fic).style.display='block';	
}
function valida_recibirnews()
{
if ((document.form1.txt_nombre.value=="")|(document.form1.txt_email.value==""))
	{
		alert("Todos los datos son obligatorios.")
	}
else
	{	
		q=document.form1.txt_email.value;
		var b=/^[^@\s]+@[^@\.\s]+(\.[^@\.\s]+)+$/ 
		if(b.test(q)==false)
		{
			alert ("La dirección de e-mail es incorrecta.")
			document.form1.txt_email.focus();
		}
		else
		{
			document.form1.action='recibir_newscmd.php';
			document.form1.submit();
		}
	}
}
function valida_encuesta(preguntas,respuestas)
{
var val='';var resp='';var c=0;
var preg=preguntas.split("|");
var cant=preg.length;
for(var x = 0; x < cant-1; x++)
	{
	var pr='pregunta_'+preg[x];
	var radioObj=document.forms['form1'].elements[pr];
	if(!radioObj)
		{
		return "";
		}
	else
		{
		var radioLength = radioObj.length;
		if(radioLength == undefined)
			{
			if(radioObj.checked)
				{
				val= radioObj.value;
				}
			else
				{
				val= "";
				}
			}
		else
			{
			for(var i = 0; i < radioLength; i++)
				{
				if(radioObj[i].checked)
					{
					val= radioObj[i].value;
					}
				}
			}
		}
	if(val){c++;}
	if((x)<(cant-2)){var sep='|';}else{var sep='';}
	resp+=preg[x]+'-'+val+sep;
	val=0;
	}
if(c!=(cant-1))
	{
	alert("Para poder finalizar la encuesta debe contestar todas las preguntas.");
	}
else
	{
	document.form1.action='comandos.php?accion=encuestas&opt='+resp+'&pag=encuesta_end.php';
	document.form1.submit();
	}
}
