function mostrarLog(){
//$("#ingreso").slideToggle("slow"); 	
$("#ingreso-grande").slideToggle("slow"); 

}
function ocultarLog(){
//$("#ingreso").slideToggle("slow"); 
$("#ingreso-grande").slideToggle("slow"); 
}


function enviarContacto(pForm)
{
	with(pForm)
	{
		if(nombre.value == '' || nombre.value == 'Nombre' || nombre.value.length < 5) {alert("Por favor, ingrese su nombre!"); nombre.focus(); return false;}
		if(apellido.value == '' || apellido.value == 'Telefono' || apellido.value.length < 5) {alert("Por favor, ingrese su telefono!"); apellido.focus(); return false;}
		if(direccion.value == '' || direccion.value == 'Direccion' || direccion.value.length < 5) {alert("Por favor, ingrese su direccion!"); direccion.focus(); return false;}
		if(email.value == '') {alert("Por favor, ingrese su e-mail"); email.focus(); return false;}
		if(!validarEmail(email.value)) {alert("Por favor, ingrese un e-mail v\u00e1lido"); email.focus(); return false;}		
		if(consulta.value.length > 10 && consulta.value!='Consulta') {
			x_EnviarContacto(nombre.value, apellido.value, direccion.value, email.value, ciudad.value, consulta.value, function(pCadena){
					alert("Su mensaje ha sido enviado! Gracias.");
					pForm.reset();
					});
		}else{
			alert("Por favor, ingrese un mensaje!"); consulta.focus(); return false;	
		}
	}
	return false;
}

function enviarSt(pForm)
{
	with(pForm)
	{
		if(nombre.value == '' || nombre.value == 'Nombre' || nombre.value.length < 5) {alert("Por favor, ingrese su nombre!"); nombre.focus(); return false;}
		if(apellido.value == '' || apellido.value == 'Telefono' || apellido.value.length < 5) {alert("Por favor, ingrese su telefono!"); apellido.focus(); return false;}
		if(direccion.value == '' || direccion.value == 'Direccion' || direccion.value.length < 5) {alert("Por favor, ingrese su direccion!"); direccion.focus(); return false;}
		if(email.value == '') {alert("Por favor, ingrese su e-mail"); email.focus(); return false;}
		if(!validarEmail(email.value)) {alert("Por favor, ingrese un e-mail v\u00e1lido"); email.focus(); return false;}		
		if(consulta.value.length > 10 && consulta.value!='Consulta') {
			x_EnviarST(nombre.value, apellido.value, direccion.value, email.value, ciudad.value, pruducto.value, consulta.value, function(pCadena){
					alert("Su mensaje ha sido enviado! Gracias.");
					pForm.reset();
					});
		}else{
			alert("Por favor, ingrese un mensaje!"); consulta.focus(); return false;	
		}
	}
	return false;
}



function enviarConsulta(pForm)
{
	with(pForm)
	{
		if(nombre.value == '' || nombre.value == 'Nombre' || nombre.value.length < 5) {alert("Por favor, ingrese su nombre!"); nombre.focus(); return false;}
		if(apellido.value == '' || apellido.value == 'Telefono' || apellido.value.length < 5) {alert("Por favor, ingrese su telefono!"); apellido.focus(); return false;}
		if(direccion.value == '' || direccion.value == 'Direccion' || direccion.value.length < 5) {alert("Por favor, ingrese su direccion!"); direccion.focus(); return false;}
		if(email.value == '') {alert("Por favor, ingrese su e-mail"); email.focus(); return false;}
		if(!validarEmail(email.value)) {alert("Por favor, ingrese un e-mail v\u00e1lido"); email.focus(); return false;}		
		if(consulta.value.length > 10 && consulta.value!='Consulta') {
			x_EnviarConsulta(nombre.value, apellido.value, direccion.value, email.value, ciudad.value, consulta.value, producto.value, function(pCadena){
					alert("Su consulta ha sido enviado! Gracias.");
					pForm.reset();
					});
		}else{
			alert("Por favor, ingrese un mensaje!"); consulta.focus(); return false;	
		}
	}
	return false;
}




function validarEmail(pEmail)
{
	var oRegExp = /^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$/;
	return oRegExp.test(pEmail);
}

function cargarContenido(id,tipo){
	x_CargarContenido(id,tipo, function(pCadena){
		$("#"+id).html(pCadena);	
	});
	
}

function registrarEmpresa(pForm){
	with(pForm)
	{
		if(usuario.value == '') {alert("Por favor, ingrese su nombre de usuario!"); usuario.focus(); return false;}
		if(clave.value == '') {alert("Por favor, ingrese una clave!"); clave.focus(); return false;}	
		if(razon.value == '') {alert("Por favor, ingrese una razon social!"); razon.focus(); return false;}	
		//if(idciudad.value == 0){alert("Por favor, seleccione una ciudad!"); idciudad.focus(); return false;}
		if(pais.value == '') {alert("Por favor, ingrese un pais!"); pais.focus(); return false;}				
		if(provincia.value == '') {alert("Por favor, ingrese una provincia!"); provincia.focus(); return false;}				
		if(localidad.value == '') {alert("Por favor, ingrese una localidad!"); localidad.focus(); return false;}				
		if(telefono.value == '') {alert("Por favor, ingrese su telefono!"); telefono.focus(); return false;}		
		if(email.value == '') {alert("Por favor, ingrese su e-mail"); email.focus(); return false;}
		if(!validarEmail(email.value)) {alert("Por favor, ingrese un e-mail v\u00e1lido"); email.focus(); return false;}
		x_ComprobarEmailEmpresa(email.value, function(pCadena){
				if(pCadena=="S"){ 
					alert("El email ingresado ya esta registrado, ingrese otro email!");
					email.focus();
					return false;
					}else{
						x_ComprobarUsuarioEmpresa(usuario.value, function(pCadena){
						if(pCadena=="S"){
							alert("El usuario ingresado ya esta registrado, ingrese otro usuario!");
							usuario.focus();
							return false;
								}else{	
								  x_GuardarEmpresa(usuario.value, clave.value, razon.value, pais.value, provincia.value, localidad.value, domicilio.value, telefono.value, email.value, function(pCadena){
								  alert("Usuario registrado! Gracias\nAhora puede ingresar utilizando su nombre de usuario y clave.");
								  pForm.reset();
								  location.href=url.value;
								  });
								}
			
							});
						}
				});
	}
	return false;
}

function cargarProvincia(id){
	x_CargarProvincia(id,function(pCadena){
		$("#idprovincia").html(pCadena);	
	});
}

function cargarLocalidad(id){
	x_CargarLocalidad(id,function(pCadena){
		$("#idlocalidad").html(pCadena);	
	});
}
function enviarCV(pForm)
{
	with(pForm)
	{
		if(nombre.value == '') {alert("Por favor, ingrese su nombre!"); nombre.focus(); return false;}
		if(apellido.value == '') {alert("Por favor, ingrese su apellido!"); apellido.focus(); return false;}
		if(pais.value == '') {alert("Por favor, seleccione una ciudad!"); pais.focus(); return false;}
		if(idlocalidad.value == '0') {alert("Por favor, seleccione una ciudad!"); idlocalidad.focus(); return false;}
		if(telefono.value == '') {alert("Por favor, ingrese su telefono!"); telefono.focus(); return false;}
		if(email.value == '') {alert("Por favor, ingrese su email!"); email.focus(); return false;}
		if(nombre.value.length > 0) {
			x_EnviarCV(nombre.value, apellido.value, dia.value, mes.value, año.value, email.value, telefono.value, pais.value, idprovincia.value, idlocalidad.value, adjunto.value, function(pCadena){
					//alert(pCadena);
					alert("Su CV ha sido enviado! Gracias.");
					pForm.reset();
					});
		}else{
		alert("Por favor, ingrese un nombre!"); nombre.focus(); return false;	
		}
	}
	return false;
}

function enviarAmigo(pForm){
	with(pForm)
	{
		if(tunombre.value.length > 0)
		{
			if(validarEmail(tuemail.value))
			{
				
				if(amigonombre.value.length > 0)
				{
					if(validarEmail(amigoemail.value))
					{
						
						x_EnviarAmigo(tunombre.value,
											 tuemail.value,
											 amigonombre.value,
											 amigoemail.value,mensaje.value,function(pCadena)
								{
									alert("Su mensaje ha sido enviado");
									pForm.reset();
									$('#amigo').slideToggle('fast');
								});	
						
					}
					else
					{
						alert("Por favor, ingrese el email de su amigo");
						amigoemail.focus();
					}
				}
				else
				{
					alert("Por favor, ingrese el nombre de su amigo");
					amigonombre.focus();
				}
								
				
			}
			else
			{
				alert("Por favor, ingrese su Email");
				tuemail.focus();
			}
		}
		else
		{
			alert("Por favor, ingrese su nombre");
			tunombre.focus();
		}
	}
	return false;
}
