function cambiar(elemento,cuantos)
{
	for(var i=1; i<(cuantos+1);i++)
	{
		document.getElementById('seleccionibarra'+i).style.display='none';
		document.getElementById('grupoibarra'+i).style.display='none';
	}
	document.getElementById('seleccionibarra'+elemento).style.display='block';
	document.getElementById('grupoibarra'+elemento).style.display='block';
	
}
function ocultar(nombre,elemento,cuantos)
{
	for(var i=1; i<(cuantos+1);i++)
	{
		document.getElementById(nombre+i).style.display='none';
	}
	document.getElementById(nombre+elemento).style.display='block';
	
}
function verificarCorreo(correo)
{
        if(sign("<>,?|{}[]-+/*&^%$#\\ ",correo))
        {
            return true;
        }
        var c=correo.split('@');
        if(c.length!=2)
        {
            return true;
        }
        else
        {
            if(c[0]=="")
            {
                return true;
            }
            if(c[1]=="")
            {
                return true;
            }
            var j=c[1].split('.');
            if(j.length<2)
            {
                return true;
            }
            else
            {  
                if(j[0]=="")
                {
                    return true;
                }
                if(j[1]=="")
                {
                    return true;
                }
                return false;
            }
        }
 }
 function sign(s,correo)
{
	for(var i=0;i<s.length;i++)
	{
		if(correo.indexOf(s.charAt(i))!=-1)
		{
			return true;
		}
	}
	return false;
}
var seleccionProducto=0;
function cambiarProducto(index,donde)
{
	var c=document.getElementById('selectProducto');
	if(index!=0)
	{
		document.location=donde;
	}
}
function cambiarImagen(elemento,img)
{
	if(img=="")
		img="img/defaultIbarra.jpg";
	document.getElementById(elemento).src=img;
}
function cambiarImagenI(elemento,img)
{
	if(img=="")
		img="img/defaultIbarraG.png";
	document.getElementById(elemento).src=img;
}
function enviarReceta(idioma)
{
	if(document.getElementById('productEnviar').value=="0")
	{
		if(idioma=="es")
			alert('Selecciona el producto.');
		else if(idioma="en")
			alert('Choose the product.');
		document.getElementById('productEnviar').focus();
	}
	else if(document.getElementById('nombre').value=="")
	{
		if(idioma=="es")
			alert('Ingresa el nombre.');
		else if(idioma="en")
			alert('Put the name.');
		document.getElementById('nombre').focus();
	}
	else if(document.getElementById('email').value=="")
	{
		if(idioma=="es")
			alert('Ingresa el correo.');
		else if(idioma="en")
			alert('Put the mail.');
		document.getElementById('email').focus();
	}
	else if(verificarCorreo(document.getElementById('email').value))
	{
		if(idioma=="es")
			alert('El formato de correo no es correcto.');
		else if(idioma="en")
			alert('The format of the email is not correct.');
		document.getElementById('email').focus();
	}
	else if(document.getElementById('nombreReceta').value=="")
	{
		if(idioma=="es")
			alert('Ingresa el nombre de la receta.');
		else if(idioma="en")
			alert('Put the name.');
		document.getElementById('nombreReceta').focus();
	}
	else if(document.getElementById('ingredientes').value=="")
	{
		if(idioma=="es")
			alert('Ingresa los ingredientes de la receta.');
		else if(idioma="en")
			alert('Fill the ingredients.');
		ocultar('recetasEnviar',2,3);
		document.getElementById('ingredientes').focus();
	}
	else if(document.getElementById('mododepreparacion').value=="")
	{
		if(idioma=="es")
			alert('Ingresa el mode de preparacion de la receta.');
		else if(idioma="en")
			alert('Fill the preparation mode.');
		ocultar('recetasEnviar',3,3);
		document.getElementById('mododepreparacion').focus();
	}
	else
	{
		document.getElementById('formReceta').value="1";
		recetaE.submit();
	}
}
function limpiarEnviar()
{
	document.getElementById('comentarios').value="";
	document.getElementById('ciudad').value="";
	document.getElementById('pais').value="";
	document.getElementById('telefono').value="";
	document.getElementById('email').value="";
	document.getElementById('nombre').value="";
	document.getElementById('selectProducto').selectedIndex=0;

}
function contactoEnviar(idioma)
{
	if(document.getElementById('nombre').value=="")
	{
		if(idioma=="es")
			alert('Ingresa el nombre.');
		else if(idioma="en")
			alert('Put the name.');
		document.getElementById('nombre').focus();
	}
	else if(document.getElementById('email').value=="")
	{
		if(idioma=="es")
			alert('Ingresa el correo.');
		else if(idioma="en")
			alert('Put the mail.');
		document.getElementById('email').focus();
	}
	else if(verificarCorreo(document.getElementById('email').value))
	{
		if(idioma=="es")
			alert('El formato de correo no es correcto.');
		else if(idioma="en")
			alert('The format of the email is not correct.');
		document.getElementById('email').focus();
	}
	else if(document.getElementById('telefono').value=="")
	{
		if(idioma=="es")
			alert('Ingresa el Telefono.');
		else if(idioma="en")
			alert('Fill the telefhone.');
		document.getElementById('telefono').focus();
	}
	else if(document.getElementById('estado').value=="")
	{
		if(idioma=="es")
			alert('Ingresa el estado.');
		else if(idioma="en")
			alert('Fill the state.');
		document.getElementById('estado').focus();
	}
	else if(document.getElementById('ciudad').value=="")
	{
		if(idioma=="es")
			alert('Ingresa la ciudad.');
		else if(idioma="en")
			alert('Fill the city.');
		document.getElementById('ciudad').focus();
	}
	else if(document.getElementById('selectProducto').value=="0")
	{
		if(idioma=="es")
			alert('Selecciona el producto.');
		else if(idioma="en")
			alert('Choose the product.');
		document.getElementById('selectProducto').focus();
	}
	else
	{
		document.getElementById('enviarCon').value="1";
		enviarContacto.submit();
	}
}
function limpiar(elemento)
{
	document.getElementById(elemento).value="";
}
function limpiarVisita()
{
	limpiar('vmotivo');
	limpiar('vdia');
	limpiar('vnumero');
	limpiar('vescuela');
	limpiar('vdireccion');
	limpiar('vciudad');
	limpiar('vestado');
	limpiar('vnombreContacto');
	limpiar('vcorreo');
	limpiar('vtelefono');
	limpiar('vcomentarios');
}
function enviarVisitas(idioma)
{
	
	ocultar('recetasVisitas',1,2);
	if(document.getElementById('vmotivo').value=="")
	{
		if(idioma=="es")
			alert('Ingresa el motivo de la visita.');
		else if(idioma="en")
			alert('Fill the visit.');
		document.getElementById('vmotivo').focus();
	}
	else if(document.getElementById('vdia').value=="")
	{
		if(idioma=="es")
			alert('Ingresa el dia.');
		else if(idioma="en")
			alert('Fill the date.');
		document.getElementById('vdia').focus();
	}
	else if(isDate(document.getElementById('vdia').value))
	{
		if(idioma=="es")
			alert('El formato del dia no es correcto. Ejemplo: 25/12/2000');
		else if(idioma="en")
				alert('The format of the date is not correct. Example: 25/12/2000');
		document.getElementById('vdia').focus();
	}
	else if(document.getElementById('vnumero').value=="")
	{
		if(idioma=="es")
			alert('Ingresa el numero de personas.');
		else if(idioma="en")
			alert('Fill the number of person.');
		document.getElementById('vnumero').focus();
	}
	else if(isNumber(document.getElementById('vnumero').value))
	{
		if(idioma=="es")
			alert('Ingresa el numero de personas.');
		else if(idioma="en")
			alert('Fill the number of person.');
		document.getElementById('vnumero').value='';
		document.getElementById('vnumero').focus();
	}
	else if(document.getElementById('vnumero').value>30)
	{
		if(idioma=="es")
			alert('Maximo numero de personas es de 30.');
		else if(idioma="en")
			alert('Only 30 peoples.');
		document.getElementById('vnumero').value='';
		document.getElementById('vnumero').focus();
	}
	else if(document.getElementById('vescuela').value=="")
	{
		if(idioma=="es")
			alert('Ingresa la escuela/empresa de donde nos visitan.');
		else if(idioma="en")
			alert('Fill the field.');
		document.getElementById('vescuela').focus();
	}
	else if(document.getElementById('vdireccion').value=="")
	{
		if(idioma=="es")
			alert('Ingresa la direccion.');
		else if(idioma="en")
			alert('Fill the address.');
		document.getElementById('vdireccion').focus();
	}
	else if(document.getElementById('vciudad').value=="")
	{
		if(idioma=="es")
			alert('Ingresa la ciudad.');
		else if(idioma="en")
			alert('Fill the city.');
		document.getElementById('vciudad').focus();
	}
	else if(document.getElementById('vestado').value=="")
	{
		if(idioma=="es")
			alert('Ingresa el estado.');
		else if(idioma="en")
			alert('Fill the state.');
		document.getElementById('vestado').focus();
	}
	else if(document.getElementById('vnombreContacto').value=="")
	{
		ocultar('recetasVisitas',2,2);
		if(idioma=="es")
			alert('Ingresa el nombre del contacto.');
		else if(idioma="en")
			alert('Fill the name of the contact.');
		document.getElementById('vnombreContacto').focus();
	}
	else if(document.getElementById('vcorreo').value=="")
	{
		ocultar('recetasVisitas',2,2);
		if(idioma=="es")
			alert('Ingresa el correo del contacto.');
		else if(idioma="en")
			alert('Fill the email of the contact.');
		document.getElementById('vcorreo').focus();
	}
	else if(verificarCorreo(document.getElementById('vcorreo').value))
	{
		ocultar('recetasVisitas',2,2);
		if(idioma=="es")
			alert('El formato de correo no es correcto.');
		else if(idioma="en")
			alert('The format of the email is not correct.');
		document.getElementById('vcorreo').focus();
	}
	else if(document.getElementById('vtelefono').value=="")
	{
		ocultar('recetasVisitas',2,2);
		if(idioma=="es")
			alert('Ingresa el telefono del contacto.');
		else if(idioma="en")
			alert('Fill the telefhone of the contact.');
		document.getElementById('vtelefono').focus();
	}
	else
	{
		document.getElementById('visitasEnviar').value="1";
		contactovisitas.submit();
	}
}
function isDate(dateStr) {
var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
var matchArray = dateStr.match(datePat); // is the format ok?

	if (matchArray == null) {
	return true;
	}
	return false;
}
function isNumber(value){
	if (isNaN(value)==true)
    	return true;
	else
		return false;
}
function limpiarEncuesta()
{
	for( var i=1;i<12;i++)
	{
		for(var b=1;b<7;b++)
		{
			if(document.getElementById('pregunta'+i+"-"+b)!=null)
			{
				document.getElementById('pregunta'+i+"-"+b).checked=false;
			}
		}
	}
	document.getElementById('pregunta12').value="";
}
function enviarEncuesta(idioma)
{
	for( var i=1;i<12;i++)
	{
		var bandera=false;
		for(var b=1;b<7;b++)
		{
			if(document.getElementById('pregunta'+i+"-"+b)!=null)
			{
				if(document.getElementById('pregunta'+i+"-"+b).checked)
				{
					bandera=true;
					break;
				}
			}
		}
		if(!bandera)
		{
			if(idioma="es")
				alert('Selecciona una respuesta, para la pregunta '+i);
			else if(idioma="es")
				alert('Choose one answerd for the question '+i);
			document.getElementById('pregunta'+i+"-1").focus();
			return;
		}
				
	}
	if(document.getElementById('pregunta12').value=="")
	{
		if(idioma="es")
			alert('Ingresa una respuesta, para la pregunta 12');
		else if(idioma="es")
			alert('Fill one answerd for the question 12');
		document.getElementById('pregunta12').focus();
	}
	else
	{
		document.getElementById('enviarEncuestaCompletaTrue').value="1";
		enviarEncuestaCompleta.submit();
	}
}
function cambiarMenuImagen(elemento,i)
{
	document.getElementById('fondoProductoInc'+i).style.backgroundImage="url(img/productos/"+elemento+".png)";
	
	if(document.getElementById('textoTodo1'+i)!=undefined)
	{
		
		document.getElementById('textoTodo1'+i).className="texto";
		document.getElementById('textoTodo2'+i).className="texto";
		document.getElementById('textoTodo3'+i).className="texto";
	}
	
}
function enviarEncuestaPequena(idioma)
{
	var i=1;
	var bandera=false;
	while(document.getElementById('encuestarespuesta'+i)!=null)
	{
		if(document.getElementById('encuestarespuesta'+i).checked==true)
			bandera=true;
		i++;
	}
	if(!bandera)
	{
		if(idioma=="es")
			alert('Ingresa la respuesta');
		else
			alert('Fill the answerd.');
	}
	else
	{
		document.getElementById('encuestapequenaenviar').value="1";
		encuestapequena.submit();
	}
}
function limpiarBolsa(i)
{
	document.getElementById('b1'+i).value="";
	document.getElementById('b2'+i).value="";
	document.getElementById('b3'+i).value="";
	document.getElementById('b4'+i).value="";
	document.getElementById('b5'+i).value="";
	document.getElementById('b6'+i).value="";
}
function enviarBolsa(i,idioma)
{
	if(document.getElementById('b1'+i).value=="")
	{
		if(idioma=="es")
			alert("Ingresa el nombre");
		else
			alert('Fill the name');
		document.getElementById('b1'+i).focus();
	}
	else if(document.getElementById('b2'+i).value=="")
	{
		if(idioma=="es")
			alert("Ingresa el email");
		else
			alert('Fill the email');
		document.getElementById('b2'+i).focus();
	}
	else if(document.getElementById('b6'+i).value=="")
	{
		if(idioma=="es")
			alert("Ingresa el curriculum");
		else
			alert('Fill the curricula');
		document.getElementById('b6'+i).focus();
	}
	else
	{
		document.getElementById('enviarBolsa'+i).value="1";
		document.getElementById('bolsaEnc'+i).submit();
		
		
	}
}
