﻿/***********************************************
* Contractible Headers script- © Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use. Last updated Oct 21st, 2003.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

var g_enablepersist = "yes" //Enable saving state of content structure using session cookies? (yes/no)
var g_collapseprevious = "no" //Collapse previously open content when opening present? (yes/no)

if (document.getElementById) {
 document.write('<style type="text/css">')
 document.write('.switchcontent{display:none;}')
 document.write('</style>')
}

// MGMA/GRH:6/27/06 Added to support "toggling" content block content on/off
if (document.getElementById) {
 document.write('<style type="text/css">')
 document.write('.nodisplay{display:none;}')
 document.write('</style>')
}

// MGMA/GRH:6/27/06 Added to support "toggling" content block content on/off
function toggleDisplay1( p_cid ) {
	var el = document.getElementById( p_cid );
	if ( el.style.display == "block" )
		el.style.display = "none";
	else
		el.style.display = "block";
}

// MGMA/GRH:6/27/06 Added to support "toggling" content block content on/off
function toggleDisplay2( p_cid, p_xid ) {
  //var strUrl = getUrl()
  var strUrl = ""
  
  var oldstyle = document.getElementById( p_cid ).style.display
  document.getElementById( p_cid ).style.display = (document.getElementById( p_cid ).style.display != "block") ? "block" : "none"
  if ( oldstyle == "none" ) {
    strUrl = strUrl + getImagePath( "minus_img" )
    document.getElementById( p_xid ).src = strUrl
  }
  if ( oldstyle == "block" ) {
    strUrl = strUrl + getImagePath( "plus_img" )
    document.getElementById( p_xid ).src = strUrl
  }
}

// MGMA/GRH:6/27/06 Added to support "toggling" content block content on/off
function getElementbyClass2( p_classname ) {
 g_arrTags2 = new Array()
 var inc = 0
 var alltags=document.all? document.all : document.getElementsByTagName("*")
 for ( i = 0; i < alltags.length; i++ ){
  if ( alltags[i].className == p_classname ) {
   g_arrTags2[inc++] = alltags[i]
  }
 }
}

// MGMA/GRH:6/27/06 Added to support "toggling" content block content on/off
function contractcontent2(p_omit){
 var inc = 0
 while ( g_arrTags2[inc ]){
  if ( g_arrTags2[inc].id != p_omit) {
   g_arrTags2[inc].style.display = "none"
  }
  inc++
 }
}

// MGMA/GRH:4/26/06 Added
function getUrl() {

 // *grh* not called as of 8/15/06
 
 var strLoc = new String( window.location ) // e.g., http://dev2.mgma.com/cms400min/file.htm
 var strPath = new String( window.location.pathname ) // e.g., /cms400min/file.htm
 var strSubsite = new String("")
  
 var intIndex = strPath.indexOf( "/", 1 ) // try to find the second "/" in the Path
 if ( intIndex >= 0 ) {
  strSubsite = new String( strPath.substr( 0, intIndex + 1 )) // e.g. /cms400min/   
 }
 else {
  strSubsite = new String( "/" )  
 } 

 intIndex = strLoc.indexOf( strPath ) // e.g., 20
 var strServer = new String( strLoc.substr( 0, intIndex ) ) // e.g., http://dev2.mgma.com
 var strUrl = strServer + strSubsite
 return strUrl

}

function getElementbyClass1(p_classname){
 g_arrTags1 = new Array()
 var inc = 0
 var alltags = document.all? document.all : document.getElementsByTagName("*")
 for ( i = 0; i < alltags.length; i++ ){
  if ( alltags[i].className == p_classname ) {
   g_arrTags1[inc++] = alltags[i]
  }
 }
}

function contractcontent1(p_omit){
 var inc = 0
 while ( g_arrTags1[inc ]){
  if ( g_arrTags1[inc].id != p_omit) {
   g_arrTags1[inc].style.display = "none"
  }
  inc++
 }
}

function expandcontent( p_cid, p_xid ) {
 if ( typeof g_arrTags1 != "undefined" ) {
  //var strUrl = getUrl()
  var strUrl = ""
  
	if ( g_collapseprevious == "yes" ) {
   contractcontent1( p_cid )
  }
  var oldstyle = document.getElementById( p_cid ).style.display
  document.getElementById( p_cid ).style.display = (document.getElementById( p_cid ).style.display != "block") ? "block" : "none"
  if ( oldstyle == "none" ) {
   strUrl = strUrl + getImagePath( "minus_img" )
   document.getElementById( p_xid ).src = strUrl
  }
  if (oldstyle == "block") {
   strUrl = strUrl + getImagePath( "plus_img" )
   document.getElementById( p_xid ).src = strUrl
  }
 }
}

// MGMA/GRH:7/27/06 Added so that the image to use is retrieved from the HTML and not hard-coded.
// Assumes that a span tag with display:none and id of plus_sign is in the HTML.
// Assumes that a span tag with display:none and id of minus_sign is in the HTML.
// These span tags are put in the HTML by MGMAColAndMenuHtmlUtils.
function getImagePath( p_image_type ) {
  if ( document.getElementById( p_image_type ) != null) {
   if ( document.all ) {
    // IE browser		
    return document.getElementById( p_image_type ).innerText
   }
   else {
    if ( document.getElementById( p_image_type ).textContent ) {
     // Firefox ?
     return document.getElementById( p_image_type ).textContent
    }
    else {
     return ""
    }
   }
  }
  else {
   return ""
  }
}

function revivecontent(){
 g_savecookie = ""
 contractcontent1("omitnothing")
 var selectedItem = getselectedItem()
 var selectedComponents = selectedItem.split("|")
 
 for ( i = 0; i < selectedComponents.length - 1; i++ ) {
 
  var selectedImage = "i" + selectedComponents[i]
  
  if ( document.getElementById(selectedComponents[i]) != null) {
   document.getElementById(selectedComponents[i]).style.display = "block"
  }
  else {
   g_savecookie += selectedComponents[i] + "|"
  }
  
	//var strUrl = getUrl()
	var strUrl = ""
  strUrl = strUrl + getImagePath( "minus_img" )
  
  if ( document.getElementById(selectedComponents[i] ) != null) {
	 if ( document.getElementById( selectedImage ) != null ) {
    document.getElementById( selectedImage ).src = strUrl
   }
  }
 }
}

function get_cookie(p_Name) { 
 var search = p_Name + "="
 var returnvalue = "";
 if (document.cookie.length > 0) {
  var offset = document.cookie.indexOf(search)
  
  if (offset != -1) { 
   offset += search.length
   var end = document.cookie.indexOf(";", offset);
   if (end == -1) end = document.cookie.length;
   returnvalue = unescape( document.cookie.substring( offset, end ) )
  }
 }
 return returnvalue;
}

function getselectedItem() {
 //if (get_cookie(window.location.pathname) != ""){
  //selectedItem=get_cookie(window.location.pathname)
  //if ( get_cookie( escape( window.location.href ) ) != "" ) {
  //selectedItem = get_cookie( escape( window.location.href ) )
  
 if (get_cookie( "ekObj" ) != "" ){
  var selectedItem = get_cookie( "ekObj" )

  return selectedItem
 }
 else {
  return ""
 }
}

function saveswitchstate() {
 var inc = 0
 var selectedItem = ""
 //GRH:8/15/07 Added typeof check.
 if ( typeof g_arrTags1 != "undefined" ) {
  while ( g_arrTags1[inc] ) {
   if ( g_arrTags1[inc].style.display == "block" ) {
    selectedItem += g_arrTags1[inc].id + "|"
   }
  inc++
  }
 }
 selectedItem += g_savecookie
 
 document.cookie="ekObj" + "=" + selectedItem + ";" + " path=/;"
 
 //var escapedHref = escape( window.location.href )
 //document.cookie = escapedHref + "=" + selectedItem
 //document.cookie=window.location.pathname+"="+selectedItem
}

function do_onload() {
  getElementbyClass1("switchcontent")
  if ( g_enablepersist == "yes" && typeof g_arrTags1 != "undefined" ) {
    revivecontent()
  }
  // MGMA/GRH:6/27/06 Added to support "toggling" content block content on/off
  getElementbyClass2("nodisplay")
  contractcontent2("omitnothing") 
  // MGMA/HFS:11/7/07 Add test for MGMA ID cookie
  // HFS:09/11/08 Replacing RememberMe with Keepalive cookie - hide
  //checkRememberMe()
}

// Pop-up window function //
/*
Open Centered Popup Window Script-
© DHTML Shock (www.dhtmlshock.com)
To add more shock to your site, visit www.DHTML Shock.com
*/
function OpenBrWindow(theURL,winName,features, myWidth, myHeight, isCenter) { //v3.0
  if(window.screen)if(isCenter)if(isCenter=="true"){
    var myLeft = (screen.width-myWidth)/1.25;
    var myTop = (screen.height-myHeight)/4;
    features+=(features!='')?',':'';
    features+=',left='+myLeft+',top='+myTop;
  }
  window.open(theURL,winName,features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight);
}
// END pop-up window function //

if (window.addEventListener)
 window.addEventListener("load", do_onload, false)
else if (window.attachEvent)
 window.attachEvent("onload", do_onload)
else if (document.getElementById)
 window.onload = do_onload

if ( g_enablepersist == "yes" && document.getElementById )
 window.onunload = saveswitchstate

	

/*************************** Post Search form *****************************/
function postSearch(search_url) {
	var strURL = new String("");
	var strQuery = new String("");
	strURL = search_url;
	//Holly:12/18/07 Why are there two = statements below? Fixed it.
	//strQuery = strQry = document.forms[0].txtQ.value
	strQuery = document.forms[0].txtQ.value;
	
	//left trim
	while (strQuery.substring(0,1) == ' ')
			{
			strQuery = strQuery.substring(1, strQuery.length);
			}

	if ( strQuery == "" ) {
		alert("Please enter a search term.");
		}
	else {
		document.forms[0].__VIEWSTATE.value = "";
		document.forms[0].__VIEWSTATE.name = "NOVIEWSTATE";
		document.forms[0].action = strURL + strQuery;
		document.forms[0].submit();
		}
	}	
// END search form functions //




/**********************************************************************/
/*************** Login Validation functions below ******************/


/********* CURRENT (Dec 2007) Login Form Submit using last name as password) **********/
///*** Login button click event ***///
function checkLoginForm(login_url, login_id, login_pwd) {
	var blnUserIDFail = false;
	var blnPasswordFail = false;
	var strAlert1 = "";
	var strAlert2 = "";
	var strSelectField = login_pwd;
	
	if ((checkUserID(login_id) == false) ) {
		blnUserIDFail = true;
		strSelectField = login_id;
	
		//Reset the MGMA ID field
		//login_id.value = "";
		strAlert1 = strAlert1 + "Please enter your six-digit MGMA ID number in the \"MGMA ID\" field, \rincluding leading zeros (examples: 001111, 011111). \r\r";

	}
	
	if ((checkPassword(login_pwd) == false ))	{
		blnPasswordFail = true;
		strSelectField = login_pwd;
		strAlert2 = strAlert2 + "Please enter your last name in the \"Last name\" field.";
		//Reset the lastname/password field
		//login_pwd.value = "";	
		if ( blnUserIDFail ) {
			var strSelectField = login_pwd;
			strAlert1 = strAlert1 + strAlert2;	
		 	}
		else {
			//var strSelectField = login_pwd;
			strAlert1 = strAlert2;
		}	
	}
				
	if ( blnUserIDFail || blnPasswordFail ) { 
		alert(strAlert1);		
		strSelectField.select();
		strSelectField.focus();
		return false;
		}
		else {
			//Check for remember me and set cookie for MGMA ID if true.	
			//if ( document.getElementById("remember").checked ) {
			if ( document.getElementById("keepalive").checked ) {
				var id = document.getElementById("id").value;
				//setRememberMe(id);			
				//setKeepAlive();
				}		
			postLoginForm(login_url);
		}
}


//////////////////////////////////////////////////////////////////////////////////
///************ NEW Login button click event, for password login **************///
//////////////////////////////////////////////////////////////////////////////////

function checkLoginIdPwd(login_url, login_id, login_pwd) {
	var blnUserIDFail = false;
	var blnPasswordFail = false;
	var strAlert1 = "";
	var strAlert2 = "";
	var strSelectField = login_pwd;
	
	//Remove all white spaces from the user id field before validating
	var strId = login_id.value;
	strId = removeWhiteSpace(strId);
	//Reset the original value entered to the trimmed value
	login_id.value = strId;
	
	if ((checkLoginUserID(strId) == false) ) {
		blnUserIDFail = true;
		strSelectField = login_id;
		strSelectField.value = strId;
		//Reset the MGMA ID field
		//login_id.value = "";
		strAlert1 = strAlert1 + "Please enter your six-digit MGMA ID number in the \"MGMA ID\" field, \rincluding leading zeros (examples: 001111, 011111). \r\r";
	}
	
//Hide. For testing new password-based log-in, this javascript should just look for empty field.

	if ((checkPasswordField(login_pwd) == false ))	{
		blnPasswordFail = true;
		strSelectField = login_pwd;
		strAlert2 = strAlert2 + "Please enter your password to log in.";
		//Reset the lastname/password field
		//login_pwd.value = "";	
		if ( blnUserIDFail ) {
			var strSelectField = login_pwd;
			strAlert1 = strAlert1 + strAlert2;	
		 	}
		else {
			//var strSelectField = login_pwd;
			strAlert1 = strAlert2;
		}	
	}
				
	if ( blnUserIDFail || blnPasswordFail ) { 
		alert(strAlert1);		
		strSelectField.select();
		strSelectField.focus();
		return false;
		}
		else {
			//Check for remember me and set cookie for MGMA ID if true.	
			//if ( document.getElementById("remember").checked ) {
			if ( document.getElementById("keepalive").checked ) {
				var id = document.getElementById("id").value;
				//setRememberMe(id);
				setKeepAlive();
				}
			postLoginForm(login_url);
		}
}


/***********************************************************************************/
/***********************************************************************************/
/************ NEW validatePasswordFormat - for creating new passwords **************/
/***********************************************************************************/
/***********************************************************************************/

function validatePassword(CurrPwd, Pwd1, Pwd2, objCurrPwd, objPwd1, objPwd2) {

//	alert("Value of objCurrPwd: " + objCurrPwd);
//	return false;

 var strAlertErrorMsg = "";
 var strErrorDetail = "";
 var strSelectField = CurrPwd;
 var blnFieldIsBlank = false;

	//Check for blank values
	//Check pwd1 and pwd2 match
	
	if (chkMinFieldLen(CurrPwd, "1") == false) {
		alert("Please enter your current password.");
		var strSelectField = objCurrPwd;
		//blnFieldIsBlank = true;
		strSelectField.focus();
		return false;
	}
	
	if (chkMinFieldLen(Pwd1, "1") == false) {
		alert("New password cannot be blank.");
		var strSelectField = objPwd1;
		//blnFieldIsBlank = true;
		strSelectField.focus();
		return false;
	}
	
		if (chkMinFieldLen(Pwd2, "1") == false) {
		alert("Please retype your new password.");
		var strSelectField = objPwd2;
		strSelectField.focus();
		return false;
	}

	 var strAlertErrorMsg = "";
 var strErrorDetail = "";

	// Check if new password fields match

	if ( Pwd1 != Pwd2 ) {
		//alert("passwords do not match");
		//return false;
		
//		strErrorDetail = strErrorDetail + "\r\n  * New password and retyped password do not match.";
		strErrorDetail = strErrorDetail + "<li class='redtext'>New password and retyped password do not match.</li>";

		//reset retype password field to blank
		//objPwd2.value = "";
		}
 
	if (chkMinFieldLen(Pwd1, "8") == false)
		{
//		strErrorDetail = strErrorDetail + "\r\n  * New password too short -- must be at least 8 characters long.";
		strErrorDetail = strErrorDetail + "<li class='redtext'>New password is too short. Passwords must 8-20 characters long.</li>";	
		//alert("Password too short.");
		//return false;
		}

	
	//Check for existence of at least one number
	if ( IsOneNumber(Pwd1) == false ) {
		
//		strErrorDetail = strErrorDetail + "\r\n  * New password must include at least one number.";
		strErrorDetail = strErrorDetail + "<li class='redtext'>New password must include at least one number.</li>";
		//alert("Number was NOT found ...");
		//return false;	
		}

		
	//Check for existence of at least one letter	
	if ( IsOneLetter(Pwd1) == false) {
//		strErrorDetail = strErrorDetail + "\r\n  * New password must include at least one letter.<br/>";
			strErrorDetail = strErrorDetail + "<li class='redtext'>New password must include at least one letter.</li>";

		//alert("Letter NOT found ...");
		//return false;	
		}

	//Check for existence of white spaces	
	if ( IsWhiteSpace(Pwd1) == true) {
		strErrorDetail = strErrorDetail + "<li class='redtext'>New password cannot contain spaces.</li>";
		//alert("Letter NOT found ...");
		//return false;	
		}
		
	if ( strErrorDetail != "" ) {
		strAlertErrorMsg = "The following errors were found:<ol>" + strErrorDetail + "</ol>";
		//Write the errors to the span on the HTML
		document.getElementById("lblAlert").innerHTML  = strAlertErrorMsg;
		return false;
		//For alert box
		//	 strAlertErrorMsg = "The following errors were found: \r";
		//	 alert (strAlertErrorMsg + strErrorDetail);
		//
	}
}

/***********************************************************************************/
/************************** End Validate Password function *************************/
/***********************************************************************************/

///************ Check for one alpha char **************/
//function chkOneLetter( strValue ) {
//		var objRegExp  =  /^[a-zA-Z]+$/;
//	  return (objRegExp.test(strValue));
//}

/*********** Check for at least one number (used for password validation) *********/
function IsOneNumber( strValue ) {
	var nums = "0123456789";
	//if (expression.length==0)return(false);
	//If any value is a number, return true and exit function.
	for (var i=0; i < strValue.length; i++) {
		if ( nums.indexOf(strValue.charAt(i)) >= 0 )
			{ 
			//A number was found, so return true and break out of loop
			return true;
			break;
			}			
	}
	return false;
}

/************ Check for at least ONE alpha char (password validation) **************/
function IsOneLetter( strValue ) {

	for (var i=0; i < strValue.length; i++) {
		var objRegExp  =  /^[a-zA-Z]+$/;
		if ( objRegExp.test(strValue.charAt(i)) ) {
		//A letter was found, so return true and break out of loop
		return true;
		break;
		}
	}
	return false;
}

/************ Check for existence of white space (password validation) **************/
function IsWhiteSpace( strValue ) {
	for (var i=0; i < strValue.length; i++) {
		//var objRegExp  =  /^[a-zA-Z]+$/;
		var objRegExp = 	/\s+/;
		if ( objRegExp.test(strValue.charAt(i)) ) {
		//A white space was found; return true and break out of loop
		return true;
		break;
		}
	}
	return false;
}


/************ checkUserID (used in current (lastname is password) login validation ************/
function checkUserID(objUserID) {
	var strUserID = trimStr(objUserID.value);
	if ( (validateInteger(strUserID) == false)  || (chkExactFieldLen(strUserID, "6") == false) )
		{	
		return false;
		}
	else
		{  
		return true;
		}
	}
	
	
/************ checkLoginUserID (NEW) **************/
function checkLoginUserID(strUserID) {
	//var strUserID = trimStr(objUserID.value);
	if ( (validateInteger(strUserID) == false)  || (chkExactFieldLen(strUserID, "6") == false) )
		{	
		return false;
		}
	else
		{  
		return true;
		}
	}


/************ check Password NEW (password secure) **************/
function checkPasswordField(strPassword) {
	var strPassword = trimStr(strPassword.value);
	if (chkMinFieldLen(strPassword, "2") == false)
		{
		return false;
		}
	else
		{  
		return true;
		}
	}

/************ check Password (password is last name) **************/
function checkPassword(objLastname) {
	var strLastname = trimStr(objLastname.value);
	
	if (validateLname(strLastname) == false)
		{
		return false;
		}
	else
		{  
		return true;
		}
	}


	/************ Trim spaces from beginning and end of string *************/
	function trimStr(strUserID) {
	return strUserID.replace(/^\s+|\s+$/g,"");
}

	/********* Remove all white space characters from a string ************/
	function removeWhiteSpace(strString) {
	//var str = strString;
	//alert("str is: '" + str + "'")
	return strString.replace(/\s+/g,'');
	//str = str.replace
	//return str

}

//////// Test: Remove commas //////////////
function removeCommas( strValue ) {
	//search for commas globally
  var objRegExp = /,/g; 
  //replace all matches with empty strings
  return strValue.replace(objRegExp,'');
}

/********* Check for valid integer. **********/
function validateInteger(strUserID) {
  var objRegExp  = /(^-?\d\d*$)/;
	return objRegExp.test(strUserID);
}

/************ Check for valid Last Name **************/
function validateLname( strValue ) {
	// Alphabetical chars, hypens, apostrophes and spaces are allowed in last name field
		var objRegExp  =  /^[a-zA-Z-'\s]+$/;
	  return (objRegExp.test(strValue));
}



/****** checkUserIDLen: check for at least six digits in UserID field. ******/
function chkUserIDLen(strFormField) {
	if (strFormField.length < 6)
		{
			return false;
		}
	}

/****** checkExactFieldLen: check for exact number of chars in form field ******/
function chkExactFieldLen(strFormField, strLen) {
	if ((strFormField.length < strLen) || (strFormField.length > strLen))
		{
			//alert("Not right number")
			return false;
		}
	}
	
/****** checkMinLen: check for exact number of chars in form field ******/
function chkMinFieldLen(strFormField, strLen) {
	if (strFormField.length < strLen)
		{
			//alert("Not right number")
			return false;
		}
	}
	
	
/********* Post Login Form OLD************/
function postLoginFormSAVEOLD(login_url) {	
  var strURL = new String("");
  strURL = document.URL;
  strURL = strURL.replace("?","!");
  strURL = strURL.replace("&","|");
  
  document.forms[0].__VIEWSTATE.value = "";
  document.forms[0].__VIEWSTATE.name = "NOVIEWSTATE";
  document.forms[0].action = login_url + strURL;
  document.forms[0].submit();
}

/********* Post Login Form: Corrected to globally replace all ? and & chars ****/
function postLoginForm(login_url) {	
  var strURL = new String("");
  strURL = document.URL;
  strURL = strURL.replace(/\?/g,"!");
  strURL = strURL.replace(/&/g,"|");
  
  document.forms[0].__VIEWSTATE.value = "";
  document.forms[0].__VIEWSTATE.name = "NOVIEWSTATE";
  document.forms[0].action = login_url + strURL;
  document.forms[0].submit();
}

//var myNewString = myOldString.replace(/username/g, visitorName);

/*********** Cookie Logic for Log-in **************/

/************** Set MGMA ID cookie ****************/
function setRememberMe(objID) {
	var DaysToLive = 3650; // number of days the cookie will persist.
	var now = new Date();
	var strID = objID;
	then = now.getTime() + (DaysToLive * 24 * 60 * 60 * 1000);
	now.setTime(then);
	var strCookie = "";
	strCookie = "RememberMe=" + strID + "; domain=.mgma.com; expires=" + now.toGMTString() + "; Path=/";
	document.cookie = strCookie;	
}

/************** Set Keepalive cookie ****************/
function setKeepAlive() {
	var strCookie = "";
	strCookie = "KeepAlive=1; " + "domain=.mgma.com;" + " Path=/";
	document.cookie = strCookie;	
}

/*********** Check existence of RememberMe cookie ***********/
function checkRememberMe() {
	if ( document.getElementById("id") != null) {
		var strCookie = getCookie('RememberMe');
		if ( strCookie != "" )
			{		
				prefill_ID(strCookie);
			}		
		}
}

/************* Prefill the MGMA ID field with RememberMe cookie value ************/
function prefill_ID(objID) {
	var strID = objID;
	document.getElementById("id").value = strID;
	// HFS:11/14/07 Leave checkbox empty
	//document.getElementById("remember").checked = true;
}

/********* Get Cookie ***********/
function getCookie(p_Name) { 
 var search = p_Name + "=";
 var returnvalue = "";
 if (document.cookie.length > 0) {
  var offset = document.cookie.indexOf(search);
  
  if (offset != -1) { 
   offset += search.length;
   var end = document.cookie.indexOf(";", offset);
   if (end == -1) end = document.cookie.length;
   returnvalue = unescape( document.cookie.substring( offset, end ) );
  }
 }
 return returnvalue;
} 

/*********** Validate Customer Reset Password form **************/
function checkResetPassword(cus_id, cus_email, objCusId, objCusEmail) {
	var blnUserIDFail = false;
	var blnEmailFail = false;
	var objSelField = objCusId;	
	var errMsg = "";
	
	if ( checkLoginUserID(cus_id) == false ) {
		blnUserIDFail = true;
		//objCusId.value = "";
		errMsg += "MGMA ID must be six characters, including leading zeros.";
	}
	
	if ( isValidEmailRegExp(cus_email) == false ) {
		blnEmailFail = true;
		//objCusEmail.value = "";
		errMsg += " E-mail address format is not valid.";
		if (!blnUserIDFail) {
			objSelField = objCusEmail;
		}		
	}
	
	if ( blnUserIDFail || blnEmailFail ) { 
		alert(errMsg);
		//objSelField.value = "";	
		objSelField.select();
		objSelField.focus();
		return false;
		}
} //end function


///**** simple email format validation *****/

//function isValidEmail(str) {
//   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
//}

/******** copy of the microsoft regular expression for internet email addresses ***/
//Validates emailAddress on Forgot MGMA ID form
function isValidEmailRegExp(strValue) {
		var objRegExp  =  /\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
	  return (objRegExp.test(strValue));
}

// \w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*


/*** Post the Change Password to Login form ***/

function postChangePwdLogin(newPwd, cusId, login_url, dest_url, inv_id) {	 
	//change name of lastname form value to password b4 posting to www5 
	document.forms[0].lastname.value = newPwd;
	document.forms[0].lastname.name = "password";	
	document.forms[0].id.value = cusId;	
  var strDestURL = new String("");
  strDestURL = dest_url.replace("?","!");
  strDestURL = strDestURL.replace("&","|");  
  document.forms[0].__VIEWSTATE.value = "";
  document.forms[0].__VIEWSTATE.name = "NOVIEWSTATE";
	document.forms[0].action = login_url + strDestURL + "&InvitationId=" + inv_id;
  document.forms[0].submit();
}

/*********** Validate Customer get MGMA ID **************/
	function checkGetId(cus_email, objCusEmail) {
		var blnEmailFail = false;
		var errMsg = "";
		var objSelField = objCusEmail;
		
		if ( isValidEmailRegExp(cus_email) == false ) {
			errMsg += "Invalid e-mail address format.";
			alert(errMsg);
			objSelField.select();
			objSelField.focus();
			return false;	
		}	
	} 

