/*

function IncludeJavaScript(jsFile)
{
  document.write('<script type="text/javascript" src="'
    + jsFile + '"></scr' + 'ipt>'); 
}

*/


		function findAndExpand(v1, v2, v3, tab, myTab) {
			if (myTab.length<=0) {
				return;
			}
			
			var n=0;
			/*
			recuperare id della 'pagina' a partire dalla descrizione, tale id sarà utilizzato per recuperare l'oggetto
			Root_ che indica l'albero in questione
			*/
			var i;
			for(i=0; i<myTab.length;i++) {
				
				if (myTab[i][1]==tab) {
					n=myTab[i][0];
					break;
				}
				
			}
			
			var root = eval("Root_"+n);
			
			if (root==null) {
				alert('Errore!');
				return;
			}
			
			
			//abilitare il tab corretto
			//var myTab=[['1','Links','doctab','1'], ['2','Offerte','smpltab','0']];
			var dd = myTab[i][3];
			$("#accordion1").accordion({
				active:		parseInt(dd)
			});
			
//			if (tab!=null && tab!='') {
//			 	try {
					//per explorer sempbra che non funzioni correttamente
//					a_tabbar.setTabActive(myTab[i][2]);
//				}
//				catch(err) {
					//alert(err.description);
//				}
//			}
			
			/*
			una volta recuperato l'oggetto root scorrere per espandere l'albero
			*/
			var x;
			if (v1!=null && v1!='') {
				for(var i=0; i<root.childNodes.length; i++) {
					if (root.childNodes[i].text==v1) {
						if (root.childNodes[i].folder) {
							root.childNodes[i].expand();
							setIcon(root.childNodes[i]);
							
							x = root.childNodes[i];
							
							if (v2!=null && v2!='') {
								for(var i=0; i<x.childNodes.length; i++) {
									if (x.childNodes[i].text==v2) {
										if (x.childNodes[i].folder) {
											x.childNodes[i].expand();
											setIcon(x.childNodes[i]);
											
											x = x.childNodes[i];
											
											//return;
										}
										else {
											//se non è folder potrebbe essere una foglia e quindi evidenziarla
											document.getElementById(x.childNodes[i].id + '-anchor').focus();
											
											return;
										
										}
										
									}
								}

							}
							
							
							//non è una folder ma una foglia sicuramente
							if (v3!=null && v3!='') {
								for(var i=0; i<x.childNodes.length; i++) {
									if (x.childNodes[i].text==v3) {
										//if (y.childNodes[i].folder) {
											
										z = x.childNodes[i];
										document.getElementById(z.id + '-anchor').focus();
										//document.getElementById(z.id + '-anchor').className = 'selected';
											
										return;
										
										//}
									}
								}
							}
							
							return;
						}
					}
				}
			}
			
		}
		
		
		function cerca() {
			document.links.submit();
		}

		function pulisci() {
			document.links.ricercaC.value="";
			document.links.ricercaS.value="";
			document.links.ricercaL.value="";
		}
		
		function expandLocal(x, l1, l2, l3, tab) {
			if (x.open) { x.collapse(); }
			else { 
				x.expand(); 
				
				setIcon(x);
			}
			
			setPath(l1, l2, l3, '', tab);
		}
		
		function setIcon(x) {
			for (var i = 0; i < x.childNodes.length; i++) {
			
				if (!x.childNodes[i].folder)
					if (x.childNodes[i].icon2!=null)
						document.getElementById(x.childNodes[i].id + '-icon').src = x.childNodes[i].icon2;
			}
		}


		function openFrame(url, l1, l2, l3, tab, tag) {
			window.frames.sampleframe.location.href = url;
			setPath(l1, l2, l3, url, tab);
			setTag(tag);
		}
		
		
		
		function openNewWindow(url) {
			window.open(url,'','top=50,left=50,height=500,width=900,status=yes,toolbar=yes,menubar=yes,location=yes,scrollbars=yes');
		}
		
		function setTag(tag) {
		
			if (tag!=null && tag!='') {
				var array = tag.split(',');
				
				link = "";
				for(i=0; i<array.length; i++) {
				
					if (array[i]!=null && array[i]!='') {
					
						var x = trim(array[i]);
					
						//#02285C
						link = link + "<a title=\"tag\" href=\"javascript:findTag('"+x+"');\"><b><font color=\"#A2A0A0\" face=\"Arial\" size=\"2\">"+x+"</font></b></a>&nbsp;";
					}
				
				}
				
				document.getElementById('tagContainer').innerHTML=link;
			}
			else {
				document.getElementById('tagContainer').innerHTML="&nbsp;";
			}
		}


		function setPath(value1, value2, value3, url, tab) {
			value="";
			value_="";
			//function expandLocal(x, l1, l2, l3, tab)
			
			if (tab!=null && tab!='' && tab!=' ') {
				value = tab + " - ";
				//value_ = "<font class=\"LblFieldBlack\" style=\"border: none; background-color: #45B5DA; color: #FFFFFF\">" + tab + " - " + "</font>";
				value_ = value_ + "<a href=\"javascript:expandChild('', '', '', '"+tab+"');\"  style=\"color: #FFFFFF\">"  + tab + "</a>" + 
				"<font style=\"color: #FFFFFF\">" + "  -  " + "</font>";
			}
			if (value1!=null && value1!='' && value1!=' ') {
				value = value + value1;
				value_ = value_ + "<a href=\"javascript:expandChild('"+value1+"', '', '', '"+tab+"');\" style=\"color: #FFFFFF\">" + value1 + "</a>";
				if (value2!=null && value2!='' && value2!=' ') {
					value = value + " -> " + value2;
					value_ = value_ + 
						"<font style=\"color: #FFFFFF\">" + "  ->  " + "</font>" +
						"<a href=\"javascript:expandChild('"+value1+"', '"+value2+"', '', '"+tab+"');\" style=\"color: #FFFFFF\">" + value2 + "</a>";
				}
				if (value3!=null && value3!='' && value3!=' ') {
					value = value + " -> " +value3;
					value_ = value_ +
					"<font style=\"color: #FFFFFF\">" + "  ->  " + "</font>" +
					"<a href=\"javascript:expandChild('"+value1+"', '"+value2+"', '"+value3+"', '"+tab+"');\" style=\"color: #FFFFFF\">" + value3 + "</a>";
				}
				
				if (url!=null && url!='' && url!=' ') {
					value = value + " -> " + url;
					value_ = value_ + "<font style=\"color: #FFFFFF\">" +"  ->  " + url+ "</font>";
				}
			}
			
			//document.links.path.value=value;
			
			//document.getElementById("pathToolbar").innerHTML="vvvv";
			
			document.getElementById("pathToolbar").innerHTML=value_;
			//document.getElementByName("path").innerHTML="ciao";
		}


		function avanti() {
			window.frames.sampleframe.history.forward();
		}
		
		function indietro() {
			
			//window.frames.sampleframe.callM(); 
			window.frames.sampleframe.history.back();		
			/*
			d = document;
			f = d.frames ? d.frames['sampleframe'] : d.getElementById('sampleframe');
			p = f.document || f.contentWindow.document;
			p.callM();
			*/
		
			//document.getElementById('sampleframe').contentWindow.callM();
			//window.frames.sampleframe.callM();
			//window.frames.sampleframe.history.back();
		}
		
		function trim(str, chars) {
			return ltrim(rtrim(str, chars), chars);
		}
		 
		function ltrim(str, chars) {
			chars = chars || "\\s";
			return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
		}
		 
		function rtrim(str, chars) {
			chars = chars || "\\s";
			return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
		}		


/* 
In una struttura a frames può apparire difficile caricare il contenuto di un link nella sezione appropriata. Grazie all’attributo target possiamo specificare qual'è la destinazione del link; con questa sintassi siamo dunque in 
grado di caricare il contenuto di un collegamento nel riquadro che riteniamo più opportuno:
<a href=”paginaDaLinkare.html” target=”nomeDelFrame”>
come si può vedere nell’esempio.
ci sono poi delle “parole chiave” che ci consentono di ricaricare i link in destinazioni predefinite:
target=”_blank”
Apre il link in una nuova finestra, senza nome
L'esempio è qui
target=”_self”
Apre il link nel frame stesso (è così di default) L'esempio è qui
target=”_parent”
Il documento viene caricato nel frameset precedente a quello corrente (più esattamente nel frame genitore)
L'esempioè qui
Il comportamento di “_parent” è particolarmente evidente in una struttura annidata in cui alcune pagine HTML contengono a loro volta dei frameset, come nell’esempio: in questo caso viene caricato il contenuto del link nel frameset immediatamente precedente alla pagina del link.
target=”_top”
Il documento viene caricato nella finestra originale, cancellando ogni struttura a frame.
L'esempio è qui
(si noti la differenza con “_parent”).
Più esattamente il documento viene carictao nella parte piùalta ("top") della struttura, ed è questo il motivoper cui il frameset stesso viene annullato e sostituito dal contenutodel link.
Può essere noioso specificare per tutti i link il target appropriato. Ci viene in aiuto allora il tag <base> che ci consente di specificare la destinazione dei tutti link in una sola volta. Il tag va inserito nella pagina contenente i link. Ad esempio:
<base target=”_blank”> 
*/


		
		
		
		//      myLinks ***************
		
		function gestisciDisabilitazione() {
			var c = "ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only";
			var d = "ui-button ui-widget ui-state-disabled ui-corner-all ui-button-text-only";
			var arr = document.getElementsByTagName("button");
			for (i = 0; i < arr.length; i++) {
				if (arr[i].className == c) { 
					arr[i].className = d
				}
			}
		}
		

		function disableField() {
			document.formMyLinks.name.disabled=true;
			document.formMyLinks.password.disabled=true;
			document.formMyLinks.email.disabled=true;
			document.formMyLinks.name.value='';
			document.formMyLinks.password.value='';
			document.formMyLinks.email.value='';
		}
		
		function enableField() {
			document.formMyLinks.name.disabled=false;
			document.formMyLinks.password.disabled=false;
			document.formMyLinks.email.disabled=false;
			document.formMyLinks.name.value='';
			document.formMyLinks.password.value='';
			document.formMyLinks.email.value='';
		}
		
		function azzera() {
			myLinks.remove();
			
			myLinks = new WebFXTreeItem('MyLinks', 'javascript:myLinksFunctionT();', '','','', '', '');
			Root.add(myLinks);
			document.getElementById(myLinks.id + '-icon').src = 'codebase/ico/Tuttolink.ico';
		}
	
		function aggiungi(titolo, http, chiave, descrizione, id) {
			//var mm = new WebFXTreeItem(titolo, 'javascript:openFrame(\''+http+'\', \'MyLinks\', \''+titolo+'\', \'\', \'Links\', \''+chiave+'\');', ''+http+'',''+descrizione+'','', '', '');
			//myLinks.add(mm);
			eval("mm"+id+" = new WebFXTreeItem(titolo, \"javascript:openFrame('"+http+"', 'MyLinks', '"+titolo+"', '', 'Links', '"+chiave+"');\", '"+http+"','"+descrizione+"','', '', '')");
			eval("myLinks.add(mm"+id+")");
		}
		
		function removeMyLink(ob) {
			eval(ob+".remove();");
		}
		
		
