Array.prototype.mostrar = function(seleccionat){
  	document.write('<ul id="navegacio">');
		for (var i=0; i < this.length; i++) {
				if(this[i].text == seleccionat){this[i].mostrar("on","item",0);}
				else{
					//opcio especifica per esports
					if(this[i].text == "Separador"){this[i].mostrar("punt","item",1,'esp_separador');}
					else{this[i].mostrar("","item",0);}
				}
		}
		document.write('</ul>');
};


function Menu(text,estil,link,fnova) {
  this.addOption = function (text,estil,link,fnova) {
   this.optionsObj.push(new Menu(text,estil,link,fnova));
  }

	this.mostrar = function (classOn, classLink, noShowOptions, nomOpcioEspecial) {
			
			//poner aqui toda las posibles opciones especiales
			if(nomOpcioEspecial == 'esp_3levelstitol'){
				document.write('<li id="m'+this.estil+'" class="'+classOn+'"><strong>'+this.text+'&nbsp;</strong>');
			}
			else if(nomOpcioEspecial == 'esp_separador'){
				document.write('<li id="m'+this.estil+'" class="'+classOn+'"><span>&nbsp;</span>');
			}
			else{
				document.write('<li id="m'+this.estil+'" class="'+classOn+'"><a href="'+this.link+'" class="'+classLink+'" title="'+this.text+'"><span>'+this.text+'</span></a>');
			}			
			
			if (this.optionsObj.length > 0 && noShowOptions==0) {
				document.write('<div>');
				for (var i=0; i < this.optionsObj.length; i++) {
					if(this.optionsObj[i].optionsObj.length>0){
						document.write('<ul>');
						this.optionsObj[i].mostrar(this.optionsObj[i].estil,"",1,'esp_3levelstitol');
						for (var j=0; j < this.optionsObj[i].optionsObj.length; j++) {
							if(j == 0){this.optionsObj[i].optionsObj[j].mostrar("primer","",0);}
							else{this.optionsObj[i].optionsObj[j].mostrar("","",0);}
						}
						document.write('</ul>');
					}
					else{
							if(i == 0){
								document.write('<ul>');
								this.optionsObj[i].mostrar("primer","",0);
							}
							else{
								this.optionsObj[i].mostrar("","",0);
								if(i == this.optionsObj.length -1){document.write('</ul>');}	
							}					
					}
				}
				document.write('</div>');
			}
			document.write('</li>');
	}
	    
 this.optionsObj = [];
 this.text=text;
 this.estil=estil;
 this.link=link;
 this.fnova=fnova;
}


