function DateFormat(Obj,Frm){
	var tmpDate = "";
	var FirstPosition = "";
	var SecondPosition = "";
	var TempDays = "";
	var TempMonths = "";
	var TempYears = "";
	var tmpStr = new String();
	var aaaa_2 = "";
	var mm_2 = "";
	var gg_2 = "";					
	//tmpStr = eval("document.forms[0]." + Obj + ".value;");
	tmpStr = eval("document." + Frm + "." + Obj + ".value;");
	if(tmpStr != ""){//CHECK LENGTH

		if(tmpStr.length<6){
			alert("La data inserita non è corretta.");
			//eval("document.forms[0]." + Obj + ".focus();" );
			eval("document." + Frm + "." + Obj + ".focus();" );
			return;
		}

		//CHECK YEARS
		FirstPosition = tmpStr.indexOf("/");
		SecondPosition = tmpStr.indexOf("/", FirstPosition + 1);
		TempYears = tmpStr.substr(SecondPosition + 1);

		//CHECK MONTHS
		FirstPosition = tmpStr.indexOf("/");
		SecondPosition = tmpStr.indexOf("/", FirstPosition + 1);
		TempMonths = tmpStr.substr(FirstPosition + 1, (SecondPosition - FirstPosition)-1);

		//CHECK DAYS
		FirstPosition = tmpStr.indexOf("/");
		TempDays = tmpStr.substr(0,FirstPosition);

		//CHECK SLASH
		if(FirstPosition  == -1 || SecondPosition == -1){
			alert("La data inserita non è corretta.");
			//eval("document.forms[0]." + Obj + ".focus();" );
			eval("document." + Frm + "." + Obj + ".focus();" );
		}

		//REBUILD
		if(TempDays.length < 2){
			TempDays = "0" + TempDays;
		}
		if(TempMonths.length < 2){
			TempMonths = "0" + TempMonths;
		}
		if(TempYears.length < 3){
			if(TempYears >= 50){
				TempYears = "19" + TempYears;
			}else{
				TempYears = "20" + TempYears;
			}
		}
		tmpDate = new Date (TempYears,TempMonths-1,TempDays);
		aaaa_2 = tmpDate.getFullYear();
		mm_2 = tmpDate.getMonth() + 1;
		gg_2 = tmpDate.getDate();
		if (aaaa_2 != TempYears || mm_2 != TempMonths || gg_2 != TempDays){
			alert("La data inserita non è corretta.");
			//eval("document.forms[0]." + Obj + ".focus();" );
			eval("document." + Frm + "." + Obj + ".focus();" );
			return (false);
		}else{
			//eval("document.forms[0]." + Obj + ".value ='" + TempDays + "/" + TempMonths + "/" + TempYears +"';" );
			eval("document." + Frm + "." + Obj + ".value ='" + TempDays + "/" + TempMonths + "/" + TempYears +"';" );
			return (true);
		}
	}else{
		return (true);
	}
}

function DoPopUp(URL,Name,X,Y,Center,Resizable,ScrollBars)
{
	//Center = yes or no
  	//Resizable = yes or no
  	//ScrollBars = yes or no

  	if (Center == 'yes'){
    		var PopUpX = (screen.width/2)-(parseInt(X)/2);
    		var PopUpY = (screen.height/2)-(parseInt(Y)/2);
    		var pos = ",left="+PopUpX+",top="+PopUpY;
  	}else{
    		var pos = "";
  	}
  	PopUpWindow = window.open(URL,Name,'scrollbars='+ScrollBars+',resizable='+Resizable+',width='+X+',height='+Y+pos);
}

function TimeFormat(Obj){
	var tmpTime = "";
	var FirstPosition = "";
	var SecondPosition = "";
	var TempHours = "";
	var TempMinutes = "";
	var tmpStr = new String();
	var hh_2 = "";
	var mm_2 = "";					
	tmpStr = eval("document.forms[0]." + Obj + ".value;");
	if(tmpStr != ""){
		//CHECK LENGTH		
		if(tmpStr.length<5){
			alert("La data inserita non è corretta.");
			eval("document.forms[0]." + Obj + ".value = '';" );
			eval("document.forms[0]." + Obj + ".focus();" );
			return;
		}
		//CHECK HOURS
		FirstPosition = tmpStr.indexOf(":");
		TempHours = tmpStr.substr(0, FirstPosition);
	
		//CHECK MONTHS
		FirstPosition = tmpStr.indexOf(":");
		SecondPosition = tmpStr.indexOf(":", FirstPosition);
		TempMinutes = tmpStr.substr(FirstPosition + 1, SecondPosition );
		
		//CHECK SLASH
		if(FirstPosition  == -1 || SecondPosition == -1){
			alert("La data inserita non è corretta.");
			eval("document.forms[0]." + Obj + ".value = '';" );
			eval("document.forms[0]." + Obj + ".focus();" );
		}

		//REBUILD
		if(TempHours.length < 2){
			TempHours = "0" + TempHours;
		}
		if(TempMinutes.length < 2){
			TempMinutes = "0" + TempMinutes;
		}		
		if (TempHours > 23 || TempMinutes > 59){
			alert("La data inserita non è corretta.");
			eval("document.forms[0]." + Obj + ".value = '';" );
			eval("document.forms[0]." + Obj + ".focus();" );
			return (false);
		}else{
			eval("document.forms[0]." + Obj + ".value ='" + TempHours + ":" + TempMinutes +"';" );
			return (true);
		}
	}else{
		return (true);
	}
}

function CheckLen(txtArea, maxLen)
{
	var sArea = txtArea.value;
	if (sArea.length > maxLen)
	{
		alert("Il testo è troppo lungo!");			
		txtArea.value = sArea.substring(0, maxLen);
	}
}