$(document).ready(function() {
	$(".external").attr("target","_blank");
	$(".sHuman").hide();
	
	$("a").focus(function() {
		$(this).blur();
	});
	
});

function validarfrmContacte() {
	var nom = document.getElementById("frmContacte.sNom").value;
	var mail = document.getElementById("frmContacte.sMail").value;
	var text = document.getElementById("frmContacte.sText").value;

	if (nom == "") { 
		alert("Has d'indicar un nom.")
		return false;
	}

	if (mail == "") { 
		alert("Has d'indicar una direcci\xF3 de correu electr\xF2nic.")
		return false;
	}

	if (mail != "") { 
		if (validaEmail(mail)==false) {
			alert("Format de correu electr\xF2nic no v\xE0lid.");
			return false;}
	}

	if (text == "") { 
		alert("El text no pot estar en blanc.")
		return false;
	}

	if (text != "") { 
		if (isLegal(text)==false) {
			alert("Car\xE0cters no permessos: #$^&*~<>/\|");
			return false;}
	}

	return true;
}


function isLegal(txt) {
var invalids = "#$^&*~<>/\|"
	for(i=0; i<invalids.length; i++) {
		if(txt.indexOf(invalids.charAt(i)) >= 0 ) {
		return false;}
     }
return true;}


function validaEmail(checkStr)
{var nI, sS, nN, nP;
 // Arroba ...
 sS = "@"; nN = 0; nP = 0;
 for(nI = 0; nI < checkStr.length; nI++)
 { if(checkStr.charAt(nI) == sS) 
  { nN++; nP = nI;
  }
 }
 if(nN == 0) return (false);
 if(nN > 1)  return (false);
 var nPArroba = nP;
 // Punto ...
 sS = "."; nN = 0; nP = 0;
 for(nI = 0; nI < checkStr.length; nI++)
 { if(checkStr.charAt(nI) == sS) 
  { nN++; nP = nI;
  }
 }
 if(nN == 0) return (false);
 var nPPunto = nP;
 // Posicion Arroba/Punto ...
 if(nPArroba > nPPunto) return (false);
 //
 return (true);
}