/*
This file contains the data validation JavaScript functions
It is included in the HTML pages with forms that need these
data validation routines.
The functions in this file are
1.	isPassportNo		-	Checks for valid time
2.	isDate				-	Checks for valid Date and date not => today's date
3.	isEarlier			-	Checks for valid Date and date not < today's date
4.	isLater				-	Checks for valid Date and date not > today's date
5.	DaysInMonth			-	Checks for the no of days in a given month
6.	isNumber			-	Checks for valid Numeric Entry
7.	isPhone				-	Checks for valid Phone Numbers
8.	isZipcode			-	Checks for valid email string
9.	CheckisEmail		-	Force Entry for a particular field
10.	isEmpty				-	Force numeric entry 
11.	isWhitespace		-	Checks if the string contains space, tab, carriage return
12.	Trim				-	Trims a string on both sides
13.	RTrim				-	Right Trims a string 
14.	LTrim				-	Left Trims a given string
15.	blnCheckSplChar		-	Checks for invalid entry of special characters		 
16. ForceDate			-	Checks for valid date
17  forceDateAsDDMMYYYY	-	Checks whether the given date is in DDMMYYYY Format

18. isCheckSpecialChar  -   Checks Valid String allows only dot & whitespace 
								if the string contains Numbers and special Character is not Allowed
19. NewDateDiff			-  Checks Date difference between two dates and FromDate can not be greater then ToDate.
20. DraftDateDiff       - Checks That Entered Draft Date Should Not Be Earlier Then 170 Days From Current Date.	
21. isalphaNumeric		- Checks for valid alphanumeric entries							
*/

// DEFINE VARIABLES

// whitespace characters
var whitespace = " \t\n\r";

/**************************  By Shoba  *************************
1. This function isPassportNo checks if the 1st letter is a character
and subsequent entries are numbers  - Used by Shoba
****************************************************************/
function isPassportNoOld(strField)
{
	if (strField.charAt(0)>=0 && strField.charAt(0)<=9)
		return false;
	if (strField.length < 5)
		return false;
	for (var i = 1; i < strField.length; i++)
		if (strField.charCodeAt(i)<48 || strField.charCodeAt(i)>57)
			return false;

	return true;
}

function isalphaNumeric(strField)
{
	for (var i = 0; i < strField.length; i++)
		if ((strField.charCodeAt(i)<48) || ((strField.charCodeAt(i)>57) && (strField.charCodeAt(i)<65)) || ((strField.charCodeAt(i)>90) && (strField.charCodeAt(i)<97)) || (strField.charCodeAt(i)>123))
			return false;

	return true;
}


function isPassportNo(strField)
{
	for (var i = 0; i < strField.length; i++)
		if ((strField.charCodeAt(i)<48) || ((strField.charCodeAt(i)>57) && (strField.charCodeAt(i)<65)) || ((strField.charCodeAt(i)>90) && (strField.charCodeAt(i)<97)) || (strField.charCodeAt(i)>123))
			return false;

	return true;
}
/***********************   By Shoba    ***********************
Checks whether the given date is valid or not and it is not equal
to or greater than today's date
Checks for the Following formats
	(mm/dd/yyyy) or (m/dd/yyyy) or (mm/d/yyyy) or (m/d/yyyy)
	(mm-dd-yyyy) or (m-dd-yyyy) or (mm-d-yyyy) or (m-d-yyyy)
This function calls the daysInMonth to get the number of days for 
a given month & date Returns true if dteCheck is a valid date 
else false. It checks for leap year also.
****************************************************************/
function isDate(dteCheck) 
{
	var intDate
	var today
	dtetoday = new Date();
	for(var intCtr=0;intCtr<=dteCheck.length-1;intCtr++)
		if(dteCheck.charAt(intCtr)=="-")
			dteCheck=dteCheck.replace(/\-/,"/");
	intDate=dteCheck.split("/") //Splits the given date as day,month,year & stores in intDate array
	//After dteCheck is split it stores in intDate as 
	// intDate[0] is the month
	// intdate[1] is the day
	// intDate[2] is the year
	//
	if (intDate.length != 3)
		return false;
	if (intDate[0].length > 2 || intDate[1].length > 2 || intDate[0].length < 1 || intDate[1].length < 1 || intDate[2].length != 4 )
		return false;
	if (eval(intDate[2])>dtetoday.getFullYear())
		return false;
	if (eval(intDate[2])==dtetoday.getFullYear() && eval(intDate[0])> (dtetoday.getMonth() + 1))
		return false;
	if (eval(intDate[2])==dtetoday.getFullYear() && eval(intDate[0]) == (dtetoday.getMonth() +1) && eval(intDate[1]) >= dtetoday.getDate())
		return false;
	if (intDate[2]>1850 && intDate[0]>=1 && intDate[0]<=12 && intDate[1]>=1 && intDate[1]<=DaysInMonth(intDate[0],intDate[2]))
		return true;
	else
		return false;
}


function isEarlier(dteCheck) 
{
	var intDate
	var today
	dtetoday = new Date();
	for(var intCtr=0;intCtr<=dteCheck.length-1;intCtr++)
		if(dteCheck.charAt(intCtr)=="-")
			dteCheck=dteCheck.replace(/\-/,"/");
	intDate=dteCheck.split("/") //Splits the given date as day,month,year & stores in intDate array
	//After dteCheck is split it stores in intDate as 
	// intDate[0] is the month
	// intdate[1] is the day
	// intDate[2] is the year
	//
	if (intDate.length != 3)
		return false;
	if (intDate[0].length > 2 ||  intDate[1].length > 2 || intDate[0].length < 1 || intDate[1].length < 1 || intDate[2].length != 4 )
		return false;
	if (eval(intDate[2])<dtetoday.getFullYear())
		return false;
	if (eval(intDate[2])==dtetoday.getFullYear() && eval(intDate[0])< (dtetoday.getMonth() + 1))
		return false;
	if (eval(intDate[2])==dtetoday.getFullYear() && eval(intDate[0]) == (dtetoday.getMonth() +1) && eval(intDate[1]) < dtetoday.getDate())
		return false;
	if (intDate[2]>1850 && intDate[0]>=1 && intDate[0]<=12 && intDate[1]>=1 && intDate[1]<=DaysInMonth(intDate[0],intDate[2]))
		return true;
	else
		return false;
}

function DateDiff(FromDate, ToDate) 
{
	var intDate
	var today
	dtetoday = new Date(FromDate);
	for(var intCtr=0;intCtr<=ToDate.length-1;intCtr++)
		if(ToDate.charAt(intCtr)=="-")
			ToDate=ToDate.replace(/\-/,"/");
	intDate=ToDate.split("/") //Splits the given date as day,month,year & stores in intDate array
	//After dteCheck is split it stores in intDate as 
	// intDate[0] is the month
	// intdate[1] is the day
	// intDate[2] is the year
	//
	if (intDate.length != 3)
		return false;
	if (intDate[0].length > 2 || intDate[1].length > 2 || intDate[0].length < 1 || intDate[1].length < 1 || intDate[2].length != 4 )
		return false;
	if (eval(intDate[2])<dtetoday.getFullYear())
		return false;
	if (eval(intDate[2])==dtetoday.getFullYear() && eval(intDate[0])< (dtetoday.getMonth() + 1))
		return false;
	if (eval(intDate[2])==dtetoday.getFullYear() && eval(intDate[0]) == (dtetoday.getMonth() +1) && eval(intDate[1]) < dtetoday.getDate())
		return false;
	if (intDate[2]>1850 && intDate[0]>=1 && intDate[0]<=12 && intDate[1]>=1 && intDate[1]<=DaysInMonth(intDate[0],intDate[2]))
		return true;
	else
		return false;
}




/****************************By Maha****************************
Checks whether the given date is valid & is later than Today's Date
Checks for the Following formats
	(mm/dd/yyyy) or (m/dd/yyyy) or (mm/d/yyyy) or (m/d/yyyy)
	(mm-dd-yyyy) or (m-dd-yyyy) or (mm-d-yyyy) or (m-d-yyyy)
This function calls the isDate function to Check for valid date
and then checks for date greater than today.
Returns true if dteCheck is greater than today else false
****************************************************************/
function isLater(dteCheck)	
{
	var intDate
	var today
	dtetoday = new Date();
	for(var intCtr=0;intCtr<=dteCheck.length-1;intCtr++)
		if(dteCheck.charAt(intCtr)=="-")
			dteCheck=dteCheck.replace(/\-/,"/");
	intDate=dteCheck.split("/") //Splits the given date as day,month,year & stores in intDate array
	//After dteCheck is split it stores in intDate as 
	// intDate[0] is the month
	// intdate[1] is the day
	// intDate[2] is the year
	if (intDate.length != 3)
		return false;
	if (eval(intDate[2])>dtetoday.getFullYear())
		return false;
	if (eval(intDate[2])==dtetoday.getFullYear() && eval(intDate[0])> (dtetoday.getMonth() + 1))
		return false;
	if (eval(intDate[2])==dtetoday.getFullYear() && eval(intDate[0]) == (dtetoday.getMonth() +1) && eval(intDate[1]) > dtetoday.getDate())
		return false;
	if (intDate[2]>1850 && intDate[0]>=1 && intDate[0]<=12 && intDate[1]>=1 && intDate[1]<=DaysInMonth(intDate[0],intDate[2]))
		return true;
	else
		return false;
}

/****************************By Maha****************************
	This function DaysInMonth returns the No. of days for given 
	valid Month & Year. It checks for leap year also which accurs 
	in years divisible by four. If the year is a century checks it  
	is divisible by 400.
****************************************************************/
function DaysInMonth(intMon,intYr)
{
//	switch(parseInt(intMon,10))
	switch(eval(intMon))
	{
		case 2:
			if ((intYr%100)==0)
				if ((intYr%400)==0) 
					return 29;
				else
					return 28;
			else if((intYr%4)==0)
					return 29;
			else
				return 28;
			break;
		case 4:
			return 30
			break;
		case 6:
			return 30
			break;
		case 9:
			return 30
			break;
		case 11:
			return 30
			break;
		default:
			return 31;
			break;
	}
}



/*****************************By Srini*****************************
Returns true if the string passed in is a valid number
(no alpha characters), else it displays an error message
****************************************************************/
function isNumber(objValue)
{
	var strField = objValue;
	
	if (isWhitespace(strField)) return false;

	var i = 0;

	for (i = 0; i < strField.length; i++)
		if (strField.charAt(i) < '0' || strField.charAt(i) > '9') 
		{
			return false;
		}

	return true;
}

function isNumeric(objValue)
{
	var strField = objValue;
	
	if (isWhitespace(strField)) return false;

	var i = 0;
	var decimalAppeared = 0;

	for (i = 0; i < strField.length; i++)
		if (strField.charAt(i) < '0' || strField.charAt(i) > '9') 
		{
			if(strField.charAt(i) == '.')
			{
				decimalAppeared = decimalAppeared + 1;
			}
			if((strField.charAt(i) != '.') || decimalAppeared > 1)
			{
				return false;
			}
		}

	return true;
}

/******************************************************************
Returns true if the string passed in is a valid phone number
(no alpha characters), else it displays an error message
****************************************************************/
function isPhone(objValue)
{
     var i,s;
	var condition;
	//var obj=Trim(str.value);
	var obj=objValue;
	var len = obj.length;
	
	for (i=0;i<len;i=i+1)
	 {
		s =  obj.charCodeAt(i);
		condition=((s >= 48) && (s <= 57)) || (s==32)||(s==45)||(s==40)||(s==41);
		if (!(condition))
		{
		   return false;
		}
	}
 return true;
}


/*****************************By Srini*****************************
 This function determines if the string passed in is a valid
 Indian zip code.  It accepts  ######. If the
 string is valid, it returns true, else false.
 Change Description :For Philippines Area Code Contains Only Four Digit And It IS Similar to ZipCode
 Done BY:Abhishek
****************************************************************/
function isZipcode(strZip)
{
	var s = strZip;
	
	if (s.length < 4)
		{
		// inappropriate length
		return false;
		}

	for (var i=0; i < s.length; i++)
		if (s.charAt(i) < '0' || s.charAt(i) > '9')
		{
		return false;
		}
	return true;
}




/*****************************By Srini*****************************
Check whether string s is empty.
***************************************************************/
function isEmpty(s)
{   
	return ((s == null) || (s.length == 0))
}



/*****************************By Srini*****************************
 Returns true if string s is empty or 
 whitespace characters only.
*****************************************************************/
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;
}


/***********************    By Shoba   *************************
This function Trim is used to trim blank spaces in the 
given string on both sides(right & left)
****************************************************************/

function Trim(s) 
{
	var j='';
	var i ='';

	var first='';
	var last ='';

	var val;
	val = s;


	for(i = 0;i<val.length;i++)
	{
		if(val.charCodeAt(i)!=32)
		{
		 for(j=i;j <val.length ;j++)
			first = first + val.charAt(j);
			
		break;
		}	
	}

	i= first.length-1;
	while(first.charCodeAt(i)==32)
		i=i-1;	
	
	j=0;
	for(j=0;j<i+1;j++)
		last = last + first.charAt(j);
	return last;
}


/****************************By Maha****************************
This function RTrim is used to trim blank spaces in the 
given string on right side
****************************************************************/
function RTrim(strVal)
{
	var j=strVal.length-1;
	while(strVal.charAt(j--)==' ');
	return strVal.substr(0,j+2);
}


/****************************By Maha****************************
This function RTrim is used to trim blank spaces in the 
given string on left side
****************************************************************/
function LTrim(strVal)
{
	var i=0;
	while(strVal.charAt(i++)==' '); 
	alert(i);
	return strVal.substr(--i,strVal.length-i+2);
}




function blnCheckSplChar(prmStrTextField)
{
	var strX = prmStrTextField     //strX and strY variables to check for a matching string
	var strY = (prmStrTextField.match("\[^@]+\[@]{1}\[^@]+"));
	
	if ((prmStrTextField.match("\[^@]+\[@]{1}\[^@]+"))==null)
		{
			return true;
		}
		else
		{
			if (strX == strY)
			{
				return false;
			}			
			else
			{
				return true;
			}
		}
}

function ForceDate(val)
{
	var intDate
	var today
	dtetoday = new Date();
	for(var intCtr=0;intCtr<=val.length-1;intCtr++)
		if(val.charAt(intCtr)=="-")
			val=val.replace(/\-/,"/");
	intDate=val.split("/") //Splits the given date as day,month,year & stores in intDate array
	//After dteCheck is split it stores in intDate as 
	// intDate[0] is the month
	// intdate[1] is the day
	// intDate[2] is the year
	if (intDate.length != 3)
		return false;
	if (intDate[0].length > 2 || intDate[0].length==0 || intDate[1].length > 2 || intDate[1].length==0 )
		return false;
	if (intDate[2].length != 4)
		return false;
	if (intDate[2]>1950 && intDate[0]>=1 && intDate[0]<=12 && intDate[1]>=1 && intDate[1]<=DaysInMonth(intDate[0],intDate[2]))
		return true;
	else
		return false;
} 


function ForceDateAsDDMMYYYY(val)
{
	var intDate
	var today
	dtetoday = new Date();
	for(var intCtr=0;intCtr<=val.length-1;intCtr++)
		if(val.charAt(intCtr)=="-")
			val=val.replace(/\-/,"/");
	intDate=val.split("/") //Splits the given date as day,month,year & stores in intDate array
	//After dteCheck is split it stores in intDate as 
	// intDate[0] is the month
	// intdate[1] is the day
	// intDate[2] is the year
	if (intDate.length != 3)
		return false;
	if (intDate[0].length > 2 || intDate[0].length==0 || intDate[1].length > 2 || intDate[1].length==0 )
		return false;
	if (intDate[2].length != 4)
		return false;
	if (intDate[2]>1950 && intDate[1]>=1 && intDate[1]<=12 && intDate[0]>=1 && intDate[0]<=DaysInMonth(intDate[1],intDate[2]))
		return true;
	else
		return false;
}


function CheckIsmail(obj)
 {
  var locAt=0;
  var locDot=0;
  var flagAt=0;
  var flagDot=0;
  var cntAt=0;
  var cntDot=0;

  for (i=0;i<obj.length;i++)
   {
     s =  obj.charCodeAt(i)
     if (i==0 || i==obj.length-1)
       {
         if ((s ==45) || (s==95))
          {
            return false;
          } 
       }
     cndt=(s >=48 && s <= 57) || (s>=65 && s<=90) || (s>=97 && s<=122) || (s==64) || (s==46) || (s==95) || (s==45)
	 if (!(cndt))
		{
		  return false;
		}
      s1=obj.substr(i,1)
      if (s1=='@')
        {
          cntAt=cntAt+1
          locAt=i
        }
      if (s1=='.')
        {
          cntDot=cntDot+1
          locDot=i
        }
     /* if (locDot!=0 && locAt!=0)
      {     
		if(locDot<locAt)
		  {
		    return false;
		  }                     
       }*/ 
	  if (cntAt >1)
	  {
		return false;
      }        
  }
	s2=obj.charCodeAt(locAt+1)
	s3=obj.charCodeAt(locAt-1)
	s=s2
	cndtBef=(s >= 48 && s <= 57) || (s>=65 && s<=90) || (s>=97 && s<=122) 
	s=s3
	cndtAft=(s >= 48 && s <= 57) || (s>=65 && s<=90) || (s>=97 && s<=122) 
	if (cndtBef && cndtAft)
	 {
	   flagAt=1
	 }
	 s2=obj.charCodeAt(locDot+1)
	 s3=obj.charCodeAt(locDot-1)
	 s=s2
	 cndtBef=(s >= 48 && s <= 57) || (s>=65 && s<=90) || (s>=97 && s<=122) 
	 s=s3
	 cndtAft=(s >= 48 && s <= 57) || (s>=65 && s<=90) || (s>=97 && s<=122) 
	 if (cndtBef && cndtAft)
	  {
	    flagDot=1 
	  }
	  
	 if (flagAt==1 && flagDot==1)
	    {
	      return true;
		}
	 else
	  {
		return false;
	  }		
 } 
 
 
 function ContainsSpecialChar(strVal)
{
	var pos;
	for (pos=0;pos<strVal.length;pos++)
	{
		if(strVal.charCodeAt(pos)==60 ||strVal.charCodeAt(pos)==62 ||strVal.charCodeAt(pos)==34)
			return true;
	}
	return false;
}


function isAddressValid(strVal)
{
	var pos;
	for (pos=0;pos<strVal.length;pos++)
	{
		if(strVal.charCodeAt(pos)==44 || strVal.charCodeAt(pos)==60 ||strVal.charCodeAt(pos)==62 ||strVal.charCodeAt(pos)==34)
			return true;
	}
	return false;
}

function isAlphabetsOnly(strVal)
{
	var pos;
	for (pos=0;pos<strVal.length;pos++)
	{
		if (strVal.charCodeAt(pos) != 32)
		{
			if ((strVal.charCodeAt(pos) > 90 && strVal.charCodeAt(pos) < 97) || strVal.charCodeAt(pos)< 65 || strVal.charCodeAt(pos)> 122)
				return false;
		}
	}
	return true;
}

function isAlphaNumericOnly(strVal)
{
	var pos;
	for (pos=0;pos<strVal.length;pos++)
	{
		if (strVal.charCodeAt(pos) != 32)
		{
			if ((strVal.charCodeAt(pos) > 90 && strVal.charCodeAt(pos) < 97) || (strVal.charCodeAt(pos) > 57 && strVal.charCodeAt(pos) < 65) || strVal.charCodeAt(pos)< 48 || strVal.charCodeAt(pos)> 122)
				return false;
		}
	}
	return true;
}

function isAllowed(strVal)
{
	var pos;
	for (pos=0;pos<strVal.length;pos++)
	{
		if (strVal.charCodeAt(pos) != 38 && strVal.charCodeAt(pos) != 39 && strVal.charCodeAt(pos) != 32)
		{
			if ((strVal.charCodeAt(pos) > 90 && strVal.charCodeAt(pos) < 97) || (strVal.charCodeAt(pos) > 57 && strVal.charCodeAt(pos) < 65) || strVal.charCodeAt(pos)< 48 || strVal.charCodeAt(pos)> 122)
				return false;
		}
	}
	return true;
}

function isDateDMY(dteCheck) 
{
	var intDate
	var today
	dtetoday = new Date();
	for(var intCtr=0;intCtr<=dteCheck.length-1;intCtr++)
		if(dteCheck.charAt(intCtr)=="-")
			dteCheck=dteCheck.replace(/\-/,"/");
	intDate=dteCheck.split("/") //Splits the given date as day,month,year & stores in intDate array
	//After dteCheck is split it stores in intDate as 
	// intDate[0] is the day
	// intdate[1] is the month
	// intDate[2] is the year
	//
	if (intDate.length != 3)
		return false;
	if (intDate[1].length > 2 || intDate[0].length > 2 || intDate[1].length < 1 || intDate[0].length < 1 || intDate[2].length != 4 )
		return false;
	if (eval(intDate[2])>dtetoday.getFullYear())
		return false;
	if (eval(intDate[2])==dtetoday.getFullYear() && eval(intDate[1])> (dtetoday.getMonth() + 1))
		return false;
	if (eval(intDate[2])==dtetoday.getFullYear() && eval(intDate[1]) == (dtetoday.getMonth() +1) && eval(intDate[0]) >= dtetoday.getDate())
		return false;
	if (intDate[2]>1850 && intDate[1]>=1 && intDate[1]<=12 && intDate[0]>=1 && intDate[0]<=DaysInMonth(intDate[1],intDate[2]))
		return true;
	else
		return false;
}

function ChangeFormat(InputDate)
{
	var OutputDate;
	var dteDate;
	for(var intCtr=0;intCtr<=InputDate.length-1;intCtr++)
		if(InputDate.charAt(intCtr)=="-")
			InputDate=InputDate.replace(/\-/,"/");
	dteDate=InputDate.split("/") //Splits the given date as day,month,year & stores in intDate array
	//After InputDate is split it stores in intDate as 
	// dteDate[0] is the day
	// dtedate[1] is the month
	// dteDate[2] is the year
	OutputDate = dteDate[1] + '/' + dteDate[0] + '/' + dteDate[2];
	return OutputDate;
}

function isTimeValid(strTime)
{
	if(strTime.value.length!=5)
		return false
	for (i = 0; i < strTime.value.length; i++)
	{
		if(i!=2)
		{
			if (strTime.value.charAt(i) < '0' || strTime.value.charAt(i) > '9')
					return false;
					
		}	
		else if(i==2)
		{
			if (strTime.value.charAt(i)!=':') 
				return false
				
		}	
	}	
				
	startArr=strTime.value.split(":")
	if ((startArr[0]>23) || (startArr[1]>59))
		return false
}

/** This function is Allows Only Characters, Dot,whitespace,
			where numbers and special characters are not allowed 
created by Rajesh.p
on 16th Nov 2005
*/
function isCheckSpecialChar(strVal)
{
	var pos;
	for(pos=0; pos<strVal.length;pos++)
	{
		if((strVal.charCodeAt(pos)>=65 && strVal.charCodeAt(pos)<=90)  || (strVal.charCodeAt(pos)>=97 && strVal.charCodeAt(pos)<=122) || (strVal.charCodeAt(pos)==32)||(strVal.charCodeAt(pos)==46))
		{
			//return true;
		}
		else
		{
			return false;
		}
	}
	return true;
}

/** This function is avoid Enter date is greater then Current Date
Modified by Rajesh.P
on 17th Nov 2005
*/
function isLaterNew(dteCheck)	
{
	var intDate
	var today
	dtetoday = new Date();
	for(var intCtr=0;intCtr<=dteCheck.length-1;intCtr++)
		if(dteCheck.charAt(intCtr)=="-")
			dteCheck=dteCheck.replace(/\-/,"/");
	intDate=dteCheck.split("/") //Splits the given date as day,month,year & stores in intDate array
	//After dteCheck is split it stores in intDate as 
	// intDate[0] is the month
	// intdate[1] is the day
	// intDate[2] is the year
	if (intDate.length != 3)
		return false;
	if (eval(intDate[2])>dtetoday.getFullYear())
		return false;
	if (eval(intDate[2])==dtetoday.getFullYear() && eval(intDate[1])> (dtetoday.getMonth() + 1))
		return false;
	if (eval(intDate[2])==dtetoday.getFullYear() && eval(intDate[1]) == (dtetoday.getMonth() +1) && eval(intDate[0]) > dtetoday.getDate())
		return false;
	if (intDate[2]>1850 && intDate[1]>=1 && intDate[1]<=12 && intDate[0]>=1 && intDate[0]<=DaysInMonth(intDate[1],intDate[2]))
		return true;
	else
		return false;
}
/***************************************************************************************************************/
/*****************By Abhishek ************************

	Purpose: To check that FromDate is always less then ToDate when Both dates 
			 are in DD/MM/YYYY format
*****************************************************************/
function newDateDiff(FromDate, ToDate) 
				{
				
					var date1
					var date2
		
/*					for (var intCtr1=0;intCtr1<FromDate.length;intCtr1++)
					{
		
						if (FromDate.charAt(intCtr1) == "-")
							FromDate=FromDate.replace(/\-/,"/");
					}*/
					date1=FromDate.split("/");
					var str1=date1[1]+"/"+date1[0]+"/"+date1[2]	
			
					for (var intCtr2=0;intCtr2<ToDate.length;intCtr2++)
					{
						if(ToDate.charAt(intCtr2)=="-")
							ToDate=ToDate.replace(/\-/,"/");
					}
					date2=ToDate.split("/");
					var str2=date2[1]+"/"+date2[0]+"/"+date2[2]
					
					return(DateDiff(str1,str2))
				}
				
/***************************************************************************************************************/
/*****************By Abhishek ************************

	Purpose: To check that That Entered Draft Date Should Not Be Earlier Then 170 Days From Current Date. 
			 
*****************************************************************/	
function DraftDateDiff(FromDate, ToDate) 
				{
				
					var date1
					var date2
					var days
		
					for (var intCtr1=0;intCtr1<FromDate.length;intCtr1++)
					{
		
						if (FromDate.charAt(intCtr1) == "-")
							FromDate=FromDate.replace(/\-/,"/");
					}
					date1=FromDate.split("/");
					dtStr1=new Date(date1[1]+"/"+date1[0]+"/"+date1[2])
					
			
					for (var intCtr2=0;intCtr2<ToDate.length;intCtr2++)
					{
						if(ToDate.charAt(intCtr2)=="-")
							ToDate=ToDate.replace(/\-/,"/");
					}
					date2=ToDate.split("/");
					dtStr2=new Date(date2[1]+"/"+date2[0]+"/"+date2[2])
				
					var dtDiff=new Date();
					var timeDiff=Math.abs(dtStr1.getTime()-dtStr2.getTime());
				
					days=Math.floor(timeDiff/(1000 * 60 * 60 * 24));
					
					if (days>170)
					{
						return false;
					}
				}			 
		/*function fnClear(oSrc, args)
		{
			if(window.document.all("trresult").style.visibility == "visible")
			{
				window.document.all("trresult").style.visibility = "hidden";
				window.document.all("trresult").style.display = "none";
			}		
			args.IsValid= (args.Value.length == 12);
		}*/
	