






function init() {
	reTarget();
	startList();
}

function startList() {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("nav");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {this.className+=" over";}
				node.onmouseout=function() {this.className=this.className.replace(" over", "");}
			}
		}
	}
}


function pop_up(where,width,height,scrollbars) {
      window.open( where, 'popupwindow', 'width='+width+', height='+height+', scrollbars='+scrollbars+', resizable=no');
}

function reTarget() {
	var external = document.getElementsByTagName("a");
	for (var k=0; k<external.length; k++){
		if (external[k].href && external[k].rel.indexOf('popup') != -1) {
			var url = external[k].href;
			var mesures =  external[k].rel.substring(6).split("x");
			var scrollbars = "yes";
			var width = mesures[0];
			var height = mesures[1];
			external[k].onclick = function(){pop_up(this.href,width,height,scrollbars);return false;}
		}
	}
}

window.onload =  init;


function mostrar(continent, contingut) {
	document.getElementById(continent).innerHTML=contingut;
}

// Removes leading whitespaces
function LTrim( value ) {
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
}

// Removes ending whitespaces
function RTrim( value ) {
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
}

// Removes leading and ending whitespaces
function trim( value ) {
	return LTrim(RTrim(value));
}


var AVIS_ERROR=false;

function validateForm (form)
{
	for (i=0;i<form.elements.length;i++) {
		if(form.elements[i].onblur!=null) {
			if (checkDefault(form.elements[i].value)) {
				errorDefault(form.elements[i]);
				form.elements[i].focus()
				return false;
			}
			if (!eval(form.elements[i].onblur())) return false;
		}
	}
return true;
}

function validate(camp, valor, long) {
	if (AVIS_ERROR == false) {
		if (trim(valor)=="" || trim(valor).length<long) {
			errorLong(camp);
			AVIS_ERROR = true;
			camp.focus()
			return false;
		}
	}
	AVIS_ERROR = false;
	return true;
}

function validateMail(camp, valor, long) {
	if (AVIS_ERROR == false) {
		if (validate(camp, valor, long)) {
			var filter=/^[a-z0-9]+([\.]?[a-z0-9_-]+)*@[a-z0-9]+([\.-]+[a-z0-9]+)*\.[a-z]{2,}$/;
			if (filter.test(valor)) {
				AVIS_ERROR = false;
				return true;
			}
			else {
				errorMail(camp);
				AVIS_ERROR = true;
				camp.focus();
				return false;
			}
		}
		return false;
	}
	AVIS_ERROR = false;
	return false;
}

function checkDefault(valor) 
{
	if (valor == NOM) return true;
	if (valor == COGNOMS) return true;
	if (valor == EMAIL) return true;
	if (valor == ASSUMPTE) return true;
	if (valor == COMENTARI) return true;
	return false;
}




// Links externs
function obrefinestra(alink) { window.open(alink); return false;  }

window.onload = function() {


	var lnks = document.getElementsByTagName("a");
	
	for(var i=0; i<lnks.length; i++) {
		
		if((lnks[i].getAttribute("class") == "popup")  || (lnks[i].getAttribute("rel") == "external") ) { 
			lnks[i].onclick = function() { return obrefinestra(this.href);  }
		}
	}
}








	