String.prototype.trim=function(){return this.replace(/(^\s*)|(\s*$)/g,'');}
String.prototype.ltrim=function(){return this.replace(/^\s*/g,'');}
String.prototype.rtrim=function(){return this.replace(/\s*$/g,'');}
String.prototype.is_numeric=function(){return /^[+-]{0,1}[0-9]+$/.test(this);}
String.prototype.is_mail=function(){return /^[a-z0-9]([.]?[\w-])*@[a-z0-9]([.]?[\w-])*[.][a-z]{2,3}$/i.test(this);}
String.prototype.br2nl=function(){return this.replace(/<br \/>/g,'\n');};
String.prototype.nl2br=function(){return this.replace(/\n/g,"<br />");};
String.prototype.HTMLEncode=function(){
	var A=this.replace(/&/g,"&amp;");
	A=A.replace(/"/g,"&quot;");
	A=A.replace(/</g,"&lt;");
	A=A.replace(/>/g,"&gt;");
	A=A.replace(/'/g,"&#39;");
	return A;
}
function dataValida(a,m,d){
	m--;
	dt=new Date(a,m,d);
	return (dt.getFullYear()==a && dt.getMonth()==m && dt.getDate()==d);
}
function ocu_mos(nom){
	var A=document.getElementById(nom);
	var B='';
	var C="grafics/text_ocultar.png";
	if(A.style.display!='none'){
		B='none';
		C="grafics/text_mostrar.png";
	}
	A.style.display=B;
	document.getElementById("img_"+nom).src=C;
}

var editor=new Object();
editor.isMax=new Array();
editor.maximitza=function(A,B,C){
	var id=A+B;
	var n1="editorTextArea"+B;
	valor=document.getElementById(id).value;
	ax=document.getElementById("aux");
	ej=document.getElementById("empordajove");
	if(this.isMax[id]){
		ax.style.display="none";
		ax.style.width="100%";
		copiaDiv=ax.innerHTML;
		ax.innerHTML="";
		ej.style.display="block";
		document.getElementById(n1).innerHTML=copiaDiv;
		document.getElementById(id).style.height=C+"px";
		parent.scrollTo(0,document.getElementById(n1).offsetTop);
		this.isMax[id]=false;
	}else{
		if(parent.innerWidth){
			frameHeight=parent.innerHeight;
		}else if(document.documentElement && document.documentElement.clientWidth){
			frameHeight=document.documentElement.clientHeight;
		}else if(document.body){
			frameHeight=document.body.clientHeight;
		}else return;
		ej.style.display="none";
		copiaDiv=document.getElementById(n1).innerHTML;
		document.getElementById(n1).innerHTML="";
		ax.style.display="block";
		ax.style.width="99%";
		ax.innerHTML=copiaDiv;
		document.getElementById(id).style.height=(frameHeight-document.getElementById(id).offsetTop-10)+"px";
		parent.scrollTo(0,0);
		this.isMax[id]=true;
	}
	document.getElementById(id).value=valor;
}
function stats(i){
	var A=document.createElement("script");
	A.type="text/javascript";
	A.src="estats/script.php?i="+i+"&x="+(window.screen.width)+"&y="+(window.screen.height)+"&z="+(window.screen.colorDepth);
	document.getElementsByTagName("head")[0].appendChild(A);
}
function inserirtxt(nom,txt){
	txtarea=document.getElementById(nom);
	txtarea.focus();
	if(document.selection){//IE
		document.selection.createRange().text=txt;
	}else if(txtarea.selectionStart >=0){//nIE
		var ini=txtarea.selectionStart;
		var fin=txtarea.selectionEnd;
		txtarea.value=txtarea.value.substring(0,ini)+txt+txtarea.value.substring(fin,txtarea.textLength);
		if(ini!=fin){
			txtarea.selectionStart=ini;
			txtarea.selectionEnd=ini+txt.length;
		}else txtarea.selectionStart=txtarea.selectionEnd=ini+txt.length;
	}else txtarea.value+=txt;
}
function inserirtxt2(nom,txt1,txt2){
	txtarea=document.getElementById(nom);
	txtarea.focus();
	if(document.selection){//IE
		txt=document.selection.createRange().text;
		document.selection.createRange().text=txt1+txt+txt2;
	}else if(txtarea.selectionStart >=0){//nIE
		var ini=txtarea.selectionStart;
		var fin=txtarea.selectionEnd;
		txtarea.value=txtarea.value.substring(0,ini)+txt1+txtarea.value.substring(ini,fin)+txt2+txtarea.value.substring(fin,txtarea.textLength);
		if(ini!=fin){
			txtarea.selectionStart=ini;
			txtarea.selectionEnd=ini+txt1.length+(fin-ini)+txt2.length;
		}else txtarea.selectionStart=txtarea.selectionEnd=ini+txt1.length;
	}else txtarea.value+=txt1+txt2;
}
function inserirtxt3(nom,txt1,txt2,txt3){
	txtarea=document.getElementById(nom);
	txtarea.focus();
	if(document.selection){//IE
		txt=document.selection.createRange().text;
		document.selection.createRange().text=txt1+txt+txt2+txt+txt3;
	}else if(txtarea.selectionStart >=0){//nIE
		var ini=txtarea.selectionStart;
		var fin=txtarea.selectionEnd;
		txtarea.value=txtarea.value.substring(0,ini)+txt1+txtarea.value.substring(ini,fin)+txt2+txtarea.value.substring(ini,fin)+txt3+txtarea.value.substring(fin,txtarea.textLength);
		if(ini!=fin){
			txtarea.selectionStart=ini;
			txtarea.selectionEnd=ini+txt1.length+(fin-ini)*2+txt2.length+txt3.length;
		}else txtarea.selectionStart=txtarea.selectionEnd=ini+txt1.length;
	}else txtarea.value+=txt1+txt2+txt3;
}
function canviaTxtMida(nom,opcio){
	var mida=document.getElementById(nom).style.fontSize;
	if(mida.length!=0){
		mida=parseInt(mida.replace(/(\D)/g,""));
		if(mida<50){mida=100;}
	}else{
		mida=100;
	}
	if(opcio==0){
		if(mida>=100){mida-=25;}
	}else{
		if(mida<500){mida+=25;}
	}
	document.getElementById(nom).style.fontSize=mida+"%";
}
