	function isnull(sValue) 
	{
					sValue = String(sValue);
		return (	sValue == '' || sValue == 'null' || sValue == 'undefined'); 
	}// end function isnull
		
	function trim(sValue,sDefault)
	{
			var trm = CStr(sValue);
			var dfl = CStr(sDefault);
	
		trm = trm.replace(/(^\s*)|(\s*$)/g, ""); 
		dfl = dfl.replace(/(^\s*)|(\s*$)/g, ""); 
	
		return trm==""?dfl:trm;
	}// end function trim
		
	function CInt(vValue,vDefault)
	{
		var str	= trim(vValue);
		var strd = trim(vDefault);

			var intg = parseInt(str,10);
			var intd = parseInt(strd,10);

		intd = (isNaN(intd)?0:intd);

		return (isNaN(intg)?intd:intg);
	}// end function CInt	 
	
	function isInt(vle)// +,-, 0-9
	{
		vle	= vle.replace(/,/gi,""); 
		var isint = trim(vle);
		return(isint.match(/^[ ]*[+-]?\d+[ ]*$/)); // integer||null
	}// end function isInt	
	
	function CStr(vValue,vDefault)
	{
		vDefault += "";
		if(vDefault	== "undefined") vDefault = "";
		if(vDefault	== "null")      vDefault = ""; 
		
			vValue	+= "";
		if(vValue	== "undefined") return vDefault;
		if(vValue	== "null")      return vDefault;
		
		return vValue;
	}// end function CStr
	
	function CDate(sDate)
	{
		try
		{
			
			var iDay;						// The day part.
			var iMonth;						// The month part.
			var iYear;						// The year part.
			sDate	 = String(sDate);
			iDay	 = CInt(sDate.substring(0, sDate.indexOf("/")), 0);
			iMonth = CInt(sDate.substring(sDate.indexOf("/") + 1, sDate.lastIndexOf("/")), 1);
			iYear	 = CInt(sDate.substr(sDate.lastIndexOf("/") + 1, 4), 0);
			if (isDate1(iYear, iMonth, iDay))
			{
				return new Date(iYear, iMonth - 1, iDay)
			}
		}
		catch(e)
		{
			//alert(e.description);
		}	
	}	// End of CDate function.

	function isDate1 (year,month,day)
	{
		try
		{	
			if (!isYear1(year)) //&& !(isMonth(month)) && !(isDay(day)))
			{
				return false;
			}
			if (!isMonth1(month)) 
			{
				return false;
			}
			if (!isDay1(day)) 
			{
				return false;
			}
			var intYear = parseInt(year);
			var intMonth = parseInt(month);
			var intDay = parseInt(day);
			if (intDay > daysInM[intMonth]) return false;
			if ((intMonth == 2) && (intDay > daysInFebruary1(intYear))) return false;
			return true;
		}
		catch(e)
		{
			throw(e);
		}
	}//End function isDate1

	function ValidDates(oObjStartDate,oObjFinishDate)
	{
		try
			{
				if(!isnull(oObjStartDate) && !isnull(oObjFinishDate))
				{
					var Result = CDate(oObjStartDate) - CDate(oObjFinishDate)
					if(Result > 0)
					{
						return false;	
					}
				}
				else
				{
					return false;	
				}	
   			return true;   
   		}
   		catch(e)
			{
				//alert(e.description);
			}		
	}//End function Valid()

	function isMonth1 (sValue){
		try{
			if (isnull(sValue)) return false;
			return isIntegerInRange1 (sValue, 1, 12);
		}
		catch(e){
			throw(e);
		}
	}// end function isMonth1

	function isDay1 (sValue){
		try{
			if (isnull(sValue)) return false;
			return isIntegerInRange1 (sValue, 1, 31);
		}
		catch(e){
			throw(e);
		}
	}// end function isDay1
	
	function isYear1 (sValue){
		try{
			if (isnull(sValue))  return false;
			if (!isInt(sValue+'')) return false;
			return (((sValue+'').length == 2) || ((sValue+'').length == 4));
		}
		catch(e){
			throw(e);
		}
	}// end function isYear1

	function isIntegerInRange1 (sValue, a, b){
		try{
			if (isnull(sValue)) return false;
			if (!isInt(sValue+'')) return false;
			var num = parseInt (sValue);
			return ((num >= a) && (num <= b));
		}
		catch(e){
			throw(e);
		}
	}// end function isIntegerInRange1
	
	function makeArray1(n) 
	{
		for (var i = 1; i <= n; i++) 
		{
			this[i] = 0
		} 
		return this
	}// end function makeArray1

	var daysInM = makeArray1(12);
	daysInM[1] = 31;
	daysInM[2] = 29;   
	daysInM[3] = 31;
	daysInM[4] = 30;
	daysInM[5] = 31;
	daysInM[6] = 30;
	daysInM[7] = 31;
	daysInM[8] = 31;
	daysInM[9] = 30;
	daysInM[10] = 31;
	daysInM[11] = 30;
	daysInM[12] = 31; 

	function daysInFebruary1 (year){
		try{
			return (  ((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0) ) ) ? 29 : 28 );
		}
		catch(e){
			throw(e);
		}
	}// end function daysInFebruary1
var whitespace = " \t\n\r";
function isWhitespace (s)
{   var i;

    // Is s empty?
    if (isEmpty(s)) return true;

    // Search through string's characters one by one
    // until we find a non-whitespace character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);

        if (whitespace.indexOf(c) == -1) return false;
    }

    // All characters are whitespace.
    return true;
}

function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}	
function isEmail (s)
{   if (isEmpty(s)) 
       if (isEmail.arguments.length == 1) return defaultEmptyOK;
       else return (isEmail.arguments[1] == true);
   
    // is s whitespace?
    if (isWhitespace(s)) return false;
    
    // there must be >= 1 character before @, so we
    // start looking at character position 1 
    // (i.e. second character)
    var i = 1;
    var sLength = s.length;

    // look for @
    while ((i < sLength) && (s.charAt(i) != "@"))
    { i++
    }

    if ((i >= sLength) || (s.charAt(i) != "@")) return false;
    else i += 2;

    // look for .
    while ((i < sLength) && (s.charAt(i) != "."))
    { i++
    }

    // there must be at least one character after the .
    if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
    else return true;
}//end function isEmail
	
function CheckFireFox()
{
	return window.XMLHttpRequest;
}
function isDigit (c)
	{
		var strAllowed = "1234567890";
		return (strAllowed.indexOf (c) != -1);
	}// end function isDigit
	
function getEl(sID)
{
   return document.getElementById(sID);
} // end function getEl

function ShowError(i)
{
    if (getEl("dError" + i) != null)
    {
        getEl("dError" + i).style.display = "inline";
    }
}

function hideAllErrors()
{
    var divs = document.getElementsByTagName('div');
    for (var i = 0; i < divs.length; i++)
    {
        if (divs[i].className == 'error')
        {
            divs[i].style.display = 'none';
        }
    }
}

function getEl(sID) {
    return document.getElementById(sID);
}

