function Check_numeric (arg,len) {
        var re = /^[0-9]+$/;
        if (arg.length != len && len > 0)
                return (false);

        if (arg.search(re) == -1){
            return (false);
        } else {
                return (true);
        }
}

function Check_numeric_len (arg,min,max) {
        var re = /^[0-9]+$/;
        if (arg.length < min || arg.length > max)
                return (false);

        if (arg.search(re) == -1){
            return (false);
        } else {
                return (true);
        }
}

function Check_alphanumeric_len (arg,min,max) {
        //var re = /^[A-Za-z0-9\s]+$/;
        var re = /\"/;
        if (arg.length < min || arg.length > max)
                return false;

        if (arg.search(re) == -1){
            return (true);
        } else {
                return (false);
        }
}

function Check_alpha_len (arg,min,max) {
        var re = /^[A-Za-z\s]+$/;

        if (arg.length < min || arg.length > max)
                return false;

        if (arg.search(re) == -1){
            return (false);
        } else {
                return (true);
        }
}

function get_month(arg) {
        if (arg == 1) arg2 = "January";
        if (arg == 2) arg2 = "February";
        if (arg == 3) arg2 = "March";
        if (arg == 4) arg2 = "April";
        if (arg == 5) arg2 = "May";
        if (arg == 6) arg2 = "June";
        if (arg == 7) arg2 = "July";
        if (arg == 8) arg2 = "August";
        if (arg == 9) arg2 = "September";
        if (arg == 10) arg2 = "October";
        if (arg == 11) arg2 = "November";
        if (arg == 12) arg2 = "December";
        return arg2;
}

function get_day(arg) {
        arg2 = "";
     	if (arg == 0) arg2 = "Sunday";
       	if (arg == 1) arg2 = "Monday";
       	if (arg == 2) arg2 = "Tuesday";
       	if (arg == 3) arg2 = "Wednesday";
       	if (arg == 4) arg2 = "Thursday";
       	if (arg == 5) arg2 = "Friday";
       	if (arg == 6) arg2 = "Saturday";
        return arg2;
}


function fn_DateConformation(nDate,nMonth,nYear)
{
	var join_date = (nMonth+"/"+ nDate+"/"+ nYear);
       	var offset_date = new Date(join_date);
       	var day_index = offset_date.getDay();
        var new_day1 = offset_date.getDate();	
	if ( day_index == 0 )
	{
		alert( "The date you entered is a Sunday. Please try again.");
		return false;
	}
	else
	{
		message = "You have entered " + get_day(day_index) + " " + get_month(nMonth) +" " + new_day1 +", " + nYear + ". Is this correct?" ;
       		if (confirm(message)) 
			 return true;
		else
 			 return false;
	}
}

function fn_DateConformation2(nDate,nMonth,nYear)
{
	var join_date = (nMonth+"/"+ nDate+"/"+ nYear);
       	var offset_date = new Date(join_date);
       	var day_index = offset_date.getDay();
	var new_day1 = offset_date.getDate();

	message = "You have entered " + get_day(day_index) + " " + get_month(nMonth) +" " +new_day1 +", " + nYear + ". Is this correct?" ;
	if (confirm(message)) 
		 return true;
	else
		 return false;
}
	/*----------------------------------------------------------------------------------------
	Function Name       : IsDate
	Author		    : Pathiri Venugopal
	Parameters			: pszFieldObj - The field to be validated. Eg. "document.frmTest.txtTheField"
	Purpose				: Verifies if the value in the text object passed is a proper date or not. 
						  It validates format matching either mm-dd-yyyy or mm/dd/yyyy. 
						  Then it checks to make sure the month has the proper number of days, 
						  based on which month it is.
	-------------------------------------------------------------------------------------------*/
	function IsDate ( pszFieldObj )
	{
		var szTheDate = TrimTheString( eval ( pszFieldObj ).value )
		var reTheRegExp = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
		var aMatchArray = szTheDate.match(reTheRegExp); // is the format ok?

		if (aMatchArray == null) 
		{
			alert("Please enter date as either mm/dd/yyyy or mm-dd-yyyy.");
			return false;
		}

		nMonth = aMatchArray[1]; // parse date into variables
		nDay = aMatchArray[3];
		nYear = aMatchArray[5];
		
		if ( nYear < 1900 )
		{
			alert("Year must be greater than 1900.");
			return false;
		}

		if ( nMonth < 1 || nMonth > 12 ) // check month range
		{
			alert("Month must be between 1 and 12.");
			return false;
		}

		if ( nDay < 1 || nDay > 31 ) 
		{
			alert("Day must be between 1 and 31.");
			return false;
		}

		if ( ( nMonth == 4 || nMonth == 6 || nMonth == 9 || nMonth == 11) && nDay == 31 ) 
		{
			alert("Month " + nMonth + " does not have 31 days!")
			return false;
		}

		if ( parseInt ( nMonth ) == 2) // check for february 29th
		{
			var isleap = ( nYear % 4 == 0 && ( nYear % 100 != 0 || nYear % 400 == 0 ) );
			if ( parseInt ( nDay ) > 29 || ( parseInt ( nDay ) == 29 && !isleap ) ) 
			{
				alert("February " + nYear + " doesn't have " + nDay + " days!");
				return false;
			}
		}
		return true; // date is valid
	}

	/*----------------------------------------------------------------------------------------
	Function Name       : IsProperDate
	Author		: Pathiri Venugopal
	Parameters			: pszFieldObj - The field to be validated. Eg. "document.frmTest.txtTheField"
	Purpose				: Another Variation for date Validation that allows the following entries -
							MM/DD/YYYY, M/D/YYYY, MMDDYYYY and MDYYYY
						  This function is also used in the FormatDate() function.
	-------------------------------------------------------------------------------------------*/
	function IsProperDate ( pszFieldObj,pszConfirmFlag,pszFuturFlag,TIMEZONE )
   	{
		//Find out what broswer type the user has.
        	var IE  = document.all;
        	var DOM = document.getElementById;

		var lobjFieldObj = eval( pszFieldObj );
		if ( lobjFieldObj.value.length > 10 )
		{
			 alert("Date length cannot exceed 10 characters.");
			 lobjFieldObj.focus()
			 return false;
		}

		var mystring = pszFieldObj.value;
		if (mystring.search("/") > -1)
		{
			var temp = mystring.split ( "/" );
			var nMonth = temp[0];
			var nDay = temp[1];
			var nYear = temp[2];
		}
		else if (mystring.search("-") > -1)
		{
			var temp = mystring.split ( "-" );
			var nMonth = temp[0];
			var nDay = temp[1];
			var nYear = temp[2];
		}
		else if (mystring.length == 6)
		{
			var nMonth = mystring.substring(0,2);
			var nDay = mystring.substring(2,4);
			var nYear = mystring.substring(4,6);
		}
		else if (mystring.length == 8)
		{
			var nMonth = mystring.substring(0,2);
			var nDay = mystring.substring(2,4);
			var nYear = mystring.substring(4,8);
			// Additional Change not displaying alert box with Date change. 02-26-04 p.t.
			//alert (nMonth + "|" + nDay + "|" + nYear);
		}
		else
		{
		//Change made Issue 23 per client request. Display generic error message instead. p.t. 02-26-04
	   		alert("Please enter the date in MM/DD/YYYY format.");
			return false;
		}

		if( (isNaN(nMonth)) || (isNaN(nDay)) || (isNaN(nYear)) )
		{
	   		alert("Please enter the date in MM/DD/YYYY format.");
			return false;
		}

		if(nYear.length == 2)
		{
			nYear = "20" + nYear;
		}
		
		if(nMonth.length == 1)
		{
			nMonth = "0" + nMonth;
		}

		if(nDay.length == 1)
		{
			nDay = "0" + nDay;
		}

		//Create the new date string and put it in the text box
		var newYear = nMonth + "/" + nDay + "/" + nYear;
		pszFieldObj.value = newYear;

		day = parseInt ( nDay, 10 )
		month = parseInt ( nMonth, 10 )
		year = parseInt ( nYear, 10 )
		if ( isNaN ( day ) || isNaN ( month ) || isNaN ( year ) )
		{
			alert("Invalid Date.");
			return false;
		}
		   
		if ( ( day < 0 ) || ( month < 0 ) || ( year < 0 ) )
		{
			alert("Please enter the date in MM/DD/YYYY format.");
			return false;
		}
		if ( ( day == 0 ) || ( month == 0 ) || ( year == 0 ) )
		{
			alert("Invalid Date.");
			return false;
		}
		if ( month > 12 )
		{
		   alert("Please enter the date in MM/DD/YYYY format.");
		   return false;
		}

		if ( day > 31 )
		{
			 alert("Please enter the date in MM/DD/YYYY format.")
			 return false;
		}
		if ( ( month == 4 ) || ( month == 6 ) || ( month == 9 ) || ( month == 11 ) )
		{
			if ( day > 30 ) 
			{
				alert("Please enter the date in MM/DD/YYYY format.")
				return false;
			}
		}
		if ( month == 2 )
		{
			if  ( ( year % 4 == 0 ) && ( ( !(year % 100 == 0) ) || ( year % 400 == 0 ) ) ) 
			{
				if ( day > 29 )
				{
					alert("Please enter the date in MM/DD/YYYY format.")
					return false;
				}        
					   
			}  
			else     
			{
				if ( day > 28 )
				{
					alert("Please enter the date in MM/DD/YYYY format.")
					return false;
				} 
			}    
		}  

		if ( nYear < 1900 )
		{
			alert("Year cannot be less than 1900.");
			return false;
		}

		//**************************************//
		// Convert to our type of date.		//
		//**************************************//
		var mydate = new Date(nMonth, nDay, nYear);
		/* Future date checking*/
     		if ( pszFuturFlag == true )
		{
 	         	var todate = new Date();
                	var today   = todate.getDate();
                	var tomonth = todate.getMonth()+1;
                	var toyear  = todate.getYear();
			//Gets Hours reporting.
			//Determine Hours by Timezone is no longer Needed the functionality is diffrent The Date function in Java Script gives you the local time of the user not the EST time. 04/08/04
			//Gathering Minute and Hour
			var min_time = todate.getMinutes();
			var time = todate.getHours();
			//NETSCAPE returns the year as num of years from 1900
			if(!IE)
			{
				toyear = 1900 + toyear;
			}

       		        if ( year > toyear)
                	{
                        	alert("You can not report for a delivery date in the future. Please enter another date.");
                        	return false;
                	}
     
     		        if ( year == toyear)
                	{
				if (month > tomonth)
                        	{
                        		alert("You can not report for a delivery date in the future. Please enter another date.");
                                	return false;
                        	}  
				if  (month == tomonth)
                        	{
					if ( day > today )
					{
                        			alert("You can not report for a delivery date in the future. Please enter another date.");
                              	 		return false;
					}
					//Checking for Callers Timezone and Today's date. 
					// Additional Change Checking for The minutes on the 7 am hour. 
					if ( ( day == today ) && ( time >= 0 ) && ( time <= 7 ) ) 
					{
						if ( ( time == 7 ) && ( min_time < 55 ) )
						{
						alert("You cannot report mail for today's date before 8:00 AM.  Please try again.");
						return false;
						}
						if  ( time <= 6 ) 	
						{
					        alert("You cannot report mail for today's date before 8:00 AM.  Please try again.");
						return false;
						}
					}
				}
			}
		}
		/* End Future date checking*/
/*
TODO: Remove me if no one else needs me. Do this on the page itself.
		//if ( pszConfirmFlag == true )
		{	
			//if ( fn_DateConformation ( day,month,year) )
			//	return true;
			//else
			//	return false;
		}
		else
		{
		   return true;
		}
*/
		   return true;

	}

	/*----------------------------------------------------------------------------------------
	Function Name       : IsEmail
	Author		: Pathiri Venugopal
	Parameters			: pszFieldObj - The field to be validated. Eg. "document.frmTest.txtTheField"
	Purpose				: For E-mail validation
	-------------------------------------------------------------------------------------------*/
	function IsEmail ( pszFieldObj )
	{
		//var reEmail = /^.+\@.+\..+$/	
		var reEmail = /^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;
		//var reEmail = /^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.([a-zA-Z]){2,4})$/
		var szBadStrings = " ~`!#$%^&*()+=[{]}|\<>?,:';";
		var szCurrChar;

		szFieldValue = TrimTheString( eval ( pszFieldObj ).value );
		for ( var i=0 ; i < szFieldValue.length ; i++)
		{
			j = i + 1;
			szCurrChar = szFieldValue.substring ( i , j );
			if ( szBadStrings.indexOf ( szCurrChar ) != -1 )
			{		
				alert("Sorry, Special Character are Not allowed in this Field.");
				eval ( pszFieldObj ).focus();
				return false;
			}
		}

		if ( reEmail.test ( szFieldValue ) == false )
		{
			alert("Please enter a Valid E-mail address.");
			eval ( pszFieldObj ).focus();
			//alert("false");
			return false;
		}
		//alert("true");
		return true;
	}

	/*----------------------------------------------------------------------------------------
	Function Name       : IsValidTime
	Author		: Pathiri Venugopal
	Parameters			: pszFieldObj - The field to be validated. Eg. "document.frmTest.txtTheField"
	Purpose				: To validate the Time in HH:MM format
	-------------------------------------------------------------------------------------------*/
	function IsValidTime ( pszFieldObj )
	{
		var szFieldValue;
		var szHourPart;
		var szMinutePart;
		var szDivider;
		var reInteger = /^\d+$/
		
		szFieldValue = TrimTheString( eval ( pszFieldObj ).value )
		if ( szFieldValue.length < 4 || szFieldValue.length > 5 )
		{
			alert("Please enter a Time or Unknown if you don't know the time of delivery.");
			eval( pszFieldObj ).value="";
			eval( pszFieldObj ).focus();
			return false;
		}
	
		if ( szFieldValue.indexOf ( "." ) != -1 )
		{
			alert(" The Time should be specified in HH:MM format.");
			eval( pszFieldObj ).focus();
			return false;
		}  
	
		var option = 0;
		if ( szFieldValue.length == 5 )
		{
			szDivider = szFieldValue.substr ( 2 , 1 );
			if ( szDivider != ":" )
			{
				alert(" The Time should be specified in HH:MM format.");
				eval( pszFieldObj ).focus();
				return false;
			}
			  
		}
		
		if ( szFieldValue.indexOf ( ":" ) == -1 )
		{
			szHourPart = szFieldValue.substr ( 0 , 2 );
			szMinutePart = szFieldValue.substr ( 2 , 2 );
		}
		else if ( szFieldValue.indexOf( ":" ) == 1 )
		{
			szHourPart = szFieldValue.substr( 0, 1 );
			szMinutePart = szFieldValue.substr( 2, 2);
		}
		else
		{
			szHourPart = szFieldValue.substr ( 0 , 2 );
			szMinutePart = szFieldValue.substr ( 3 , 2 );
		}
	
		if ( reInteger.test(szHourPart) == false || reInteger.test ( szMinutePart ) == false )
		{
			alert("3 - The Time should be specified in HH:MM format.");
			eval( pszFieldObj ).focus();
			return false;
		}
		else
		{
			if ( parseInt ( szHourPart ) > 23 || parseInt ( szHourPart ) < 0 )
			{
				alert("The hour value should not exceed 23.");
				eval( pszFieldObj ).focus();
				return false;
			}
			if ( parseInt ( szMinutePart ) > 59 || parseInt ( szMinutePart ) < 0)
			{
				alert("The minute value should not exceed 59.");
				eval( pszFieldObj ).focus();
				return false;
			}	
		}
		return true
	}

	/*----------------------------------------------------------------------------------------
	Function Name       : IsEmpty
	Author		: Pathiri Venugopal
	Parameters			: pszStringtoCheck
	Purpose				: Check whether string s is empty and returns true if the string is empty
	-------------------------------------------------------------------------------------------*/
	function IsEmpty ( pszStringtoCheck )
	{   
			
		return ( ( pszStringtoCheck == null ) || ( pszStringtoCheck.length == 0 ) )
	}

	/*----------------------------------------------------------------------------------------
	Function Name       : TrimTheString
	Author			: Pathiri Venugopal
	Parameters			: pszStringtoTrim
	Purpose				: Returns the string after triming it.
	-------------------------------------------------------------------------------------------*/
	function TrimTheString ( pszStringtoTrim )
	{
		var bflag = true;
		var i = 0;
		if ( IsWhitespace ( pszStringtoTrim ) == true )
			return "";
		while ( ( i < pszStringtoTrim.length ) && ( bflag ) )
		{
			retChar = pszStringtoTrim.charAt ( i++ );
			if ( retChar != " " ) bflag = false;
		}
		if ( bflag ) return "";
		var j = pszStringtoTrim.length-1;
		bflag = true;
		while ( ( j >= 0 ) && ( bflag ) ) 
		{
			retChar = pszStringtoTrim.charAt ( j-- );
			if ( retChar != " " ) bflag = false;
		}
		if ( bflag ) return "";
		pszStringtoTrim = pszStringtoTrim.substring ( i-1 ,j+2 );
		return pszStringtoTrim;
	}

	/*----------------------------------------------------------------------------------------
	Function Name       : FormatDate
	Author			: Pathiri Venugopal
	Parameters			: pszFieldObj - The field to be validated. Eg. "document.frmTest.txtTheField"
	Purpose				: Formatting the date value (used on the onBlur of the date field)
	-------------------------------------------------------------------------------------------*/
	function FormatDate ( pszFieldObj )
	{
		var szFinalDate;
		var szDay;
		var szMonth;
		var szYear;		
		var lobjFieldObj;
		
		lobjFieldObj = eval( pszFieldObj );
		
		if ( TrimTheString ( lobjFieldObj.value ) == "" )
		{
		   return true;
		}
		
		if ( IsProperDate ( pszFieldObj ) == true )
		{
			// If '/' is present in the resultant date string, the date's fine and can be just passed along for display.
			if ( FindChar ( lobjFieldObj.value, "/" ) >= 0 )
			{
				szFinalDate = lobjFieldObj.value;
			}
			else if ( lobjFieldObj.value.length == 8 )
			{
				szDay   = lobjFieldObj.value.charAt ( 0 ) + lobjFieldObj.value.charAt ( 1 )
				szMonth = lobjFieldObj.value.charAt ( 2 ) + lobjFieldObj.value.charAt ( 3 )
				szYear  = lobjFieldObj.value.charAt ( 4 ) + lobjFieldObj.value.charAt ( 5 ) + lobjFieldObj.value.charAt ( 6 ) + lobjFieldObj.value.charAt ( 7 )
	
				szFinalDate  = szDay + "/" + szMonth + "/" + szYear
			}
			else if ( lobjFieldObj.value.length == 6 )
			{
				szDay   = "0" + lobjFieldObj.value.charAt ( 0 )
				szMonth = "0" + lobjFieldObj.value.charAt ( 1 )
				szYear  = lobjFieldObj.value.charAt ( 2 ) + lobjFieldObj.value.charAt ( 3 ) + lobjFieldObj.value.charAt ( 4 ) + lobjFieldObj.value.charAt ( 5 )
	
				szFinalDate  = szDay + "/" + szMonth + "/" + szYear
			}
			lobjFieldObj.value = szFinalDate;			
			return true;
		}
		else
		{
			lobjFieldObj.focus();
			return false;
		}
	}


	/* ---------------------------------------------------------------------------------------------
   	Function Name : IsDateDiff
  	Author	: Pathiri venugopal
   	Parameter     : Start Date, End date
   	Purpose       : The Function returns the number of days different between tow dates 
	-----------------------------------------------------------------------------------------------*/
	function IsDateDiff ( pszLaterDate, pszEarlierDate) 
	{
//return "12";	

	  
		var aDateArr, nMonth, nDay, nYear
		
		if ( FindChar ( pszLaterDate, "/" ) >= 0 )
		 	aDateArr = pszLaterDate.split ( "/" );
		else 
			aDateArr = pszLaterDate.split ( "-" );

		
		nMonth = aDateArr [ 0 ]
		nDay = aDateArr [ 1 ]
		nYear = aDateArr [ 2 ]
		pszLaterDate = new Date ( nYear, nMonth-1, nDay )
		
		if ( FindChar ( pszEarlierDate, "-" ) >= 0 )
				aDateArr = pszEarlierDate.split ( "-" );
		 else 
				aDateArr = pszEarlierDate.split ( "/" );
				
		nMonth = aDateArr [ 0 ]
		nDay = aDateArr [ 1 ]
		nYear = aDateArr [ 2 ]
		pszEarlierDate = new Date ( nYear, nMonth-1, nDay )

		var nThedifference =  pszEarlierDate.getTime() - pszLaterDate.getTime();
		//var nThedifference =  (pszEarlierDate.parse() - pszLaterDate.parse());
		//var nDaysDifference = Math.floor(nThedifference/1000/60/60/24);
		var nDaysDifference = ((((nThedifference / 1000) / 60) / 60) / 24);
		return Math.floor(nDaysDifference);
		//return nDaysDifference;
	
	}

/*----------------------------------------------------------------------------------------
	Function Name       : IsWhitespace
	Author		: Pathiri Venugopal
	Parameters			: pszStringtoCheck
	Purpose				: Returns true if string 'a' is empty or whitespace characters only.
	-------------------------------------------------------------------------------------------*/
	function IsWhitespace ( pszStringtoCheck )
	{
		var reWhitespace = /^\s+$/
		return ( IsEmpty ( pszStringtoCheck ) || reWhitespace.test ( pszStringtoCheck ) );
	}

/*----------------------------------------------------------------------------------------
	Function Name       : IsFromGtTo
	Author 			: Pathiri Venugopal 
	Parameters			: FromDate(ctrl1), ToDate (ctrl2), FromDate Filed Name, ToDate Field Name, Message
	Purpose				: This function check the from date less than todate..it from date greater then todays it retrun false other wise return true
	-------------------------------------------------------------------------------------------*/
     function IsFromGtTo(ctr1,ctr2,msg1,msg2,msg3)
	 { 

			if(ctr1.value.length==10)
			{
				frcharmonth = ctr1.value.charAt(0)+ctr1.value.charAt(1)
				frcharday = ctr1.value.charAt(3)+ctr1.value.charAt(4)
				frcharyear = ctr1.value.charAt(6)+ctr1.value.charAt(7) + ctr1.value.charAt(8)+ctr1.value.charAt(9)
			}

			if(ctr1.value.length==8)
			{
				frcharmonth = ctr1.value.charAt(0)
				frcharday = ctr1.value.charAt(2)
				frcharyear = ctr1.value.charAt(4)+ctr1.value.charAt(5) + ctr1.value.charAt(6)+ctr1.value.charAt(7)
			}	

			if(ctr1.value.length==9)
			{
				if (ctr1.value.charAt(1)== "/") 
					{
						frcharmonth = ctr1.value.charAt(0)
						frcharday = ctr1.value.charAt(2)+ctr1.value.charAt(3)
						frcharyear =ctr1.value.charAt(5) + ctr1.value.charAt(6)+ctr1.value.charAt(7)+ ctr1.value.charAt(8)
					}
				else
					{
						frcharmonth = ctr1.value.charAt(0)+ctr1.value.charAt(1)
						frcharday = ctr1.value.charAt(3)
						frcharyear =ctr1.value.charAt(5) + ctr1.value.charAt(6)+ctr1.value.charAt(7)+ ctr1.value.charAt(8)
					}
			}	


	 //for to year
	 

	if(ctr2.value.length==10)
		{
			tocharmonth = ctr2.value.charAt(0)+ctr2.value.charAt(1)
			tocharday = ctr2.value.charAt(3)+ctr2.value.charAt(4)
			tocharyear = ctr2.value.charAt(6)+ctr2.value.charAt(7) + ctr2.value.charAt(8)+ctr2.value.charAt(9)
		}

	if(ctr2.value.length==8)
			{
				tocharmonth = ctr2.value.charAt(0)
				tocharday = ctr2.value.charAt(2)
				tocharyear = ctr2.value.charAt(4)+ctr1.value.charAt(5) + ctr1.value.charAt(6)+ctr1.value.charAt(7)
			}	

	if(ctr2.value.length==9)
		{
			 if (ctr2.value.charAt(1)== "/") 
				{
				tocharmonth = ctr2.value.charAt(0)
				tocharday = ctr2.value.charAt(2)+ctr2.value.charAt(3)
				tocharyear =ctr2.value.charAt(5) + ctr2.value.charAt(6)+ctr2.value.charAt(7)+ ctr2.value.charAt(8)
				}
			else
				{
				tocharmonth = ctr2.value.charAt(0)+ctr2.value.charAt(1)
				tocharday = ctr2.value.charAt(2)
				tocharyear =ctr2.value.charAt(5) + ctr2.value.charAt(6)+ctr2.value.charAt(7)+ ctr2.value.charAt(8)
				}
		}	

	frday = parseInt(frcharday,10)
	frmonth = parseInt(frcharmonth,10)
	fryear = parseInt(frcharyear,10)

	today = parseInt(tocharday,10)
	tomonth = parseInt(tocharmonth,10)
	toyear = parseInt(tocharyear,10)
	
	if (fryear > toyear)
	  {

	        var write_
		write_ = msg1 + " can not be " + msg3 + " than " + msg2
		alert(write_+".")	   	 
		return true;
        }
    if (toyear == fryear)
	  {
	 
	    if (frmonth > tomonth)
	      {
	        var write_
		write_ = msg1 + " can not be " + msg3 + " than " + msg2
		alert(write_+".")	   	 
		return true;
	      }	
	     if  (frmonth == tomonth)
	      {
	        if (frday > today)
	        {
	        var write_
		write_ = msg1 + " can not be " + msg3 + " than " + msg2
		alert(write_+".")	   	 
		return true;
	        } 
          }    
      }
  return false;
 }

/*----------------------------------------------------------------------------------------
	Function Name       : FindChar
	Author		: Pathiri venugopal
	Parameters			: pszStringtoSrch
						  pszSrchChars
	Purpose				: Returns True if the characters specified in list passed as 'pszSrchChars' 
						  is present in 'pszStringtoSrch'. Is Case-sensitive.
						  'pszSrchChars' can be a comma-seperated list. All the chars are searched 
						  for in the 'pszStringtoSrch', and even all the characters specified in the 
						  comma-seperated list is present in the 'pszStringtoSrch', 'true' is returned.
						  Even if one of the characters specified in the comma-seperated list is not 
						  present, 'false' is returned.
	-------------------------------------------------------------------------------------------*/
	function FindChar ( pszStringtoSrch, pszSrchChars )
    {
		var szRetString = "";
		if ( pszSrchChars.indexOf ( "," ) != -1 )
		{
			var bToReturn
			bToReturn = true;
			aSplitArr = pszSrchChars.split ( "," );
			for ( nCounter=0 ; nCounter<aSplitArr.length ; nCounter++ )
			{
				if ( pszStringtoSrch.indexOf ( TrimTheString ( aSplitArr [ nCounter ] ) ) != -1 )
				{
					if ( TrimTheString ( szRetString ) == "")
					{
						szRetString = szRetString + ( pszStringtoSrch.indexOf ( TrimTheString ( aSplitArr [ nCounter ] ) ) + 1 );
					}
					else
					{
						szRetString = szRetString + ", " + ( pszStringtoSrch.indexOf ( TrimTheString ( aSplitArr [ nCounter ] ) ) + 1 );
					}
	
					if ( bToReturn )
					{
						bToReturn = true;
					}
				}
				else
				{
					bToReturn = false;
				}
			}
			if ( bToReturn )
			{
				return szRetString;
			}
			else
			{
				return -1;
			}
		}
		else
		{
			if ( pszStringtoSrch.indexOf ( pszSrchChars ) != -1 )
			{
				szRetString = ( pszStringtoSrch.indexOf ( pszSrchChars ) + 1 );
				return szRetString;
			}
			else
			{
				szRetString = -1;
				return szRetString;
			}
		}
    }
/*
		for ( i = 0 ; i < pszStringtoSrch.length ; i++ )
		{
			if (pszStringtoSrch.charAt(i)==pszSrchChars)
			{
				return true;
			}
		}
		return false;
*/
/*----------------------------------------------------------------------------------------
	Function Name       : IsSmallLongInt
	Author		: Pathiri venugopal
	Parameters			: pszFieldObj - The field to be validated. Eg. "document.frmTest.txtTheField"
						  pszMaxValue
	Purpose				: To check if the entry is valid for a corresponding SMALLINT (0 - 32767) 
						  or INT (0 - 2147483647) database fields depending on the second 
					 	  parameter. A Maximum value can also be passed as the second parameter 
						  and the function would not allow entries more than the maximum value 
						  specified. Allows only Positive values. If no pszMaxValue is specified,
						  'SMALLINT' is defaulted.
------------------------------------------------------------------------------------------*/
	function IsSmallLongInt ( pszFieldObj, pszMaxValue )
	{
		if ( TrimTheString( pszMaxValue ) == "" )
		{
			pszMaxValue = "SMALLINT";
		}
		var pnMaxValue;
		var szFieldValue = eval( pszFieldObj ).value
		if ( isNaN( TrimTheString( szFieldValue ) ) )
		{
			alert("Field should contain only numeric value.");
			eval( pszFieldObj ).focus();
			return false;
		}
		else
		{
			if ( TrimTheString( pszMaxValue ).toUpperCase() == "SMALLINT")
				pnMaxValue = 32767;
			else if ( TrimTheString( pszMaxValue ).toUpperCase() == "INT")
				pnMaxValue = 2147483647;
			else
				pnMaxValue = parseInt(pszMaxValue);
		
			if ( szFieldValue > pnMaxValue )
			{
				alert( "Input should be between 0 and " + pnMaxValue +".");
				eval( pszFieldObj ).focus();
				return false;
			}
			else
				return true;
		}
	
	}

  function IsVal ( pszMessage, pszValue )
	{
		if ( isNaN ( pszValue ) )
		{
			var szWrite
			szWrite = pszMessage + " has to be Numeric"
			alert ( szWrite )
			return false
		}
		return true
	}

  function FieldLength( objField,FieldName,AllowedLength)
	{
		lobjFieldObj = eval( objField );
		if ( !IsEmpty ( lobjFieldObj.value ) )
		{
			if ( lobjFieldObj.value.length > AllowedLength )
			{
				alert( "The " + FieldName + " must be " + AllowedLength + " digits in length. Please try again.");
				lobjFieldObj.focus();
				return false;
			}
			else if ( lobjFieldObj.value.length < AllowedLength )
			{
				alert ( "The " + FieldName + " must be " + AllowedLength + " digits in length. Please try again.");
				lobjFieldObj.focus();
				return false;
			}
		}
		else
		{
			//alert( FieldName + ' Is Empty' );
			// Changes for Client's Request 06-07-04 p.t.
			if ( FieldName == "Mailpiece ID" )
			{
			alert( ' Please enter a Mailpiece ID.');
			}
			else if ( FieldName == "Article Number")
			{
			alert ( 'Please enter an ' + FieldName + '.' );
			}
			else
			{
			alert( FieldName + ' Is Empty' );
			}	
			lobjFieldObj.focus();
			return false;
		}
		return true;
	}

// Button Image Objects
imgExpress = new Image(186,95);
imgExpress.src = "images/reportexpress.jpg";
imgExpressOut = new Image(153,105);
imgExpressOut.src = "images/mouseexpress.jpg";

// Button Image Objects
imgInvalidMail = new Image(186,95);
imgInvalidMail.src = "images/invalid.gif";
imgInvalidMailOut = new Image(153,105);
imgInvalidMailOut.src = "images/mouseinvalid.gif";



// Login Button
imgLogin = new Image(186,95);
imgLogin.src = "images/Loginbutton.gif";
imgLoginOut = new Image(153,105);
imgLoginOut.src = "images/mouseLoginbutton.gif";

//Logout Button
imgLogOut = new Image(186,95);
imgLogOut.src = "images/Logoutbutton.gif";
imgLogOutOut = new Image(153,105);
imgLogOutOut.src = "images/mouseLogoutbutton.gif";

// Contact Button
imgContact = new Image(186,95);
imgContact.src = "images/contact.gif";
imgContactOut = new Image(153,105);
imgContactOut.src = "images/mousecontact.gif";

// FAQ button
imgFaq = new Image(186,95);
imgFaq.src = "images/faqpic.gif";
imgFaqOut = new Image(153,105);
imgFaqOut.src = "images/mousefaqpic.gif";

// Prospect button
imgProspect = new Image(186,95);
imgProspect.src = "images/prospect.gif";
imgProspectOut = new Image(153,105);
imgProspectOut.src = "images/mouseprospect.gif";

// New Prospect button
imgNewProspect = new Image(186,95);
imgNewProspect.src = "images/newprospect.gif";
imgNewProspectOut = new Image(153,105);
imgNewProspectOut.src = "images/mousenewprospect.gif";

// Submit ADI
imgSubmitADI = new Image(186,95);
imgSubmitADI.src = "images/SubmitADI.gif";
imgSubmitADIOut = new Image(153,105);
imgSubmitADIOut.src = "images/mousesubmitadi.gif";


// Clear Value
imgClearValue = new Image(186,95);
imgClearValue.src = "images/ClearValuesPurple.gif";
imgClearValueOut = new Image(153,105);
imgClearValueOut.src = "images/mouseclearvalues.gif";

// No ADI
imgNoAdi = new Image(186,95);
imgNoAdi.src = "images/noADIinfo.gif";
imgNoAdiOut = new Image(153,105);
imgNoAdiOut.src = "images/mousenoadiinfo.gif";

// Confirm
imgConfirm = new Image(186,95);
imgConfirm.src = "images/ConfirmRpt.gif";
imgConfirmOut = new Image(153,105);
imgConfirmOut.src = "images/mouseconfirmrpt.gif";


// Change 
imgChange = new Image(186,95);
imgChange.src = "images/ChangeRpt.gif";
imgChangeOut = new Image(153,105);
imgChangeOut.src = "images/mousechangerpt.gif";

imgClearValueLg = new Image(186,95);
imgClearValueLg.src = "images/ClearValuesLg.gif";
imgClearValueLgOut = new Image(153,105);
imgClearValueLgOut.src = "images/mouseclearvalueslg.gif";


imgSmdd = new Image(186,95);
imgSmdd.src = "images/delivdate.gif";
imgSmddOut = new Image(153,105);
imgSmddOut.src = "images/mousedelivdate.gif";

imgAddMail = new Image(186,95);
imgAddMail.src = "images/addmail.gif";
imgAddMailOut = new Image(153,105);
imgAddMailOut.src = "images/mouseaddmail1.gif";


imgSVac = new Image(186,95);
imgSVac.src = "images/SubmitVac.gif";
imgSVacOut = new Image(153,105);
imgSVacOut.src = "images/mousesubmitvac.gif";

imgRRMail = new Image(186,95);
imgRRMail.src = "images/rrmail.gif";
imgRRMailOver = new Image(153,105);
imgRRMailOver.src = "images/mouserrmail.gif";


imgMoreVac = new Image(186,95);
imgMoreVac.src = "images/MoreVac.gif";
imgMoreVacOut = new Image(153,105);
imgMoreVacOut.src = "images/mousemorevac.gif";

imgFCReportMail = new Image(186,95);
//imgFCReportMail.src = "images/reportmail.jpg";
imgFCReportMail.src = "images/reportmail2.jpg";
imgFCReportMailOut = new Image(153,105);
//imgFCReportMailOut.src = "images/mousereportmail.jpg";
imgFCReportMailOut.src = "images/mousereportmail2.jpg";

imgReportMail = new Image(186,95);
//imgReportMail.src = "images/Reportmail1.jpg";
imgReportMail.src = "images/reportmail2.jpg";
imgReportMailOut = new Image(153,105);
//imgReportMailOut.src = "images/Mousereportmail1.jpg";
imgReportMailOut.src = "images/mousereportmail2.jpg";


imgReportNormMail = new Image(186,95);
imgReportNormMail.src = "images/reportmail2.jpg";
imgReportNormMailOut = new Image(153,105);
imgReportNormMailOut.src = "images/mousereportmail2.jpg";


imgReportVac = new Image(186,95);
imgReportVac.src = "images/reportvac.jpg";
imgReportVacOut = new Image(153,105);
imgReportVacOut.src = "images/mousereportvac.jpg";

imgHistory = new Image(186,95);
imgHistory.src = "images/history.jpg";
imgHistoryOut = new Image(153,105);
imgHistoryOut.src = "images/mousehistory.jpg";

imgSubmitExpress = new Image(186,95);
imgSubmitExpress.src = "images/submitexpress.jpg";
imgSubmitExpressOut = new Image(153,105);
imgSubmitExpressOut.src = "images/Mousesubmitexpress.jpg";
//Added Additional for Express 
imgAddtlExpress = new Image(186,95);
imgAddtlExpress.src = "images/additionalexpress.jpg";
imgAddtlExpressOut = new Image(153,105);
imgAddtlExpressOut.src = "images/mouseadditionalexpress.jpg";

imgSubmitCmt = new Image(186,95);
imgSubmitCmt.src = "images/SubmitCmt.gif";
imgSubmitCmtOut = new Image(153,105);
imgSubmitCmtOut.src = "images/mouseSubmitCmt.gif";

imgRewardz = new Image(153,105);
imgRewardz.src = "images/rewards_on.gif";
imgRewardz1 = new Image(153,105);
imgRewardz1.src = "images/rewards.gif";

function changeimage(imgx,placex)
 {
  	if (document.images)
  	{
    		document.images[placex].src = eval(imgx + ".src");
  	}
} 

function changeimage2(imgx,placex)
{
	placex.src  = eval(imgx + ".src");
} 

function changeimage3(imgx,placex)
{
	placex.src  = eval(imgx + ".src");
}

function validateLoginInput()
{
        if ( TrimTheString( document.frmLogin.reporter_id.value) == "" || isNaN(TrimTheString(document.frmLogin.reporter_id.value)) )
        {
                //alert("Please enter a valid reporter id.");
		alert("You have entered an invalid Reporter ID. Please try again.");
                return false;
        }

        if ( TrimTheString( document.frmLogin.project_code.value) == "")
        {
                alert("Please enter a valid password.");
                return false;
        }

        return true;
}
function fn_validREPID()
{
        if ( TrimTheString( document.frmLogin.reporter_id.value) == "" || isNaN(TrimTheString(document.frmLogin.reporter_id.value)) )
        {
                //alert("Please enter a valid reporter id.");
                alert("You have entered an invalid Reporter ID. Please try again.");
                return false;
        }
        return true;
}

function Check_Overview_Form(form)
{
	var yesRadio=document.getElementById("yes");
	var noRadio =document.getElementById("no");

   	if (yesRadio.checked == 0 && noRadio.checked == 0)
 	{
		alert('Please choose whether or not you are interested.');
		yesRadio.focus();
		return false;
	}
}

function Check_Address_Form(form)
{	
	if (form.prefix.value == "")
	{
		alert('Prefix is a required field. Please enter a prefix.');
		form.prefix.focus();
		return false;
	}
//	if (form.fname.value == "")
        if (TrimTheString(form.fname.value) == "")
	{
		alert('First name is a required field. Please enter your first name.');
		form.fname.focus();
		return false;
	}
//	if (form.lname.value == "")
        if (TrimTheString(form.lname.value) == "")
	{
		alert('Last name is a required field. Please enter your last name.');
		form.lname.focus();
		return false;
	}

        var hRadio=document.getElementById("household");
        var bRadio =document.getElementById("business");

        if (hRadio.checked == 0 && bRadio.checked == 0)
        {
                alert('Address type is a required field. Please select either household or business.');
                hRadio.focus();
                return false;
        }

        if (bRadio.checked == 1 && form.company.value == "")
        {
                alert('Company is a required field if you selected business. Please enter a Company name.');
                form.company.focus();
                return false;
        }

//	if (form.address.value == "")
        if (TrimTheString(form.address.value) == "")
	{
		alert('Address 1 is a required field. Please enter your address.');
		form.address.focus();
		return false;
	}

//	if (form.city.value == "")
        if (TrimTheString(form.city.value) == "")
	{
		alert('City is a required field. Please enter your city.');
		form.city.focus();
		return false;
	}

	if (!Check_alpha_len(form.state.value,2,2))
	{
		alert('State is a required field. Please enter your state.');
		form.state.focus();
//		form.state.select();
		return false;
	}

	//if (!Check_numeric_len(form.zip.value))
	//{
	//	alert('Zip code is invalid.');
	//	form.zip.focus();
	//	form.zip.select();
	//	return false;
	//}

//	if (form.zip.value == "")
//	{
//		alert('Zip code is invalid.');
//		form.zip.focus();
//		form.zip.select();
//		return false;
//	}

if (!Check_numeric(form.zip.value,5))
{
	alert('ZIP Code is a required field. Please enter your 5 digit ZIP code.');
	form.zip.focus();
	form.zip.select();
	return false;
}

	if (form.npa.value == 0)
	{
		alert('Phone Number is a required field. Please enter your valid 10 digit phone number. Phone extension is optional.');
		form.npa.focus();
		return false;
	}
	else if (!Check_numeric(form.npa.value,3))
	{
		alert('Phone Number is a required field. Please enter your 10 digit phone number. Phone extension is optional.');
		form.npa.focus();
		return false;
	}
	
	if (form.nxx.value == 0)
	{
		alert('Phone Number is a required field. Please enter your valid 10 digit phone number. Phone extension is optional.');
		form.nxx.focus();
		return false;
	}
	else if (!Check_numeric(form.nxx.value,3))
	{
		alert('Phone Number is a required field. Please enter your 10 digit phone number. Phone extension is optional.');
		form.nxx.focus();
		return false;
	}

	if (form.lnxx.value == 0)
	{
		alert('Phone Number is a required field. Please enter your valid 10 digit phone number. Phone extension is optional.');
		form.lnxx.focus();
		return false;
	}
	else if (!Check_numeric(form.lnxx.value,4))
	{
		alert('Phone Number is a required field. Please enter your 10 digit phone number. Phone extension is optional.');
		form.lnxx.focus();
		return false;
	}	
	var tempVal = form.npa.value+form.nxx.value+form.lnxx.value;
	var temp = 0;
	for(var k=0;k<9;k++){
		if(tempVal.charAt(k)!=tempVal.charAt(k+1)){
			temp = parseInt(temp)+1;
		}
	}
	if(!temp){
		alert('Each digit in phone number should be different.');
		form.lnxx.focus();
		return false;
	}
	/*
	if ((TrimTheString(form.lnxxx.value) != "") && !Check_numeric_len(form.lnxxx.value,0,4))
	{
		alert('Please enter your valid phone extension.');
		form.lnxxx.focus();
		return false;
	}
	*/
	
//	if (form.email.value == "" && form.noemail_addr.checked == 0 )
        if ((TrimTheString(form.email.value) == "") && (form.noemail_addr.checked == 0))
	{
		 alert('Email address is a required field. Please either enter an email address or check the box to indicate that you do not have an email address.');
		//alert('Email address is a required field. Please either enter an email address or check the box to indicate that you do not have an email address');
		form.email.focus();
		return false;
	}

//	if (form.email.value != "" && form.noemail_addr.checked == 1 )
        if ((TrimTheString(form.email.value) != "") && (form.noemail_addr.checked == 1))
	{
		alert('The Email checkbox should not be checked if email address is provided.');
		form.email.focus();
		return false;
	}
	
}

function Check_Screen_Form(form,max)
{
	var count = 1;
//	var maxcount = 12;
	var maxcount = max;

	while (count <= maxcount)
	{
		if (!document.question.elements["val"+count][0].checked && !document.question.elements["val"+count][1].checked)
		{
			alert("Please select an answer for question " + count + ".");
			return false;
		}
		count ++;
	}
}

function Check_OtherStudy_Form(form)
{
	var yesRadio=document.getElementById("yes");
	var noRadio =document.getElementById("no");

   	if (yesRadio.checked == 0 && noRadio.checked == 0)
 	{
		alert('Please select Yes or No.');
		yesRadio.focus();
		return false;
	}
}

function autotab(original,destination)
{
   if (original.getAttribute&&original.value.length==original.getAttribute("maxlength"))
   {
	destination.focus()
	return false;
   }
}

function popUp(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=1,scrollbars=1,location=1,statusbar=1,menubar=1,resizable=1,width=500,height=400');");
}

