function valida_login(){
	var user = $('#form_log input[@name=email]').val();
	var pwd = $('#form_log input[@name=soci]').val();
	if(user!=""){
		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(user))
		{
		  user=user;
		}else{
			$("#resultado").html('');
			$("#resultado").fadeIn();
			$("#resultado").html('<p style="color:#B94A42;">Email incorrecte</p>');
			$("#resultado").fadeOut(4000);
			return false;
		}	
	}else{
		$("#resultado").html('');
		$("#resultado").fadeIn();
		$("#resultado").html('<p style="color:#B94A42;">Tots els camps son obligatorios.</p>');
		$("#resultado").fadeOut(4000);
	}
	
	if (user!="" && pwd!="")
		{
		$.ajax({ //inicio ajax
			url: "funcions/funciones_ajax.php",
			async:true,
			dataType: "html",
			global: true,
			ifModified: false,
			processData:true,
			type: "POST",
			data: "user="+user+"&pwd="+pwd,
			success: function(json)
				{
					if(json!="ko"){
						$("#resultado").fadeIn();
						$("#resultado").html('<p style="color:#B94A42;">Benvingut '+json+'. Un moment, si us plau</p>');
						
						//parent.location.reload(true);
						setTimeout("location_index();", 3000);
					}else{
						$("#resultado").html('');
						$("#resultado").fadeIn();
						$("#resultado").html('<p style="color:#B94A42;">Soci incorrecte</p>');
						$("#resultado").fadeOut(4000);

					}
				}
		}); 
		} else{
						$("#resultado").html('');
						$("#resultado").fadeIn();
						$("#resultado").html('<p style="color:#B94A42;">Tots els camps son obligatorios.</p>');
						$("#resultado").fadeOut(4000);
		}	
		return false;
} 

function location_index(){
	parent.location='index.php';
}
function desconectat(){
	
	$.ajax({ //inicio ajax
			url: "funcions/funciones_ajax.php",
			async:true,
			dataType: "html",
			global: true,
			ifModified: false,
			processData:true,
			type: "POST",
			data: "accio=deslog",
			success: function(json)
				{
					if(json=="ok")
					{				
						location.reload(true);
					}
				}
		}); 
		
		return false;
}
function valida_contacte(){
	$("#resultado").html('');
	var email = $('#form_contacte input[@name=email]').val();
	var nom = $('#form_contacte input[@name=nom]').val();
	if(email!=""){
		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email))
		{
		  email=email;
		}else{
			$("#resultado").html('<p style="color:#B94A42;">Email no es correcta.</p>');
			return false;
		}	
	var comentari = $('#form_contacte textarea[@name=comentari]').val();
	if(email=='' || nom=="" || comentari=="" || email==undefined || nom==undefined || comentari==undefined){
		$("#resultado").html('<p style="color:#B94A42;">Els camps amb * son obligatoris.</p>');
		
		return false;
	}else{
		$("#resultado").html('');
		document.getElementById('form_contacte').submit();
		return true;
	}
	}
}
