function canviSeleccionat(id,estat) {
	if (estat == 1) {
		document.getElementById(id).style.backgroundColor="#bcc7b8";
		document.getElementById("menudecoracio_"+id).src="/imgs/menu_decoracio_seleccionat.gif";
		document.getElementById("link_"+id).style.padding="0px 0px 0px 5px";
	}
	else {
		document.getElementById(id).style.backgroundColor="#f6f6ef";
		document.getElementById("menudecoracio_"+id).src="/imgs/menu_decoracio.gif";
		document.getElementById("link_"+id).style.padding="0px 0px 0px 0px";
	}
}

function submitForm() {
	//make sure hidden and iframe values are in sync before submitting form
	//to sync only 1 rte, use updateRTE(rte)
	//to sync all rtes, use updateRTEs
	updateRTE('rte1');
	//updateRTEs();
	//alert("rte1 = " + document.form1.rte1.value);
	//change the following line to true to submit form
	return true;
}

function Foto(estat) {
	if (estat==true) {
		document.getElementById("nomFoto").value="/imatges/noticies/";
		document.getElementById("nomFoto").style.display="inline";
	}
	else {
		document.getElementById("nomFoto").value="";
		document.getElementById("nomFoto").style.display="none";
	}
}

function checkEmail(num) {
	var email=document.getElementById("email"+num).value;
	if (email!="") {
		if (email.indexOf("@")==-1) alert("L'e-mail és incorrecte");
		else document.getElementById("form"+num).submit();
	}
	else alert("T'has descuidat d'escriure el teu e-mail");
}

function getElementsByClass(searchClass,node,tag) {
  var classElements = new Array();
  if (node == null)
    node = document;
  if (tag == null)
    tag = '*';
  var els = node.getElementsByTagName(tag);
  var elsLen = els.length;
  var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
  for (i = 0, j = 0; i < elsLen; i++) {
    if (pattern.test(els[i].className) ) {
      classElements[j] = els[i];
      j++;
    }
  }
  return classElements;
}

function canviMidaFont(mida) {
	var cssElements = new Array("formulari", "top3_bottom_mides", "menu", "titol", "titolNoticia", "titol2", "texte", "noticiesDataText", "paginacio", "footerText");
	var valorsInicials = new Array(10,11,11,18,14,14,12,12,12,10);
	for (var i=0;i<cssElements.length;i++) {
		var classElements = getElementsByClass(cssElements[i]);
		switch (mida) {
		case ("gran"):
			for (var j=0;j<classElements.length;j++) classElements[j].style.fontSize=(Number(classElements[j].style.fontSize.substr(0,classElements[j].style.fontSize.length-2))+2)+"px";
			break;
		case ("petit"):
			for (var j=0;j<classElements.length;j++) classElements[j].style.fontSize=(Number(classElements[j].style.fontSize.substr(0,classElements[j].style.fontSize.length-2))-2)+"px";
			break;
		case ("reset"):
			for (var j=0;j<classElements.length;j++) classElements[j].style.fontSize=valorsInicials[i]+"px";
			break;
		}
	}
}

function canviaFons(id,color) {
	document.getElementById(id).style.backgroundColor="#"+color;
}