	function DatePicker(DateBox) 
	{	
		var spaceInvader = "&nbsp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
		var retVal = window.showModalDialog("script/date/DatePicker.asp?CurDate=" + DateBox.value,"Select Date " + spaceInvader,"dialogHeight: 250px; dialogWidth: 250px; center: Yes; status:no; help: No; resizable: No; scroll:No;");

		if(retVal!=null)
		{
			DateBox.value = retVal;
		}
	}



	function fnAskTheExpert(strIndustry)
	{
		win = window.open('AskOurExpert.asp?Ind=' + strIndustry,'AskOurExpert','width=400, height=500, location=no, menubar=no, status=no, toolbar=no, scrollbars=no, resizable=no'); 
		win.focus();
		return;
	}



	// -------------------------------------------------------------------
	// Hilight 
	// -------------------------------------------------------------------
	function fnLoadForm(objField)
	{
		objField.focus()
		objField.select()
	}
	
	
	// -------------------------------------------------------------------
	// Show calendar
	// -------------------------------------------------------------------
	function fnTriggerCal(fldObjDate)
	{
		fnCalShow(fldObjDate,'calendar.html');
	}

	
	function fnCheckForMaxLength(obj,msg,maxlen)
	{
		if ( obj.value.length > maxlen )
		{
			if ( msg.length != 0 )
				alert(msg)
			else
				alert("No of characters cannot be more than " + maxlen )

			obj.select();
			obj.focus();
			return false;
		}

		return true;
	}

	
	//-----------------------------------------------------------------------------------------------------------------------
	//	Syntax : fnCalShow(vDateField)
	//	Description : This function is used to select the date from the calender
	//	Parameters : The textbox to display the selected date
	//--------------------------------------------------------------------------------------------------------------------------
	function fnCalShow(vDateField, vPath)
	{
		var vReturnValue;

		vReturnValue = window.showModalDialog(vPath, vDateField.value, "dialogWidth:236px; dialogHeight:245px; center:yes");
		if (vReturnValue != null)
		{
			vDateField.value = vReturnValue;
			vDateField.focus();
		}
		return false;
	}

	
	
	// -------------------------------------------------------------------
	// CHECK FOR "CHARLIST". 
	// i.e charlist can be "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_."
	// If the charlist obj's value contains ANY other character not found in charlist then it is NOT valid
	// -------------------------------------------------------------------
	function fnCheckForChars( obj, txt, charlist )
	{
		if ( obj != "[object]")  // check whether the field exists or not. If doesn't exist, just return TRUE
			return true;

		if ( isChars( obj.value, charlist ) == false )
		{	alert( txt );
			obj.select();
			obj.focus();
			return false;
		}
		else
			return true;

		return true;
	}

	function isChars(string,charlist) 
	{    
	  if (!string) return false;
	  var Chars = charlist;    
	  for (var i = 0; i < string.length; i++) 
	  {		if (Chars.indexOf(string.charAt(i)) == -1) { return false }		}
	  return true;
	} 



	// -------------------------------------------------------------------
	// CHECK FOR ALPHANUMERIC
	// -------------------------------------------------------------------
	function CheckAlphaNumeric( obj, txt )
	{
		if ( obj != "[object]")  // check whether the field exists or not. If doesn't exist, just return TRUE
			return true;

		if ( isAlphaNumeric( obj.value ) == false )
		{	alert( txt + " can contain only alpha numeric characters" );
			obj.select();
			obj.focus();
			return false;
		}
		else
			return true;

		return true;
	}

	function isAlphaNumeric(string) 
	{    
	  if (!string) return false;
	  var Chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
	  for (var i = 0; i < string.length; i++) 
	  {		if (Chars.indexOf(string.charAt(i)) == -1) { return false }		}
	  return true;
	} 


	// -------------------------------------------------------------------
	// CHECK FOR ALPHABETS
	// -------------------------------------------------------------------

	function CheckAlphabet( obj, txt )
	{
		if ( obj != "[object]")  // check whether the field exists or not. If doesn't exist, just return TRUE
			return true;

		if ( isAlpha( obj.value ) == false )
		{	alert( txt + " can contain only alphabets" );
			obj.select();
			obj.focus();
			return false;
		}
		else
			return true;

		return true;
	}

	function isAlpha(string) 
	{    
	  if (!string) return false;
	  var Chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";    
	  for (var i = 0; i < string.length; i++) 
	  {		if (Chars.indexOf(string.charAt(i)) == -1) { return false }		}
	  return true;
	} 



	// -------------------------------------------------------------------
	// CHECK FOR NUMERIC
	// -------------------------------------------------------------------
	function fnCheckNumeric( obj, txt )
	{
		if ( obj != "[object]")  // check whether the field exists or not. If doesn't exist, just return TRUE
			return true;

		if ( isNum( obj.value ) == false )
		{	alert( txt + " has to be a number" );
			obj.select();
			obj.focus();
			return false;
		}
		else
			return true;

		return true;
	}


	function isNum(string) 
	{    
	  if (!string) return false;
	  var Chars = "0123456789";    
	  for (var i = 0; i < string.length; i++) 
	  {		if (Chars.indexOf(string.charAt(i)) == -1) { return false }		}
	  return true;
	} 


	// -------------------------------------------------------------------
	// CHECK FOR COMBO SELECTION
	// -------------------------------------------------------------------
	function CheckCombo( obj, txt, n )
	{
		if (obj.selectedIndex < n)
		{	alert( "Please select " + txt );
			obj.focus();
			return false;
		}
		
		//if ( obj.options[obj.selectedIndex].value < n )
		//{	alert( "Please select " + txt );
		//	obj.focus();
		//	return false;
		//}
	}


	// -------------------------------------------------------------------
	// CHECK FOR EMPTY
	// -------------------------------------------------------------------
	function fnCheckEmpty( obj, txt )
	{	//alert("CheckEmpty")
		if ( obj != "[object]")  // check whether the field exists or not. If doesn't exist, just return TRUE
			return true;

		if ( obj.value == "" )
		{	alert( txt + " cannot be empty" );
			obj.select();
			obj.focus();
			return false;
		}
		
		return true;
	}


	// -------------------------------------------------------------------
	// CHECK FOR VALID EMAIL ADDRESS
	// -------------------------------------------------------------------
	function fnCheckMail( obj, strValue )
	{
		if ( obj != "[object]")  // check whether the field exists or not. If doesn't exist, just return TRUE
			return true;

		/*
		//var vFilter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9])+$/;
		var vFilter  = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;

		if ( ! vFilter.test(strValue)) 
		{
			alert( strValue + " is not a valid email address" );
			obj.select();
			obj.focus();
			return false;
		}
		return true;	
		*/

		if (fnEmailCheck(obj.value) == false)
		{
			//alert( strValue + " is not a valid email address" );
			obj.select();
			obj.focus();
			return false;
		}
		return true;
	}

	
	function fnEmailCheck(emailStr) {

		/* The following variable tells the rest of the function whether or not
		to verify that the address ends in a two-letter country or well-known
		TLD.  1 means check it, 0 means don't. */

		var checkTLD=1;

		/* The following is the list of known TLDs that an e-mail address must end with. */

		var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;

		/* The following pattern is used to check if the entered e-mail address
		fits the user@domain format.  It also is used to separate the username
		from the domain. */

		var emailPat=/^(.+)@(.+)$/;

		/* The following string represents the pattern for matching all special
		characters.  We don't want to allow special characters in the address. 
		These characters include ( ) < > @ , ; : \ " . [ ] */

		var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";

		/* The following string represents the range of characters allowed in a 
		username or domainname.  It really states which chars aren't allowed.*/

		var validChars="\[^\\s" + specialChars + "\]";

		/* The following pattern applies if the "user" is a quoted string (in
		which case, there are no rules about which characters are allowed
		and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
		is a legal e-mail address. */

		var quotedUser="(\"[^\"]*\")";

		/* The following pattern applies for domains that are IP addresses,
		rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
		e-mail address. NOTE: The square brackets are required. */

		var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;

		/* The following string represents an atom (basically a series of non-special characters.) */

		var atom=validChars + '+';

		/* The following string represents one word in the typical username.
		For example, in john.doe@somewhere.com, john and doe are words.
		Basically, a word is either an atom or quoted string. */

		var word="(" + atom + "|" + quotedUser + ")";

		// The following pattern describes the structure of the user

		var userPat=new RegExp("^" + word + "(\\." + word + ")*$");

		/* The following pattern describes the structure of a normal symbolic
		domain, as opposed to ipDomainPat, shown above. */

		var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

		/* Finally, let's start trying to figure out if the supplied address is valid. */

		/* Begin with the coarse pattern to simply break up user@domain into
		different pieces that are easy to analyze. */

		var matchArray=emailStr.match(emailPat);

		if (matchArray==null) {

		/* Too many/few @'s or something; basically, this address doesn't
		even fit the general mould of a valid e-mail address. */

		alert("Email address seems incorrect (check @ and .'s)");
		return false;
		}
		var user=matchArray[1];
		var domain=matchArray[2];

		// Start by checking that only basic ASCII characters are in the strings (0-127).

		for (i=0; i<user.length; i++) {
		if (user.charCodeAt(i)>127) {
		alert("Ths username contains invalid characters.");
		return false;
		   }
		}
		for (i=0; i<domain.length; i++) {
		if (domain.charCodeAt(i)>127) {
		alert("Ths domain name contains invalid characters.");
		return false;
		   }
		}

		// See if "user" is valid 

		if (user.match(userPat)==null) {

		// user is not valid

		alert("The username doesn't seem to be valid.");
		return false;
		}

		/* if the e-mail address is at an IP address (as opposed to a symbolic
		host name) make sure the IP address is valid. */

		var IPArray=domain.match(ipDomainPat);
		if (IPArray!=null) {

		// this is an IP address

		for (var i=1;i<=4;i++) {
		if (IPArray[i]>255) {
		alert("Destination IP address is invalid!");
		return false;
		   }
		}
		return true;
		}

		// Domain is symbolic name.  Check if it's valid.
		 
		var atomPat=new RegExp("^" + atom + "$");
		var domArr=domain.split(".");
		var len=domArr.length;
		for (i=0;i<len;i++) {
		if (domArr[i].search(atomPat)==-1) {
		alert("The domain name does not seem to be valid.");
		return false;
		   }
		}

		/* domain name seems valid, but now make sure that it ends in a
		known top-level domain (like com, edu, gov) or a two-letter word,
		representing country (uk, nl), and that there's a hostname preceding 
		the domain or country. */

		if (checkTLD && domArr[domArr.length-1].length!=2 && 
		domArr[domArr.length-1].search(knownDomsPat)==-1) {
		alert("The address must end in a well-known domain or two letter " + "country.");
		return false;
		}

		// Make sure there's a host name preceding the domain.

		if (len<2) {
		alert("This address is missing a hostname!");
		return false;
		}

		// If we've gotten this far, everything's valid!
		return true;
	}


	
	function fnEmailCheck_1(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		
			alert(str.indexOf(at))

		if (str.indexOf(at)==-1){
		   alert("0. Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("1. Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("2. Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("3. Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("4. Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("5. Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("6. Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}


	// -------------------------------------------------------------------
	// DATE VALIDATION FUNCTIONS -- FORMAT  = "dd/mm/yyyy"
	// -------------------------------------------------------------------

	function fnCheckValidDate( objDate, txt )
	{
		strDate = objDate.value
		if ( fnValidDate(strDate) == false )
		{
			alert ( txt + " is not a valid date" );
			objDate.focus();
			objDate.select();
			return false;
		}

		return true;
	}



	function fnValidDate(strInputDate)
	{
		// strInputDate = "dd/mm/yyyy"

		var arrDate  // This variable is used to store Date(dd,mm,yyyy) as an array element
		
		//strInputDate = fnTrim(strInputDate); // Remove Leading and Trailing Spaces
		
		//arrDate = strInputDate.split("/"); //Split date into Day, Month and Year
		arrDate = strInputDate.split("-"); //Split date into Day, Month and Year
		
		if (arrDate.length < 3) //at least one of the component is missing  from the date
		{
			//alert ("Invalid date")
			return false
		}
		if ((arrDate[2] >= 1900) && (arrDate[2] <= 2099)) //Year(YYYY) must lies between 1900 to 2099
		{
			var intMonth = fnGetMonValue(arrDate[1]); //Get Month in MMM Format
			//var intMonth = arrDate[1];  // Get Month in mm format
			if ((intMonth >=1) && (intMonth <= 12)) //Month must lies between 1 to 12
			{
				a = fnGetDaysInMonth(intMonth, arrDate[2])
				//Validate Date for given month and year
				if ((Math.abs(arrDate[0]) <= fnGetDaysInMonth(intMonth, arrDate[2])) && (Math.abs(arrDate[0]) >= 1))
				{
					//alert ("Valid Date")
					return true;
				}
			}
		}
		//alert ("InValid Date")
		return false; //Invalid date
	}

	
	function fnGetMonValue(strMonthName)
	{
		//strMonthName = fnTrim(strMonthName); //remove leading and trailing spaces;
		strMonthName = strMonthName.toLowerCase(); //convert string into lowercase
		switch (strMonthName) //check for month
		{
			case "jan" :
				return "01";
			case "feb" :
				return "02";
			case "mar" :
				return "03";
			case "apr" :
				return "04";
			case "may" :
				return "05";
			case "jun" :
				return "06";
			case "jul" :
				return "07";
			case "aug" :
				return "08";
			case "sep" :
				return "09";
			case "oct" :
				return "10";
			case "nov" :
				return "11";
			case "dec" :
				return "12";
			default:
				return -1;	//error
		}
	}

	function fnGetDaysInMonth(strMonth, strYear) 
	{
		switch (Math.abs(strMonth)) //Convert month into interger type and then match
		{
			case 1:
				return 31; 
			case 2:
				if (fnLeapYear(strYear)) //Check for leap year
					return 29; //If Leap year
				else 
					return 28;
			case 3:
				return 31;
			case 4:
				return 30;
			case 5:
				return 31;
			case 6:
				return 30;
			case 7:
				return 31;
			case 8:
				return 31;
			case 9:
				return 30;
			case 10:
				return 31;
			case 11:
				return 30;
			case 12:
				return 31;
			default :
				alert ("Not a Valid Month");
				return -1;
		}
	}

	function fnLeapYear(strYear)
	{
		var intYear;
		
		//strYear = fnTrim(strYear); //Remove leading and trailing spaces
		intYear = Math.abs(strYear); //Cast Year into numerci value.
		if ((intYear >=0) && (intYear <= 99))
		{
			//If year passed as a parameter lies between 0 and 99 then convert year into 2000 - 2099 
			intYear = 2000 + intYear;
		}
		if ((intYear % 400 == 0) || (intYear % 100 != 0 && intYear % 4 == 0))
		{	
			// Below statement is wriiten only for testing
			return true; //Given Year is a leap year
		}
		else
		{
			// Below statement is wriiten only for testing
			return false; //Given Year is not leap year
		}
	}


	function fnTrim(strString)
	{
		// white space consist of (blank,tab,newline)
		var intLeftIndex = 0; //Store position of first non-white space from leftmost side
		var intRightIndex = 0; //Store position of first non-white space from rightmost side
		var blnFound = false; //Check for any non-white space character
		var regExp = /\S+/; 
		var intCount;
		if (strString.search(regExp) == -1) //Check for non-white space character
		{
			strString = ""; //Valid character not found then return empty string
			return(strString);
		}

		//If  atleast one non-white space character found.
		for (intCount=0;intCount < strString.length; intCount++)
		{
			
			if (strString.charAt(intCount) != " ") // Checking for first non-white spaces 
												// from left side
			{
				intLeftIndex = intCount - 1;
				break;
			}
		}
		for (intCount=strString.length - 1;intCount >= 0; intCount--)
		{
			if (strString.charAt(intCount) != " ") // Checking for first non-white spaces 
												// from Right most side
			{
				intRightIndex = intCount + 1;
				break;
			}
		}

		strString=strString.substring(intLeftIndex+1,intRightIndex); //Remove leading and trailing
															// spaces
		return (strString);
	}


	function fnDateCompare(strFromDate,strToDate)
	{
		// Date parameters are in form "dd/mm/yyyy"

		strFromDate = fnTrim(strFromDate); // Remove Leading and Trailing Spaces
		strToDate = fnTrim(strToDate); // Remove Leading and Trailing Spaces

		var dtmFromDate, intTime1, arrTemp
		var dtmToDate, intTime2

		arrTemp = strFromDate.split("/")
		dtmFromDate = new Date(arrTemp[2], arrTemp[1]-1, arrTemp[0]);

		arrTemp = strToDate.split("/")
		dtmToDate =  new Date(arrTemp[2], arrTemp[1]-1, arrTemp[0]);

		intTime1 = Date.parse(dtmFromDate)
		intTime2 = Date.parse(dtmToDate)

		if ( intTime1 >  intTime2 ) 
			return 1		
		else if ( intTime1 <  intTime2 ) 
			return -1
		else
			return 0
	}


	function fnDateCompare30(strFromDate,strToDate)
	{
		// Date parameters are in form "dd/mm/yyyy"

		strFromDate = fnTrim(strFromDate); // Remove Leading and Trailing Spaces
		strToDate = fnTrim(strToDate); // Remove Leading and Trailing Spaces

		var dtmFromDate, intTime1, arrTemp
		var dtmToDate, intTime2

		arrTemp = strFromDate.split("/")
		dtmFromDate = new Date(arrTemp[2], arrTemp[1]-1, arrTemp[0]);

		arrTemp = strToDate.split("/")
		dtmToDate =  new Date(arrTemp[2], arrTemp[1]-1, arrTemp[0]);

		intTime1 = Date.parse(dtmFromDate)
		intTime2 = Date.parse(dtmToDate)

		if ( ( intTime1 -  intTime2 ) > 30 )
			return 1
		else if ( ( intTime1 -  intTime2 ) < 30 )
			return -1
		else
			return 0
	}


	// Format of strDate => DD MMM YYYY
	// Output format => DD/MM/YYYY

	function fnConvertToDDMMYYYY(strDate)	
	{
		arrDate = strDate.split(" ")

		if ( arrDate.length != 3 )
			return ""

		day	= fnTrim( arrDate[0] )
		month	= fnTrim( arrDate[1] )
		year	= fnTrim( arrDate[2] )
		if ( day.length == 1 )
			day = "0" + day		
		month = fnGetMonValue(month)
		if ( month.length == 1 )
			month = "0" + month
		r = day + "/" + month + "/" + year
		return r
	}
	

	// -------------------------------------------------------------------
	// END OF DATE VALIDATION FUNCTIONS
	// -------------------------------------------------------------------

function fnY2K(number) 
 { 
  return (number < 1000) ? number + 1900 : number; 
 }
 
 function fnDaysElapsed(date1,date2) 
 {
   var difference =
     Date.UTC(fnY2K(date1.getYear()),date1.getMonth(),date1.getDate(),0,0,0)
    - Date.UTC(fnY2K(date2.getYear()),date2.getMonth(),date2.getDate(),0,0,0);
   return difference/1000/60/60/24;
 }
 
 function fnGetDateObject(strDate)
 {
  arrTemp = strDate.split("/");  // "dd/mm/yyyy"
  return new Date(arrTemp[2], arrTemp[1]-1, arrTemp[0]);
 }
 
 function fnDateDiff(strFromDate,strToDate)
 {
  // Date parameters are in form "dd/mm/yyyy"
  var strFromDate, strToDate
  strFromDate = fnTrim(strFromDate); // Remove Leading and Trailing Spaces
  strToDate = fnTrim(strToDate); // Remove Leading and Trailing Spaces
 
  dtmFromDate = fnGetDateObject(strFromDate);
  dtmToDate =  fnGetDateObject(strToDate); 
 
  return fnDaysElapsed(dtmFromDate,dtmToDate);
 }
 
 function fnDateDiffCurrentDate(strDate)
 {
  var dtmDate;
  dtmDate = fnGetDateObject(strDate);
  return fnDaysElapsed(dtmDate,new Date())
 }
