function reload_pages(str,id){
	if(str!=-1)
		document.location=str;
	if(id!=-1)
		top.document.all.MTracer.src="/../lib/tracer.asp?id="+id;
	
}

/*function controlla(){
	//alert();
   return true;
}*/


function invia(){
	if(controlla()){
		document.form_login.submit();
	}
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
		if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
			document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
		else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
	}
	MM_reloadPage(true);

function MM_findObj(n, d) { //v4.01
		var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
		  d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
		if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
		for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
		if(!x && d.getElementById) x=d.getElementById(n); return x;
	}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function change_color_hex(val,form){
	if(val==1){
		var colore_hex=form.color1_hide.value;
		if(colore_hex.length==6){
			red=parseInt(colore_hex.substr(0,2),16);
			green=parseInt(colore_hex.substr(2,2),16);
			blue=parseInt(colore_hex.substr(4,2),16);
			red=red.toString(10);
			green=green.toString(10);
			blue=blue.toString(10);
			if(!isNaN(red) && !isNaN(green) && !isNaN(blue) && colore_hex.length==6){
				form.colore1_r.value=red;
				form.colore1_g.value=green;
				form.colore1_b.value=blue;
				change_color(1,form);
			}else{
				alert("Attenzione: colore non valido!");
			}
		}
	}else{
		var colore_hex=form.color2_hide.value;
		if(colore_hex.length==6){
			red=parseInt(colore_hex.substr(0,2),16);
			green=parseInt(colore_hex.substr(2,2),16);
			blue=parseInt(colore_hex.substr(4,2),16);
			red=red.toString(10);
			green=green.toString(10);
			blue=blue.toString(10);
			if(!isNaN(red) && !isNaN(green) && !isNaN(blue) && colore_hex.length==6){
				form.colore2_r.value=red;
				form.colore2_g.value=green;
				form.colore2_b.value=blue;
				change_color(2,form);
			}else{
				alert("Attenzione: colore non valido!");
			}
		}
	}
}

function change_color(val,form){
	if(val==1){
		if((form.colore1_r.value.length>=1)&&(form.colore1_g.value.length>=1)&&(form.colore1_b.value.length>=1)){
			var int_red=parseInt(form.colore1_r.value);
			var int_green=parseInt(form.colore1_g.value);
			var int_blue=parseInt(form.colore1_b.value);
			if ((int_red>=0 && int_red<256)&&(int_green>=0 && int_green<256)&&(int_blue>=0 && int_blue<256)){
				if(int_red!=0)
					var red=int_red.toString(16);
				else var red="00";
				if(int_green!=0)
					var green=int_green.toString(16);
				else var green="00";
				if(int_blue!=0)
					var blue=int_blue.toString(16);
				else var blue="00";
				if(red.length==1)
					red="0"+red;
				if(green.length==1)
					green="0"+green
				if(blue.length==1)
					blue="0"+blue;
				var colore=red+green+blue;
				document.getElementById("colore_1").style.backgroundColor="#"+colore;
				document.getElementById("scroll_color_Ar").scrollLeft=int_red;
				document.getElementById("scroll_color_Ag").scrollLeft=int_green;
				document.getElementById("scroll_color_Ab").scrollLeft=int_blue;
				form.color1_hide.value=colore;
			}else{
				if(int_red<0 || int_red>255)
					form.colore1_r.value="";
				if(int_green<0 || int_green>255)
					form.colore1_g.value="";
				if(int_blue<0 || int_blue>255)
					form.colore1_b.value="";
			}
		}else{
			document.getElementById("colore_1").style.backgroundColor="#000000";
			form.color1_hide.value="000000";
		}
	}else{
		if((form.colore2_r.value.length>=1)&&(form.colore2_g.value.length>=1)&&(form.colore2_b.value.length>=1)){				
			var int_red=parseInt(form.colore2_r.value);
			var int_green=parseInt(form.colore2_g.value);
			var int_blue=parseInt(form.colore2_b.value);
			if ((int_red>=0 && int_red<256)&&(int_green>=0 && int_green<256)&&(int_blue>=0 && int_blue<256)){
				if(int_red!=0)
					var red=int_red.toString(16);
				else var red="00";
				if(int_green!=0)
					var green=int_green.toString(16);
				else var green="00";
				if(int_blue!=0)
					var blue=int_blue.toString(16);
				else var blue="00";
				if(red.length==1)
					red="0"+red;
				if(green.length==1)
					green="0"+green
				if(blue.length==1)
					blue="0"+blue;
				var colore=red+green+blue;
				document.getElementById("colore_2").style.backgroundColor="#"+colore;
				document.getElementById("scroll_color_Br").scrollLeft=int_red;
				document.getElementById("scroll_color_Bg").scrollLeft=int_green;
				document.getElementById("scroll_color_Bb").scrollLeft=int_blue;
				form.color2_hide.value=colore;
			}else{
				if(int_red<0 || int_red>255)
					form.colore2_r.value="";
				if(int_green<0 || int_green>255)
					form.colore2_g.value="";
				if(int_blue<0 || int_blue>255)
					form.colore2_b.value="";
			}
		}else{
			document.getElementById("colore_2").style.backgroundColor="#000000";
			form.color2_hide.value="000000";
		}
	}
}

function menu_home(){
	
	struttura = document.getElementById("xmlMenu").XMLDocument;
	//disabilito i livelli con stato=0
	var tmpImg;
	var sezioni2;
	
	var sezioni=struttura.documentElement.selectNodes("section");
	for(i=0;i<sezioni.length;i++){
		//eval("tmpImg=document.img_"+sezioni(i).getAttribute("name")+".src");
		//eval("document.img_"+sezioni(i).getAttribute("name")+".src=tmpImg.substr(0,tmpImg.length-4)+'_gh.gif'");
		sezioni2=sezioni(i).selectNodes("section[@stato='0']");
		if(sezioni2.length>0){
			for(j=0;j<sezioni2.length;j++){
				if(eval("document.img_"+sezioni2(j).getAttribute("name"))){
					eval("tmpImg=document.img_"+sezioni2(j).getAttribute("name")+".src");
					eval("document.img_"+sezioni2(j).getAttribute("name")+".src=tmpImg.substr(0,tmpImg.length-4)+'_gh.gif'");
					eval("document.getElementById('a_"+sezioni2(j).getAttribute("name")+"').href='#'");
					eval("document.getElementById('a_"+sezioni2(j).getAttribute("name")+"').onmouseout=''");
					eval("document.getElementById('a_"+sezioni2(j).getAttribute("name")+"').onmouseover=''");
					eval("document.getElementById('a_"+sezioni2(j).getAttribute("name")+"').style.cursor='default'");
				}
			}
		}
	}
	
	//abilito i livelli con stato=1
	var sezioni_b=struttura.documentElement.selectNodes("section");
	for(i=0;i<sezioni_b.length;i++){
		//eval("tmpImg=document.img_"+sezioni(i).getAttribute("name")+".src");
		//eval("document.img_"+sezioni(i).getAttribute("name")+".src=tmpImg.substr(0,tmpImg.length-4)+'_gh.gif'");
		sezioni2=sezioni_b(i).selectNodes("section[@stato='1']");
		if(sezioni2.length>0){
			for(j=0;j<sezioni2.length;j++){
				if(eval("document.getElementById('a_"+sezioni2(j).getAttribute("name")+"')"))
					eval("document.getElementById('a_"+sezioni2(j).getAttribute("name")+"').href='"+sezioni2(j).getAttribute("link")+"'");
			}
		}
	}
}


////////////////////////////EDITOR HOME PAGE\\\\\\\\\\\\\\\\\\\\\\\\\\\\

function e_popUp(obj){
	var id = obj.id;
	window.open("e_pop/"+id, "popup", "width=400,height=400");
}

function replace_carat(stringa)
{
	var nuova_stringa = stringa.replace(/<P>/g,"");
	nuova_stringa = nuova_stringa.replace(/<\/P>/g,"");
	nuova_stringa = nuova_stringa.replace(/<P>&nbsp;<\/P>/g,"<BR>");
	nuova_stringa = nuova_stringa.replace(/<BR><BR>/g,"<BR>");
	return (nuova_stringa);
	
}

limite_titolo = 255;
limite = 3000;
limite_desc = 4000;









