<!-- 
function checkdate(obj) {
	var bRet=true;
	var bVerb=true;
	if (!isEmpty(obj.value)) {
		var sData=funIsDate(obj.value, bVerb);
		if (sData==''&&obj.value!=''){
			bRet = false;
		} else {
			obj.value = sData
		}
	}
	funCtrlSetBgCol(obj, bRet)
	return bRet
}

function funCtrlSetBgCol(obj, bValid) {
	if (bValid)
		obj.style.background="ffffff"
	else
		obj.style.background="ffffcc"
}

function isEmpty(inputStr) {
	if (inputStr == "" || inputStr == null) { return true; }
	return false;
}

//### VERIFICA CHE L'ARGOMENTO SIA UNA LETTERA
function isLetter (c) {
	return ( ((c >= "a") && (c <= "z")) || ((c >= "A") && (c <= "Z")) )
}

//### VERIFICA CHE L'ARGOMENTO SIA UN NUMERO
function isDigit (c) {
	return ((c >= "0") && (c <= "9"))
}

//### VERIFICA CHE L'ARGOMENTO SIA UN NUMERO
function isnumber (s) {
	var i;
	for (i = 0; i > s.length; i++){
		var c = s.charAt(i);
		if (! ((c >= "0") && (c <= "9"))) {
			return false;
		}
	}
	return true;
}

function funDecAp(s) {
	return s.replace(/\'/g, "\'");
}

function SetFocus(objMT) {
	objMT.focus();
}

//### funzione che restituisce true se la data è valida e false se è una stringa vuota
function IsDate(sDate, bVerb) {
	datastr=funIsDate(sDate, bVerb)
	if (datastr="")
		return false
	else
		return true
}

//### restituisce la data validata e nel formato gg/mm/aaaa se la data non esiste restituisce la stringa vuota
function funIsDate(sDate, bVerb) {
	aa= new Array();
	rExp = /-/g;
	tmp=""

	day=sDate
	day=day.replace(rExp,"/")
	for (i=0;i<day.length;i++) {
		if ((day.charCodeAt(i)>=48 && day.charCodeAt(i)<=57) || day.charCodeAt(i)==47)
	  		   tmp+=day.charAt(i)
	}
  	day=tmp


  	if(day.indexOf("/")==-1) {
			aa[0]=day.substring(0,2)
			aa[1]=day.substring(2,4)
			if (day.length==8) {
				aa[2]=day.substring(4,8)
			} else {
				aa[2]=day.substring(4,6)
			}
		} else {		
		  	if(day.lastIndexOf("/")==5) {
					aa[0]=day.substring(0,2)
					aa[1]=day.substring(3,5)
					if (day.length==10) {
						aa[2]=day.substring(6,10)
					} else {
						aa[2]=day.substring(6,8)
					}
				} else if((day.lastIndexOf("/")==4)&&(day.indexOf("/")==2)) {
					aa[0]=day.substring(0,2)
					aa[1]='0'+day.substring(3,4)
					if (day.length==9) {
						aa[2]=day.substring(5,9)
					} else {
						aa[2]=day.substring(5,7)
					}
				} else if((day.lastIndexOf("/")==4)&&(day.indexOf("/")==1)) {
					aa[0]='0'+day.substring(0,1)
					aa[1]='0'+day.substring(3,4)
					if (day.length==9) {
						aa[2]=day.substring(5,9)
					} else {
						aa[2]=day.substring(5,7)
					}
				} else if(day.lastIndexOf("/")==3) {
					aa[0]='0'+day.substring(0,1)
					aa[1]='0'+day.substring(2,3)
					if (day.length==8) {
						aa[2]=day.substring(4,8)
					} else {
						aa[2]=day.substring(4,6)
					}					
				} else if(day.lastIndexOf("/")==2) {
					aa[0]=day.substring(0,2)
					aa[1]=day.substring(3,5)
					if (day.length==9) {
						aa[2]=day.substring(5,9)
					} else {
						aa[2]=day.substring(5,7)
					}			
				} else {
					aa=day.split("/")
				}			
		}

	if (aa[2].length==2)
		if (aa[2]<30)
			aa[2]="20"+aa[2]
		else
			aa[2]="19"+aa[2]

	parseInt(aa[0]);
	parseInt(aa[1]);
	parseInt(aa[2]);

	var ok = true;
	if (aa[2] < 1000) ok = false;
	if (aa[1] < 1 || aa[1] > 12) ok = false;
	if (aa[0] < 1 || aa[0] > 31) ok = false
	if (aa[0] > 30 && aa[1] == 4) ok = false
	if (aa[0] > 30 && aa[1] == 6) ok = false
	if (aa[0] > 30 && aa[1] == 9) ok = false
	if (aa[0] > 30 && aa[1] == 11) ok = false
	if (aa[0] > 29 && aa[1] == 2) ok = false
	if (aa[0] == 29 && aa[1] == 2) {
		if (aa[2] % 4 == 0) {
			if (aa[2] % 100 == 0) {
				if (aa[2] % 400 != 0)
					ok = false
			}
		} else
			ok = false
	}
	if (ok) {
		if (aa[0].length==1)
			aa[0]="0"+aa[0]
		if (aa[1].length==1)
			aa[1]="0"+aa[1]

		day=aa.join("/");
	} else {
		day="";
		if (bVerb)
			alert('La Data inserita non è valida!')

	}
	return day;
}

function funIsNumber(sNum, bVerb) {
	var kDec=','	// indicatore dei decimali
	var tmp=""
	var bVirg=true
	var i
	var cur

	for (i=sNum.length-1;i>=0;i--) {
		s = sNum.charAt(i)
		if ((s>="0"&&s<="9")||(s==kDec&&bVirg)) {
   	     	tmp=s+tmp
   	 		if(s==kDec)
				bVirg=false
   	    }
   	}
   	if (tmp!=''){
	   	cur = parseFloat('0'+tmp.replace(kDec,'.'))
	}

//	   	if (cur==undefined||cur=='0')
		if (cur==undefined)
	   		cur=''
   	else if (bVerb)
		alert('Numero non valido!')

   	return cur
}

function funFormatNum(sNum,iDec,bMille) {
	var iOri
	var sInt=""
	var sDec=""
	var sDest=""
	var iDest
	var j = 0


	//### N.d.Miriam: ho messo iDec = 0 perchè in altre pagine come ad es. PrgProgettiEdit.asp mi dava problemi con i
	//############### numeri senza decimali, ovvero mi metteva 2 decimali quando in realtà non ne avevo bisogno.
	//############### Il problema l'ho riscontrato nel campo 'N.giorni durata' dopo l'invio.
	//if (!isDigit(iDec)) iDec = 2;

	if (!isDigit(iDec)) iDec = 2;
	if (!bMille) bMille = false;
	iOri = funIsNumber(sNum)

	if (iOri=="")
		return ""

	//### Trovo il decimale di iOri
	iOri = Math.round(iOri*(Math.pow(10,iDec)))
	sInt = Math.floor(iOri / (Math.pow(10,iDec)))
	sDec = iOri - (sInt * (Math.pow(10,iDec)))

	//gestisco i decimali
	sDec = String(sDec)
	sDest = '000000000' + sDec
	sDec = sDest.substr((sDest.length-iDec),iDec)

	if (sDec.length<iDec)
	{
		sDest = sDec + '000000000'
		sDest = sDest.substring(0,iDec)
		sDec = sDest
	}

	//### Trovo l'intero di iOri
	sInt = String(sInt)
	sDest = ''

	//### Gestisco il punto delle migliaia
	if (bMille) {
		for (i=sInt.length-1;i>=0;i--)
		{
			//### % = Mod
			if (((j % 3)==0)&&(j!= 0) )
				sDest = '.' + sDest
			sDest = sInt.charAt(i) + sDest
			j++
		}
		sInt = sDest
	}

	sDest = ''

	if (iDec!=0)
		sDest = ',' + sDec
	sDest = String(sInt) + String(sDest)

   	return sDest
}

//### restituisce l'ora validata e nel formato hh/mm se l'ora non esiste restituisce la stringa vuota
function funIsTime(sTime, bVerb) {
//  ancora da completare 
	aa= new Array();
	rExp = /:/g;
	tmp=""

	day=sTime
	day=day.replace(rExp,".")
	for (i=0;i<day.length;i++) {
		if ((day.charCodeAt(i)>=48 && day.charCodeAt(i)<=57) || day.charAt(i)=='.')
	  		   tmp+=day.charAt(i)
	}
  	day=tmp

  	if(day.indexOf(".")==-1) {
		aa[0]=day.substring(0,2)
		aa[1]=day.substring(2,4)
	} else {
		aa=day.split(".")
	}
	
	parseInt(aa[0]);
	parseInt(aa[1]);

	var ok = true;
	if (aa[0] == '') ok = false
	if (aa[1] == '') ok = false
	if (!(aa[0] >= 0 && aa[0] <= 24)) ok = false
	if (!(aa[1] >= 0 && aa[1] <= 59)) ok = false
	if (aa[0] == 24) aa[0] = 0
	if (ok) {
		if (aa[0].length==1)
			aa[0]="0"+aa[0]
		if (aa[1].length==1)
			aa[1]="0"+aa[1]
		day=aa.join(".");
	} else {
		day="";
		if (bVerb)
			alert("L'ora inserita non è valida!")
	}
	return day;
}

// manda in messaggio a video l'alt o il title del'oggetto che si passa
function funShowAlt(obj){
	if (obj.title!='')
		alert(obj.title)
	else
		alert(obj.alt)
}

