/*
NON CANCELLARE!
Questo è il file onloadAll personalizzato per la sezione Montagna e Foreste
*/

/*
====================================================================
=========== LIBRERIA FUNZIONI JAVASCRIPT SISTEMAPIEMONTE ===========
Versione: 1.0
Data aggiornamento: gg/mm/aaaa
Manutentore: ???

Note: le funzioni seguenti sono condivise tra tutti i servizi di
SistemaPiemonte e pertanto dovranno essere validate dal gruppo di
sviluppatori XHTML/CSS2 e programmatori. Il file è diviso in due
parti: nella prima c'è la libreria di funzioni consolidate, nella
seconda il richiamo alle stesse e la creazione di una funzione
concatenante.
====================================================================
/*



/*
========== FUNZIONI PER APERTURE NUOVE FINESTRE E POPUP ============
*/


// Apertura finestra con parametri nel codice xhtml ////////////////

function MM_openBrWindow (theURL,winName,features) {
window.open(theURL,winName,features);
}


// Apertura finestra per link esterni (nome finestra variabile) ////////////////

function apri(file)
    {
var prop = "toolbar=yes,location=yes, directories=yes, status=yes, menuBar=yes, scrollbars=yes, resizable=yes, width=800, height=600, top=0, left=0";
var ran_unrounded=Math.random()*1000;
var ran_number=Math.round(ran_unrounded);
       newwin = window.open(file,'finestra'+ran_number,prop);
       newwin.focus();
 return false;
    }

		
// Apertura finestra per link esterni (nome finestra fisso) ////////////////

 function aprifinestra(file)
    {
 var prop = "toolbar=yes,location=yes, directories=yes, status=yes, menuBar=yes, scrollbars=yes, resizable=yes, width=800, height=600, top=0, left=0";
       newwin = window.open(file,'finestra',prop);
       newwin.focus();
 return false;
    }

	
// Apertura finestra per contatti ////////////////

 function apricontatti(file)
    {
 var prop = "toolbar=no,location=no, directories=no, status=no, menuBar=no, scrollbars=no, resizable=no, width=510, height=260";
       newwin = window.open(file,'contatti',prop);
       newwin.focus();
 return false;
    }


// Apertura finestra per help con scroll da css ////////////////

 function aprihelp(file)
    {
 var prop = "toolbar=no,location=no, directories=no, status=no, menuBar=no, scrollbars=no, resizable=no, width=780, height=475";
       newwin = window.open(file,'help',prop);
       newwin.focus();
 return false;
    }


// Apertura finestra per help con scroll su finestra ////////////////
 function aprihelpwin(file)
    {
 var prop = "screenX=0,screenY=0,toolbar=no,location=no, directories=no, status=no, menuBar=no, scrollbars=yes, resizable=yes, width=780, height=475";
       newwin = window.open(file,'helpwin',prop);
       newwin.focus();
 return false;
    }

	
// Apertura finestra per credits ////////////////

 function apricredits(file)
    {
 var prop = "toolbar=no,location=no, directories=no, status=no, menuBar=no, scrollbars=no, resizable=yes, width=600, height=250";
       newwin = window.open(file,'credits',prop);
       newwin.focus();
 return false;
    }


// Apertura finestra per glossario con scroll su finestra ////////////////
 function apriglossario(file)
    {
 var prop = "toolbar=no,location=no, directories=no, status=no, menuBar=no, scrollbars=yes, resizable=yes, width=736, height=402";
       newwin = window.open(file,'glossario',prop);
       newwin.focus();
 return false;
    }


/* FUNZIONE NEW 2 */

function apri_new() { 
var prop="toolbar=yes,location=yes, directories=yes, status=yes, menuBar=yes, scrollbars=yes, resizable=yes, width=800, height=600, top=0, left=0";
var dimensione = 'apri'; apri_url(prop, dimensione); }
 
function apricontatti_new() {
var prop = "toolbar=no,location=no, directories=no, status=no, menuBar=no, scrollbars=no, resizable=no, width=510, height=260";	
var dimensione = 'apricontatti'; apri_url(prop, dimensione); }	

function aprihelp_new() {
var prop = "toolbar=no,location=no, directories=no, status=no, menuBar=no, scrollbars=no, resizable=no, width=780, height=475";	
var dimensione = 'aprihelp'; apri_url(prop, dimensione); }	

function aprihelpwin_new() {
var prop = "screenX=0,screenY=0,toolbar=no,location=no, directories=no, status=no, menuBar=no, scrollbars=yes, resizable=yes, width=780, height=475";	
var dimensione = 'aprihelpwin'; apri_url(prop, dimensione); }

function apricredits_new() {
var prop = "screenX=0,screenY=0,toolbar=no,location=no, directories=no, status=no, menuBar=no, scrollbars=yes, resizable=yes, width=600, height=250";	
var dimensione = 'apricredits'; apri_url(prop, dimensione); }

function apriglossario_new() {
var prop = "screenX=0,screenY=0,toolbar=no,location=no, directories=no, status=no, menuBar=no, scrollbars=yes, resizable=yes, width=736, height=402";	
var dimensione = 'apriglossario'; apri_url(prop, dimensione); }

function aprifaq_new() {
var prop = "screenX=0,screenY=0,toolbar=no,location=no, directories=no, status=no, menuBar=no, scrollbars=yes, resizable=yes, width=736, height=402";	
var dimensione = 'aprifaq'; apri_url(prop, dimensione); }

function apri_url(prop, dimensione) { 
a = document.getElementsByTagName('a');
for(i=0;a[i];i++) if(a[i].className == dimensione) 
{	
if(a[i].title) {a[i].title += ""; }
else { if (!a[i].textContent) {a[i].title = a[i].innerText + " - Attenzione: questo link si apre in una nuova finestra"} else {a[i].title = a[i].textContent + " - Attenzione: questo link si apre in una nuova finestra";}}
a[i].title = a[i].title + "";
a[i].onclick = function () {window.open(this.href, '_blank',prop);return false;};
a[i].onkeypress = function (e) {k = (e) ? e.keyCode : window.event.keyCode; if(k==13) 
{window.open(this.href,'_blank',prop); return false;}
}}}


/*
=====(FINE)===== FUNZIONI PER APERTURE NUOVE FINESTRE E POPUP ============
*/




/*
========== FUNZIONI VARIE ============
*/
		

// JavaScript per la gestione di overOutHandler solo su Internet Explorer.
// A causa di un bug grafico su Opera è stata gestita la funzione in modo 
// che non venga processata da Opera e Browser Gecko.


 function overOutHandler(obj, styleClassName)
 {
   if (navigator.appName=='Microsoft Internet Explorer')
    { obj.className=styleClassName; }
 }




/*
========== FUNZIONI PER LA GESTIONE DI TOOLTIP ============
*/


function enableTooltips(){
var links=document.getElementsByTagName("label");
for(i=0;i<links.length;i++){
    var t=links[i].getAttribute("title");
	if (!t) {   
    }
	else {
	if(t!=""){
        links[i].removeAttribute("title");
        links[i].style.position="relative";
		var tooltip=document.createElement("strong");
        tooltip.className="tooltip";
        tooltip.style.display="none";
        tooltip.appendChild(document.createTextNode(t));
        links[i].appendChild(tooltip);
        links[i].onmouseover=showTooltip;
        links[i].onmouseout=hideTooltip;
        }
	}
	}
}

function showTooltip(event){
    //this.style.zIndex="100000";
    this.getElementsByTagName("strong")[0].style.display="block";
    }

function hideTooltip(event){
    this.style.zIndex="0";
    this.getElementsByTagName("strong")[0].style.display="none";
    } 
    
/*
=====(FINE)===== FUNZIONI PER LA GESTIONE DI TOOLTIP ============
*/





/*
========== FUNZIONI PER LA GESTIONE DI BOX A SCOMPARSA ============
*/


// visualizza e nascondi
function add_spanLink(){
	var el = document.getElementsByTagName("span");
	var link = new Array(); 
    var text = new Array();    
	for(i=0;el[i];i++) {
		if(el[i].id){
			var divTarget = spantoDiv(el[i]);
			//alert(el[i].firstChild.nextSibling);
			if(el[i].firstChild.nextSibling == null){
				link[i] = document.createElement("a");
				link[i].setAttribute("href","#");
				link[i].setAttribute("id","link_"+el[i].id);
				
				if(divTarget.style.display != 'none'){
					text[i] = document.createTextNode("nascondi elenco servizi");
					//link[i].setAttribute("class","nascondi");
					link[i].className = "nascondi";
					
				}else{
					text[i] = document.createTextNode("visualizza elenco servizi");
					//link[i].setAttribute("class","visualizza");
					//alert(link[i].ClassName);
					link[i].className = "visualizza";
					//link[i].setAttribute("class","visualizza");
					//alert(link[i].ClassName);
				}
				link[i].appendChild(text[i]);
				el[i].appendChild(link[i]);
			}
		}
		
	}
}
function add_onClick(nomeclasse,tagtarget,callback) { 
	var el = document.getElementsByTagName(tagtarget);
	for(i=0;el[i];i++) {
		if(el[i].className == nomeclasse || nomeclasse == '*') 
		{
			el[i].onclick = function () {
				eval(callback);
				return false;
				};
		}	
	}
}
function invertTextLink(element,textlink){
			var id = element.id.replace("csilist_","");
			var link = document.getElementById("link_"+id);
			//link.removeChild(link.firstChild);
			//alert(link.firstChild);
			//var text = document.createTextNode(textlink);
			//link.appendChild(text);
			if(link.firstChild.nodeValue == 'visualizza elenco servizi'){
				link.className = "nascondi";
				//link.setAttribute("class","nascondi");
				link.firstChild.nodeValue = 'nascondi elenco servizi';
			}else{
				//link.setAttribute("class","visualizza");
				link.className = "visualizza";
				link.firstChild.nodeValue = 'visualizza elenco servizi';				
			}
}
function clickAndHide(element){
		//alert(divElement);
		if(element.style.display != 'none'){
			invertTextLink(element);
			element.style.display = 'none';
		}else{
			invertTextLink(element);
			element.style.display = 'block';
		}
}
function clickAndHideAll(element){
		myAutoHide("csilist_contenuti","div", true);
		if(element.style.display != 'none'){
			element.style.display = 'none';
		}else{
			element.style.display = 'block';
		}
}
function spantoDiv(element){
		return divElement = document.getElementById('csilist_' + element.id);
}
function cahImpl(element,callback){
		var elementTarget = spantoDiv(element);
		//clickAndHide(elementTarget);
		eval(callback+"(elementTarget);");
}
function myAutoHide(nomeclasse,tagtarget,all){
	
	var el = document.getElementsByTagName(tagtarget);
	for(i=0;el[i];i++) {
		var classe = el[i].className;
		//classe.length>0?alert(classe.indexOf('[0]')):false;
		if(el[i].className.indexOf(nomeclasse) == 0 && (el[i].className.indexOf("0")>0 || all == true))
		{
		//	alert(el[i].className);
			el[i].style.display = 'none';
		}	
	}
}


//vis nascondi faq


function add_dtLink(){
	var el = document.getElementsByTagName("dt");
	var link = new Array(); 
    var text = new Array();    
	for(i=0;el[i];i++) {
		if(el[i].id){
			var divTarget = dttoDiv(el[i]);
			//alert(el[i].firstChild.nextSibling);
			if(el[i].firstChild.nextSibling == null){
				link[i] = document.createElement("a");
				link[i].setAttribute("href","#");
				link[i].setAttribute("id","link_"+el[i].id);
				
				if(divTarget.style.display != 'none'){
					text[i] = document.createTextNode("chiudi");
					//link[i].setAttribute("class","chiudi");
					link[i].className = "chiudi";
					
				}else{
					text[i] = document.createTextNode("risposta");
					//link[i].setAttribute("class","risposta");
					//alert(link[i].ClassName);
					link[i].className = "risposta";
					//link[i].setAttribute("class","risposta");
					//alert(link[i].ClassName);
				}
				link[i].appendChild(text[i]);
				el[i].appendChild(link[i]);
			}
		}
		
	}
}
function add_onClick2(nomeclasse,tagtarget,callback) { 
	var el = document.getElementsByTagName(tagtarget);
	for(i=0;el[i];i++) {
		if(el[i].className == nomeclasse || nomeclasse == '*') 
		{
			el[i].onclick = function () {
				eval(callback);
				return false;
				};
		}	
	}
}
function invertTextLink2(element,textlink){
			var id = element.id.replace("csilist_","");
			var link = document.getElementById("link_"+id);
			//link.removeChild(link.firstChild);
			//alert(link.firstChild);
			//var text = document.createTextNode(textlink);
			//link.appendChild(text);
			if(link.firstChild.nodeValue == 'risposta'){
				link.className = "chiudi";
				//link.setAttribute("class","chiudi");
				link.firstChild.nodeValue = 'chiudi';
			}else{
				//link.setAttribute("class","risposta");
				link.className = "risposta";
				link.firstChild.nodeValue = 'risposta';				
			}
}
function clickAndHide2(element){
		//alert(divElement);
		if(element.style.display != 'none'){
			invertTextLink2(element);
			element.style.display = 'none';
		}else{
			invertTextLink2(element);
			element.style.display = 'block';
		}
}
function clickAndHideAll2(element){
		myAutoHide2("csilist_contenuti","dd", true);
		if(element.style.display != 'none'){
			element.style.display = 'none';
		}else{
			element.style.display = 'block';
		}
}
function dttoDiv(element){
		return divElement = document.getElementById('csilist_' + element.id);
}
function cahImpl2(element,callback){
		var elementTarget = dttoDiv(element);
		//clickAndHide(elementTarget);
		eval(callback+"(elementTarget);");
}
function myAutoHide2(nomeclasse,tagtarget,all){
	
	var el = document.getElementsByTagName(tagtarget);
	for(i=0;el[i];i++) {
		var classe = el[i].className;
		//classe.length>0?alert(classe.indexOf('[0]')):false;
		if(el[i].className.indexOf(nomeclasse) == 0 && (el[i].className.indexOf("0")>0 || all == true))
		{
		//	alert(el[i].className);
			el[i].style.display = 'none';
		}	
	}
}


/*
========== FUNZIONI PER LA GESTIONE DI PULSANTI FUNZIONALI ============
*/

//aggiunge il pulsante chiudi
function add_spanChiudi(){
	var el = document.getElementsByTagName("span");
	var link = new Array(); 
    var text = new Array();    
	var div = new Array(); 
	var div2 = new Array(); 
	for(i=0;el[i];i++) {
			if(el[i].className == 'chiudi'){
				//div2[i] = document.createElement("div");
				link[i] = document.createElement("a");
				link[i].setAttribute("href","#");
				link[i].setAttribute("rel","chiudi");
				link[i].onclick = function chiudi(){
													window.close();
													}
												;
				link[i].onkeypress = function chiudi(){
														window.close();
														}
													;
				text[i] = document.createTextNode("chiudi");
				link[i].appendChild(text[i]);
				//div2[i].appendChild(link[i]);
				el[i].appendChild(link[i]);
			}
	}
}
// aggiunge il pulsante stampa
function add_spanStampa(){
	var el = document.getElementsByTagName("span");
	var link = new Array(); 
    var text = new Array();    
	var div = new Array(); 
	var div2 = new Array(); 
	for(i=0;el[i];i++) {
			if(el[i].className == 'stampa'){
				//div[i] = document.createElement("div");
				link[i] = document.createElement("a");
				link[i].setAttribute("href","#");
				link[i].setAttribute("rel","stampa");
				link[i].onclick = function stampa(){
													window.print();
													}
												;
				link[i].onkeypress = function stampa(){
														window.print();
														}
													;
				text[i] = document.createTextNode("stampa");
				link[i].appendChild(text[i]);
				//div[i].appendChild(link[i]);
				el[i].appendChild(link[i]);
				
			}
	}
}

/*
========== FUNZIONI PER LA GESTIONE DI MENU ============
*/


function mmenu(mID) {
	if(mID) {
	var menu = document.getElementById(mID);
	var root = mID.substring(0, 9);
	var menuroot = document.getElementById(root);
	var display = menu.style.display;
	menuroot.style.display = "block";
	menu.style.display = (display == "block") ? "none" : "block";
     } 
}

function chiudiMenu() {
	var divs = document.getElementsByTagName("ul");
	for (i=0;i<divs.length;i++) {
		if(divs[i].getAttribute("class")=="submenu"){
			divs[i].style.display = "none";
		}
		if(divs[i].getAttribute("id") && divs[i].getAttribute("id").search("submenu-")!= -1){
			 divs[i].style.display = "none";
		}
	}
}

/*
=====(FINE)===== FUNZIONI PER LA GESTIONE DI MENU ============
*/


function chiudiMenu2() {
	var divs = document.getElementsByTagName("div");
	for (i=0;i<divs.length;i++) {
		if(divs[i].getAttribute("class")=="submenu"){
			divs[i].style.display = "none";
		}
		if(divs[i].getAttribute("id") && divs[i].getAttribute("id").search("submenu-")!= -1){
			 divs[i].style.display = "none";
		}
	}
}

/*
============= FUNZIONI PER ANGOLI ARROTONDATI ===============
*/


/* Nifty Corners Cube - rounded corners with CSS and Javascript
Copyright 2006 Alessandro Fulciniti (a.fulciniti@html.it)

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/


function AddCss(){
niftyCss=true;
var l=CreateEl("link");
l.setAttribute("type","text/css");
l.setAttribute("rel","stylesheet");
l.setAttribute("href","http://www.sistemapiemonte.it/ris/css/generaliV2/niftyCorners.css");
l.setAttribute("media","screen");
document.getElementsByTagName("head")[0].appendChild(l);
}

function Nifty(selector,options){
if(niftyOk==false) return;
if(niftyCss==false) AddCss();
var i,v=selector.split(","),h=0;
if(options==null) options="";
if(options.find("fixed-height"))
    h=getElementsBySelector(v[0])[0].offsetHeight;
for(i=0;i<v.length;i++)
    Rounded(v[i],options);
if(options.find("height")) SameHeight(selector,h);
}

function Rounded(selector,options){
var i,top="",bottom="",v=new Array();
if(options!=""){
    options=options.replace("left","tl bl");
    options=options.replace("right","tr br");
    options=options.replace("top","tr tl");
    options=options.replace("bottom","br bl");
    options=options.replace("transparent","alias");
    if(options.find("tl")){
        top="both";
        if(!options.find("tr")) top="left";
        }
    else if(options.find("tr")) top="right";
    if(options.find("bl")){
        bottom="both";
        if(!options.find("br")) bottom="left";
        }
    else if(options.find("br")) bottom="right";
    }
if(top=="" && bottom=="" && !options.find("none")){top="both";bottom="both";}
v=getElementsBySelector(selector);
for(i=0;i<v.length;i++){
    FixIE(v[i]);
    if(top!="") AddTop(v[i],top,options);
    if(bottom!="") AddBottom(v[i],bottom,options);
    }
}

function AddTop(el,side,options){
var d=CreateEl("b"),lim=4,border="",p,i,btype="r",bk,color;
d.style.marginLeft="-"+getPadding(el,"Left")+"px";
d.style.marginRight="-"+getPadding(el,"Right")+"px";
if(options.find("alias") || (color=getBk(el))=="transparent"){
    color="transparent";bk="transparent"; border=getParentBk(el);btype="t";
    }
else{
    bk=getParentBk(el); border=Mix(color,bk);
    }
d.style.background=bk;
d.className="niftycorners";
p=getPadding(el,"Top");
if(options.find("small")){
    d.style.marginBottom=(p-2)+"px";
    btype+="s"; lim=2;
    }
else if(options.find("big")){
    d.style.marginBottom=(p-10)+"px";
    btype+="b"; lim=8;
    }
else d.style.marginBottom=(p-5)+"px";
for(i=1;i<=lim;i++)
    d.appendChild(CreateStrip(i,side,color,border,btype));
el.style.paddingTop="0";
el.insertBefore(d,el.firstChild);
}

function AddBottom(el,side,options){
var d=CreateEl("b"),lim=4,border="",p,i,btype="r",bk,color;
d.style.marginLeft="-"+getPadding(el,"Left")+"px";
d.style.marginRight="-"+getPadding(el,"Right")+"px";
if(options.find("alias") || (color=getBk(el))=="transparent"){
    color="transparent";bk="transparent"; border=getParentBk(el);btype="t";
    }
else{
    bk=getParentBk(el); border=Mix(color,bk);
    }
d.style.background=bk;
d.className="niftycorners";
p=getPadding(el,"Bottom");
if(options.find("small")){
    d.style.marginTop=(p-2)+"px";
    btype+="s"; lim=2;
    }
else if(options.find("big")){
    d.style.marginTop=(p-10)+"px";
    btype+="b"; lim=8;
    }
else d.style.marginTop=(p-5)+"px";
for(i=lim;i>0;i--)
    d.appendChild(CreateStrip(i,side,color,border,btype));
el.style.paddingBottom=0;
el.appendChild(d);
}

function CreateStrip(index,side,color,border,btype){
var x=CreateEl("b");
x.className=btype+index;
x.style.backgroundColor=color;
x.style.borderColor=border;
if(side=="left"){
    x.style.borderRightWidth="0";
    x.style.marginRight="0";
    }
else if(side=="right"){
    x.style.borderLeftWidth="0";
    x.style.marginLeft="0";
    }
return(x);
}

function CreateEl(x){
return(document.createElement(x));
}

function FixIE(el){
if(el.currentStyle!=null && el.currentStyle.hasLayout!=null && el.currentStyle.hasLayout==false)
    el.style.display="inline-block";
}

function SameHeight(selector,maxh){
var i,v=selector.split(","),t,j,els=[],gap;
for(i=0;i<v.length;i++){
    t=getElementsBySelector(v[i]);
    els=els.concat(t);
    }
for(i=0;i<els.length;i++){
    if(els[i].offsetHeight>maxh) maxh=els[i].offsetHeight;
    els[i].style.height="auto";
    }
for(i=0;i<els.length;i++){
    gap=maxh-els[i].offsetHeight;
    if(gap>0){
        t=CreateEl("b");t.className="niftyfill";t.style.height=gap+"px";
        nc=els[i].lastChild;
        if(nc.className=="niftycorners")
            els[i].insertBefore(t,nc);
        else els[i].appendChild(t);
        }
    }
}

function getElementsBySelector(selector){
var i,j,selid="",selclass="",tag=selector,tag2="",v2,k,f,a,s=[],objlist=[],c;
if(selector.find("#")){ //id selector like "tag#id"
    if(selector.find(" ")){  //descendant selector like "tag#id tag"
        s=selector.split(" ");
        var fs=s[0].split("#");
        if(fs.length==1) return(objlist);
        f=document.getElementById(fs[1]);
        if(f){
            v=f.getElementsByTagName(s[1]);
            for(i=0;i<v.length;i++) objlist.push(v[i]);
            }
        return(objlist);
        }
    else{
        s=selector.split("#");
        tag=s[0];
        selid=s[1];
        if(selid!=""){
            f=document.getElementById(selid);
            if(f) objlist.push(f);
            return(objlist);
            }
        }
    }
if(selector.find(".")){      //class selector like "tag.class"
    s=selector.split(".");
    tag=s[0];
    selclass=s[1];
    if(selclass.find(" ")){   //descendant selector like tag1.classname tag2
        s=selclass.split(" ");
        selclass=s[0];
        tag2=s[1];
        }
    }
var v=document.getElementsByTagName(tag);  // tag selector like "tag"
if(selclass==""){
    for(i=0;i<v.length;i++) objlist.push(v[i]);
    return(objlist);
    }
for(i=0;i<v.length;i++){
    c=v[i].className.split(" ");
    for(j=0;j<c.length;j++){
        if(c[j]==selclass){
            if(tag2=="") objlist.push(v[i]);
            else{
                v2=v[i].getElementsByTagName(tag2);
                for(k=0;k<v2.length;k++) objlist.push(v2[k]);
                }
            }
        }
    }
return(objlist);
}

function getParentBk(x){
var el=x.parentNode,c;
while(el.tagName.toUpperCase()!="HTML" && (c=getBk(el))=="transparent")
    el=el.parentNode;
if(c=="transparent") c="#FFFFFF";
return(c);
}

function getBk(x){
var c=getStyleProp(x,"backgroundColor");
if(c==null || c=="transparent" || c.find("rgba(0, 0, 0, 0)"))
    return("transparent");
if(c.find("rgb")) c=rgb2hex(c);
return(c);
}

function getPadding(x,side){
var p=getStyleProp(x,"padding"+side);
if(p==null || !p.find("px")) return(0);
return(parseInt(p));
}

function getStyleProp(x,prop){
if(x.currentStyle)
    return(x.currentStyle[prop]);
if(document.defaultView.getComputedStyle)
    return(document.defaultView.getComputedStyle(x,'')[prop]);
return(null);
}

function rgb2hex(value){
var hex="",v,h,i;
var regexp=/([0-9]+)[, ]+([0-9]+)[, ]+([0-9]+)/;
var h=regexp.exec(value);
for(i=1;i<4;i++){
    v=parseInt(h[i]).toString(16);
    if(v.length==1) hex+="0"+v;
    else hex+=v;
    }
return("#"+hex);
}

function Mix(c1,c2){
var i,step1,step2,x,y,r=new Array(3);
if(c1.length==4)step1=1;
else step1=2;
if(c2.length==4) step2=1;
else step2=2;
for(i=0;i<3;i++){
    x=parseInt(c1.substr(1+step1*i,step1),16);
    if(step1==1) x=16*x+x;
    y=parseInt(c2.substr(1+step2*i,step2),16);
    if(step2==1) y=16*y+y;
    r[i]=Math.floor((x*50+y*50)/100);
    r[i]=r[i].toString(16);
    if(r[i].length==1) r[i]="0"+r[i];
    }
return("#"+r[0]+r[1]+r[2]);
}

/*
======(FINE)======= FUNZIONI PER ANGOLI ARROTONDATI ===============
*/





///////////////////////////////////////////////////////


// Definisco alcune variabili per i bordi arrotondati
var niftyOk=(document.getElementById && document.createElement && Array.prototype.push);
var niftyCss=false;

String.prototype.find=function(what){
return(this.indexOf(what)>=0 ? true : false);
}

// Creo una funzione per lo sniffing del browser
function Is() {
agent = navigator.userAgent.toLowerCase();
this.major = parseInt(navigator.appVersion);
this.minor = parseFloat(navigator.appVersion);
this.ns = ((agent.indexOf('mozilla') != -1) && ((agent.indexOf('spoofer') == -1) && (agent.indexOf('compatible') == -1)));
this.ns4 = (this.ns && (this.major == 4));
this.ns6 = (this.ns && (this.major >= 5));
this.ie = (agent.indexOf("msie") != -1);
this.ie3 = (this.ie && (this.major < 4));
this.ie4 = (this.ie && (this.major == 4) && (agent.indexOf("msie 5.0") == -1));
this.ie5 = (this.ie && (this.major == 4) && (agent.indexOf("msie 5.0") != -1));
this.ie55 = (this.ie && (this.major == 4) && (agent.indexOf("msie 5.5") != -1));
this.ie6 = (this.ie && (agent.indexOf("msie 6.0")!=-1) );
}


// Istanzio l'oggetto che rileva lo user-agent 
var is = new Is();

// Inizializzo il caricamento delle funzioni comuni
window.onload=function()
{
	apri_new();
	apricontatti_new();
	aprihelp_new();
	aprihelpwin_new();
	apricredits_new();
	apriglossario_new();
	aprifaq_new();
	enableTooltips();
	add_spanChiudi();
	add_spanStampa();
	add_onClick("*","span","cahImpl(this,'clickAndHide');");
	myAutoHide("csilist_contenuti","div");	
	add_spanLink();
	add_onClick2("*","dt","cahImpl2(this,'clickAndHide2');");
	myAutoHide2("csilist_contenuti","dd");	
	add_dtLink();
	chiudiMenu();
	chiudiMenu2(); //serve per  programma casa
//Attivo i bordi arrotondati solo per browser diversi da IE5
	if (!is.ie5) {
		AddCss();
	Nifty("#colonnaDestra h3.primo","small");
	Nifty("#colonna h3","small");
	Nifty("#colonna h4","small");
	Nifty("#colonnaCont h3","small");
	Nifty("#colonnaDestra h3","small");
	Nifty("#colonnaDestra h4","small");
	Nifty("div#infoConth","small");	
	Nifty("div#content h3","small");
	Nifty("div#nav h3","small");
	Nifty("div#menuDiNavigazioneSisp2 h3","small");
	}
}


// Creo la funzione concatenante per inizializzare funzioni esterne

var caricaVecchio=window.onload;
if(typeof(caricaTutto)!='function') caricaTutto=function(){};
if(typeof(caricaVecchio)=='function')
    window.onload=function(){caricaVecchio();caricaTutto()};
else window.onload=function(){caricaTutto()};


