<!--

var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function View2cols(){
	doppiaColonna.style.display = '';
	colonnaCentrale.style.display = 'none';
	colonnadidestra.style.display = 'none';
}

function Hidden23cols(){
	doppiaColonna.style.display = 'none';
	colonnaCentrale.style.display = '';
	colonnadidestra.style.display = '';
}


function convdate(vdata){
	var strdata=vdata
	var strgiorno="0"+strdata.substring(0,strdata.indexOf("/"))
	strgiorno=strgiorno.slice(-2)
	strdata=strdata.substring(strdata.indexOf("/")+1)
	var strmese="0"+strdata.substring(0,strdata.indexOf("/"))
	strmese=strmese.slice(-2)
	strdata=strdata.substring(strdata.indexOf("/")+1)
	if (strdata.length>1) {
		var stranno="20"+strdata
	} else {
		var stranno="200"+strdata
	}
	stranno=stranno.slice(-4)
	strdata=stranno+strmese+strgiorno
	strdata=parseInt(strdata)
	return strdata
}

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}
function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}
function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strDay=dtStr.substring(0,pos1)
	var strMonth=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		return false
	}
return true
}

function popup(scelta){
	finestra = window.open(scelta,'','scrollbars=yes,resizable=NO,width=600,height=350,status=no,location=no,toolbar=no,left=50,top=50');
}

function popupwh(scelta,w,h){
	finestra = window.open(scelta,'COFILOC','scrollbars=yes,resizable=NO,width='+w+',height='+h+',status=no,location=no,toolbar=no,left=50,top=50');
}

function openImageWindow(imageSrc,altText) {
	fileName = 'popupgall.htm?' + escape(imageSrc) + '&altText=' + altText;
	myWindowHandle = window.open(fileName,'popup','directories=no,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=no');
}
function openImageWindowAsp(parametri) {
	fileName = 'popupgall.asp?' + parametri;
	myWindowHandle = window.open(fileName,'popup','directories=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,resizable=yes');
}
function cambiaSfondi(quale){
	var qualeSfondo = "";
	if (quale=="1"){
		qualeSfondo = "2";
	}else{
		qualeSfondo = "1";
	}
	document.getElementById('mainBody'+quale).style.background='url(css/img/bgSfumo'+qualeSfondo+'.png)';
	document.getElementById('menu'+quale).style.background='url(css/img/bgMenu'+qualeSfondo+'.png)';
	document.getElementById('footer'+quale).style.background='url(css/img/bgFooter'+qualeSfondo+'.png)';
}

function cambiaSfondiUsato(qualeSfondo){
	document.getElementById('mainBody1').style.background='url(css/img/bgSfumo'+qualeSfondo+'.png)';
	document.getElementById('menu1').style.background='url(css/img/bgMenu'+qualeSfondo+'.png)';
	document.getElementById('footer1').style.background='url(css/img/bgFooter'+qualeSfondo+'.png)';
}

function cambiaImmagine(origine){
	var orig =  document.getElementById(origine);
	var newOrig = orig.src.replace('/min/','/med/')
	var dest = document.getElementById("imgEvento");
	var oldDest = dest.src.replace('/med/','/min/')
	dest.src = newOrig;
	orig.src = oldDest;
}

function cambiaImmagineSez(origine){
	var orig =  document.getElementById(origine);
	var newOrig = orig.src.replace('/med/','/max/')
	var dest = document.getElementById("imgDellaSez");
	var oldDest = dest.src.replace('/max/','/med/')
	dest.src = newOrig;
	orig.src = oldDest;
}

function checkMail(mail){
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(mail)){
		return true;
	}else{
		return false;
	}
}

function controlla(obbligatorio,nome,campo_data,campo_numero,campo_mail,campoPrivacy,controlloDate,tolleranza,stringaParole){
	var sAgent = navigator.userAgent.toLowerCase() ;
	var elemento = document.getElementById(nome)
	len =elemento.elements.length;
	var i=0;
	arrParole = stringaParole.split("|")
	var campo=' '+arrParole[0]+'\n'
	var passa=true
	var dtDal = ""
	var dtAl = ""
	campo=campo+'_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \n\n\t\t '
	for( i=0 ; i<len ; i++) {
		if (controlloDate){
			if(elemento.elements[i].name.indexOf('Dal')>0){
				 dtDal+= elemento.elements[i].value;
				 if(elemento.elements[i].name.indexOf('yyyy')<0){
					 dtDal+= '/' ;
				 }
			}
			if(elemento.elements[i].name.indexOf('Al')>0){
				 dtAl+= elemento.elements[i].value;
				 if(elemento.elements[i].name.indexOf('yyyy')<0){
					 dtAl+= '/' ;
				 }
			}
		}
		if (tolleranza){
			if(elemento.elements[i].name.indexOf('tolleranza')>=0){
				if (elemento.elements[i].value<=0){
					campo=campo+' # '+elemento.elements[i].title+' # \n\n\t\t '
					passa=false
				}
			}
		}
		if (elemento.elements[i].name.length > 0){
			if (elemento.elements[i].name.indexOf(obbligatorio)>0 & elemento.elements[i].value.length<=0 ) {
				campo=campo+' # '+elemento.elements[i].title+' # \n\n\t\t '
				passa=false
			} else if (elemento.elements[i].name.indexOf(campo_mail)>0 & !checkMail(elemento.elements[i].value)) {
				campo=campo+' # '+elemento.elements[i].title+' # \n\n\t\t '
				passa=false
			} else if (elemento.elements[i].name.indexOf(campoPrivacy)>0 & !elemento.elements[i].checked) {
				campo=campo+' # '+elemento.elements[i].title+' # \n\n\t\t '
				passa=false
			} else {
				if (elemento.elements[i].name.indexOf(campo_numero)>0 & isNaN(elemento.elements[i].value.replace(',','.')) & elemento.elements[i].value.length > 0) {
					campo=campo+' # '+elemento.elements[i].title+' # \n\n\t\t '
					passa=false
				}
			}
		}
	}
	if (controlloDate){
		if (isDate(dtDal) && isDate(dtAl)){
			//alert(convdate(dtDal) + '\n' + convdate(dtAl))
			if(convdate(dtDal)>convdate(dtAl)){
				campo=campo+' # '+ arrParole[1] +' # \n\n\t\t '
				passa=false
			}
		}else{
			if (!isDate(dtDal)){
				campo=campo+' # '+ arrParole[2] +' # \n\n\t\t '
				passa=false
			}
			if (!isDate(dtAl)){
				campo=campo+' # '+ arrParole[3] +' # \n\n\t\t '
				passa=false
			}
		}
	}
	campo=campo+'\n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ '
	if (passa){
		controlla=true;
		return true;
	}else{ 
		alert(campo.replace("'","\'"))
		return false;
	}
}

			
var initI=0
function scrollMenu() {
	var boxTop=document.getElementById('divScroll');
	var menuDeiTipimacchina=document.getElementById('menuDeiTipimacchina');
	if (boxTop!=undefined && boxTop!=null){
		if (document.body.scrollTop-274>0) {
			posizione=Math.floor((initI+((document.body.scrollTop-274)))/2);
			var altezzaCheMiServe = (document.body.scrollTop-274)+boxTop.clientHeight;
			if (altezzaCheMiServe<menuDeiTipimacchina.clientHeight){
				boxTop.style.marginTop = posizione;
				initI=posizione;
			}
		} else {
			boxTop.style.marginTop = 0;
			initI=0;
		}
	}
}
function vediSiNo(quale){
	ele = document.getElementById(quale)
	if (ele.style.display=='none'){
		ele.style.display='';
	}else{
		ele.style.display='none';
	}
}
function menuSaci(quale,num){
	var ele = document.getElementsByTagName("ul");
	var colonnaChange = document.getElementById("colonnaCentrale")
	var colonnaTitoloChange = document.getElementById("titCol1")
	var barraAlta = document.getElementById("barraAlta")
	var barraBassa = document.getElementById("barraBassa")
	for(i=0;i<ele.length;i++){
		if(ele[i].id.substring(0,8)=='subMenu_'){
			if (ele[i].style.display=='none' && ele[i].id==quale){
				ele[i].style.display='';
				colonnaChange.innerHTML = arrImg[num][0];
				colonnaTitoloChange.innerHTML = arrImg[num][1];
				barraAlta.style.background = arrImg[num][2];
				barraBassa.style.background = arrImg[num][2];
				//alert(ele[i].parentNode.firstChild.style.color)
			}else{
				ele[i].style.display='none';
			}
		}
	}
}

function menuSaci2(qualeAprire,colore,prefisso){
	var elePremuto = document.getElementById(qualeAprire)
	var ele = document.getElementsByTagName("ul");
	for(i=0;i<ele.length;i++){
		if(ele[i].id.substring(0,prefisso.length)==prefisso){
			if (ele[i].style.display=='none' && ele[i].id==qualeAprire){
				ele[i].style.display='';
				ele[i].parentNode.firstChild.style.color = colore;
			}else{
				ele[i].style.display='none';
				ele[i].parentNode.firstChild.style.color = '';
			}
		}
	}
}

function menuSaci3(qualeAprire,colore,prefisso,elem,url,url2){
	var elePremuto = document.getElementById(qualeAprire)
	var ele = document.getElementsByTagName("ul");
	for(i=0;i<ele.length;i++){
		if(ele[i].id.substring(0,prefisso.length)==prefisso){
			if (ele[i].style.display=='none' && ele[i].id==qualeAprire){
				ele[i].style.display='';
				ele[i].parentNode.firstChild.style.color = colore;
				document.location.href=url+'?s='+url2+'&id_101='+elem;
			}else{
				ele[i].style.display='none';
				ele[i].parentNode.firstChild.style.color = '';
			}
		}
	}
}

function cambiaTestoGall(bottonePrima,bottoneDopo,hrefPrint){
	var testoGall = document.getElementById("textPagGall");
	var testoSez = document.getElementById("textPagSez");
	var testoBottone = document.getElementById("cambiaTestoGall");
	if (testoSez.style.display=='none'){
		testoSez.style.display = '';
		testoGall.style.display = 'none';
		testoBottone.innerHTML = bottoneDopo;
		if (hrefPrint!=undefined){
			document.getElementById("StampaPagina").href='javascript:print();'}
	}else{
		testoSez.style.display = 'none';
		testoGall.style.display = '';
		testoBottone.innerHTML = bottonePrima;
		if (hrefPrint!=undefined){
			document.getElementById("StampaPagina").href=hrefPrint}
	}
}
//-->
