    var testresults
    var lines = 1;
    var DinnersTotal = 0;

// *************************
function fnPrint(divId)
{
    w=window.open('','newwin')
    w.document.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" \"http://www.w3.org/TR/html4/loose.dtd">');
    w.document.write('<html><head> \<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">');
    w.document.write('<body bgcolor="white">'+document.getElementById(divId).innerHTML+'</body>');
    w.document.write('</html>');
    print(document);
    //window.close();
    //return false
}
// *************************
function fnNote()
{
alert('Please be aware that this Registration Page will be down 10/11/2005 between 10pm-cst until 10/12/2005 9am undergoing maintenance');
}
// *************************
function fnPreSetCCNum(_type)
{
	switch(_type)
            { // Start Switch
              case "Visa":
		document.getElementById('txtCreditCardNumber').value = "4";
        	break;

              case "Master Card":
		document.getElementById('txtCreditCardNumber').value = "5";
        	break;

              case "Discover":
		document.getElementById('txtCreditCardNumber').value = "6";
        	break;

		default:
		document.getElementById('txtCreditCardNumber').value = "";


	    }
}
// ********************************************************************************************************************
function fnPopup(_url)
{
	settings="toolbar=no,location=no,status=yes,member=no,scrollbars=yes,resizable=yes,width=750,height=500,left=10,top=10";
	window.open(_url ,'',settings);

}
// ********************************************************************************************************************
function fnCCVAL(s)
{
// remove non-numerics
var v = "0123456789";
var w = "";
for (i=0; i < s.length; i++)
{
	x = s.charAt(i);
	if (v.indexOf(x,0) != -1)
	w += x;
}
// validate number
j = w.length / 2;
if (j < 6.5 || j > 8 || j == 7) return false;
	k = Math.floor(j);
	m = Math.ceil(j) - k;
	c = 0;
	for (i=0; i<k; i++)
	{
		a = w.charAt(i*2+m) * 2;
		c += a > 9 ? Math.floor(a/10 + a%10) : a;
	}
	for (i=0; i<k+m; i++) c += w.charAt(i*2+1-m) * 1;
	return (c%10 == 0);
}
// ********************************************************************************************************************
function fnDisplayCCVAL(_cc,_ccfld)
{
	if(fnCCVAL(_cc) == false)
	 {
                document.getElementById(_ccfld).style.backgroundColor='red';
		alert('Invalid Credit Card. Please check value in red field and try again.');
	        document.getElementById(_ccfld).value = "";
	 }
	else
	 {
	        document.getElementById(_ccfld).style.backgroundColor='white';
	 }
}
// ********************************************************************************************************************
var phone = "()- 0123456789";
var numb = "0123456789";
var alpha = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ";
function fnRestrictNumbers(t,v)
{
	var w = "";
	for (i=0; i < t.value.length; i++)
	{
		x = t.value.charAt(i);
		if (v.indexOf(x,0) != -1)
		 {
                        w += x;
		 }
		else
		 {
                        t.value = w;
		 }
	}
}
/*
function fnRestrictNumbers(t,v)
{
	var phone = "0123456789";
	//var numb = "0123456789";
	var alpha = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ";
		var w = "";
		for (i=0; i < t.value.length; i++)
		{
			x = t.value.charAt(i);
			if (v.indexOf(x,0) != -1)
			w += x;
		}
		t.value = w;
}
*/
// ********************************************************************************************************************
function fnToggleAdminOptions(_show,_hide)
{
//alert('hello');

	document.getElementById(_show).visibility='visible';
        document.getElementById(_hide).visibility='hidden';
}
// ********************************************************************************************************************
function fnOpenWindow(_url)
{
        settings="toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=700,height=500,left=100,top=150";
        window.open(_url ,"New",settings);
}

// ********************************************************************************************************************
function fnIsValidPhone(_num,_id)
{
	if(_num.length != 10)
	        {
	                alert('Phone number must contain 10 digits; area code + phone number');
	                document.getElementById(_id).value='';
	                document.getElementById(_id).style.backgroundColor='red';
	        }
	else
	        {
	                document.getElementById(_id).style.backgroundColor='white';

	        }
}
// ********************************************************************************************************************
function fnLoginInfo(_uid,_pwd)
	{
	        if(_uid.length == 0 || _pwd.length == 0)
	                {
				alert('Missing User ID and/or Password.');
				return false;
	                }
		else
		        {
		                return true;
		        }



	}
// ********************************************************************************************************************
	function fnIsText(_num,_id,_lbl)
   		{
   			var strValidChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ";
   			var strChar;
   			var blnResult = true;

   			if (_num.length == 0) return false;

   			//  test strString consists of valid characters listed above
   			for (i = 0; i < _num.length && blnResult == true; i++)
      				{
      					strChar = _num.charAt(i);
      					if (strValidChars.indexOf(strChar) == -1)
         					{
							alert(_lbl + ' can only contain a-z & A-Z');
							 blnResult = false;
         						document.getElementById(_id).value='';
         						document.getElementById(_id).style.backgroundColor='red';
         					}
					else
					        {
					                blnResult = true;
                                                        document.getElementById(_id).style.backgroundColor='lightgreen';
					        }
      				}
   			return blnResult;
   		}

// ********************************************************************************************************************
	function fnIsNumber(_num,_id,_lbl)
   		{
   			var strValidChars = "0123456789";
   			var strChar;
   			var blnResult = true;

   			if (_num.length == 0) return false;

   			//  test strString consists of valid characters listed above
   			for (i = 0; i < _num.length && blnResult == true; i++)
      				{
      					strChar = _num.charAt(i);
      					if (strValidChars.indexOf(strChar) == -1)
         					{
							alert(_lbl + ' can only contain 0-9');
							 blnResult = false;
         						document.getElementById(_id).value='';
         						document.getElementById(_id).style.backgroundColor='red';
         					}
					else
					        {
					                blnResult = true;
                                                        document.getElementById(_id).style.backgroundColor='white';
					        }
      				}
   			return blnResult;
   		}
// ********************************************************************************************************************
function fnShowCC(_action,_item)
{
	if(_action == "show")
	 {
		document.getElementById(_item).style.bgcolor="white";
	 }
}
// ********************************************************************************************************************
function fnConfirmMidstateSubmission()
{
  var error = "";
  var b_Renewal;
  var _Total = document.getElementById('txtRegistrationFee').value;
  var h1 = "....................................................\n";
  var msg = "**************** IAHPERD Convention Registration  ****************\n\n";
  //msg+="\tYou are about to submit your hours for approval.\n";
  //msg+="This will include any non-billable hours.\n";
  msg+="\t\tYou are about to submit your application and your total charges is $ " + _Total + ".\n\n";
  msg+="\t\tDO YOU WANT TO CONTINUE  ?\n\n";
  msg+="************************************************************";

  // Personal Data -----------------------------------------------------------
  var b_School = document.getElementById('BadgeSchoolOrg').value;
  var b_City = document.getElementById('BadgeCity').value;
  var b_State = document.getElementById('BadgeState').value;
  var b_Zip = document.getElementById('BadgeZip').value;
  //var b_County = document.getElementById('BadgeCounty').value;

  var a_FName = document.getElementById('AddressFirstName').value;
  var a_LName = document.getElementById('AddressLastName').value;
  var a_Address = document.getElementById('AddressText').value;
  var a_City = document.getElementById('AddressCity').value;
  var a_State = document.getElementById('AddressState').value;
  var a_Zip = document.getElementById('AddressZip').value;
  var a_County = document.getElementById('AddressCounty').value;
  var w_County = document.getElementById('WorkCounty').value;

  var a_HomePhone_A = document.getElementById('AHN_A').value;
  var a_HomePhone_P = document.getElementById('AHN_P').value;
  var a_HomePhone_E = document.getElementById('AHN_E').value;

  var a_WorkPhone_A = document.getElementById('AWN_A').value;
  var a_WorkPhone_P = document.getElementById('AWN_P').value;
  var a_WorkPhone_E = document.getElementById('AWN_E').value;

  var a_Email = document.getElementById('AddressEmail').value;

  var a_Reg = document.getElementById('txtRegistrationText').value;

  var c_CCNUM =  document.getElementById('txtCreditCardNumber').value;
  var c_CCSEC = document.getElementById('txtCreditCardSecNum').value;
  var c_EXPDAT = document.getElementById('txtCreditCardExpDate').value;

  if(a_FName.length == 0 || a_LName.length == 0)
    {
      error = "Missing First And/Or Last Name";
    }

  if(a_Address.length == 0)
    {
      error += "\nMissing Street Address";
    }

  if(a_City.length == 0)
    {
      error += "\nMissing City";
    }

  if(a_Zip.length == 0)
    {
      error += "\nMissing Zip Code";
    }


  if(b_School.length == 0)
    {
      error += "\nMissing School Name";
    }

  if(b_City.length == 0)
    {
      error += "\nMissing School City";
    }

  if(b_Zip.length == 0)
    {
      error += "\nMissing School Zip Code";
    }

  if(a_County.length == 0)
    {
      error += "\nMissing Home County";
    }

  if(w_County.length == 0)
    {
      error += "\nMissing Work County";
    }

  if(a_HomePhone_A.length == 0 || a_HomePhone_P.length == 0 || a_HomePhone_E.length == 0)
    {
      error += "\nMissing Home Phone Number";
    }

  if(a_WorkPhone_A.length == 0 || a_WorkPhone_P.length == 0 || a_WorkPhone_E.length == 0)
    {
      error += "\nMissing Work Phone Number";
    }

  if(a_Email.length == 0)
    {
      error += "\nMissing Email";
    }

  if(a_Reg.length == 0)
    {
      error += "\nMissing Registrstion";
    }

  if(c_CCNUM.length == 0 || c_CCNUM.length != 16)
    {
      error += "\nMissing/Invalid Credit Card Number";
    }

  if(c_CCSEC.length == 0 || c_CCSEC.length > 4)
    {
      error += "\nMissing/Invalid Security Code";
    }

  if(c_EXPDAT.length == 0 || c_EXPDAT.length != 4)
    {
      error += "\nMissing/Invalid Expiration Date.";
    }

    if(error.length > 0 )
      {
        alert('We are sorry, but your application has some errors. Please fix the following error before submitting your application: \n' + h1 + error);
        return false
      }

  if(confirm(msg))
  {
    return true;
  }
  else
  {
    return false;
  }

}
// ********************************************************************************************************************
function fnConfirmSubmission()
{
  var error = "";
  var b_Renewal;
  var _Total = document.getElementById('txtGrandTotal').value;
  var h1 = "....................................................\n";
  var msg = "**************** IAHPERD Convention Registration  ****************\n\n";
  //msg+="\tYou are about to submit your hours for approval.\n";
  //msg+="This will include any non-billable hours.\n";
  msg+="\t\tYou are about to submit your application and your total charges is $ " + _Total + ".\n\n";
  msg+="\t\tDO YOU WANT TO CONTINUE  ?\n\n";
  msg+="************************************************************";

  // Personal Data -----------------------------------------------------------
  var b_Name = document.getElementById('BadgeName').value;
  var b_School = document.getElementById('BadgeSchoolOrg').value;
  var b_City = document.getElementById('BadgeCity').value;
  var b_State = document.getElementById('BadgeState').value;
  var b_County = document.getElementById('BadgeCounty').value;

  var a_Name = document.getElementById('AddressName').value;
  var a_Address = document.getElementById('AddressText').value;
  var a_City = document.getElementById('AddressCity').value;
  var a_State = document.getElementById('AddressState').value;
  var a_Zip = document.getElementById('AddressZip').value;
  var a_County = document.getElementById('AddressCounty').value;
  var a_TeachYears = document.getElementById('YearsTeaching').value;

  var a_HomePhone_A = document.getElementById('AHN_A').value;
  var a_HomePhone_P = document.getElementById('AHN_P').value;
  var a_HomePhone_E = document.getElementById('AHN_E').value;

  var a_WorkPhone_A = document.getElementById('AWN_A').value;
  var a_WorkPhone_P = document.getElementById('AWN_P').value;
  var a_WorkPhone_E = document.getElementById('AWN_E').value;

  var a_Email = document.getElementById('AddressEmail').value;


  var _Renewal = document.getElementById('txtMembershipRenewal').value;
  var _Conv = document.getElementById('txtConvRegValue').value;

  var _SECURITY_CODE = document.getElementById('sec_code').value;
  var _SECURITY_CODE_CONFIRM = document.getElementById('code').value;

  var c_CCNUM =  document.getElementById('txtCreditCardNumber').value;
  var c_CCSEC = document.getElementById('txtCreditCardSecNum').value;
  var c_EXPDATE = document.getElementById('txtCreditCardExpDate').value;



  if(b_Name.length == 0 )
    {
      error = "[Badge Information] >> Missing Name";
    }

  if(b_School.length == 0)
    {
      error += "\n[Badge Information] >> Missing School/Orgnization Name";
    }

  if(b_City.length == 0)
    {
      error += "\n[Badge Information] >> Missing City";
    }

  if(b_State.length == 0)
    {
      error += "\n[Badge Information] >> Missing State";
    }

  if(b_County.length == 0)
    {
      error += "\n[Badge Information] >> Missing County";
    }
// -------------------------------------------------------------------------
  if(a_Name.length == 0)
    {
      error += "\n[Personal Information] >> Missing Name";
    }

  if(a_Address == 0 || a_City.length == 0 || a_State.length == 0 || a_Zip.length == 0 || a_County.length == 0)
    {
      error += "\n[Personal Information] >> Missing Address,City,State,Zip or County";
    }

  if(a_TeachYears.length == 0 )
    {
      error += "\n[Personal Information] >> Initial Year of Teaching";
    }

  if(a_HomePhone_A.length == 0 || a_HomePhone_P.length == 0 || a_HomePhone_E.length == 0)
    {
      error += "\n[Personal Information] >> Missing Home Phone Number";
    }

  if(a_Email.length == 0)
    {
      error += "\n[Personal Information] >> Missing Email";
    }
// -------------------------------------------------------------------------
  if(_Renewal.length == 0)
    {
     error += "\n[Membership Renewal Options] >> Missing Renewal Selection";
    }
// -------------------------------------------------------------------------
  if(_Conv == 0)
    {
     error += "\n[Convention Registration Options] >> Missing Registration Selection";
    }
// -------------------------------------------------------------------------
	if(_SECURITY_CODE != _SECURITY_CODE_CONFIRM)
	{
			error += "\n[Security Code] >> \t Missing or Invalid Security Code";
	}
// -------------------------------------------------------------------------
  if(c_CCNUM.length == 0 || c_CCNUM.length != 16)
    {
      error += "\n[Credit Card Information] >> Missing/Invalid Credit Card Number";
    }

  if(c_CCSEC.length == 0 || c_CCSEC.length > 4)
    {
      error += "\n[Credit Card Information] >> Missing/Invalid Security Code";
    }

  if(c_EXPDATE.length == 0 || c_EXPDATE.length != 4)
    {
      error += "\n[Credit Card Information] >> Missing/Invalid Expiration Date." + c_EXPDATE;
    }

// -------------------------------------------------------------------------


    if(error.length > 0 )
      {
        alert('We are sorry, but your application has some errors. Please fix the following error before submitting your application: \n' + h1 + error);
        return false
      }


  if(confirm(msg))
  {
    return true;
  }
  else
  {
    return false;
  }
}
// ********************************************************************************************************************
// ******************* Delete Guest
function fnDeleteLine(_lineIndex)
        {
            	var _r=document.getElementById('tblAwardDinner').rows
    		//var _c=_r[_lineIndex].cells
    		//var _cc = _c[2].innerText
    		//var _actline = _c[0].innerText;
                document.getElementById('tblAwardDinner').deleteRow(_lineIndex)
                if(_r.length == 1)
		 {
		        alert('All Award Reservations had been removed.');
		        //document.getElementById('AllDinners').value = '';
		 }

        	fnKeepRunningTotal("delete");
        	fnCompileGuestsList();
        }
// ********************************************************************************************************************
function fnKeepRunningTotal(_action)
{
 var Total  = 0;
 var tmpAmount = 0;
 var lr=document.getElementById('tblAwardDinner').rows;

    for( var rx=1; rx<lr.length; rx++)
      {
        tmpAmount = lr[rx].cells;
        if(_action == "delete")
	 {
	  Total -= eval(tmpAmount[3].innerHTML);
	 }
	else
	 {
          Total += eval(tmpAmount[3].innerHTML);
         }
      }
	document.getElementById('txtTotalDinner').value = Total;
	fnUpdateGrandTally();
}
// ******************* Add Award Dinner Guests ************************************************************************
function fnAddAwardDinnerGuest()
{

   if(document.getElementById('txtGuest').value == '' || document.getElementById('selDinner').value == 0)
        {
                alert('Please provide a guest name and a dinner from the drop down');
                return;
        }

    var r=document.getElementById('tblAwardDinner').rows.length; // Assign the current length of the table to variable r.
    var x=document.getElementById('tblAwardDinner').insertRow(r); // Insert a new row to after the last row.

    x.id = r+1; // Assign dynamic id to each row added.
    var llv; // Initialize variable llv.

    // Inserting Cells cells
    var _line=x.insertCell(0);
    var _guest=x.insertCell(1);
    var _dinner=x.insertCell(2);
    var _price=x.insertCell(3);
    var cr = r - 1;


    _line.innerHTML=  '<a href="javascript:" onclick="javascript:fnDeleteLine(this.parentNode.parentNode.rowIndex); fnCompileGuestsList();" Title="Remove line" + (this.id;)><Font style="color: crimson"><B>' + r +'</B></font></a></Font>' ;
    _guest.innerHTML=  document.getElementById('txtGuest').value;
    _dinner.innerHTML= document.getElementById('txtDinner').value;
    _price.innerHTML = document.getElementById('txtPrice').value;
    fnCompileGuestsList();
}
// ******************* End Of Function Add Award Dinner Guests ********************************************************

// ********************************************************************************************************************
// ******************* Clear All Guests
function fnClearAllGuests()
{
        frmRegister.AllDinners.value = '';
        lines= 0;
        document.all.divTotalGuests.innerHTML = '<b>All Guests Were Removed.</b>';

}
// ******************* End Of Function Add Award Dinner Guests ********************************************************

// ********************************************************************************************************************
// ******************* Get the Price for Selected Dinner **************************************************************
function fnGetDinnerPrice()
{
        document.getElementById('txtDinner').value = document.getElementById('selDinner').options[document.getElementById('selDinner').options.selectedIndex].text;
        document.getElementById('txtPrice').value = document.getElementById('selDinner').value;
}
// ******************* End Of Function Get the Price for Selected Dinner **********************************************

// ********************************************************************************************************************
function fnCompileGuestsList()
{
   // Initialize array, get table length and number of rows
    var _fArray = '';
    var lr=document.getElementById('tblAwardDinner').rows;
    var _lastprice = 0;
    var _total = 0;
    var _cell_count = 0;

    // Loop through all rows in table lr
    for(var rx=1; rx<lr.length; rx++)
      {
		_cell_count = lr[rx].cells;

		for( var cy = 1 ; cy < _cell_count.length ; cy++)
	          {
	            	var _xcell = _cell_count[cy].innerHTML;
	            	//var _lcell = lr[rx].cells.length;
	            	var _lcell = _cell_count.length;

	            	if(cy != _lcell-1)
	              	{
	                	_fArray += _xcell + ',';
	              	}
	            	else
	              	{
	                	_fArray += _xcell + '#';
	              	}

	        	// Dump array into hidden textarea object TA
		        document.getElementById('AllDinners').value = _fArray;
		        //_lastprice = _cell_count[3].innerHTML;
      		  }
      		  /*
      		  if(_action == "Add")
		   {
      		  	var c_price=lr[rx].cells
			_total += eval(c_price[3].innerHTML);
			document.getElementById('txtTotalDinner').value = _total;
		   }
		  else
		   {
			_total -= eval(c_price[3].innerHTML);
			document.getElementById('txtTotalDinner').value = _total;
		   }
		   */
		   fnKeepRunningTotal("add");
      }
}
// *********************** End Of Function Compile Award Dinners
// ********************************************************************************************************************
// ******************* Get Registration Value For Total Tally *********************************************************
function fnRegTally(_RegText)
{
  var RegTally = 0;
  var RegText = _RegText;
  for(c=0; c<frmRegister.Registration.length; c++)
    {   //Start For Loop

      if(frmRegister.Registration[c].checked==true)
        {   // Start IF
          switch(frmRegister.Registration[c].value)
            { // Start Switch
              case "reg_Regular":
              RegTally = 65;
              RegText = "Regular Registration";
              break;

              case "reg_Student":
              RegTally = 15;
              RegText = "Student Registeration";
              break;

              case "reg_Retired":
              RegTally = 10;
              RegText = "Retired Registeration";
              break;

              case "reg_RetiredNM":
              RegTally = 25;
              RegText = "Retired Registeration / Non-Member";
              break;


              case "reg_NonMember":
              RegTally = 115;
              RegText = "Non-Member Registeration";
              break;
            } // End Switch
              frmRegister.regTally.value = RegTally;
              frmRegister.regText.value = RegText;
        }   // End IF
    }   // End For Loop
    fnUpdateGrandTally();

}
// *********************** Registration Value For Total Tally

// ********************************************************************************************************************
// ******************* Get Registration Value For Total Tally *********************************************************
function fnRenTally(_RenText)
{
  var RenTally = 0;
  var RenText = _RenText;

  for(c=0; c<frmRegister.MembershipRenewal.length; c++)
    {   //Start For Loop

      if(frmRegister.MembershipRenewal[c].checked==true)
        {   // Start IF
          switch(frmRegister.MembershipRenewal[c].value)
            { // Start Switch
              case "mr_Existing":
              RenTally = 50;
              RenText = "Existing Member";
              break;

              case "mr_New":
              RenTally = 50;
              RenText = "New Member";
              break;

              case "mr_Student":
              RenTally = 20;
              RenText = "Student";
              break;
            } // End Switch
              frmRegister.renTally.value = RenTally;
              frmRegister.renText.value = RenText;
        }   // End IF
    }   // End For Loop
    fnUpdateGrandTally();

}

// ********************************************************************************************************************
// ******************* Get Registration Value For Total Tally *********************************************************
function fnHndBkTally()
{
  var HndBkTally = 0;
  for(c=0; c<frmRegister.Handbook.length; c++)
    {   //Start For Loop

      if(frmRegister.Handbook[c].checked==true)
        {   // Start IF
              frmRegister.HndBkTally.value = HndBkTally;
        }   // End IF
    }
       // End For Loop
       fnUpdateGrandTally();

}

// ********************************************************************************************************************

function fnCheckEmail(_id)
{
var str=document.getElementById(_id).value;
var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (filter.test(str))
	{
		testresults=true
		document.getElementById(_id).style.backgroundColor='lightgreen';
	}
	else
	{
		alert("Please input a valid email address!")
		document.getElementById(_id).value = "";
		document.getElementById(_id).style.backgroundColor='red';
		testresults=false
	}
	return (testresults)
}
// ******************* Update Total Application *********************************************************
function fnUpdateGrandTally()
{
        var GrandTotal;
        GrandTotal = parseFloat(document.getElementById('txtMembershipRenewal').value) + parseFloat(document.getElementById('txtConvRegValue').value) + parseFloat(document.getElementById('txtHandbookFee').value) + parseFloat(document.getElementById('txtTotalDinner').value);
        document.getElementById('txtGrandTotal').value = GrandTotal;



        /*GrandTotal = eval(frmRegister.renTally.value) +
                                        eval(frmRegister.HndBkTally.value) +
                                        eval(frmRegister.regTally.value) +
                                        eval(document.all.txtTotalDinner.value) ;
        divGrandTotal.innerHTML = 'Application Total  $' + GrandTotal;

        document.all.txtGrandTally.value = GrandTotal;*/
        //alert('Total is ' + GrandTotal);

}
// ******************* Update Total Application *********************************************************
	function fnToggleColor(_row)
	        {
			_cbgcolor = document.getElementById(_row).style.backgroundColor;

	                if(_cbgcolor=="gainsboro")
	                        {
	                                document.getElementById(_row).style.backgroundColor="yellow";
	                        }
			else
				{
                                        document.getElementById(_row).style.backgroundColor="gainsboro";
			        }
	        }
// ******************* Confirm Search *********************************************************
	function fnSearch()
	{
		var _regid = document.getElementById('id').value;

		if(_regid.length == 0)
		 {
		        alert('\tMissing Reference Number . Please make sure to enter reference number or select one from the list.');
		        return false;
		 }
		else
		 {
		        return true;
		 }

	}
// ******************* Create Credit Card Exp. Date ********************************************
function fnCreateCCExpDate()
{
    document.getElementById('txtCreditCardExpDate').value = document.getElementById('ccexpdate_m').value + document.getElementById('ccexpdate_y').value;
}

// ********************************************************************************************************************
function fnGetMembershipClass(_class)
{
        document.getElementById('M_Class').value = _class;

		stu_tags = new Array("fsCollegeInfo","fsCreditInfo");
        pro_tags = new Array("fsMembershipYears","fsEmploymentInfo","fsSpecInfo","fsEmpInfo");
		ret_tags=new Array("fsMembershipYears","fsEmploymentInfo","fsSpecInfo","fsEmpInfo","fsCollegeInfo","fsInterestInfo");

	var tmp;

	switch(_class)
	 {

		case "Student":
					for(s=0; s<stu_tags.length; s++)
				 {
						tmp = stu_tags[s];
						document.getElementById(tmp).style.display='';
				 }

					for(h=0; h<pro_tags.length; h++)
				 {
						tmp = pro_tags[h];
						document.getElementById(tmp).style.display='none';
				 }
					 document.getElementById('Total').value=20;
		break;

		case "Sr_Student":
					for(s=0; s<stu_tags.length; s++)
				 {
						tmp = stu_tags[s];
						document.getElementById(tmp).style.display='';
				 }

					for(h=0; h<pro_tags.length; h++)
				 {
						tmp = pro_tags[h];
						document.getElementById(tmp).style.display='none';
				 }
					 document.getElementById('Total').value=35;
		break;

		case "Professional":
					for(s=0; s<stu_tags.length; s++)
				 {
						tmp = stu_tags[s];
						document.getElementById(tmp).style.display='none';
				 }

					for(h=0; h<pro_tags.length; h++)
				 {
						tmp = pro_tags[h];
						document.getElementById(tmp).style.display='';
				 }
					document.getElementById('Total').value=50;

		break;

		case "Retiree":
	        for(s=0; s<ret_tags.length; s++)
		 		{
		       		 	tmp = ret_tags[s];
		        		document.getElementById(tmp).style.display='none';
		 		}


/*
	        for(h=0; h<pro_tags.length; h++)
		 		{
		        		tmp = pro_tags[h];
		       		 	document.getElementById(tmp).style.display='';
		 		}

			for(h=0; h<stu_tags.length; h++)
		 		{
		        		tmp = stu_tags[h];
		       		 	document.getElementById(tmp).style.display='';
		 		}
*/
			document.getElementById('Total').value=15;
			document.getElementById('fsInterestInfo').style.display='';
			document.getElementById('fsSpecInfo').style.display='';



		break;
	 }
	 document.getElementById('fsInterestInfo').style.display='';
	 document.getElementById('fsCreditInfo').style.display='';
}
// ********************************************************************************************************************
function fnGetCollegeLevel(_level)
{
	document.getElementById('C_lvl').value = _level;
}
// ********************************************************************************************************************
function fnGetMembershipYearsFee(_years)
{
        document.getElementById('M_Years').value = _years;
        document.getElementById('Total').value = _years;
}
// ********************************************************************************************************************
function fnGetMembershipStatus(_status)
{
	document.getElementById('M_Status').value = _status;
}
// ********************************************************************************************************************
function fnConfirmSubmissionMembership()
{
  var error = "";
  var b_Renewal;
  var _Total = document.getElementById('Total').value;
  var h1 = "....................................................\n";
  var msg = "**************** IAHPERD Membership  ****************\n\n";
  msg+="\t\tYou are about to submit your application and your total charges is $ " + _Total + ".\n\n";
  msg+="\t\tDO YOU WANT TO CONTINUE  ?\n\n";
  msg+="************************************************************";

  // Personal Data -----------------------------------------------------------
  var F_Name = document.getElementById('FName').value;
  var L_Name = document.getElementById('LName').value;
  var I_Years = document.getElementById('InitYear').value;
  var _Address = document.getElementById('Address').value;
  var _City = document.getElementById('City').value;
  var _State = document.getElementById('State').value;
  var _Zip = document.getElementById('Zip').value;
  var _APhone = document.getElementById('A_Phone').value;
  var _PPhone = document.getElementById('P_Phone').value;
  var _EPhone = document.getElementById('E_Phone').value;

  var _County = document.getElementById('County').value;

  var _MembershipStatus = document.getElementById('M_Status').value;
  var _MembershipYears = document.getElementById('M_Years').value;

  var _College = document.getElementById('CollegeAttending').value;
  var _CollegeCity = document.getElementById('CollegeCity').value;
  var _CollegePerson = document.getElementById('CollegeChairPerson').value;
  var _CollegeLevel = document.getElementById('C_lvl').value;

  var _EmpName = document.getElementById('EmployeeName').value;
  var _EmpCity = document.getElementById('EmployeeCity').value;
  var _EmpCounty = document.getElementById('EmployeeCounty').value;
  var _EmpPhone = document.getElementById('EmployeePhone').value;

  //var _SECURITY_CODE = document.getElementById('sec_code').value;
  //var _SECURITY_CODE_CONFIRM = document.getElementById('code').value;

  var _CCType = document.getElementById('CreditCardType').value;
  var _CCNum = document.getElementById('CreditCardNumber').value;
  var _CCExp = document.getElementById('txtCreditCardExpDate').value;
  var _CCName = document.getElementById('CCName').value;
  var _CCcode = document.getElementById('CCcode').value;


  _act = document.getElementById('M_Class').value;

  if(_act == "Professional")
   {
			  if(F_Name.length == 0 )
			    {
			      error = "Personal Information -> \t Missing First Name\n";
			    }

			  if(L_Name.length == 0 )
			    {
			      error += "Personal Information -> \t Missing Last Name\n";
			    }

			  if(I_Years.length == 0 || I_Years.length != 4)
			    {
			      error += "Personal Information -> \t Missing or Invalid Initial Year of Teaching\n";
			    }

			  if(_City.length == 0)
			    {
			      error += "Personal Information -> \t Missing City\n";
			    }

			  if(_State.length == 0 || _State.length != 2)
			    {
			      error += "Personal Information -> \t Missing or Invalid State Code\n";
			    }

			  if(_Zip.length == 0 || _Zip.length != 5)
			    {
			      error += "Personal Information -> \t Missing or Invalid Zip Code\n";
			    }

			  if(_APhone.length == 0 || _PPhone.length ==0 || _EPhone.length == 0)
			    {
			      error += "Personal Information -> \t Missing or Invalid Phone Number\n";
			    }


			  if(_County.length == 0)
			    {
			      error += "Personal Information -> \t Missing County\n";
			    }
			  /* ------- */
			  if(_MembershipStatus.length == 0)
			    {
			      error += "Status Information -> \t Missing Membership Status\n";
			    }

			  if(_MembershipYears.length == 0)
			    {
			      error += "Membership Information -> \t Missing Membership Length\n";
			    }
                           /* ------- */
			  if(_EmpName.length == 0)
			    {
			      error += "Employment Information -> \t Missing Employer Name\n";
			    }

			  if(_EmpCity.length == 0)
			    {
			      error += "Employment Information -> \t Missing Employer City\n";
			    }

			  if(_EmpCounty.length == 0)
			    {
			      error += "Employment Information -> \t Missing Employer County\n";
			    }

			  if(_EmpPhone.length == 0)
			    {
			      error += "Employment Information -> \t Missing or Invalid Employer Phone Number\n";
			    }
                          /* ------- */
			  if(_CCType.length == 0)
			    {
				error += "Credit Card Information -> \t Missing or Invalid Credit Card Type\n";
			    }

			  if(_CCNum.length == 0 || _CCNum.length != 16)
			    {
				error += "Credit Card Information -> \t Missing or Invalid Credit Card Number\n";
			    }

			  if(_CCExp.length == 0 || _CCExp.length != 4)
			    {
				error += "Credit Card Information -> \t Missing or Invalid Credit Card Expiration Date\n";
			    }

			  if(_CCName.length == 0)
			    {
				error += "Credit Card Information -> \t Missing Name on Credit Card\n";
			    }
   }
  else if(_act == "Student" || _act == "Sr_Student")
   {
   			  if(F_Name.length == 0 )
			    {
			      error = "Personal Information -> \t Missing First Name\n";
			    }
                          if(_CCcode.length == 0 || _CCcode.length != 3)
			    {
			      error += "Personal Information -> \t Missing or Invalid Security Code\n";
			    }
			  if(L_Name.length == 0 )
			    {
			      error += "Personal Information -> \t Missing Last Name\n";
			    }

			  if(_City.length == 0)
			    {
			      error += "Personal Information -> \t Missing City\n";
			    }

			  if(_State.length == 0 || _State.length != 2)
			    {
			      error += "Personal Information -> \t Missing or Invalid State Code\n";
			    }

			  if(_Zip.length == 0 || _Zip.length != 5)
			    {
			      error += "Personal Information -> \t Missing or Invalid Zip Code\n";
			    }

			  /* ------- */
			  if(_MembershipStatus.length == 0)
			    {
			      error += "Status Information -> \t Missing Membership Status\n";
			    }
			  /* ------- */
			  if(_College.length == 0)
			    {
			      error += "College Information -> \t Missing College Name\n";
			    }

			  if(_CollegeCity.length == 0)
			    {
			      error += "College Information -> \t Missing College City\n";
			    }

			  if(_CollegePerson.length == 0)
			    {
			      error += "College Information -> \t Missing College Chairperson Name\n";
			    }

			  if(_CollegeLevel.length == 0)
			    {
			      error += "College Information -> \t Missing College Level\n";
			    }
                          /* ------- */
			  if(_CCType.length == 0)
			    {
				error += "Credit Card Information -> \t Missing or Invalid Credit Card Type\n";
			    }

			  if(_CCNum.length == 0 || _CCNum.length != 16)
			    {
				error += "Credit Card Information -> \t Missing or Invalid Credit Card Number\n";
			    }

			  if(_CCExp.length == 0 || _CCExp.length != 4)
			    {
				error += "Credit Card Information -> \t Missing or Invalid Credit Card Expiration Date\n";
			    }

			  if(_CCName.length == 0)
			    {
				error += "Credit Card Information -> \t Missing Name on Credit Card\n";
			    }
   }
  else
  {
   			  if(F_Name.length == 0 )
			    {
			      error = "Personal Information -> \t Missing First Name\n";
			    }

			 	if(L_Name.length == 0 )
			    {
			      error += "Personal Information -> \t Missing Last Name\n";
			    }

			  if(I_Years.length == 0 || I_Years.length != 4)

			    {
			      error += "Personal Information -> \t Missing or Invalid Initial Year of Teaching\n";
			    }

			  if(_City.length == 0)
			    {
			      error += "Personal Information -> \t Missing City\n";
			    }

			  if(_State.length == 0 || _State.length != 2)
			    {
			      error += "Personal Information -> \t Missing or Invalid State Code\n";
			    }

			  if(_Zip.length == 0 || _Zip.length != 5)
			    {
			      error += "Personal Information -> \t Missing or Invalid Zip Code\n";
			    }

			  if(_County.length == 0)
			    {
			      error += "Personal Information -> \t Missing County\n";
			    }
			  /* ------- */
			  if(_MembershipStatus.length == 0)
			    {
			      error += "Status Information -> \t Missing Membership Status\n";
			    }
			  /* ------- */
			  if(_CCType.length == 0)
			    {
				error += "Credit Card Information -> \t Missing or Invalid Credit Card Type\n";
			    }

			  if(_CCNum.length == 0 || _CCNum.length != 16)
			    {
				error += "Credit Card Information -> \t Missing or Invalid Credit Card Number\n";
			    }

			  if(_CCExp.length == 0 || _CCExp.length != 4)
			    {
				error += "Credit Card Information -> \t Missing or Invalid Credit Card Expiration Date\n";
			    }

			   if(_CCcode.length == 0 || _CCcode.length != 3)
			    {
			      error += "Credit Card Information -> \t Missing / Invalid Security Code \n";
			    }

			  if(_CCName.length == 0)
			    {
				error += "Credit Card Information -> \t Missing Name on Credit Card\n";
			    }

  }

/*
	if(_SECURITY_CODE != _SECURITY_CODE_CONFIRM)
	{
			error += "Security Code -> \t Missing or Invalid Security Code\n";
	}
*/
// -------------------------------------------------------------------------


    if(error.length > 0 )
      {
        alert('We are sorry, but your application has some errors. Please fix the following error before submitting your application: \n' + h1 + error);
        return false
      }


  if(confirm(msg))
  {
    return true;
  }
  else
  {
    return false;
  }
}
// ********************************************************************************************************************
function fnConfirmDelete(_rec)
{
	var msg ="Are you sure you want to delete record # " + _rec + " ?";

	if(confirm(msg))
	 {
	        return(true);
	 }
	 else
	 {
	        return(false);
	 }


}
// ********************************************************************************************************************
function  jsf_ApplyInputMask(str,textbox,loc,delim)
{
	var locs = loc.split(',');
	for (var i = 0; i <= locs.length; i++)
	{
		for (var k = 0; k <= str.length; k++)
		{
		 	if (k == locs[i])
				 {
		 			 if (str.substring(k, k+1) != delim)
		  				{
							str = str.substring(0,k) + delim + str.substring(k,str.length)
		  				}
		 		}
		}
	 }
	textbox.value = str
}
// ********************************************************************************************************************
function jsf_NumbersOnly(myfield, e, dec)
{
  var key;
  var keychar;

  if (window.event)
    key = window.event.keyCode;
  else if (e)
    key = e.which;
  else
    return true;
  keychar = String.fromCharCode(key);

  // control keys
  if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27) )
    return true;

  // numbers
  else if ((("0123456789.").indexOf(keychar) > -1))
    return true;

  // decimal point jump
  else if (dec && (keychar == ".")) {
    myfield.form.elements[dec].focus();
    return false;
  } else
    return false;
}
