function emailCheck (emailStr) {
	var emailPat=/^(.+)@(.+)$/
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
	var validChars="\[^\\s" + specialChars + "\]"
	var quotedUser="(\"[^\"]*\")"
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
	var atom=validChars + '+'
	var word="(" + atom + "|" + quotedUser + ")"
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
	var matchArray=emailStr.match(emailPat)
	if (matchArray==null) {
		alert("El correu electrònic introduït és incorrecte")
		return false
	}
	var user=matchArray[1]
	var domain=matchArray[2]
	if (user.match(userPat)==null) {
    	alert("El correu electrònic introduït és incorrecte.")
	    return false
	}
	var IPArray=domain.match(ipDomainPat)
	if (IPArray!=null) {
		for (var i=1;i<=4;i++) {
	    	if (IPArray[i]>255) {
	        	alert("El correu electrònic introduït és incorrecte")
				return false
			}
		}
	return true
	}

	var domainArray=domain.match(domainPat)
	if (domainArray==null) {
		alert("El correu electrònic introduït és incorrecte.")
	    return false
	}
	var atomPat=new RegExp(atom,"g")
	var domArr=domain.match(atomPat)
	var len=domArr.length
	if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>4) {
		alert("El correu electrònic introduït és incorrecte.")
		return false
	}
	if (len<2) {
   		var errStr="El correu electrònic introduït és incorrecte"
		alert(errStr)
		return false
	}
return true;
}

function mostrar(uno,dos){
	document.getElementById(""+uno+"").style.display="block";
	document.getElementById(""+dos+"").style.display="none";
}
function cambiaVista(c){
	if(document.getElementById(""+c+"").style.display=="none"){
		document.getElementById(""+c+"").style.display="block";
	}else{
		document.getElementById(""+c+"").style.display="none";
	}
}
function onQuickLink(item){
	item.className = item.active=="yes"?"quickLinkActiveOn":"quickLinkOn";
	window.status = "Federació Catalana Ciclisme: " + item.statustext;
}
function offQuickLink(item){
	item.className = item.active=="yes"?"quickLinkActiveOff":"quickLinkOff";
	window.status = "Federació Catalana Ciclisme";
}
function gotoQuickLinkItem(url){
	document.location = url;
}
function tr_on(_tr){
	_tr.style.backgroundColor  = "#faff03";
}
function tr_off(_tr){
	_tr.style.backgroundColor  = "white";
}
function tr_click(_tr, _url){
	//_tr.style.backgroundColor  = "#ACC3D2";
	document.location = _url;
}

function tr_on2(_tr){
	_tr.style.backgroundColor  = "#faff03";
}
function tr_off2(_tr){
	_tr.style.backgroundColor  = "yellow";
}

function mostrarMenu(c,t){
	w=c.split("-")
	for(i=0;i<w.length;i++){
		k=w[i];
		if(document.getElementById(""+k+"").style.display=="none"){
			document.getElementById(""+k+"").style.display="block";
			if(t!=""){	document.getElementById(""+t+"").src="/admin/images/menos.gif";}
		}else{
			document.getElementById(""+k+"").style.display="none";
			if(t!=""){	document.getElementById(""+t+"").src="/admin/images/mas.gif";}
		}
	}
}
function enviaramigo(){
	var xpos=(screen.width - 300)/2;
	var ypos=(screen.height -340)/3;
	pagina="/envio_amigo.php"
	window.open(pagina,'Enviar','width=300,height=290,top='+ypos+',left='+xpos+',scrollbars=no,resizable=no')
}

function imprimir(c){
	var xpos=(screen.width - 650)/2;
	var ypos=(screen.height -500)/3;
	pagina="/"+c;
	window.open(pagina,'Imprimir','width=650,height=500,top='+ypos+',left='+xpos+',scrollbars=yes,resizable=yes')
}
function compruebaEnvioNoticia(){
	if(emailCheck(document.forms.send.from_email.value)==false){
		return false;
	}else if(document.forms.send.from_name.value=="" || document.forms.send.body.value==""){
		alert("Has de completar tots els camps");
		return false;
	}else{
		return true;
	}
}
