//*******************************************************
//********************* TRIM ****************************
//*******************************************************
function Trim(TRIM_VALUE){
	if(TRIM_VALUE.length < 1)
	{
		return"";
	}
	TRIM_VALUE = RTrim(TRIM_VALUE);
	TRIM_VALUE = LTrim(TRIM_VALUE);
	if(TRIM_VALUE=="")
	{
		return "";
	}
	else
	{
		return TRIM_VALUE;
	}
} // end function Trim()


//*******************************************************
//********************* RTRIM ***************************
//*******************************************************
function RTrim(VALUE){
	var w_space = String.fromCharCode(32);
	var v_length = VALUE.length;
	var strTemp = "";
	
	if(v_length < 0)
	{
		return"";
	}
	var iTemp = v_length -1;

	while(iTemp > -1)
	{
		if(VALUE.charAt(iTemp) == w_space)
		{
		
		}
		else
		{
			strTemp = VALUE.substring(0,iTemp +1);
			break;
		}
		iTemp = iTemp-1;

	} //End While
	return strTemp;

} // end function RTrim()

//*******************************************************
//********************* LTRIM ***************************
//*******************************************************
function LTrim(VALUE){
	var w_space = String.fromCharCode(32);
	
	if(v_length < 1)
	{
		return"";
	}
	var v_length = VALUE.length;
	var strTemp = "";

	var iTemp = 0;

	while(iTemp < v_length)
	{
		if(VALUE.charAt(iTemp) == w_space)
		{
		}
		else
		{
			strTemp = VALUE.substring(iTemp,v_length);
			break;
		}
		iTemp = iTemp + 1;
	} //End While
	return strTemp;
} // end function LTrim()


//*******************************************************
//*********** FUNZIONE PER VERIFICA DATE ****************
//*******************************************************
function verificaData(objsource, objargs)
{
	re = /-/g;	
	reOre = /\./g;
	dataGiusta=objargs.Value.replace(re,"/");
	
	ctl=true;
	msg="";
	
	arrDataI=new Array();

	arrDataI=dataGiusta.split("/");

	if(isNaN(parseInt(arrDataI[0])) || parseInt(arrDataI[0])>31 || parseInt(arrDataI[0])!=0 && (parseInt(arrDataI[0].length)>2)) {ctl=false;}
	if(isNaN(parseInt(arrDataI[1])) || parseInt(arrDataI[1])>12 || parseInt(arrDataI[1])!=0 && (parseInt(arrDataI[1].length)>2)) {ctl=false;}
	if(isNaN(parseInt(arrDataI[2])) || parseInt(arrDataI[2])<1900 || parseInt(arrDataI[2])!=0 && (parseInt(arrDataI[2].length)!=4)) {ctl=false;}
	if(dataGiusta.length==0){ctl=false;}
	if(objargs.Value==""){ctl=false;}
	
	objargs.IsValid=ctl;
	return;			
		
} // end function verificaData()

//*******************************************************
//********* PROPRIETA' CONTROLLO CROSSBROWSER ***********
//*******************************************************
function getObj(name)
{
	/* DHTML Micro API
	* Source: http://www.quirksmode.org/js/dhtmloptions.html
	*/
	if (document.getElementById) // test if browser supports document.getElementById
	{
		this.obj = document.getElementById(name);
		this.style = document.getElementById(name).style;
		this.parent = document.getElementById(name).parentNode;
	}
	else if (document.all) // test if browser supports document.all
	{
		this.obj = document.all[name];
		this.style = document.all[name].style;
		this.parent = document.all[name].parentElement;
	}
	else if (document.layers) // test if browser supports document.layers
	{
		this.obj = document.layers[name];
		this.style = document.layers[name].style;
		this.parent = document.layers[name].parentNode;
	}
} // end function getObj()


