	//Function To Check For Special Characters
	function IsSplChar(strValue,desc)
	{
	 var SplChars;
	 var intLoop;
	 var Temp;
	 
	 SplChars="~`!@#$%^&*()_-+={}[]\|\"\\\"':;/?>.<,";
	 
	 for (intLoop = 0;intLoop < SplChars.length;intLoop++)
	 {
		Temp=SplChars.charAt(intLoop);
		if (strValue.indexOf(Temp) != -1)
		{
			alert("Special characters(!@#$%^&*()_-+={}[]\|\"\"':;/?>.<,\") not allowed in " + desc );
			return true;
			break;
		}
		else
		{
			continue;
		}
	 }	
		return false		
	}
	//Function To Check If a Sting has Special Characters
	/*
	This function is slightly different from IsSplChar() defined above in this file as follows.
	IsSplChar() searches for each char of the special chars string in the given string whereas 
	IsAllSplChar() searches for the each of chars of the given string in the string containing
	special chars. This is done because the former logic doesnt give the count of repeated 
	special chars, which is requred in this function to compare the length of the input string 
	& the number of specail chars in it.
	*/
	function IsAllSplChar(strValue)
	{
	 var SplChars;
	 var intLoop;
	 var Temp;
	 var intTotalSplChars = 0;
 	 var intStringLength = strValue.length;
	 
	 SplChars="~`!@#$%^&*()_-+={}[]\|\"\\\"':;/?>.<,";
	 
	 for (intLoop = 0;intLoop < intStringLength;intLoop++)
	 {
		Temp=strValue.charAt(intLoop);
		if (SplChars.indexOf(Temp) != -1)
		{
			intTotalSplChars++;
		}
		else
		{
			continue;
		}
	 }	
	 if(intTotalSplChars == intStringLength)
		return true;		
	 else 
	 	return false;
	}
	
	function IsSplCharInUrl(strValue,desc)
	{
	 var SplChars;
	 var intLoop;
	 var Temp;
	 
	 SplChars="~`!@$^*()+{}[]\|\"\\\"'><,";
	 
	 for (intLoop = 0;intLoop < SplChars.length;intLoop++)
	 {
		Temp=SplChars.charAt(intLoop);
		if (strValue.indexOf(Temp) != -1)
		{
			alert("Special characters(~`!@$^*()+{}[]\|\"\\\"'><,) not allowed in " + desc );
			return true;
			break;
		}
		else
		{
			continue;
		}
	 }	
		return false		
	}
	//Function To Check For Special Characters for hotsyncid it will allowed(_)
	function IsSplCharStationName(strValue)
	{
	 var SplChars;
	 var intLoop;
	 var Temp;
	 
	 SplChars="~`@#$%^&*()+={}[]\|\"\"':;/?><,";
	 
	 for (intLoop = 0;intLoop < SplChars.length;intLoop++)
	 {
		Temp=SplChars.charAt(intLoop);
		if (strValue.indexOf(Temp) != -1)
		{
			alert("Special Characters Not Allowed i.e ~`@#$%^&*()+={}[]\|\"\"':;/?><,");
			return true;
			break;
		}
		else
		{
			continue;
		}
	 }	
		return false		
	}
	//Function TO Check For Ampersand in string
	function IsAmpersand(strValue)
	{
		if(strValue.indexOf("&")!= -1)
		{
			alert("Ampersand Not Allowed !");
			return true;
		}		
			return false;
	}	
	
	//objRegex=new Regex(@"\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"); 
	function IsEmailValidNew(strValue)
	{
		//var filter = /^[\w-\.\']{1,}\@([\da-zA-Z-]{1,}\.){1,}[\da-zA-Z-]{2,}$/; 
        var filter = /^([\w]+)(.[\w]+)*@([\w]+)(.[\w]{2,3}){1,5}$/
		if (filter.test(strValue))
			return true;
		else 
		{
			alert("E-mail Address- "+strValue+" is not valid. Please re-enter.")
			return false;
		}
	}
	
 	//Function To Check if the string is a Number
	function IsNumber(strValue,desc)
	{
		if(isNaN(strValue))
		{	
			alert("Only numbers allowed in " + desc);
			return false;
			
		}
		else
		{	
			return true;
		}

		/*invalidchar=0
		for (count=0;count < strValue.length;count++)
		{
			if((!isNaN(strValue.charCodeAt(count))) && (strValue.charCodeAt(count) != 43) && (strValue.charCodeAt(count) != 45) && (strValue.charCodeAt(count) != 41) && (strValue.charCodeAt(count) != 40))
			{
				invalidchar = 1;
				break;
				return false;
			}
		}
		if(invalidchar==0)
		{
			alert ("Only numbers and (), +, - allowed in "+ desc) ;			
			return false;
		}
		else
			return true;*/

	}
	
//Function To Check if the string is of a valid Length	
	function ValidateLen(field, min, max, desc)
	{
		if (field.length < min || field.length > max)
		{
			alert(desc + " field should be between "+ min +" and "+max+" characters");
			return false;
		}	
		return true;
	}
	


//Function To Check if string contains only alphabets
	function isAlphabets(field,desc)
	{
		var check=0;
		
		for(count=0; count < field.length;count++)
		{
			
			if((field.charCodeAt(count) >= 97) && (field.charCodeAt(count) <= 122)) 
				check++;
			else if((field.charCodeAt(count) >= 65) && (field.charCodeAt(count) <= 90))
				check++;
			else if (field.charCodeAt(count)==32)
				check++;
			else
			{	
				check=0;
				break;
			}
		}

		if (check == 0)
		{
			alert("Only characters allowed in "+desc);		
			return false;
		}
		else
			return true;
	}

function trim(str)
{ 
return((""+str).replace(/^\s*([\s\S]*\S+)\s*$|^\s*$/,'$1') ); 
}

	//Function to check if the string is Blank
	function isBlank(field,desc)
	{	
		field = trim(field);
		var counter=0;
		for (count=0;count<field.length;count++)
		{

			if (field.charCodeAt(count)==32)
				counter++;
			else 
				counter--;
		}
	
		if ((field == "") || (field.length == counter))
		{
			alert("Please enter " + desc );
			return false;
		}	
		else
//			return true;	
			return true;
	}		
	
	function IsPwdSame(field1,field2)
	{
		if(field1 != field2)
		{	
			alert("The Passwords do not match");
			return false;
		}
		return true;
	}
	
	
	function isValidDate(strDate)
	 {
     // (\d{1,2}) means 4 or 12
     // (\/|-) means either (/ or -), 4-12 or 4/12 
     // NOTE: we have to escape / (\/)
     // or else pattern matching will interpret it to mean the end instead of the literal "/"
     // \2 use the 2nd placeholder (\/|-) "here"
     // (\d{2}|\d{4}) means 02 or 2002
     var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{2}|\d{4})$/;
     var matchArray = strDate.match(datePat);
	 if (matchArray == null) return false;

     // matchArray[0] will be the original entire string, for example, 4-12-02 or 4/12/2002
     var month = matchArray[3];     // (\d{1,2}) - 1st parenthesis set - 4
     var day = matchArray[1];         // (\d{1,2}) - 3rd parenthesis set - 12
	 /* The above declaration was changed since the date was entered in MM/DD/YYYY format
	 and the above declaration takes in the date as DD/MM/YYYY*/
/*     var day = matchArray[3];     // (\d{1,2}) - 1st parenthesis set - 4
     var month = matchArray[1];         // (\d{1,2}) - 3rd parenthesis set - 12*/
     var year = matchArray[4];        // (\d{2}|\d{4}) - 5th parenthesis set - 02 or 2002
     if (month < 1 || month > 12) 
	 /*return false; This return false was disabled since the user selects the date & it is 
	 	stored in a textbox*/
	 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 FutureDateCheck(matchArray[0]);
	}

	/*
	* Function Name			: FutureDateCheck
	* Purpose				: Validating if the entered date is not a future date.
	* Parameters			: Date string
	* Return Value			: boolean 
	* Author				: Novin Vathipatikkal
	* Creation Date			:	-- 
	* Modification Date		:	--
	*/	
	function FutureDateCheck(EnteredDate)
	{
		/*Generating the current date in the MM/DD/YYYY fomrat*/
		var currentTime = new Date()
		var month = currentTime.getMonth() + 1
		month = (month.toString().length < 2) ? "0" + month : month;
		var day = currentTime.getDate()	
		day = (day.toString().length < 2) ? "0" + day : day;
		var year = currentTime.getFullYear();
		CurrentDate = day + "/" + month + "/" + year;
		if(EnteredDate > CurrentDate)
			return false;
		else
			return true;
	}


	
	function clearFields(formname){
     var objForm = eval('document.'+formname)
     for(i=0;i<objForm.elements.length;i++){
          if(objForm.elements[i].type=="text"){
               objForm.elements[i].value = "";
          }
            if(objForm.elements[i].type=="textarea"){
               objForm.elements[i].value = "";
          }
          if(objForm.elements[i].type=="select-one"){
               objForm.elements[i].selectedIndex = -1;
          }
		  if(objForm.elements[i].type=="select-multiple"){
               objForm.elements[i].selectedIndex = -1;
          }
          if(objForm.elements[i].type=="checkbox"){
               objForm.elements[i].checked = false;
          }
          if(objForm.elements[i].type=="radio"){
               objForm.elements[i].checked = false;
          }
          if(objForm.elements[i].type=="file"){
               objForm.elements[i].value = "";
          }
     }
}




function dateAdd( start, interval, number ) 
{
	
    // Create 3 error messages, 1 for each argument. 
    var startMsg = 'Sorry the start parameter of the dateAdd function\n'
        startMsg += 'must be a valid date format.\n\n'
        startMsg += 'Please try again.' ;
		
    var intervalMsg = 'Sorry the dateAdd function only accepts\n'
        intervalMsg += 'd, h, m OR s intervals.\n\n'
        intervalMsg += 'Please try again.' ;

    var numberMsg = 'Sorry the number parameter of the dateAdd function\n'
        numberMsg += 'must be numeric.\n\n'
        numberMsg += 'Please try again.' ;
		
    // get the milliseconds for this Date object. 
    var buffer = Date.parse( start ) ;
	
    // check that the start parameter is a valid Date. 
    if ( isNaN (buffer) ) {
        alert( startMsg ) ;
        return null ;
    }
	
    // check that an interval parameter was not numeric. 
    if ( interval.charAt == 'undefined' ) {
        // the user specified an incorrect interval, handle the error. 
        alert( intervalMsg ) ;
        return null ;
    }

    // check that the number parameter is numeric. 
    if ( isNaN ( number ) )	{
        alert( numberMsg ) ;
        return null ;
    }

    // so far, so good...
    //
    // what kind of add to do? 
    switch (interval.charAt(0))
    {
        case 'd': case 'D': 
            number *= 24 ; // days to hours
            // fall through! 
        case 'h': case 'H':
            number *= 60 ; // hours to minutes
            // fall through! 
        case 'm': case 'M':
            number *= 60 ; // minutes to seconds
            // fall through! 
        case 's': case 'S':
            number *= 1000 ; // seconds to milliseconds
            break ;
        default:
        // If we get to here then the interval parameter
        // didn't meet the d,h,m,s criteria.  Handle
        // the error. 		
        alert(intervalMsg) ;
        return null ;
    }
    return new Date( buffer + number ) ;
}

//Akshay 29April 2004
 function emptyval(formname,fieldname,displayname)
{
if (eval("document."+formname+"." + fieldname + ".value==''"))
 {
 alert(displayname + " cannot be left blank");
 eval("document."+formname+"." + fieldname + ".focus()");
 return false;
 } 
 return true;
}

function isnanval(formname,fieldname,displayname)
{
if (!emptyval(formname,fieldname,displayname))
 {
 return false;
 }
 if (isNaN(eval("document."+formname+"." + fieldname + ".value")))
  {
  alert(displayname + " should be a number");
  eval("document."+formname+"." + fieldname + ".focus()");
  eval("document."+formname+"." + fieldname + ".select()");
  return false;
  } 
 return true;
}
function isalphabet(formname,fieldname,displayname)
{

 if (isNaN(eval("document."+formname+"." + fieldname + ".value")))
  {} 
 else
 {
	alert(displayname + " cannot contain numbers");
	eval("document."+formname+"." + fieldname + ".focus()");
  	eval("document."+formname+"." + fieldname + ".select()");
  	return false;
 }
 return true;
}

function MatchUrlNewOld(exp,desc)
{
	//Declare variables.
	var s = exp;
	var re=new RegExp("^(http|https)\://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(:[a-zA-Z0-9]*)?/?([a-zA-Z0-9\-\._\?\,\'/\\\+&%\$#\=~])*$");
	//Create regular expression object. "i" is for ignore case
	blnflag=re.test(s);
	if (!blnflag)
	{
		//alert('URL should be of the format http://www.xxxx.xxx')
		alert("Invalid "+ desc + " format Please re-enter.");
		return false;
	}
	return true;
}

function MatchUrlNew(exp,desc)
{
	//Declare variables.
	var s = exp; 
	var re = new RegExp("(^|[ \t\r\n])((ftp|http|https|gopher|mailto|news|nntp|telnet|wais|file|prospero|aim|webcal):(([A-Za-z0-9$_.+!*(),;/?:@&~=-])|%[A-Fa-f0-9]{2}){2,}(#([a-zA-Z0-9][a-zA-Z0-9$_.+!*(),;/?:@&~=%-]*))?([A-Za-z0-9$_+!*();/?:~-]))"); 
	blnflag=re.test(s);
	if (!blnflag)
	{
		alert("Invalid "+ desc + " format Please re-enter.");
		return false;
	}
	return true;
}

//function to check spaces
function isWhiteSpacesNew(S,desc)
{
	var isNull 
	S=trim(S);
	if (S.length == 0) 
	{ 
		
		isNull = true;
	}
	else
	{
		for (I=0;I < S.length; I++)
		{
			isNull = S.charAt(I)==' '?true:false;
			if (isNull)
			{
				alert(desc + " should not contain space(s).");
				 break;
			}
		}
	}
	return isNull;
}

//function to validate alphanumeric string
function isAlphaNumeric(strValue,desc)
{alert(desc);
	var filter = /^[a-z A-Z 0-9]+$/
	if(filter.test(strValue))
	//if(strValue.match(filter))
	{
		return true;
	}
	else 
	{
		alert("Only alphanumeric characters allowed in " + desc);
		return false;
	}
}

