function validar()
{
	$("#mensaje").removeClass();
	$("#mensaje").addClass('msg_check');
	$("#mensaje").html("Comprovant dades...");

	if ($("#nom_empresa").val().length == 0){
		$("#mensaje").removeClass();
		$("#mensaje").addClass('msg_mal');
		$("#mensaje").html("El camp <strong>Nom de l'empresa</strong> és obligatori");
		document.profile.nom_empresa.focus();
		return 0;
	}
	
	if ($("#tel").val().length == 0){
		$("#mensaje").removeClass();
		$("#mensaje").addClass('msg_mal');
		$("#mensaje").html("El camp <strong>Telèfon</strong> és obligatori");
		document.profile.tel.focus();
		return 0;
	}
	
	if ($("#carrer").val().length == 0){
		$("#mensaje").removeClass();
		$("#mensaje").addClass('msg_mal');
		$("#mensaje").html("El camp <strong>Carrer</strong> és obligatori");
		document.profile.carrer.focus();
		return 0;
	}

	if ($("#num").val().length == 0){
		$("#mensaje").removeClass();
		$("#mensaje").addClass('msg_mal');
		$("#mensaje").html("El camp <strong>Nº</strong> és obligatori");
		document.profile.num.focus();
		return 0;
	}

	if ($("#x").val().length == 0){
		$("#mensaje").removeClass();
		$("#mensaje").addClass('msg_mal');
		$("#mensaje").html("El camp <strong>Posició en el mapa</strong> és obligatori");
		document.profile.x.focus();
		return 0;
	}

	if ($("#y").val().length == 0){
		$("#mensaje").removeClass();
		$("#mensaje").addClass('msg_mal');
		$("#mensaje").html("El camp <strong>Posició en el mapa</strong> és obligatori");
		document.profile.y.focus();
		return 0;
	}

	if ($("#classificat").val().length == 0){
		$("#mensaje").removeClass();
		$("#mensaje").addClass('msg_mal');
		$("#mensaje").html("El camp <strong>Classificat a</strong> és obligatori");
		document.profile.classificat.focus();
		return 0;
	}
	
	document.profile.submit();
}

function validar_modif()
{
	$("#mensaje").removeClass();
	$("#mensaje").addClass('msg_check');
	$("#mensaje").html("Comprovant dades...");

	document.profile.submit();
}

function load_carrers(que)
{
	$("#carrer").empty();
	$.get("load_carrers.php", {poblacio: que}, function(data){
		try{
		$("elemento", data).each(function (j) {
			$("#carrer").append("<option value='" + $(this).attr("item") + "'>" + $(this).attr("valor") + "</option>");
		} );
		}
		catch(ex){alert(ex);}
	});
}

function lanzar_mapa()
{
	var carrer 	= $("#carrer").val();
	var num		= $("#num").val();
	
	if(carrer != '')
		carrer = "&carrer="+carrer;
	
	if(num != '')
		num = "&n="+num;

	window.open('/mapa/geoaddress.php?combo1=5'+carrer+num,'geo','status=yes,width=550,height=550'); 
	return false;
}

