/*
Consolidated by Jyoti Sarkar 03/31/2005
*/
	/*
	Purpose	: To display window in different modes
	*/
	function newWindow(page1, winTitle){
     	window.open(page1,winTitle, 'scrollbars,top=100,left=100,resizable=yes');
	}

	function openWindow(page1, winTitle){
     	window.open(page1,winTitle, 'scrollbars,height=400,width=530,top=300,left=300');
	}
	
	function openWindowResize(page1, winTitle){
     	window.open(page1,winTitle, 'scrollbars,height=400,width=530,top=300,left=300,resizable=yes');
	}
	
	function openWinResizeToolbar(page1, winTitle){
     	window.open(page1,winTitle, 'toolbar,scrollbars,height=550,width=750,top=50,left=30,resizable=yes');
	}
	/*
	Purpose	: To focus on a specified form input field upon loading the document
	*/
	function focusAt(formname, felement){
	    window.document.forms[formname].elements[felement].focus();
	}

	/*
	Purpose	: To Check the submit Button's value before submitting the form in CF
	*/
	function submitButton(formname){
		if(window.document.forms[formname].elements['fuseaction'].value == ""){
			var cntr = 0;
			for(var i=0; i<window.document.forms[formname].length; i++){	
				if(window.document.forms[formname].elements[i].type == 'submit'){
					window.document.forms[formname].elements[i].onclick();		
					cntr++;			
				}
				else { /*added to check for the button type */
					if((window.document.forms[formname].elements[i].type == 'button') && (cntr ==0)){	
						window.document.forms[formname].elements[i].onclick();					
					}
				}
			}
		}
	}
	/* 
		Purpose : This function is used to set cookie.
	*/
    function SetCookie (name, value) {
        var argv = SetCookie.arguments;
        var argc = SetCookie.arguments.length;
        var expires = new Date();
        var path = (argc > 3) ? argv[3] : null;
        var domain = (argc > 4) ? argv[4] : null;
        var secure = (argc > 5) ? argv[5] : false;
		expires.setYear(expires.getYear()+1);
        document.cookie = name + "=" + escape (value) +
        ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
        ((path == null) ? "" : ("; path=" + path)) +
        ((domain == null) ? "" : ("; domain=" + domain)) +
        ((secure == true) ? "; secure" : "");
    }
	/* 
		Purpose : This function is used to get cookie.
	*/
    function GetCookie (name) {
        var arg = name + "=";
        var alen = arg.length;
        var clen = document.cookie.length;
        var i = 0;
        while (i < clen)
        	{
        	var j = i + alen;
        	if (document.cookie.substring(i, j) == arg)
        	return getCookieVal (j);
        	i = document.cookie.indexOf(" ", i) + 1;
        	if (i == 0) break;
        	}
        return null;
    }
	/* 
		Purpose : This function is used to destroy cookie.
	*/
	    function DeleteCookie (name) {
        var exp = new Date();
        exp.setTime (exp.getTime() - 1);
        var cval = GetCookie (name);
        document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
    }
	
	/* 
	Purpose: This function is used to validate the login page.
	*/
  function ValidateLogin() 
  {
	var un = window.document.forms['loginForm'].elements['LoginID'].value;
	var pw = window.document.forms['loginForm'].elements['Password'].value;
	var errmsg = ''
  	if ((un =='')||(un == "Type User Name"))
    {
       errmsg = "Please enter your User Name."+'\n';
	} 
    if (pw =='')
    {
        errmsg = errmsg + "Please enter your Password.";              
	} 
	if (errmsg.length > 0)
	{
		alert(errmsg);
		return false;
	}
	return true;
  }			  
  	/* 
	Purpose: This function will check integer.
	*/
  function isPosInteger(inputVal) 
  {
	inputStr = inputVal.toString();
	for (var i = 0; i < inputStr.length; i++)
	{
		var oneChar = inputStr.charAt(i);
		if (oneChar < "0" || oneChar > "9")
		{
			return false;
		}
	}
	return true;
  }
	/* 
		Purpose : This function is used to validate the email address format.
	*/
	function secUpdateProfile(){
		var email=window.document.forms['UpdateProfile'].cEmail.value;
		if (window.document.forms['UpdateProfile'].cEmail.value == '')
		{
		   return true;
		}
			if (!CheckeMail(email)){
				window.document.forms['UpdateProfile'].cEmail.focus();
				window.document.forms['UpdateProfile'].cEmail.select();
				return false;
				}
			return true;
	}
	/*
	Purpose	: To validate eMail address
	*/							
	function CheckeMail(peMail){
	    var errors = 0;
		// Pattern is used to check the e-mail address fits the user@domain format.
		var emailPat=/^(.+)@(.+)$/
		// The following string represents the pattern for matching all special characters.
		var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
		// The following string represents the range of characters allowed in a username or domainname.
		var validChars="\[^\\s" + specialChars + "\]"
		var quotedUser="(\"[^\"]*\")"
		// The following pattern applies for domains that are IP addresses
		var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
		var atom=validChars + '+'
		var word="(" + atom + "|" + quotedUser + ")"
		var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
		var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
		var matchArray=peMail.match(emailPat)
		if (errors == 0) {
			if (matchArray==null)
		    	errors++;
		}		
		if (errors == 0) {
			var user=matchArray[1]
			var domain=matchArray[2]
			if (user.match(userPat)==null)
		   		errors++
		}	

		if (errors == 0) {
			var IPArray=domain.match(ipDomainPat)
			if (IPArray!=null) {
		    	// this is an IP address
	  			for (var i=1;i<=4;i++) {
	    			if (IPArray[i]>255)
						errors++;
	    		}
			} else {
				// Domain is symbolic name
				if (errors == 0) {
					var domainArray=domain.match(domainPat)
					if (domainArray==null)
						errors++;
				}
				if (errors == 0) {
					/* domain name seems valid, but now make sure that it ends in a
   					   three-letter word (like com, edu, gov) or a two-letter word. */
					var atomPat=new RegExp(atom,"g")
					var domArr=domain.match(atomPat)
					var len=domArr.length
					if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>3)
						errors++;
				}
				if (errors == 0) {
					// Make sure there's a host name preceding the domain.
					if (len<2)
					  	errors++;
				}		
		  	  } // end of else
		}
		if (errors == 0)  
			return true;
		else {
		   var Mesg = "eMail address "+peMail+" seems incorrect, Please check.";
		   DisplayMesg(Mesg);
		   return false;
		}   
	}
	/*
	Purpose	: To validate SSN - Social Security Number ( Format must be in ###-##-#### )
	*/							
	function CheckSSN(pSSN) {
	    var errors = 0;
		var matchArr = pSSN.match(/^(\d{3})-?\d{2}-?\d{4}$/);
		var numDashes = pSSN.split('-').length - 1;
		if (matchArr == null || numDashes == 1 || pSSN.length != 11)
		   errors = 1;
		else {
			if (parseInt(matchArr[1],10)==0)
			   errors = 2;
		}
		if (errors == 0)
		   return true;
		if (errors == 1)
		   var Mesg = pSSN + " is not a Valid SSN ";
		else
		   var Mesg = pSSN + " does not appear to be Valid SSN ";
		Mesg = Mesg + "\nPlease enter SSN like 123-45-6789";
		DisplayMesg(Mesg);
		return false;   	
	}
  	/* 
	local variables.
	*/

	var myBrowser = BrowserType();
	var nmCookie = "Flash";
	var mWidth = mainWidth();
	var displayTest = willDisplay();
	var Buffer = "";
	var requiredVersion = 4;

  	/* 
	Purpose: This function will get the window width.
	*/
	function mainWidth() {
	  	mainWidth = 0;
	  	if (self.innerWidth) {
	    	mainWidth = self.innerWidth;
	    	if (document.layers) {
	      		mainWidth -= (parent.outerWidth - parent.innerWidth);
	    	}
	  	}
	  	else if (document.documentElement && document.documentElement.clientWidth){
	    	mainWidth = document.documentElement.clientWidth;
	  	}
	  	else if (document.body){
	    	mainWidth = document.body.clientWidth;
	  	}
	
	  	if (navigator.platform.indexOf('Mac') != -1){
			mainWidth -= 15 
	  	}
	  	else if (navigator.appName.indexOf("Netscape")>=0) {
	    	if (navigator.appVersion.indexOf("5.")!=-1) {
				mainWidth -= 15
	    	}
	  	}
	  	if (mainWidth < 719) {
	    	mainWidth = 720
	  	}
	  	return mainWidth;
	}


  	/* 
	Purpose: This function will get the window height.
	*/
	function mainHeight() {
  		if (self.innerWidth) {
			mainHeight = self.innerHeight;
			if (document.layers) {
	  			mainHeight -= (parent.outerHeight - parent.innerHeight);
			}
  		}
  		else if (document.documentElement && document.documentElement.clientWidth){
			mainHeight = document.documentElement.clientHeight; 
  		}
  		else if (document.body){
			mainHeight = document.body.clientHeight;
  		}
  		return mainHeight;
	}
  	/* 
	Purpose: This function will verify display.
	*/
	function willDisplay() {
  		willDisplay = 1;
  		if (self.innerWidth) 
  		{
			if (navigator.appVersion.indexOf("5.")!=-1) 
			{
	  			if (mainHeight() < 535) 
	  			{
	    			wDisplay = 0;
	  			}	
			}
			else if (navigator.appVersion.indexOf("4.")!=-1) 
			{
	  			if (mainHeight() < 420) 
	  			{
	    			wDisplay = 0;
	  			}
			}
  		}
  		else if (document.documentElement && document.documentElement.clientWidth)
  		{
  			if (mainHeight() < 535) 
			{
	  			wDisplay = 0;
			}
  		}
  		else if (document.body)
  		{
  			if (mainHeight() < 535) 
			{
	  			wDisplay = 0;
			}
  		}
 	 	return willDisplay;
	}
  	/* 
	Purpose: This function will get the browser type.
	*/
	function BrowserType() {
  		if(navigator.appName.indexOf("Netscape") >=0) {
    		if(parseInt(navigator.appVersion) >= 5){
				BrowserType = "Newnet";
    		}
    		else {
				BrowserType = "OldNet";
    		}
  		}
  		else if(navigator.appName.indexOf("Mic") >=0)  {
    		if(parseInt(navigator.appVersion) >= 4){
				BrowserType = "IE";
    		}
    		else {
				BrowserType = "OldIE";
    		}
  		}
  		return BrowserType;
	}

	/*
	Purpose	: To validate DATE It will accept format like MMDDYY, MMDDYYYY, MONDDYY, MONDDYYYY
	*/
	function CheckDate(pDate) {
 		var strDate = " ";
 		var strDateArray = " ";
 		var strDay = " ";
 		var strMonth = " ";
 		var strYear = " ";
 		var intday = 0;
		var intMonth = 0;
 		var intYear = 0;
 		var isOk = false;
 		var strSeparatorArray = new Array("-"," ","/",".","\t","\n","\r","\f","\v");
 		var intElementNr = 0;
 		var errors = false;
 		var strMonthArray = new Array(12);
		strMonthArray[0] = "Jan";
 		strMonthArray[1] = "Feb";
 		strMonthArray[2] = "Mar";
 		strMonthArray[3] = "Apr";
 		strMonthArray[4] = "May";
 		strMonthArray[5] = "Jun";
 		strMonthArray[6] = "Jul";
 		strMonthArray[7] = "Aug";
 		strMonthArray[8] = "Sep";
 		strMonthArray[9] = "Oct";
 		strMonthArray[10] = "Nov";
 		strMonthArray[11] = "Dec";
		strDate = pDate;
 		if (strDate.length < 1) {
 			errors = true;
 		}
 		for (intElementNr = 0; intElementNr < strSeparatorArray.length; intElementNr++) {
 			if (strDate.indexOf(strSeparatorArray[intElementNr]) != -1) {
 				strDateArray = strDate.split(strSeparatorArray[intElementNr]);
 				if (strDateArray.length != 3) {
 					errors = true;
 				}
				else {
 					strDay = strDateArray[1];
 					strMonth = strDateArray[0];
					if (isNaN(strMonth))
					{ var tempdate = "";
					  var upperdate =  strMonth.toUpperCase();
						for( var i=0;i<strMonthArray.length;i++)
					 	{ 	
							tempdate = strMonthArray[i].toUpperCase();
							if(tempdate == upperdate)
							{
								strMonth = i+1;								
							}										
						}						
					}
 					strYear = strDateArray[2];
 				}
 				isOk = true;
    		}
 		}
 		if (!errors && !isOk ) {
 			if (strDate.length>5) {
 				strDay = strDate.substr(2, 2);
 				strMonth = strDate.substr(0, 2);
 				strYear = strDate.substr(4);
    		}
 		}
		if (!errors && (strYear.length != 4 || strMonth.length > 2 || strDay.length > 2)){
		   errors = true;
		}
		if (!errors){
 			intday = parseInt(strDay, 10);
 			if (isNaN(intday)) errors = true;
 		}
		if (!errors){
			intMonth = parseInt(strMonth, 10);
 			if (isNaN(intMonth)) {
 				for (i = 0;i<12;i++) {
 					if (strMonth.toUpperCase() == strMonthArray[i].toUpperCase()) {
 						intMonth = i+1;
 						strMonth = strMonthArray[i];
 						i = 12;
    				}
 				}
 				if (isNaN(intMonth)) errors = true;
    		}
 		}
		if (!errors) {
			intYear = parseInt(strYear, 10);
 			if (isNaN(intYear) || intYear == 0 || intYear < 1000) errors = true;
 		}
 		if (!errors && (intMonth>12 || intMonth<1)) errors = true;
		if (!errors && (intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth  == 8 || intMonth == 10 || intMonth == 12) && (intday > 31 || intday < 1))
 			errors = true;
 		if (!errors && (intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intday > 30 || intday < 1))
 			errors = true;
 		if (!errors && intMonth == 2) {
 			if (intday < 1) errors = true;
 			if (!errors && LeapYear(intYear) == true) { 
 				if (intday > 29) errors = true;
 			}
			else {
 				if (intday > 28) errors = true;
 			}
 		}
		if (errors) {
		  // var Mesg = "Date "+pDate+" must be valid and in the Format of MM/DD/YYYY";
		  // DisplayMesg(Mesg);
		   return false;
		}
 	   	return true;
 	}
	/*
	Purpose	: Check leapyear
	*/
 	function LeapYear(intYear) {
 		if (intYear % 100 == 0) {
 			if (intYear % 400 == 0) { return true; }
 		}
 		else {
 			if ((intYear % 4) == 0) { return true; }
 		}
 		return false;
 	}
	/*
	Purpose	: format date
	*/
	function FormatDate(pDate) {
		var YearStr ='';
 		var strDate = " ";
 		var strDateArray = " ";
 		var strDay = " ";
 		var strMonth = " ";
 		var strYear = " ";
		var strMonthArray = new Array(12);
		strMonthArray[0] = "Jan";
 		strMonthArray[1] = "Feb";
 		strMonthArray[2] = "Mar";
 		strMonthArray[3] = "Apr";
 		strMonthArray[4] = "May";
 		strMonthArray[5] = "Jun";
 		strMonthArray[6] = "Jul";
 		strMonthArray[7] = "Aug";
 		strMonthArray[8] = "Sep";
 		strMonthArray[9] = "Oct";
 		strMonthArray[10] = "Nov";
 		strMonthArray[11] = "Dec";
		strDate = pDate;
 		var isOk = false;		
 		var intday = 0;
		var intMonth = 0;
 		var intYear = 0;
 		var strSeparatorArray = new Array("-"," ","/",".","\t","\n","\r","\f","\v");
 		var intElementNr = 0;
		strDate = pDate;
 		for (intElementNr = 0; intElementNr < strSeparatorArray.length; intElementNr++) {
 			if (strDate.indexOf(strSeparatorArray[intElementNr]) != -1) {
 				strDateArray = strDate.split(strSeparatorArray[intElementNr]);
 				if (strDateArray.length == 3) {
 					strDay = strDateArray[1];
 					strMonth = strDateArray[0];
					if (isNaN(strMonth))
					{ var tempdate = "";
					  var upperdate =  strMonth.toUpperCase();
						for( var i=0;i<strMonthArray.length;i++)
					 	{ 	
							tempdate = strMonthArray[i].toUpperCase();
							if(tempdate == upperdate)
							{
								strMonth = i+1;								
							}										
						}						
					}
 					strYear = strDateArray[2];
 				}
 				isOk = true;
    		}
 		}
		
 		if (strDate.length>5 && !isOk ) {	
			strDay = strDate.substr(2, 2);
			strMonth = strDate.substr(0, 2);
			strYear = strDate.substr(4);
 		}
		intday = parseInt(strDay, 10);
		intMonth = parseInt(strMonth, 10);

		/*added to check if all the digits of the year are numbers*/
		for (var i=0;i<strYear.length;i++)
		{	
			if (!isNaN(strYear.substr(i,1)))
			{
				YearStr = YearStr+strYear.substr(i,1);
			}			
		}
		intYear = parseInt(YearStr, 10);
		
		return intYear+","+intMonth+","+intday;
	}
	/*
	Purpose	: To check the field value is between specified range of
	          Minimum and Maximum values
			  returns true if it is in range otherwise false
	*/
	function CheckRange(pField1,pMinValue,pMaxValue) {
		if (isNaN(pField1) || isNaN(pMinValue) || isNaN(pMaxValue))
		   return false;
		if (pField1 >= pMinValue && pField1 <= pMaxValue)
		   return true 
		else
		  return false;
  	}
	/*
	Purpose	: To compare two dates pDate1, pDate2 and Unit Of Measure i.e. D=>Days, M=>Months, Y=>Years
	          returns +ve Days/Months/Years if input pDate1 > pDate2 
			  returns -ve Days/Months/Years if input pDate1 > pDate2 
			  returns 0 Days/Months/Years if  input pDate1 = pDate2 
	*/
	function CompareTwoDates(pDate1, pDate2, UOM) {
		if (!CheckDate(pDate1)) return false;
		if (!CheckDate(pDate1)) return false;
 		var strMonthArray = new Array(12);
		strMonthArray[0] = "Jan";
 		strMonthArray[1] = "Feb";
 		strMonthArray[2] = "Mar";
 		strMonthArray[3] = "Apr";
 		strMonthArray[4] = "May";
 		strMonthArray[5] = "Jun";
 		strMonthArray[6] = "Jul";
 		strMonthArray[7] = "Aug";
 		strMonthArray[8] = "Sep";
 		strMonthArray[9] = "Oct";
 		strMonthArray[10] = "Nov";
 		strMonthArray[11] = "Dec";
		fDate1 = FormatDate(pDate1);
		fArray1 = fDate1.split(",");
		fArray1[1] = fArray1[1] - 1;
		fDate1 = new Date(fArray1[2]+" "+strMonthArray[fArray1[1]]+" "+fArray1[0]+" 00:00:00 EST");
		fDate2 = FormatDate(pDate2);
		fArray2 = fDate2.split(",");
		fArray2[1] = fArray2[1] - 1;
		fDate2 = new Date(fArray2[2]+" "+strMonthArray[fArray2[1]]+" "+fArray2[0]+" 00:00:00 EST");
		var diff1 = fDate1 - fDate2;
		pDays = Math.floor(diff1 / (1000 * 60 * 60 * 24));
		pMonths = Math.floor(diff1 / (1000 * 60 * 60 * 24 * 30));
		pYears = Math.floor(diff1 / (1000 * 60 * 60 * 24 * 30 * 12));
		if(UOM=='D')
		  return pDays;
		if(UOM=='M')
		  return pMonths;  
		if(UOM=='Y')
		  return pYears;  
  	}
	/*
	Purpose	: To compare inputted DATE with today and will 
	          returns -ve Days if input date > todays date
			  returns +ve Days if input date < todays date
			  returns 0 if input date = todays date
	*/
	function CheckDatewithToday(pDate) {
		if (!CheckDate(pDate)) return false;
 		var strMonthArray = new Array(12);
		strMonthArray[0] = "Jan";
 		strMonthArray[1] = "Feb";
 		strMonthArray[2] = "Mar";
 		strMonthArray[3] = "Apr";
 		strMonthArray[4] = "May";
 		strMonthArray[5] = "Jun";
 		strMonthArray[6] = "Jul";
 		strMonthArray[7] = "Aug";
 		strMonthArray[8] = "Sep";
 		strMonthArray[9] = "Oct";
 		strMonthArray[10] = "Nov";
 		strMonthArray[11] = "Dec";
		fDate = FormatDate(pDate);
		fArray = fDate.split(",");
		fArray[1] = fArray[1] - 1;
		fDate = new Date(fArray[2]+" "+strMonthArray[fArray[1]]+" "+fArray[0]+" 00:00:00 EST");
		tDate = FormatDate("<cfoutput>#DateFormat(now(),'mm/dd/yyyy')#</cfoutput>");
		tArray = tDate.split(",");
		tArray[1] = tArray[1] - 1;
		tDate = new Date(tArray[2]+" "+strMonthArray[tArray[1]]+" "+tArray[0]+" 00:00:00 EST");
		var diff1 = tDate - fDate;
		pDays = Math.floor(diff1 / (1000 * 60 * 60 * 24));
		return pDays
  	}

<BR><center>Hosted by <a href="http://www.efree2net.com/">Coldfusion Hosting</a></center>