// JavaScript Document

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

/*AMIGO*/

function enviarAmigo(idioma){
	var Nombre = document.amigo.Nombre.value;
	var NombreAmigo = document.amigo.NombreAmigo.value;
	var Email = document.amigo.Email.value;
	var EmailAmigo = document.amigo.EmailAmigo.value;
	var strError = "";
	if(Nombre==""){
		if(idioma==1){
			strError+= "- Ingrese su Nombre.\n";
		}else{
			strError+= "- Name enter.\n";
		}
	}
	
	if(Email==""){
		if(idioma==1){
			strError+= "- Ingrese su Email.\n";
		}else{
			strError+= "- Email enter.\n";
		}
	}else{
		var p = Email.indexOf("@");
		if(p<1){
			if(idioma==1){
				strError+= "- El Email debe ser una dirección de correo.\n";
			}else{
				strError+= "- The email must be a mail direction.\n";
			}
		}
	}
	if(NombreAmigo==""){
		if(idioma==1){
			strError+= "- Ingrese el Nombre de su Amigo.\n";
		}else{
			strError+= "- Name friend enter.\n";
		}
	}
	if(EmailAmigo==""){
		if(idioma==1){
			strError+= "- Ingrese el Email de su Amigo.\n";
		}else{
			strError+= "- Email friend enter.\n";
		}
	}else{
		var p = EmailAmigo.indexOf("@");
		if(p<1){
			if(idioma==1){
				strError+= "- El Email de su Amigo debe ser una dirección de correo.\n";
			}else{
				strError+= "- The email friend must be a mail direction.\n";
			}
		}
	}
	if(strError!=""){
		alert(strError);
	}else{
		document.amigo.submit();	
	}
}


/*COMENTARIOS*/

function enviarComentario(idioma){
	var Nombre = document.comentario.Nombre.value;
	var Email = document.comentario.Email.value;
	var Comentario = document.comentario.Comentario.value;
	var strError = "";
	if(Nombre==""){
		if(idioma==1){
			strError+= "- Ingrese su Nombre.\n";
		}else{
			strError+= "- Name enter.\n";
		}
	}
	if(Email!=""){
		var p = Email.indexOf("@");
		if(p<1){
			if(idioma==1){
				strError+= "- El Email debe ser una dirección de correo.\n";
			}else{
				strError+= "- The email must be a mail direction.\n";
			}
		}
	}
	if(Comentario==""){
		if(idioma==1){
			strError+= "- Ingrese la Opinión.\n";
		}else{
			strError+= "- Opinion enter.\n";
		}
	}
	
	if(strError!=""){
		alert(strError);
	}else{
		document.comentario.submit();	
	}
}

/*CONTACTO*/

function enviarContacto(idioma){
	var Nombre = document.contacto.Nombre.value;
	var Email = document.contacto.Email.value;
	var Comentario = document.contacto.Comentario.value;
	var strError = "";
	if(Nombre==""){
		if(idioma==1){
			strError+= "- Ingrese su Nombre.\n";
		}else{
			strError+= "- Name enter.\n";
		}
	}
	if(Email!=""){
		var p = Email.indexOf("@");
		if(p<1){
			if(idioma==1){
				strError+= "- El Email debe ser una dirección de correo.\n";
			}else{
				strError+= "- The email must be a mail direction.\n";
			}
		}
	}else{
		if(idioma==1){
			strError+= "- Ingrese su Email.\n";
		}else{
			strError+= "- Email enter.\n";
		}
		
	}
	if(Comentario==""){
		if(idioma==1){
			strError+= "- Ingrese el Mensaje.\n";
		}else{
			strError+= "- Message enter.\n";
		}
	}
	
	if(strError!=""){
		alert(strError);
	}else{
		document.contacto.submit();	
	}
}

/*CONTACTO*/

function enviarConsulta(idioma){
	var Comentario = document.consulta.Comentario.value;
	var strError = "";
	if(Comentario==""){
		if(idioma==1){
			strError+= "- Ingrese la consulta.\n";
		}else{
			strError+= "- Enter consults.\n";
		}
	}
	
	if(strError!=""){
		alert(strError);
	}else{
		document.consulta.submit();	
	}
}

/*BUSQUEDA*/

function enviarBusqueda(idioma){
	
	var numero = document.buscador.n.value;
	var fechai = document.buscador.fecha1.value;
	var fechaf = document.buscador.fecha2.value;
	var strError = "";
	var arfi = fechai.split("-");
	var arff = fechaf.split("-");
	var fecha1 = new Date(arfi[2],arfi[1],arfi[0]);
	var fecha2 = new Date(arff[2],arff[1],arff[0]);
	
	if(numero!=""){
		if(isNaN(numero)){
			if(idioma==1){
				strError+= "- El Número debe contener un valor numérico.\n";
			}else{
				strError+= "- The Number must contain a numerical value.\n";
			}
		}else{
			if(numero==0 || numero<0){
				if(idioma==1){
					strError+= "- El Número debe ser superior a 0.\n";
				}else{
					strError+= "- The Number must be superior to 0.\n";
				}
			}
			
		}
	}
	
	if(fechai!="" & fechaf==""){
			if(idioma==1){
				strError+= "- Ingrese la segunda fecha.\n";
			}else{
				strError+= "- The second date enters.\n";
			}
	}else if(fechaf!="" & fechai==""){
			if(idioma==1){
				strError+= "- Ingrese la primera fecha.\n";
			}else{
				strError+= "- The first date enters.\n";
			}
	}else{
		if(fechaf!="" & fechai!=""){
			if(fecha2<fecha1){
				if(idioma==1){
					strError+= "- La primera fecha debe ser menor a la segunda.\n";
				}else{
					strError+= "- The first date must be smaller to second.\n";
				}
			}
		}
	}
	if(strError!=""){
		alert(strError);
	}else{
		document.buscador.submit();	
	}
	
}

function loginCliente(idioma){
	
var usuario = document.login.Usuario.value;
var clave = document.login.Clave.value;
var strError = "";
	if(usuario==""){
		if(idioma==1){
			strError+= "- Ingrese el Usuario.\n";
		}else{
			strError+= "- Enter User.\n";
		}		
	}else{
		if(usuario.length<6){
			if(idioma==1){
					strError+= "- El Usuario debe contener por lo menos 6 caracteres.\n";
			}else{
					strError+= "- The User must contain at least 6 characters.\n";
			}	
		 }
	}
	
	if(clave==""){
		if(idioma==1){
			strError+= "- Ingrese la Clave.\n";
		}else{
			strError+= "- Enter Password.\n";
		}		
	}else{
		if(clave.length<6){
			if(idioma==1){
					strError+= "- La Clave debe contener por lo menos 6 caracteres.\n";
				}else{
					strError+= "- The Password must contain at least 6 characters.\n";
				}	
			
		}
	}
	
	if(strError!=""){
		alert(strError);
	}else{
		document.login.submit();	
	}
}

function enviarDatos(idioma){
	
	var nombre = document.datos.Nombre.value;
	var usuario = document.datos.Usuario.value;
	var clave = document.datos.Clave.value;
	var email = document.datos.Email.value;
	
	var strError = "";
	
	if(nombre==""){
		if(idioma==1){
			strError+= "- Ingrese el Nombre.\n";
		}else{
			strError+= "- Enter Name.\n";
		}	
	}
	if(usuario==""){
		strError+="- Ingrese el Usuario.\n";	
	}else{
		
		if(usuario.length<6){
			if(idioma==1){
					strError+= "- El Usuario debe contener por lo menos 6 caracteres.\n";
			}else{
					strError+= "- The User must contain at least 6 characters.\n";
			}	
		}
	}
	if(clave!=""){
		if(clave.length<6){
			if(idioma==1){
				strError+= "- La Clave debe contener por lo menos 6 caracteres.\n";
			}else{
				strError+= "- The Password must contain at least 6 characters.\n";
			}	
		}
	}
	if(email==""){
		if(idioma==1){
			strError+= "- Ingrese su Email.\n";
		}else{
			strError+= "- Email enter.\n";
		}	
	}else{
		var p = email.indexOf('@');
		if(p<0){
			if(idioma==1){
				strError+= "- El Email debe ser una dirección de correo.\n";
			}else{
				strError+= "- The email must be a mail direction.\n";
			}
		}
	}
	if(strError!= ""){
		alert(strError);
	}else{
		
		document.datos.submit();	
	}
}

function enviarCondiciones(idioma){
	if(!document.condiciones.condicion[0].checked & !document.condiciones.condicion[1].checked){
		if(idioma==1){
			alert("Seleccione la opción");	
		}else{
			alert("Selection option.");
		}
	}else{
		document.condiciones.submit();	
	}
}

function expandir(id){
	if(document.getElementById(id)){
		var img = "img_"+id;
		if(document.getElementById(id).style.display=="none"){
			document.getElementById(id).style.display = "block";
			document.images[img].src = "../img/icono_proyecto.gif"
		}else{
			document.getElementById(id).style.display = "none";
			document.images[img].src = "../img/icono_proyecto_2.gif"
		}
	}
}

