function getElementsByClassName(oElm, strTagName, oClassNames){
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	var arrRegExpClassNames = new Array();
	if(typeof oClassNames == "object"){
		for(var i=0; i<oClassNames.length; i++){
			arrRegExpClassNames.push(new RegExp("(^|\\s)" + oClassNames[i].replace(/\-/g, "\\-") + "(\\s|$)"));
		}
	}
	else{
		arrRegExpClassNames.push(new RegExp("(^|\\s)" + oClassNames.replace(/\-/g, "\\-") + "(\\s|$)"));
	}
	var oElement;
	var bMatchesAll;
	for(var j=0; j<arrElements.length; j++){
		oElement = arrElements[j];
		bMatchesAll = true;
		for(var k=0; k<arrRegExpClassNames.length; k++){
			if(!arrRegExpClassNames[k].test(oElement.className)){
				bMatchesAll = false;
				break;
			}
		}
		if(bMatchesAll){
			arrReturnElements.push(oElement);
		}
	}
	return (arrReturnElements)
}

function cambiaTesto(id, testo, testo2) {
			
			div = document.getElementById(id);
			if (div.innerHTML == '<strong class="blu">'+testo+'</strong>')
			{
				div.innerHTML = '<strong class="blu">'+testo2+'</strong>';
			}
			else
			{
				div.innerHTML = '<strong class="blu">'+testo+'</strong>';				
			}
}

function popolaTextArea(id, testo) {
			
			div = document.getElementById(id);
			
			out = "<br/>"; // replace this
			add = "\n"; // with this
			
            temp = "\n" + testo; // temporary holder


            while (temp.indexOf(out)>-1) {
               pos = temp.indexOf(out);
               temp = "" + (temp.substring(0, pos) + add + 
               temp.substring((pos + out.length), temp.length));
            }
            
            testo = temp + "";

			div.value = testo;
}


function chTxt(id, testo, testo2) {
			
			div = document.getElementById(id);
			if (div.innerHTML == testo)
			{
				div.innerHTML = testo2;
			}
			else
			{
				div.innerHTML = testo;				
			}
}

function chiudiAperti(id, idDaChiudere_interno, idDaChiudere_esterno, classe) {
			divAperto = getElementsByClassName(document, 'div', idDaChiudere_esterno);
			
			for(i=0; i<divAperto.length; i++)
			{
				divAperto = divAperto[i];
				bottone = divAperto.getAttribute('id');
				// RICORDATI CHE charAt(8) e charAt(9) SONO VALIDI SOLO SE L'ID DEL DIV E' DI 7 CARATTERI!!!!
				primacifra = bottone.charAt(8);
				secondacifra = bottone.charAt(9);
				terzacifra = bottone.charAt(10);
				cifra = primacifra + secondacifra + terzacifra;
				if (cifra != id)
				{
					r = jQuery('#'+idDaChiudere_interno+cifra);
					
					divAperto.className = classe;
					r.toggle(800);
				}
			}
		  }
		  	  

function chiudiAperti_toolbox(div) {
			
			for(i=1; i<=6; i++)
			{
				if(div)
				{
					if (i != div)
					{
						r = document.getElementById('_'+i);
						if(r){
							if(r.style.display == 'block') {
								r = jQuery('#_'+i);
								r.toggle(800);
								if (i == 1)
								{
									e = document.getElementById('calendario');
									e.className = 'calendario';
								}
								if (i == 2)
								{
									e = document.getElementById('faq');
									e.className = 'faq';
								}
								if (i == 3)
								{
									e = document.getElementById('sondaggi');
									e.className = 'sondaggi';
								}
								if (i == 4)
								{
									e = document.getElementById('links');
									e.className = 'links';
								}
								if (i == 5)
								{
									e = document.getElementById('archivio');
									e.className = 'archivio';
								}
								if (i == 6)
								{
									e = document.getElementById('glossario');
									e.className = 'glossario';
								}
							}
						}
					}
				}
				else
				{
						r = document.getElementById('_'+i);
						if(r){
							if(r.style.display == 'block') {
								r = jQuery('#_'+i);
								r.toggle(800);
								if (i == 1)
								{
									e = document.getElementById('calendario');
									e.className = 'calendario';
								}
								if (i == 2)
								{
									e = document.getElementById('faq');
									e.className = 'faq';
								}
								if (i == 3)
								{
									e = document.getElementById('sondaggi');
									e.className = 'sondaggi';
								}
								if (i == 4)
								{
									e = document.getElementById('links');
									e.className = 'links';
								}
								if (i == 5)
								{
									e = document.getElementById('archivio');
									e.className = 'archivio';
								}
								if (i == 6)
								{
									e = document.getElementById('glossario');
									e.className = 'glossario';
								}
							}
						}
				}
			}
		  }
		  

function chiudiAperti_faq(div,num,index) {

			for(i=1; i<=num; i++)
			{
				if (index != i)
				{
					r = document.getElementById('risposta'+div+i);
					if(r)
					{
						if (r.style.display == 'block') 
						{
							r = jQuery('#risposta'+div+i);
							r.toggle(800);
						}
					}
				}
			}
}
					
		  
function chiudiAperti_link(div,num) {

			for(i=1; i<=num; i++)
			{
				if (i != div)
				{
					r = document.getElementById('link'+i);
					if(r){
						if(r.style.display == 'block') {
							r = jQuery('#link'+i);
							r.toggle(800);
						}
					}
				}
			}
		  }
		  
function chiudiAperti_archivio(div,num) {

			for(i=1; i<=num; i++)
			{
				if (i != div)
				{
					r = document.getElementById('docman'+i);
					if(r){
						if(r.style.display == 'block') {
							r = jQuery('#docman'+i);
							r.toggle(800);
						}
					}
				}
			}
		  }

function chiudiAperti_generico() {

			for(i=0; i<=500; i++)
			{
					r = document.getElementById('docman'+i);
					if(r){
						if(r.style.display == 'block') {
							r = jQuery('#docman'+i);
							r.toggle(800);
						}
					}
					s = document.getElementById('risposta'+i);
					if(s){
						if(s.style.display == 'block') {
							s = jQuery('#risposta'+i);
							s.toggle(800);
						}
					}
					l = document.getElementById('link'+i);
					if(l){
						if(l.style.display == 'block') {
							l = jQuery('#link'+i);
							l.toggle(800);
						}
					}
					loghi = document.getElementById('loghi_'+i);
					if(loghi){
						if(loghi.style.display == 'block') {
							loghi = jQuery('#loghi_'+i);
							loghi.toggle(800);
							bottone = document.getElementById('bottone_'+i);
							if(bottone) {
								if(bottone.className == "blocco-categoria-clienti-aperto") {
									classe = "blocco-categoria-clienti";
								} else {
									classe = "blocco-categoria-clienti-aperto";
								}
								bottone.className = classe;
							}
						}
					}
			}
			h = document.getElementById("search");
			if(h)
			{
				h.value = '';	
			}
			k = document.getElementById("risultati");
			if(k)
			{
				k.value = '';	
			}

}




function addbookmark(link, title){

	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, link, "");
	} 
	else if( window.external ){
		window.external.AddFavorite(link,title);
	}
}

function disableAll() {
	if ($('ad_nessuntitolo').checked==true)
	{
		document.getElementById('ad_livellodistudiuno').disabled='disabled'; 
		document.getElementById("ad_livellodistudiuno").setAttribute("mosreq","0") 
		document.getElementById('ad_livellodistudidue').disabled='disabled';
		document.getElementById("ad_livellodistudidue").setAttribute("mosreq","0") 
		document.getElementById('ad_livellodistuditre').disabled='disabled';
		document.getElementById("ad_livellodistuditre").setAttribute("mosreq","0") 
		document.getElementById('ad_livellodistudiquattro').disabled='disabled';
		document.getElementById("ad_livellodistudiquattro").setAttribute("mosreq","0") 
		document.getElementById('ad_livellodistudicinque').disabled='disabled';
		document.getElementById("ad_livellodistudicinque").setAttribute("mosreq","0") 

		document.getElementById('ad_specializzazioneuno').disabled='disabled'; 
		document.getElementById('ad_specializzazionedue').disabled='disabled';
		document.getElementById('ad_specializzazionetre').disabled='disabled';
		document.getElementById('ad_specializzazionequattro').disabled='disabled';
		document.getElementById('ad_specializzazionecinque').disabled='disabled';			
		document.getElementById('ad_statostudiuno').disabled='disabled'; 
		document.getElementById("ad_statostudiuno").setAttribute("mosreq","0") 
		document.getElementById('ad_statostudidue').disabled='disabled';
		document.getElementById("ad_statostudidue").setAttribute("mosreq","0") 
		document.getElementById('ad_statostuditre').disabled='disabled';
		document.getElementById("ad_statostuditre").setAttribute("mosreq","0") 
		document.getElementById('ad_statostudiquattro').disabled='disabled';
		document.getElementById("ad_statostudiquattro").setAttribute("mosreq","0") 
		document.getElementById('ad_statostudicinque').disabled='disabled';			
		document.getElementById("ad_statostudicinque").setAttribute("mosreq","0") 
		document.getElementById('ad_titolo').disabled='disabled'; 
		document.getElementById('ad_titolodue').disabled='disabled';
		document.getElementById('ad_titolotre').disabled='disabled';
		document.getElementById('ad_titoloquattro').disabled='disabled';
		document.getElementById('ad_titolocinque').disabled='disabled';			
		document.getElementById('ad_centrostudiuno').disabled='disabled'; 
		document.getElementById('ad_centrostudidue').disabled='disabled';
		document.getElementById('ad_centrostuditre').disabled='disabled';
		document.getElementById('ad_centrostudiquattro').disabled='disabled';
		document.getElementById('ad_centrostudicinque').disabled='disabled';
		document.getElementById('ad_datainiziostudiuno_Day_ID').disabled='disabled'; 
		document.getElementById('ad_datainiziostudidue_Day_ID').disabled='disabled';
		document.getElementById('ad_datainiziostuditre_Day_ID').disabled='disabled';
		document.getElementById('ad_datainiziostudiquattro_Day_ID').disabled='disabled';
		document.getElementById('ad_datainiziostudicinque_Day_ID').disabled='disabled';
		document.getElementById('ad_datafinestudiuno_Day_ID').disabled='disabled'; 
		document.getElementById('ad_datafinestudidue_Day_ID').disabled='disabled';
		document.getElementById('ad_datafinestuditre_Day_ID').disabled='disabled';
		document.getElementById('ad_datafinestudiquattro_Day_ID').disabled='disabled';
		document.getElementById('ad_datafinestudicinque_Day_ID').disabled='disabled';	
		document.getElementById('ad_datainiziostudiuno_Month_ID').disabled='disabled'; 
		document.getElementById('ad_datainiziostudidue_Month_ID').disabled='disabled';
		document.getElementById('ad_datainiziostuditre_Month_ID').disabled='disabled';
		document.getElementById('ad_datainiziostudiquattro_Month_ID').disabled='disabled';
		document.getElementById('ad_datainiziostudicinque_Month_ID').disabled='disabled';
		document.getElementById('ad_datafinestudiuno_Month_ID').disabled='disabled'; 
		document.getElementById('ad_datafinestudidue_Month_ID').disabled='disabled';
		document.getElementById('ad_datafinestuditre_Month_ID').disabled='disabled';
		document.getElementById('ad_datafinestudiquattro_Month_ID').disabled='disabled';
		document.getElementById('ad_datafinestudicinque_Month_ID').disabled='disabled';		
		document.getElementById('ad_datainiziostudiuno_Year_ID').disabled='disabled'; 
		document.getElementById('ad_datainiziostudidue_Year_ID').disabled='disabled';
		document.getElementById('ad_datainiziostuditre_Year_ID').disabled='disabled';
		document.getElementById('ad_datainiziostudiquattro_Year_ID').disabled='disabled';
		document.getElementById('ad_datainiziostudicinque_Year_ID').disabled='disabled';
		document.getElementById('ad_datafinestudiuno_Year_ID').disabled='disabled'; 
		document.getElementById('ad_datafinestudidue_Year_ID').disabled='disabled';
		document.getElementById('ad_datafinestuditre_Year_ID').disabled='disabled';
		document.getElementById('ad_datafinestudiquattro_Year_ID').disabled='disabled';
		document.getElementById('ad_datafinestudicinque_Year_ID').disabled='disabled';				
		document.getElementById('ad_votouno').disabled='disabled'; 
		document.getElementById('ad_votodue').disabled='disabled';
		document.getElementById('ad_vototre').disabled='disabled';
		document.getElementById('ad_votoquattro').disabled='disabled';
		document.getElementById('ad_votocinque').disabled='disabled';														
	}
	else
	{
		document.getElementById('ad_livellodistudiuno').disabled=''; 
		document.getElementById("ad_livellodistudiuno").setAttribute("mosreq","1") 

		document.getElementById('ad_livellodistudidue').disabled='';
//		document.getElementById("ad_livellodistudidue").setAttribute("mosreq","1") 

		document.getElementById('ad_livellodistuditre').disabled='';
//		document.getElementById("ad_livellodistuditre").setAttribute("mosreq","1") 

		document.getElementById('ad_livellodistudiquattro').disabled='';
//		document.getElementById("ad_livellodistudiquattro").setAttribute("mosreq","1") 

		document.getElementById('ad_livellodistudicinque').disabled='';
//		document.getElementById("ad_livellodistudicinque").setAttribute("mosreq","1") 

		document.getElementById('ad_specializzazioneuno').disabled=''; 
		document.getElementById('ad_specializzazionedue').disabled='';
		document.getElementById('ad_specializzazionetre').disabled='';
		document.getElementById('ad_specializzazionequattro').disabled='';
		document.getElementById('ad_specializzazionecinque').disabled='';			
		document.getElementById('ad_statostudiuno').disabled=''; 
		document.getElementById("ad_statostudiuno").setAttribute("mosreq","1") 

		document.getElementById('ad_statostudidue').disabled='';
	//	document.getElementById("ad_statostudidue").setAttribute("mosreq","1") 

		document.getElementById('ad_statostuditre').disabled='';
//		document.getElementById("ad_statostuditre").setAttribute("mosreq","1") 

		document.getElementById('ad_statostudiquattro').disabled='';
//		document.getElementById("ad_statostudiquattro").setAttribute("mosreq","1") 

		document.getElementById('ad_statostudicinque').disabled='';			
	//	document.getElementById("ad_statostudicinque").setAttribute("mosreq","1") 

		document.getElementById('ad_titolo').disabled=''; 
		document.getElementById('ad_titolodue').disabled='';
		document.getElementById('ad_titolotre').disabled='';
		document.getElementById('ad_titoloquattro').disabled='';
		document.getElementById('ad_titolocinque').disabled='';			
		document.getElementById('ad_centrostudiuno').disabled=''; 
		document.getElementById('ad_centrostudidue').disabled='';
		document.getElementById('ad_centrostuditre').disabled='';
		document.getElementById('ad_centrostudiquattro').disabled='';
		document.getElementById('ad_centrostudicinque').disabled='';
		document.getElementById('ad_datainiziostudiuno_Day_ID').disabled=''; 
		document.getElementById('ad_datainiziostudidue_Day_ID').disabled='';
		document.getElementById('ad_datainiziostuditre_Day_ID').disabled='';
		document.getElementById('ad_datainiziostudiquattro_Day_ID').disabled='';
		document.getElementById('ad_datainiziostudicinque_Day_ID').disabled='';
		document.getElementById('ad_datafinestudiuno_Day_ID').disabled=''; 
		document.getElementById('ad_datafinestudidue_Day_ID').disabled='';
		document.getElementById('ad_datafinestuditre_Day_ID').disabled='';
		document.getElementById('ad_datafinestudiquattro_Day_ID').disabled='';
		document.getElementById('ad_datafinestudicinque_Day_ID').disabled='';	
		document.getElementById('ad_datainiziostudiuno_Month_ID').disabled=''; 
		document.getElementById('ad_datainiziostudidue_Month_ID').disabled='';
		document.getElementById('ad_datainiziostuditre_Month_ID').disabled='';
		document.getElementById('ad_datainiziostudiquattro_Month_ID').disabled='';
		document.getElementById('ad_datainiziostudicinque_Month_ID').disabled='';
		document.getElementById('ad_datafinestudiuno_Month_ID').disabled=''; 
		document.getElementById('ad_datafinestudidue_Month_ID').disabled='';
		document.getElementById('ad_datafinestuditre_Month_ID').disabled='';
		document.getElementById('ad_datafinestudiquattro_Month_ID').disabled='';
		document.getElementById('ad_datafinestudicinque_Month_ID').disabled='';		
		document.getElementById('ad_datainiziostudiuno_Year_ID').disabled=''; 
		document.getElementById('ad_datainiziostudidue_Year_ID').disabled='';
		document.getElementById('ad_datainiziostuditre_Year_ID').disabled='';
		document.getElementById('ad_datainiziostudiquattro_Year_ID').disabled='';
		document.getElementById('ad_datainiziostudicinque_Year_ID').disabled='';
		document.getElementById('ad_datafinestudiuno_Year_ID').disabled=''; 
		document.getElementById('ad_datafinestudidue_Year_ID').disabled='';
		document.getElementById('ad_datafinestuditre_Year_ID').disabled='';
		document.getElementById('ad_datafinestudiquattro_Year_ID').disabled='';
		document.getElementById('ad_datafinestudicinque_Year_ID').disabled='';		
		document.getElementById('ad_votouno').disabled=''; 
		document.getElementById('ad_votodue').disabled='';
		document.getElementById('ad_vototre').disabled='';
		document.getElementById('ad_votoquattro').disabled='';
		document.getElementById('ad_votocinque').disabled='';		
	}
}



function NessunaEsperienza() {
	if ($('n_eps').checked==true)
	{
		document.getElementById('ad_gradodiesperienzauno').disabled='disabled'; 
		document.getElementById("ad_gradodiesperienzauno").setAttribute("mosreq","0") 
		document.getElementById('ad_gradodiesperienzaunoazienda').disabled='disabled';
		document.getElementById("ad_gradodiesperienzaunoazienda").setAttribute("mosreq","0") 
		document.getElementById('ad_gradodiesperienzaunosettore').disabled='disabled';
		document.getElementById("ad_gradodiesperienzaunosettore").setAttribute("mosreq","0") 
		document.getElementById('ad_gradodiesperienzaunoposizione').disabled='disabled';
		document.getElementById("ad_gradodiesperienzaunoposizione").setAttribute("mosreq","0") 
		document.getElementById('ad_gradodiesperienzaunolocalita').disabled='disabled';
		document.getElementById("ad_gradodiesperienzaunolocalita").setAttribute("mosreq","0") 
		document.getElementById('ad_gradodiesperienzaunodatainizio_Month_ID').disabled='disabled'; 
		document.getElementById('ad_gradodiesperienzaunodatainizio_Year_ID').disabled='disabled'; 
		document.getElementById('ad_gradodiesperienzaunodatafine_Month_ID').disabled='disabled'; 
		document.getElementById('ad_gradodiesperienzaunodatafine_Year_ID').disabled='disabled'; 
		document.getElementById('276').style.display="none";  

		
	}
	else
	{
		document.getElementById('ad_gradodiesperienzauno').disabled=''; 
		document.getElementById("ad_gradodiesperienzauno").setAttribute("mosreq","0") 
		document.getElementById('ad_gradodiesperienzaunoazienda').disabled='';
		document.getElementById("ad_gradodiesperienzaunoazienda").setAttribute("mosreq","1") 
		document.getElementById('ad_gradodiesperienzaunosettore').disabled='';
		document.getElementById("ad_gradodiesperienzaunosettore").setAttribute("mosreq","1") 
		document.getElementById('ad_gradodiesperienzaunoposizione').disabled='';
		document.getElementById("ad_gradodiesperienzaunoposizione").setAttribute("mosreq","1") 
		document.getElementById('ad_gradodiesperienzaunolocalita').disabled='';
		document.getElementById("ad_gradodiesperienzaunolocalita").setAttribute("mosreq","0") 
		document.getElementById('ad_gradodiesperienzaunodatainizio_Month_ID').disabled=''; 
		document.getElementById('ad_gradodiesperienzaunodatainizio_Year_ID').disabled=''; 
		document.getElementById('ad_gradodiesperienzaunodatafine_Month_ID').disabled=''; 
		document.getElementById('ad_gradodiesperienzaunodatafine_Year_ID').disabled=''; 
		document.getElementById('276').style.display="block";  
	}
}

