//FUNZIONE PER SOSTITUIRE NEI CAMPI DI INPUT L'APPICE " CON L'APPICE ' --- INIZIO
function controlla_appice(nome_campo,nome_form){
	var campo, nome_form, valore;

	campo = eval("document."+nome_form+"."+nome_campo+".name");
	valore = eval("document."+nome_form+"."+nome_campo+".value");

	// Sostituisco l'appice doppio con l'appice singolo
	for (i=0; i<valore.length; i++) {
		posvirg = valore.indexOf('"' , 0);
		if (posvirg != -1){
			valore = valore.substring(0 , posvirg)+ "'" + valore.substring(posvirg+1 , valore.length );
		}
	}

	return valore;
}

// FUNZIONE PER CONTROLLARE I VALORI AMMESSI NELL'INPUT --- Inizio
//I valori ammessi: spazio . , / -  numerico
function ControlloValori(nome_form,campo){
	var valore = eval('document.'+nome_form+'.'+campo+'.value');
	var lunghezza = eval('document.'+nome_form+'.'+campo+'.value.length');
	var poscar;
	var esito;

	for (x=0; x<lunghezza; x++){
		poscar = valore.indexOf(" ");
		if (poscar > 0){
			valore =  valore.substr(0, poscar) + valore.substr(poscar + 1) ;
			lunghezza = valore.length;
		}
	}
	for (x=0; x<lunghezza; x++){
		poscar = valore.indexOf(".");
		if (poscar > 0){
			valore =  valore.substr(0, poscar) + valore.substr(poscar + 1) ;
			lunghezza = valore.length;
		}
	}
	for (x=0; x<lunghezza; x++){
		poscar = valore.indexOf(",");
		if (poscar > 0){
			valore =  valore.substr(0, poscar) + valore.substr(poscar + 1) ;
			lunghezza = valore.length;
		}
	}
	for (x=0; x<lunghezza; x++){
		poscar = valore.indexOf("/");
		if (poscar > 0){
			valore =  valore.substr(0, poscar) + valore.substr(poscar + 1) ;
			lunghezza = valore.length;
		}
	}
	for (x=0; x<lunghezza; x++){
		poscar = valore.indexOf("-");
		if (poscar > 0){
			valore =  valore.substr(0, poscar) + valore.substr(poscar + 1) ;
			lunghezza = valore.length;
		}
	}

	if (isNaN(valore)){
		esito = false;
	}else{
		esito = true;
	}
	return esito;
}
// FUNZIONE PER CONTROLLARE I VALORI AMMESSI NELL'INPUT --- Fine


// FUNZIONE PER ATTIVARE E DISATTIVARE IL BOTTONE INVIA --- INIZIO
var checkobj;
function accetta(el){
	checkobj=el;
	if (document.all||document.getElementById){
		for (i=0;i<checkobj.form.length;i++){
			var tempobj=checkobj.form.elements[i];
			if(tempobj.type.toLowerCase()=="submit"){
				tempobj.disabled=!checkobj.checked;
			}
		}
	}
}
function disabilita(el){
	if (!document.all&&!document.getElementById){
		if (window.checkobj&&checkobj.checked){
			return true;
		}
		else{
			alert("Per favore autorizza il trattamento dei dati personali");
			return false;
		}
	}
}
// FUNZIONE PER ATTIVARE E DISATTIVARE IL BOTTONE INVIA --- FINE

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

/***********************************************
* Switch Content script- © Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use. Last updated April 2nd, 2005.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

var enablepersist="off" //Enable saving state of content structure using session cookies? (on/off)
var collapseprevious="yes" //Collapse previously open content when opening present? (yes/no)

var contractsymbol='- ' //HTML for contract symbol. For image, use: <img src="whatever.gif">
var expandsymbol='+ ' //HTML for expand symbol.


if (document.getElementById){
document.write('<style type="text/css">')
document.write('.switchcontent{display:none;}')
document.write('</style>')
}

function getElementbyClass(rootobj, classname){
var temparray=new Array()
var inc=0
var rootlength=rootobj.length
for (i=0; i<rootlength; i++){
if (rootobj[i].className==classname)
temparray[inc++]=rootobj[i]
}
return temparray
}

function sweeptoggle(ec){
var thestate=(ec=="expand")? "block" : "none"
var inc=0
while (ccollect[inc]){
ccollect[inc].style.display=thestate
inc++
}
revivestatus()
}


function contractcontent(omit){
var inc=0
while (ccollect[inc]){
if (ccollect[inc].id!=omit)
ccollect[inc].style.display="none"
inc++
}
}

function expandcontent(curobj, cid){
var spantags=curobj.getElementsByTagName("SPAN")
var showstateobj=getElementbyClass(spantags, "showstate")
if (ccollect.length>0){
if (collapseprevious=="yes")
contractcontent(cid)
document.getElementById(cid).style.display=(document.getElementById(cid).style.display!="block")? "block" : "none"
if (showstateobj.length>0){ //if "showstate" span exists in header
if (collapseprevious=="no")
showstateobj[0].innerHTML=(document.getElementById(cid).style.display=="block")? contractsymbol : expandsymbol
else
revivestatus()
}
}
}

function revivecontent(){
contractcontent("omitnothing")
selectedItem=getselectedItem()
selectedComponents=selectedItem.split("|")
for (i=0; i<selectedComponents.length-1; i++)
document.getElementById(selectedComponents[i]).style.display="block"
}

function revivestatus(){
var inc=0
while (statecollect[inc]){
if (ccollect[inc].style.display=="block")
statecollect[inc].innerHTML=contractsymbol
else
statecollect[inc].innerHTML=expandsymbol
inc++
}
}

function get_cookie(Name) { 
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) { 
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function getselectedItem(){
if (get_cookie(window.location.pathname) != ""){
selectedItem=get_cookie(window.location.pathname)
return selectedItem
}
else
return ""
}

function saveswitchstate(){
var inc=0, selectedItem=""
while (ccollect[inc]){
if (ccollect[inc].style.display=="block")
selectedItem+=ccollect[inc].id+"|"
inc++
}

document.cookie=window.location.pathname+"="+selectedItem
}

function do_onload(){
uniqueidn=window.location.pathname+"firsttimeload"
var alltags=document.all? document.all : document.getElementsByTagName("*")
ccollect=getElementbyClass(alltags, "switchcontent")
statecollect=getElementbyClass(alltags, "showstate")
if (enablepersist=="on" && ccollect.length>0){
document.cookie=(get_cookie(uniqueidn)=="")? uniqueidn+"=1" : uniqueidn+"=0" 
firsttimeload=(get_cookie(uniqueidn)==1)? 1 : 0 //check if this is 1st page load
if (!firsttimeload)
revivecontent()
}
if (ccollect.length>0 && statecollect.length>0)
revivestatus()
}

if (window.addEventListener)
window.addEventListener("load", do_onload, false)
else if (window.attachEvent)
window.attachEvent("onload", do_onload)
else if (document.getElementById)
window.onload=do_onload

if (enablepersist=="on" && document.getElementById)
window.onunload=saveswitchstate

/***********************************************
* Highlight Table Cells Script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* Visit http://www.dynamicDrive.com for hundreds of DHTML scripts
* This notice must stay intact for legal use
***********************************************/

//Specify highlight behavior. "TD" to highlight table cells, "TR" to highlight the entire row:
var highlightbehavior="TR"

var ns6=document.getElementById&&!document.all
var ie=document.all

function changeto(e,highlightcolor){
source=ie? event.srcElement : e.target
if (source.tagName=="TABLE")
return
while(source.tagName!=highlightbehavior && source.tagName!="HTML")
source=ns6? source.parentNode : source.parentElement
if (source.style.backgroundColor!=highlightcolor&&source.id!="ignore")
source.style.backgroundColor=highlightcolor
}

function contains_ns6(master, slave) { //check if slave is contained by master
while (slave.parentNode)
if ((slave = slave.parentNode) == master)
return true;
return false;
}

function changeback(e,originalcolor){
if (ie&&(event.fromElement.contains(event.toElement)||source.contains(event.toElement)||source.id=="ignore")||source.tagName=="TABLE")
return
else if (ns6&&(contains_ns6(source, e.relatedTarget)||source.id=="ignore"))
return
if (ie&&event.toElement!=source||ns6&&e.relatedTarget!=source)
source.style.backgroundColor=originalcolor
}