function MM_preloadImages() { 
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { 
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { 
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { 
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function pasar_id(form)
{
	if ((form.urbanizacion.value != '') && (form.tipo_comida.value != ''))
	{
		form.query.value = form.urbanizacion.value + " " + form.tipo_comida.value;	
	} else if ((form.urbanizacion.value == '') && (form.tipo_comida.value != ''))
	{
		form.query.value = form.tipo_comida.value;	
	}
}

function cambiar(item) 
{
   obj=document.getElementById(item);
   visible=(obj.style.display!="none")
   if (visible) {
     obj.style.display="none";
   } else {
      //atras();
      obj.style.display="block";
   }
}

function validarComentario(form,culture)
{
	var flag = 0;
	var acum = "";
	if (culture=='es')
	{
		acum = "Por favor introduce";
		
		if ((form.comentario_ambiente.value == ''))
		{
			acum += ", ambiente";
			flag = 1;
		} 
		if ((form.comentario_comida.value == ''))
		{
			acum += ", comida";	
			flag = 1;
		} 
		if ((form.comentario_servicio.value == ''))
		{
			acum += ", servicio";
			flag = 1;
		} 
		if ((form.comentario_precio_valor.value == ''))
		{
			acum += ", precio valor";
			flag = 1;
		} 
		if ((form.comentario_fecha_comida.value == ''))
		{
			acum += ", fecha de tu visita";
			flag = 1;
		} 
		if ((form.comentario_comentario.value == ''))
		{
			acum += ", tu comentario";	
			flag = 1;
		} 
	} else {
		
		acum = "Please rank according to, ";
		
		if ((form.comentario_ambiente.value == ''))
		{
			acum += ", ambience";
			flag = 1;
		} 
		if ((form.comentario_comida.value == ''))
		{
			acum += ", cuisine";	
			flag = 1;
		} 
		if ((form.comentario_servicio.value == ''))
		{
			acum += ", service";
			flag = 1;
		} 
		if ((form.comentario_precio_valor.value == ''))
		{
			acum += ", value";
			flag = 1;
		} 
		if ((form.comentario_fecha_comida.value == ''))
		{
			acum += ", date of your meal";
			flag = 1;
		} 
		if ((form.comentario_comentario.value == ''))
		{
			acum += ", your comment";	
			flag = 1;
		} 
	}
	
	if (flag==1) 
	{
		alert(acum);
		return false;
	} else if (flag==0)
	{
		return true
	}
}

function validarRep(form,culture)
{	
	if ((form.usuario_password.value != form.repetir_clave.value))
	{
		if (culture == 'es')
		{
			alert('Las claves no son iguales, por favor verifique');
		} else {
			alert('The password fields do not match, please try again');
		}
		
		return false;
	} 
	if ((form.usuario_email.value != form.repetir_mail.value))
	{
		if (culture == 'es')
		{
			alert('Los email no coinciden, por favor verifique');
		} else {
			alert('The email fields do not match, please try again');
		}
		
		return false;
	} 
	
	return true

}

function explicar(culture)
{	

	if (culture == 'es')
	{
		alert('Por favor, para comentar debe registrarse o iniciar sesion en el sistema');
	} else {
		alert('To write a comment you must be logged in, if you are not registered please do so');
	}
}

function verificarLogin(form,culture)
{	
	if (form.email.value == "")
	{
		if (culture == 'es')
		{
			alert('Por favor introduce email');
		} else {
			alert('The email field is empty, please try again');
		}
		
		return false;
	} 
	if (form.password.value == "")
	{
		if (culture == 'es')
		{
			alert('Por favor introduce clave');
		} else {
			alert('The password field is empty, please try again');
		}
		
		return false;
	} 
	
	if (!echeck(form.email.value))
	{
		if (culture == 'es')
		{
			alert('Formato de email incorrecto');
		} else {
			alert('Invalid format (email)');
		}
		
		return false;
	}
	
	return true

}

function echeck(str) 
{
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	
	if (str.indexOf(at)==-1){
	   return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
	    return false
	}

	 if (str.indexOf(at,(lat+1))!=-1){
	    return false
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
	    return false
	 }

	 if (str.indexOf(dot,(lat+2))==-1){
	    return false
	 }
		
	 if (str.indexOf(" ")!=-1){
	    return false
	 }
 	 return true					
}

function googleAnalitycs()
{
	var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
	document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));

	try {
		var pageTracker = _gat._getTracker("UA-322902-5");
		pageTracker._trackPageview();
	} catch(err) {}
}

function verificarUrb(form,culture)
{	
	if (form.local_id_urbanizacion.value == "")
	{
		if (culture == 'es')
		{
			alert('Por favor introduce urbanizacion');
		} else {
			alert('The neighborhood field is empty, please try again');
		}
		
		return false;
	} 
	
	return true
}

function verificarCiudad(form,culture)
{	
	if (form.local_id_ciudad.value == "")
	{
		if (culture == 'es')
		{
			alert('Por favor introduce ciudad');
		} else {
			alert('The city field is empty, please try again');
		}
		
		return false;
	} 
	
	return true
}

function verificarPago(form,culture)
{	
	if (form.dominio.value == "")
	{
		if (culture == 'es')
		{
			alert('Por favor introduce email');
		} else {
			alert('The email field is empty, please try again');
		}
		
		return false;
	} 
	
	if (!echeck(form.dominio.value))
	{
		if (culture == 'es')
		{
			alert('Formato de email incorrecto');
		} else {
			alert('Invalid format (email)');
		}
		
		return false;
	}
	
	return true

}


