
function isValidDate(dateStr) 
{
	var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{2}|\d{4})$/;
	var matchArray = dateStr.match(datePat); 
	if (matchArray == null) {
	return false;
	}
	month = matchArray[1]; 
	day = matchArray[3];
	year = matchArray[4];
	if (month < 1 || month > 12) {
	return false;
	}
	if (day < 1 || day > 31) {
	return false;
	}
	if ((month==4 || month==6 || month==9 || month==11) && day==31) {
	return false
	}
	if (month == 2) {
	var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
	if (day>29 || (day==29 && !isleap)) {
	return false;
	}
	}
	return true;
}
function isValidCurrentDate(dt)
    {
        var curDate =  new Date();                      
        var selDate = new Date();           
        var today = new Date();
        var mm, dd, yyyy;
        mm = curDate.getMonth() + 1;
        dd = curDate.getDate();
        yyyy = curDate.getFullYear()
        today = mm + '/' + dd  + '/' +  yyyy;
        today = Date.parse(today);
	     selDate = Date.parse(dt);
        if (selDate >= today)        
            return true;   
        return false;   

    }
function isValidZip(xc)
{
	var myRegxp = /^([a-zA-Z0-9])+[a-zA-Z0-9'\.\s\-]*$/;
	if (!myRegxp.test(xc))
	{
		return false;
	}
	return true;

}

function isValidEmail(xc)
{      
	
	var filter=/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if(!filter.test(xc))
	{
		return false
	}
	return true
		
}

function isValidPhone(xc)
{      
	
	var filter=/^\([1-9]\d{2}\)\s?\d{3}\-\d{4}$/;
	if(!filter.test(xc))
	{
		return false
	}
	return true
		
}

function trim(inputString) 
{
	// Removes leading and trailing spaces from the passed string. Also removes
	// consecutive spaces and replaces it with one space. If something besides
	// a string is passed in (null, custom object, etc.) then return the input.
	if (typeof inputString != "string")
	{
		return inputString; 
	}
	var retValue = inputString;
	var ch = retValue.substring(0, 1);
	while (ch == " ") 
	{ // Check for spaces at the beginning of the string
		retValue = retValue.substring(1, retValue.length);
		ch = retValue.substring(0, 1);
	}
	ch = retValue.substring(retValue.length-1, retValue.length);
	while (ch == " ") 
	{ // Check for spaces at the end of the string
		retValue = retValue.substring(0, retValue.length-1);
		ch = retValue.substring(retValue.length-1, retValue.length);
	}
	while (retValue.indexOf("  ") != -1) 
	{ // Note that there are two spaces in the string - look for multiple spaces within the string
		retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
	}
	return retValue; // Return the trimmed string back to the user
} // Ends the "trim" function



function fnReplace(checkMe,toberep,repwith)
{
	var temp = checkMe;
	var i = temp.indexOf(toberep);
	while(i!=-1)
	{
		temp = temp.replace(toberep, repwith);
		//i = temp.indexOf(toberep, i + repwith.length + 1);
		i = temp.indexOf(toberep, i + repwith.length);
	}
	return temp;
}

function doDateCompare(from, to)
{
	if (Date.parse(from.value) < Date.parse(to.value))
	{
		return true;
	}
	else 
	{
		return false;
	}
}


