function dateFormat(strDate)
{
	var vecParts = new Array();
	var strYear = '';
	var strMonth = '';
	var strDay = '';
	var strDateFormatted = '';
	
	vecParts = strDate.split('/');
	strDay = vecParts[0];
	strMonth = vecParts[1];
	strYear = vecParts[2];
	
	if (strDay.length == 1)
	{
		strDay = '0' + strDay;
	}
	
	if (strMonth.length == 1)
	{
		strMonth = '0' + strMonth;
	}
	
	strDateFormatted = strDay + '/' + strMonth + '/' + strYear;
	
	return strDateFormatted;
}

function stringToDate(strDate)
{
	var dteDate = new Date();
	var strYear = '';
	var strMonth = '';
	var strDay = '';
	
	strDate = dateFormat(strDate);
	strYear = parseInt(strDate.substr(6),10);
	strMonth = parseInt(strDate.substr(3, 2),10);
	strDay = parseInt(strDate.substr(0, 2),10);
	
	dteDate.setSeconds(0,0);
	dteDate.setMinutes(0);
	dteDate.setHours(0);	
	dteDate.setDate(strDay);
	dteDate.setMonth(strMonth - 1);
	dteDate.setYear(strYear);
	
	return dteDate;
}

function dateToString(dteDate)
{
	var strYear = '';
	var strMonth = '';
	var strDay = '';
	var strDate = '';
	
	strYear = dteDate.getFullYear();
	strMonth = dteDate.getMonth() + 1;
	strDay = dteDate.getDate();
	strDate = strDay + '/' + strMonth + '/' + strYear;
	strDate = dateFormat(strDate);
	
	return strDate;
}

function isDate(strDate) {
	var rgValidDateFormat = /^[0-9]{2}\/[0-9]{2}\/[0-9]{4}$/;
	var strYear = '';
	var strMonth = '';
	var strDay = '';
	var dteNew = new Date();
	
	if (!rgValidDateFormat.test(strDate))
	{
		return false;
	} else {
		strDate = dateFormat(strDate);
		strYear = parseInt(strDate.substr(6),10);
		strMonth = parseInt(strDate.substr(3, 2),10);
		strDay = parseInt(strDate.substr(0, 2),10);
		dteNew.setDate(strDay);
		dteNew.setMonth(strMonth - 1);
		dteNew.setYear(strYear);
			
		if((dteNew.getFullYear() == strYear) && ((dteNew.getMonth() + 1) == strMonth) && dteNew.getDate() == strDay)
		{
			return true;
		} else {
			return false;
		}
	}
}

function dateCompare(strDate1, strDate2)
{
	var dteDate1 = new Date();
	var dteDate2 = new Date();
	
	dteDate1 = stringToDate(strDate1);
	dteDate2 = stringToDate(strDate1);
		
	if (dteDate1 == dteDate2)
	{
		return 0;
	} else if (dteDate1 < dteDate2) {
		return 1;
	} else {
		return -1;
	}         
}

function daysBetweenDates(strStartDate, strEndDate)
{
	var intDays = 0;

	intDays = (stringToDate(strStartDate) - stringToDate(strEndDate))/86400000;
	
	return intDays;
}

function isEmail(strEmail) {
	var rgValidEmailFormat = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
	
	if (!rgValidEmailFormat.test(strEmail) || (strEmail == "") || (strEmail == "undefined")) {
  	return false;
	} else {
		return true;
	}  
}