noticia_home = 0;

function init() {
	if (  document.getElementById("menu") ) {
	
	sfHover()
	
	document.getElementById("tapa-menu").style.display="none";
	
	if (document.getElementById('ultima-hora')) {
		noticies = getNews()
		
		if (noticies.length>1) {
			objecte_actiu = noticies[0]
			
				noticies[0].style[p] = (ie) ? "alpha(opacity="+limitSuperior+")" : limitSuperior; 
				noticies[1].style[p] = (ie) ? "alpha(opacity="+0+")" : 0; 
				noticies[1].style.display = "none";
			
			setTimeout("waitamoment()",espera);
		} else if (noticies.length>0) {
			objecte_actiu = noticies[0]
			noticies[0].style[p] = (ie) ? "alpha(opacity="+limitSuperior+")" : limitSuperior; 
		}
	}
	
	
	
	if (checkError_variable == true) {
		checkError()
	}
	}
	
}


//Menu principal
sfHover = function() {
	var sfEls = document.getElementById("menu").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className="sfhover";
			//this.style.background= "url('../img/fons_dalt_dreta_pestanya.gif') no-repeat top right red";
		}
		sfEls[i].onmouseout=function() {
			this.className="";
			//this.style.background= "url('../img/fons_dalt_dreta_pestanya.gif') no-repeat top right";
			
		}
	}
}



//Canvi d'idioma

function canviIdioma(codi) {
	
	formulari = document.getElementById('llenguatge');
	idioma = document.getElementById('idioma');
	
	var ubicacio = document.location.href
	
	if (ubicacio.charAt(ubicacio.length-1)=='/') {
		formulari.action = (document.location.href + "index.aspx")
	}
	
	idioma.value=codi;
	
	formulari.submit();
}



//Funci� que genera un numero aleatori
function aleatorio(a,b) {
	return Math.round(Math.random()*(b-a)+a);
}


//En funci� de l'extensi� de la imatge aplica un estil
var url_image, clasname, image_ext;
function selectFileClass(extension) {
	if (extension=="pdf") {classname="pdf";}
	else if (extension=="doc") {classname="word";}
	else if (extension=="xls") {classname="excel";}
	else if ((extension=="ppt") || (extension=="pps")) {classname="powerpoint";}
	else if ((extension=="gif") || (extension=="jpg") || (extension=="jpeg") || (extension=="png") || (extension=="bmp")) {classname="image";}
	else if ((extension=="mpg") || (extension=="avi") || (extension=="wmv") || (extension=="qtv") || (extension=="mov")) {classname="video";}
	else if ((extension=="wav") || (extension=="mp3") || (extension=="ogg") || (extension=="mpc") || (extension=="mp4")|| (extension=="wmf") || (extension=="wma")) {classname="audio";}
	else {classname="file";}
	return classname;
}


function getValue(formu,id) {
	if (id=="") return "";	
	if (formu=="") return "";
	formu = document.getElementById(formu);
	valor = "-"
	obj = formu[id];
	if (obj) {
		try {
		switch (obj.nodeName.toUpperCase()) {
			case "INPUT": 
				attr = obj.getAttribute("type");
				switch (attr.toUpperCase()) {
					case "TEXT": valor = obj.value; break;
					case "CHECKBOX": 
						if (obj.checked){
							valor = obj.value; 
						}
						else {
							valor = "";
						}
					break;
					default: valor = obj.value; break;
				}				
			break;
			case "TEXTAREA": valor = obj.value;  break;
			case "SELECT": valor = obj.options[obj.selectedIndex].value; break;
		}
		}
		catch (e) {
			//alert("id="+id+"\n"+e.message);
		}
		//alert("("+obj.nodeName+")"+id+" = "+valor+"\n"+obj.getAttribute("type"));
	}
	else {
		alert(id);
	}
	return valor;
}


function setValue(formu,id,valor) {	
  obj = document.getElementById(formu);
  if (obj) {
    obj[id].value = valor;
  }
}

function setAction(id,valor) {
  obj = document.getElementById(id);
  if (obj) {
    obj.action = valor;
  }
}

function doSubmit(id) {
  obj = document.getElementById(id);
  if (obj) {
    obj.submit();
  }
}


window.onload=init
checkError_variable = false