    /*--------------------------------------------------------------*/
    /* (c) 2010-2011 Netequal Technology Solutions  	           	*/
    /*                                          	               	*/
    /*  vaAdminLib.js                              	           		*/
    /*--------------------------------------------------------------*/
	
	var strHelpTip = new Array();
	
	//- Login
    strHelpTip['loginUserId']   				= 'Enter your registered e-mail address here.';
    strHelpTip['loginPassword']   				= 'Enter your password here.';
	
	//- Merchants
    strHelpTip['acc_lastupdate'] 				= 'This is the last date this record was updated.&nbsp;&nbsp;This field is read-only.';
    strHelpTip['acc_business_name']  			= 'Enter the merchant\'s name. With a maximum of 64 alphanumeric characters.  <br />This is a required field';
    strHelpTip['acc_addr1']  					= 'Enter the merchant\'s address. With a maximum of 48 alphanumeric characters.  <br />This is an optional field';
    strHelpTip['acc_city']  					= 'Enter the merchant\'s city. With a maximum of 32 alphanumeric characters.  <br />This is an optional field';
    strHelpTip['acc_state']  					= 'Select the merchant\'s state.&nbsp;&nbsp;This is a required field';
    strHelpTip['acc_zip']  						= 'Enter the merchant\'s zip code with a maximum of 10 numeric characters.  <br />This is an optional field';
    strHelpTip['acc_phone']  					= 'Enter the merchant\'s phone number including area code (digits only).&nbsp;&nbsp;This is a required field';
    strHelpTip['acc_fax']  						= 'Enter the merchant\'s fax number including area code (digits only).&nbsp;&nbsp;This is an optional field';
    strHelpTip['acc_website']  					= 'Enter the merchant\'s website address.&nbsp;&nbsp;This is an optional field';
    strHelpTip['acc_url']  						= 'Enter the merchant\'s Village Access web address.&nbsp;&nbsp;This is an optional field.<br /><br />Note that while you type the address name on the line below you will see the actual web address.';
    strHelpTip['acc_bus_type']  				= 'Select the merchant\'s business type or enter a new one.&nbsp;&nbsp;This is a required field';
    strHelpTip['acc_status']  					= 'Select the merchant\'s account status.&nbsp;&nbsp;This is a required field.&nbsp;&nbsp;You may want to send a status reminder if merchant is in a pending status.';
    strHelpTip['acc_next_contact']  			= 'Enter the next date you want to contact this merchant.&nbsp;&nbsp;This is an optional field';
    strHelpTip['dsc_description']  				= 'Enter the merchant\'s discount description.&nbsp;&nbsp;This is a required field';
	
    strHelpTip['acc_logo']  					= 'Enter the merchant\'s logo or image identifier.&nbsp;&nbsp;This is an optional field';
	strHelpTip['acc_desc']  					= 'Enter business description.&nbsp;&nbsp;This is an optional field, but it is recommended to enter a short description.';
	
    strHelpTip['acc_owner_fname']  				= 'Enter the business owner\'s first name.&nbsp;&nbsp;This is an optional field';
    strHelpTip['acc_owner_lname']  				= 'Enter the business owner\'s last name.&nbsp;&nbsp;This is an optional field';
    strHelpTip['acc_owner_phone']  				= 'Enter the business owner\'s phone number including area code (digits only).&nbsp;&nbsp;This is an optional field';
    strHelpTip['acc_owner_cell']  				= 'Enter the business owner\'s cell phone number including area code (digits only).&nbsp;&nbsp;This is an optional field';
    strHelpTip['acc_owner_email']  				= 'Enter the business owner\'s valid e-mail address.&nbsp;&nbsp;This is an optional field';
    strHelpTip['acc_owner_title']  				= 'Enter the business owner\'s title.&nbsp;&nbsp;This is an optional field';
	
    strHelpTip['acc_contact_fname'] 			= 'Enter the business contact\'s first name.&nbsp;&nbsp;This is an optional field';
    strHelpTip['acc_contact_lname'] 			= 'Enter the business contact\'s last name.&nbsp;&nbsp;This is an optional field';
    strHelpTip['acc_contact_phone']  			= 'Enter the business contact\'s phone number including area code (digits only).&nbsp;&nbsp;This is an optional field';
    strHelpTip['acc_contact_cell']  			= 'Enter the business contact\'s cell phone number including area code (digits only).&nbsp;&nbsp;This is an optional field';
    strHelpTip['acc_contact_email'] 			= 'Enter the business contact\'s valid e-mail address.&nbsp;&nbsp;This is an optional field';
    strHelpTip['acc_contact_title']  			= 'Enter the business contact\'s title.&nbsp;&nbsp;This is an optional field';
	
	strHelpTip['acc_discounts']  				= 'Add new business discounts by clicking on the (+) sign or remove items by clicking the (-) sign.&nbsp;&nbsp;This is an optional field';
	
	
	//- Agents
    strHelpTip['prf_lastupdate'] 				= 'This is the last date this record was updated.&nbsp;&nbsp;This field is read-only.';
    strHelpTip['prf_firstname']  				= 'Enter the agent\'s first name.&nbsp;&nbsp;This is a required field';
    strHelpTip['prf_lastname']  				= 'Enter the agent\'s last name.&nbsp;&nbsp;This is a required field';
    strHelpTip['prf_email']  					= 'Enter the agent\'s e-mail address.&nbsp;&nbsp;This is a required field.<br /><br />When adding a new agent, the system will send an e-mail notification to this agent with instructions how to log into to the system.';
    strHelpTip['prf_phone']  					= 'Enter the agent\'s phone number.&nbsp;&nbsp;This is a required field';
    strHelpTip['prf_cellphone']  				= 'Enter the agent\'s cell phone number.&nbsp;&nbsp;This is an optional field';
    strHelpTip['prf_ssn']  						= 'Enter the agent\'s SSN or Tax ID.&nbsp;&nbsp;This is a required field.&nbsp;&nbsp;Your earnings must be reported to the IRS.';
	strHelpTip['prf_bank']  					= 'Select your bank.&nbsp;&nbsp;Commissions are paid with direct deposit to this bank.&nbsp;&nbsp;Deposits to Wells Fargo Bank are free, all other institutions require a transfer fee.';
	strHelpTip['prf_routing']  					= 'Enter the bank\'s routing number.&nbsp;&nbsp;This is a required field to ensure your commissions are paid.';
	strHelpTip['prf_account']  					= 'Enter the bank\'s account number.&nbsp;&nbsp;This is a required field to ensure your commissions are paid.';
    strHelpTip['prf_percentage'] 				= 'This represents the agent\'s current percentage commission.&nbsp;&nbsp;This field is read-only.';
    strHelpTip['prf_pwd_1']  					= 'Change your password.&nbsp;&nbsp;This is a required field when you want to change it.';
    strHelpTip['prf_pwd_2']  					= 'Re-enter your password.&nbsp;&nbsp;This is a required field when you want to change it.';
	strHelpTip['prf_status']  					= 'This shows the agent\'s current status.&nbsp;&nbsp;This field is read-only.';
	
	var succeAdminImg		= '/img/success.gif';
	var errorAdminImg		= '/img/error.png';
	var libAdminLocation	= '';
	var jsLibLocation		= 'jslib/';
	
	/*----------------------------------------------------------------------*/
	/* includes 															*/
    /*----------------------------------------------------------------------*/
	//IncludeScript(jsLibLocation + 'download.jQuery.js');
	
    /*----------------------------------------------------------------------*/
    /*  Ajax  																*/
    /*----------------------------------------------------------------------*/
    function getHTTPObject()
    { 
        var xmlhttp = null;
        
        try
        {
            //-------------------------------------//
            //-- Firefox, Opera 8.0+, Safari     --//
            //-------------------------------------//
            xmlhttp = new XMLHttpRequest();
        }
        catch (e)
        {
            //-------------------------------------//
            //-- Internet Explorer               --//
            //-------------------------------------//
            try
            {
                xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
            }
            catch (e)
            {
                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            }
        }
        
        
        if(xmlhttp == null) {
            window.alert("ActiveX objects are not activated on this computer.  This site will not work properly.  Please activate ActiveX on your browser");
        }
        
        return xmlhttp; 
    }
	
	var gl_ContractorsTable 	= Array();
	var gl_MerchantsTable 		= Array();
	var gl_AgentsTable 			= Array();
	
	
	var gl_ProfessionalsTable 	= Array();
	var gl_ProvidersTable 		= Array();
	var gl_ActivePrograms		= Array();
	var gl_MHRUs				= Array();
	var gl_SARUs				= Array();
	var gl_CDCForms				= Array();
	var gl_LogTable				= Array();
	var gl_PrgUpdateReqTable	= Array();
	var gl_CtrUpdateReqTable	= Array();
	var gl_CurrentRecord		= '1';
	
	var gl_selectingNewRU		= false;
	var gl_getMHAddress			= false;
	var gl_getMHContractor		= false;
	var gl_OpenSearchDiv		= '';
	
    var http        = getHTTPObject(); // We create the HTTP Object
    var httpCont    = getHTTPObject(); // We create the HTTP Object for general form
    var httpUtl    	= getHTTPObject(); // We create the HTTP Object for utility functionality
	var httpSrch   	= getHTTPObject(); // We create the HTTP Object for searching functionality
	var httpMail   	= getHTTPObject(); // We create the HTTP Object for e-mailing professionals
	var httpConfirm	= getHTTPObject(); // We create the HTTP Object for e-mailing confirmations
    var httpSearch 	= getHTTPObject(); // We create the HTTP Object for searching functionality
	
    var url_admin	= "/lib/vaSender.php";
	
	
    function showHelpTips(objId, msgCustom, msgWidth)
    {
		if(!msgCustom) {
			var msgCustom = null;
		} else {
			msgCustom.replace('"', '\"');
		}
		//alert(msgCustom);
		if(!msgWidth) {
			msgWidth = -1;
		}
		
        //var sUserLang = document.getElementById('_sLanguage').value;
        
		var msgLogo = '';
		msgLogo += '<div style="float: left; margin-right: 10px; width: 30%; text-align: left; margin-bottom: 20px;">';
		msgLogo += '	<img alt="" src="/img/vaNewLogo.png" width="95%" />';
		msgLogo += '</div>';
		
        //Tip('<div style="float: left; margin-right: 10px;">' + ' <img  src="/img/vaNewLogo.png"    /></div><br /><br /><b><u>On-Line Help</u></b><br /><br />      ' + (msgCustom != null ? msgCustom : strHelpTip[objId]) + "", WIDTH, msgWidth, OPACITY, 95, CENTERMOUSE, true, OFFSETX, 0, SHADOW, true, SHADOWCOLOR, '#dd99aa', SHADOWWIDTH, 100, BALLOON, true, ABOVE, true);
        Tip(msgLogo + '<br /><br />' + (msgCustom != null ? msgCustom : strHelpTip[objId]) + "", WIDTH, 450, OPACITY, 95, CENTERMOUSE, true, OFFSETX, 0, SHADOW, true, SHADOWCOLOR, '#dd99aa', SHADOWWIDTH, 100, BALLOON, true, ABOVE, true);
        return;
    }
	
	
	
	
	
    function showAdminMenuDesc(section, forceMenu)
    {
        var sLangDesc = document.getElementById('_sLanguage').value;
        
		if(!forceMenu) {
			var forceMenu = '0';
			searchString = '';
		}
		
		if(isMenuAlreadyActive(section) && forceMenu == '0') {
			if(document.getElementById('contactName')) {
				document.getElementById('contactName').focus();
			}
			
			return;
		}
		
		if(section == '10') {
			activateActiveArea('11');
		} else {
			activateActiveArea(section);
        }
		
        switch(section)
        {
			case '10':
            case '11':
            case '12':
			case '13':
			case '14':
			case '15':
			case '16':
			case '17':
			case '24':
			case '57':
			case '120':		//- Log Table
			case '200':
			case '420':		//- Contractor Update Requests
			case '430':		//- Program Update Requests
				displayAdminForm(section, sLangDesc);
				break;
			case '756':
				document.location.href = document.getElementById('_logout_url_').value;
				break;
            default:
                break;
        }
        
		if(section == '10') {
			activateMenuItem('11');
		} else {
			activateMenuItem(section);
		}
		
        return;
    }
	
	
    function displayAdminForm(section, lang)
    {
        var sUserLang 		= document.getElementById('_sLanguage').value;
		var boccRemember	= (document.getElementById('boccRemember') ? document.getElementById('boccRemember').value : '0');
        var boccUserId 		= (document.getElementById('boccUserId') ? document.getElementById('boccUserId').value : '');
        var boccPassword 	= (document.getElementById('boccPassword') ? document.getElementById('boccPassword').value : '');
		
        if(!lang) {
            var lang = sUserLang;
        }
        
        var recordNumber = (document.getElementById('tableRecord') ? document.getElementById('tableRecord').value : '1');
		gl_CurrentRecord = recordNumber;
		
		if(section == '11') {
			if(gl_MerchantsTable[0]) {
				document.getElementById('updateSection').innerHTML = '<div style="width: 100%; height: 115px; text-align: center; margin-top: 115px;"><img src="/img/waiting.gif" /><span style="float: left; width: 100%; margin-top: 5px;">Loading...</span></div>';
				gl_MerchantsTable[3] = recordNumber;
				populateMerchantsTable();
				return;
			}
		}
		
		
		
		
		
		/*
		if(section == '12') {
			if(gl_ProfessionalsTable[0]) {
				document.getElementById('updateSection').innerHTML = '<div style="width: 100%; height: 115px; text-align: center; margin-top: 115px;"><img src="img/waiting.gif" /><span style="float: left; width: 100%; margin-top: 5px;">Loading...</span></div>';
				gl_ProfessionalsTable[3] = recordNumber;
				populateProfessionalsTable();
				return;
			}
		}
		
		if(section == '13') {
			if(gl_ProvidersTable[0]) {
				document.getElementById('updateSection').innerHTML = '<div style="width: 100%; height: 115px; text-align: center; margin-top: 115px;"><img src="img/waiting.gif" /><span style="float: left; width: 100%; margin-top: 5px;">Loading...</span></div>';
				gl_ProvidersTable[3] = recordNumber;
				populateProvidersTable();
				return;
			}
		}
		
		if(section == '16') {
			if(gl_MHRUs[0]) {
				document.getElementById('updateSection').innerHTML = '<div style="width: 100%; height: 115px; text-align: center; margin-top: 115px;"><img src="img/waiting.gif" /><span style="float: left; width: 100%; margin-top: 5px;">Loading...</span></div>';
				gl_MHRUs[3] = recordNumber;
				populateMHRUsTable();
				return;
			}
		}
		
		if(section == '17') {
			if(gl_SARUs[0]) {
				document.getElementById('updateSection').innerHTML = '<div style="width: 100%; height: 115px; text-align: center; margin-top: 115px;"><img src="img/waiting.gif" /><span style="float: left; width: 100%; margin-top: 5px;">Loading...</span></div>';
				gl_SARUs[3] = recordNumber;
				populateSARUsTable();
				return;
			}
		}
		
		if(section == '24') {
			if(gl_ActivePrograms[0]) {
				document.getElementById('updateSection').innerHTML = '<div style="width: 100%; height: 115px; text-align: center; margin-top: 115px;"><img src="img/waiting.gif" /><span style="float: left; width: 100%; margin-top: 5px;">Loading...</span></div>';
				gl_ActivePrograms[3] = recordNumber;
				populateActiveProgramsTable();
				return;
			}
		}
		*/
		
		
        var params = "method="   + section  + "&record=" + recordNumber + (lang != '' ? ("&lang=" + lang) : '') + "&id=" + boccUserId + "&pwd=" + boccPassword + "&remember=" + boccRemember;
        
        if( section == '10' || section == '11' || section == '12' || section == '13' || section == '14' || section == '15' || section == '16' || section == '17' || 
			section == '24' || section == '57' || section == '120' || section == '200' || section == '420' || section == '430')
		{
			document.getElementById('updateSection').innerHTML = '<div style="width: 100%; height: 115px; text-align: center; margin-top: 115px;"><img src="/img/waiting.gif" /><span style="float: left; width: 100%; margin-top: 5px;">Loading...</span></div>';
			
			httpCont.open("POST", url_admin, true);
            httpCont.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            httpCont.setRequestHeader("Content-length", params.length);
            httpCont.setRequestHeader("Connection", "close");
            
            switch(section)
            {
				case '10':
				case '11':
					var xReq 	= getHTTPObject();
					
					xReq.open("POST", url_admin, true);
					xReq.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
					xReq.setRequestHeader("Content-length", params.length);
					xReq.setRequestHeader("Connection", "close");
					
					xReq.onreadystatechange = function()
					{
						if (xReq.readyState == 4)
						{
							if(xReq.status == 200)
							{
								results = xReq.responseText.split("~");
								
								gl_MerchantsTable = Array();
								gl_MerchantsTable[0] = results[0];
								gl_MerchantsTable[1] = results[1];
								gl_MerchantsTable[2] = results[2].split("|");
								gl_MerchantsTable[3] = (gl_CurrentRecord == '1' ? results[3] : gl_CurrentRecord);
								
								populateMerchantsTable();
								artButtonsSetupJsHover("art-button");
								
							}
						}
					}
					xReq.send(params);
					break;
				case '12':
					httpCont.onreadystatechange = handleHttpResponse_cbhsProfessionalsTable;	//- in cbhsProfessionals.js
					httpCont.send(params);
					break;
				case '13':
					httpCont.onreadystatechange = handleHttpResponse_cbhsProvidersTable;		//- in cbhsProviders.js
					httpCont.send(params);
					break;
				case '14':
					break;
				case '15':
					httpCont.onreadystatechange = handleHttpResponse_cbhsCPProgramsTable;		//- in cbhsCPPrograms.js
					httpCont.send(params);
					break;
				case '16':
					httpCont.onreadystatechange = handleHttpResponse_cbhsMHRUsTable;			//- in cbhsMHRUs.js
					httpCont.send(params);
					break;
				case '17':
					httpCont.onreadystatechange = handleHttpResponse_cbhsSARUsTable;			//- in cbhsSARUs.js
					httpCont.send(params);
					break;
				case '24':
					httpCont.onreadystatechange = handleHttpResponse_cbhsAllActivePrograms;		//- in cbhsCPPrograms.js
					httpCont.send(params);
					break;
				case '57':
					httpCont.onreadystatechange = handleHttpResponse_cbhsCDCTable;				//- in cbhsCDCForms.js
					httpCont.send(params);
					break;
				case '120':
					httpCont.onreadystatechange = handleHttpResponse_cbhsLogTable;				//- in cbhsLog.js
					httpCont.send(params);
					break;
				case '200':
					//httpCont.onreadystatechange = handleHttpResponse_cbhsLoginAdminForm;
					//httpCont.send(params);
					
					var xReq 	= getHTTPObject();
					
					xReq.open("POST", url_admin, true);
					xReq.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
					xReq.setRequestHeader("Content-length", params.length);
					xReq.setRequestHeader("Connection", "close");
					
					xReq.onreadystatechange = function()
					{
						if (xReq.readyState == 4)
						{
							if(xReq.status == 200)
							{
								results = xReq.responseText;
								document.getElementById('updateSectionTitle').innerHTML = 'Account Login';
								document.getElementById('updateSection').innerHTML = results;
								
								if(document.getElementById('_LoginMsg')) {
									document.getElementById("contMsg").innerHTML = document.getElementById('_LoginMsg').value;
									document.getElementById("contMsg").style.display = 'block';
								}
								
								if(document.getElementById('appUserId')) {
									document.getElementById('loginUserId').value = document.getElementById('appUserId').value;
								}
								
								if(document.getElementById('appPassword')) {
									document.getElementById('loginPassword').value = document.getElementById('appPassword').value;
								}
								
								if(document.getElementById('appRemember') && document.getElementById('appRemember').value != 0) {
									document.getElementById('rememberLogin').checked = true;
								}
								
								artButtonsSetupJsHover("art-button");
								document.getElementById('loginUserId').focus();
							}
						}
					}
					xReq.send(params);
					break;
				case '420':
					httpCont.onreadystatechange = handleHttpResponse_cbhsCtrUpdateReqTable;		//- in cbhsCtrUpdateReq.js
					httpCont.send(params);
					break;
				case '430':
					httpCont.onreadystatechange = handleHttpResponse_cbhsPrgUpdateReqTable;		//- in cbhsPrgUpdateReq.js
					httpCont.send(params);
					break;
            }
            
            //httpCont.send(params);
        }
        
        return;
    }
	
	
	function handleHttpResponse_cbhsTestEmail()
	{
        if (httpCont.readyState == 4)
        {
            if(httpCont.status == 200)
            {
				alert('Test e-mail sent.  RC=' + httpCont.responseText);
				
				displayAdminForm('11');
            }
        }
		return;
	}
	
	
    function handleHttpResponse_cbhsLoginAdminForm()
    {
        var sUserLang = document.getElementById('_sLanguage').value;
        var results  = new Array();        
        
        if (httpCont.readyState == 4)
        {
            if(httpCont.status == 200)
            {
            }
        }
        return;
    }
	
	
	function submitLogin()
	{
        var sUserLang = document.getElementById('_sLanguage').value;
        var oMsgField = document.getElementById("contMsg");
		var pwdReqd = document.getElementById("pwdRequested").value;
		
        if(document.getElementById("loginUserId").value == '')
		{
			oMsgField.innerHTML = 'Please enter your user id';
			document.getElementById("loginUserId_fldMsg").innerHTML = 'Please enter your user id';
            document.getElementById("loginUserId").className = 'entryFieldWarning';
            oMsgField.style.display = 'block';
			document.getElementById("loginUserId").focus();
            return false;
		}
		
		if(!checkEmail('loginUserId'))
		{
			oMsgField.innerHTML = 'Please enter a valid e-mail address';
			document.getElementById("loginUserId_fldMsg").innerHTML = 'Please enter a valid e-mail address';
            document.getElementById("loginUserId").className = 'entryFieldWarning';
            document.getElementById("loginUserId").focus();
            oMsgField.style.display = 'block';
            return false;
		}
		
		if(pwdReqd == '0')
		{
			if(document.getElementById("loginPassword").value == '')
			{
				oMsgField.innerHTML = 'Please enter your password';
				document.getElementById("loginPassword_fldMsg").innerHTML = 'Please enter your password';
				document.getElementById("loginPassword").className = 'entryFieldWarning';
				document.getElementById("loginPassword").focus();
				oMsgField.style.display = 'block';
				return false;
			}
		}
		
		document.getElementById("requestLink").style.display = 'none';
		document.getElementById("buttonsDiv").style.display = 'none';
		
		if(pwdReqd == '0') {
			oMsgField.innerHTML = '<img alt="" src="/img/waiting.gif" />&nbsp;&nbsp;Loggin on. Please wait...';
		} else {
			oMsgField.innerHTML = '<img alt="" src="/img/waiting.gif" />&nbsp;&nbsp;Sending current password. Please wait...';
		}
		
		oMsgField.style.display = 'block';
		
		//- Submit form
		document.FormLoginAcct.submit();
		return true;
	}
	
	
	function requestPassword(reqFlag)
	{
        var sUserLang = document.getElementById('_sLanguage').value;
        var oMsgField = document.getElementById("contMsg");
		var logFlds = document.getElementById("logonFields");
		var reqLink = document.getElementById("requestLink");
		var reqCanc = document.getElementById("loginCancel");
		var pwdReqd = document.getElementById("pwdRequested");
		
		logFlds.style.display = (reqFlag == '1' ? 'none'  : 'block');
		reqLink.style.display = (reqFlag == '1' ? 'none'  : 'block');
		reqCanc.style.display = (reqFlag == '1' ? 'inline-block' : 'none');
		
		if(reqFlag == '1') {
			document.getElementById("loginUserId_fldMsg").innerHTML = 'Enter the e-mail address registered with your account.';
			oMsgField.innerHTML = 'Enter the e-mail address registered with your account.';
			oMsgField.style.display = 'block';
			pwdReqd.value = '1';
		} else {
			document.getElementById("loginUserId_fldMsg").innerHTML = '';
			oMsgField.style.display = 'none';
			pwdReqd.value = '0';
		}
		
		document.getElementById("loginUserId").focus();
		
		return true;
	}
	
	
    function vaCheckLength(textField, max)
    {
        if(textField.value.length > max)
        {
            textField.value = textField.value.substring(0, max);
        }
        
        return true;
    }
	
	
    function checkEmail(objField)
    {
        var email = document.getElementById(objField);
        var filter = /^([a-zA-Z0-9_\.\-\'])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
        
        if (!filter.test(email.value)) {
            return false;
        }
        
        return true;
    }
	
	
	function IncludeScript(script_filename)
	{
		var html_doc = document.getElementsByTagName('head').item(0);
		var js = document.createElement('script');
		
		js.setAttribute('language', 'javascript');
		js.setAttribute('type', 'text/javascript');
		js.setAttribute('src', script_filename);
		html_doc.appendChild(js);
		
		return false;
	}	
	
	
	function IncludeStylesheet(script_filename)
	{
		var html_doc = document.getElementsByTagName('head').item(0);
		var js = document.createElement('link');
		
		js.setAttribute('rel', 'stylesheet');
		js.setAttribute('type', 'text/css');
		js.setAttribute('media', 'all');
		js.setAttribute('href', script_filename);
		html_doc.appendChild(js);
		
		return false;
	}	
	
	
	function formatThisInt(inputObj)
	{
		var num = inputObj.value.replace(/\,/g,'');
		
		if(!isNaN(num)){
			if(num.indexOf('.') > -1) {
				inputObj.value = inputObj.value.substring(0,inputObj.value.length-1);
			}
		} else {
			inputObj.value = inputObj.value.substring(0,inputObj.value.length-1);
		}
		
		return;
	}
	
	
	function getDigitsOnly(value)
	{
		var retString = '';
		
		for(i=0; i < value.length; i++)
		{
			if(!isNaN(value.substr(i, 1)) && value.substr(i, 1) != ' ') {
				retString += value.substr(i, 1);
			}
		}
		
		return retString;
	}
	
	
	function validateZipCode(zip)
	{
		var zipCodePattern = /^\d{5}$|^\d{5}-\d{4}$/;
			return zipCodePattern.test(zip);
	}
	
	
	function IsNumeric(sText)
	{
	   var ValidChars = "0123456789";
	   var IsNumber=true;
	   var Char;
	   
	   for (i = 0; i < sText.length && IsNumber == true; i++) 
	   {
		  Char = sText.charAt(i); 
		  if (ValidChars.indexOf(Char) == -1) {
			  IsNumber = false;
		  }
	   }
	   return IsNumber;
	}
	
	
	function setFieldValueFromList(thisListObj, thisField)
	{
		document.getElementById(thisField).value = thisListObj.options[thisListObj.selectedIndex].text;
		return
	}
	
	
	function compareOptionText(a,b)
	{
		// textual comparison
		return a.text!=b.text ? a.text<b.text ? -1 : 1 : 0;
		// numerical comparison
		// return a.text - b.text;
	}
	
	
	function sortThisList(list)
	{
		var items = list.options.length;
		// create array and make copies of options in list
		var tmpArray = new Array(items);
		
		for ( i = 0; i < items; i++ )
			tmpArray[i] = new Option(list.options[i].text,list.options[i].value);
		
		// sort options using given function
		tmpArray.sort(compareOptionText);
			
		// make copies of sorted options back to list
		for ( i = 0; i < items; i++ )
			list.options[i] = new Option(tmpArray[i].text,tmpArray[i].value);
	}
	
	
	function activateMenuItem(menuItem) {
		nav = document.getElementById('topNavMenu');
		if(nav == null) return;
		navChildren = nav.getElementsByTagName("a");
		for (var i = 0; i < navChildren.length; ++i) {
			var oNode = navChildren.item(i);
			oNode.className = "";
		}
		
		for (var i = 0; i < navChildren.length; ++i) {
			var oNodeChild = navChildren.item(i);
			
			var thisMenuItem = 'menu_' + menuItem;
			var bottomMenu   = 'b_menu_' + menuItem;
			
			if(oNodeChild.getAttribute('id') == thisMenuItem) {
				var parentMenu = document.getElementById(oNodeChild.getAttribute('parentMenu'));
				
				if(parentMenu) {
					parentMenu.className = "active";
				}
			}
		}
		
		return;
	}
	
	
	function  isMenuAlreadyActive(menuItem)
	{
		var retResutls = false;
		
		var nav = document.getElementById('topNavMenu');
		
		if(nav == null) {
			return;
		}
		
		navChildren = nav.getElementsByTagName("a");
		
		for (var i = 0; i < navChildren.length; ++i)
		{
			var thisMenuItem = 'menu_' + menuItem;
			var bottomMenu   = 'b_menu_' + menuItem;
			var oNodeChild = navChildren.item(i);
			
			if(oNodeChild.className == "active" && oNodeChild.getAttribute('id') == thisMenuItem) {
				retResutls = true;
			}
		}
		
		return retResutls;
	}
	
	
    function activateActiveArea(menuItem) {
        nav = document.getElementById('menu');
        
        if(nav == null) return;
        navChildren = nav.getElementsByTagName("LI");
        
        for (var i = 0; i < navChildren.length; ++i) {
            navAChild = navChildren.item(i).getElementsByTagName("A");
            
            if(navAChild.length > 0) {
                navChildren.item(i).className = ((i + 1) == menuItem ? 'active' : '');
            }
        }
    }
	
	
    function clearBgColor(oField)
    {
        oField.className = 'entryFieldNormal';
        
        if(document.getElementById(oField.id + '_fldMsg')) {
			document.getElementById(oField.id + '_fldMsg').innerHTML = '';
		}
		
        if(document.getElementById("_updateMsg")) {
            document.getElementById("_updateMsg").style.display = 'none';
        }
        
        if(document.getElementById("contMsg")) {
            document.getElementById("contMsg").style.display = 'none';
        }
		
        return;
    }
	
	
	function printForm(form, params)
	{
        var sUserLang = document.getElementById('_sLanguage').value;
		var printOptions = 'location=0, menubar=0, status=1, toolbar=0, scrollbars=1, resizable=1';
		var viewOnly = '0';
		var thisWin;
		
		//-NOTE: IE Cries out loud when there is a space on the window title.  Firefox and other compliant browsers don't!!!  MOJONES!!
		thisWin = wOpenPrintForm('lib/' + form + '/?' + params + (params == '' ? '' : '&') + 'viewOnly=' + viewOnly, 'CBHSForm', 975, 550, printOptions);
		
		thisInfo = '<div style="text-align: center;">&nbsp;&nbsp;Adding/Updating record... Please wait...' +
					'<img alt="" src="/img/waiting.gif" />' +
					'</div>';
		return;
	}
	
	
	function executeForm(form, params)
	{
        var sUserLang = document.getElementById('_sLanguage').value;
		var printOptions = 'location=0, menubar=0, status=1, toolbar=0, scrollbars=1, resizable=1';
		var viewOnly = '0';
		var thisWin;
		
		//-NOTE: IE Cries out loud when there is a space on the window title.  Firefox and other compliant browsers don't!!!  MOJONES!!
		thisWin = wOpenPrintForm('lib/' + form + '?' + params + (params == '' ? '' : '&') + 'viewOnly=' + viewOnly, 'CBHSAppForm', 900, 550, printOptions);
		
		return;
	}
	
	
	function setFiscalYear(thisObj)
	{
        var sFiscalYr 	= thisObj.value;
		var method 		= '201';
        var params = "method="   + method + "&sFiscalYr=" + sFiscalYr;
		
		httpUtl.open("POST", url_admin, true);
        httpUtl.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        httpUtl.setRequestHeader("Content-length", params.length);
        httpUtl.setRequestHeader("Connection", "close");
		httpUtl.onreadystatechange = handleHttpResponse_setFiscalYear;
        httpUtl.send(params);
		return;
	}
	
	
    function handleHttpResponse_setFiscalYear()
    {
        var results;
        
        if (httpUtl.readyState == 4)
        {
            if(httpUtl.status == 200)
            {
                results = httpUtl.responseText;
				
				gl_ActivePrograms = Array();
				gl_ContractorsTable = Array();
				
				if(document.getElementById('ContractorsList')) {
					if(!document.getElementById('ContractorNumber')) {
						showAdminMenuDesc('11');
					} else {
						var ContractorNumber = (document.getElementById('ContractorNumber') ? document.getElementById('ContractorNumber').value : '');
						showCurrentContractor(ContractorNumber);
					}
				} else if(document.getElementById('ctr_table_all')) {
					showAdminMenuDesc('11');
				} else if(document.getElementById('prg_table_all')) {
					showAdminMenuDesc('24');
				} else if(document.getElementById('cdc_table_all')) {
					showAdminMenuDesc('57');
				} else if(document.getElementById('ctrReq_table_all')) {
					showAdminMenuDesc('420');
				} else if(document.getElementById('prgReq_table_all')) {
					showAdminMenuDesc('430');
				}
            }
        }
        return;
    }
	
	
    function wOpenPrintReport(url, name, w, h, printOptions)
    {
        // Fudge factors for window decoration space.
        // In my tests these work well on all platforms & browsers.
        w += 32;
        h += 96;
        wleft = (screen.width - w) / 2;
        wtop = (screen.height - h) / 2;
        var win = window.open(url, name, 'width=' + w + ', height=' + h + ', ' + 'left=' + wleft + ', top=' + wtop + ', ' + printOptions);
		
        //win.focus();
		
		return(win);
    }
	
	
    function wOpenPrintForm(url, name, w, h, printOptions)
    {
        // Fudge factors for window decoration space.
        // In my tests these work well on all platforms & browsers.
        w += 32;
        h += 96;
        wleft = (screen.width - w) / 2;
        wtop = (screen.height - h) / 2;
        var win = window.open(url, name, 'width=' + w + ', height=' + h + ', ' + 'left=' + wleft + ', top=' + wtop + ', ' + printOptions);
		
		return(win);
    }
	
	
	function sendCDCForms(formType)
	{
 		var printOptions = 'location=0, menubar=0, status=1, toolbar=0, scrollbars=1, resizable=0';
		var viewOnly = '0';
		var thisWin;
		
		//-NOTE: IE Cries out loud when there is a space on the window title.  Firefox and other compliant browsers don't!!!  MOJONES!!
		thisWin = wOpenPrintReport('lib/cbhsCDC.php?form=' + formType, 'CDCEmail', 700, 300, printOptions);
		thisWin.focus();
		return;
	}
	
	
	function processCDC(ctrForm)
	{
		var method 	= '300';
		var fiscalYear 			= document.getElementById('gl_fiscalYear').value;
		
		if(fiscalYear == 'All') {
			alert("You must select a Fiscal Year");
			return;
		}
		
		if(confirm("Are you sure you want to send all CDC " + (ctrForm == '1' ? 'HIV, HHS & HUH' : 'CBHS') + " forms now?"))
		{
			var cdc_send_copy_to 	= (document.getElementById('cdc_send_copy_to').checked ? '1' : '0');
			var cdc_copy_email 		= document.getElementById('cdc_copy_email').value;
			
			var params 	= "method="   + method + "&ctrForm=" + ctrForm + "&fy=" + fiscalYear + "&cdc_copy_email=" + (cdc_send_copy_to == '1' ? cdc_copy_email : '');
			
			document.getElementById('cdcButtonsDiv').style.display = 'none';
			document.getElementById('cdcFormDetailsDiv').style.display = 'none';
			document.getElementById('cdcProgressDiv').style.display = 'block';
			//return;
			
			
			httpMail.open("POST", "../lib/cbhsSender.php", true);
			httpMail.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			httpMail.setRequestHeader("Content-length", params.length);
			httpMail.setRequestHeader("Connection", "close");
			httpMail.onreadystatechange = handleHttpResponse_processCDC;
			httpMail.send(params);
		}
		return;
	}
	
	
    function handleHttpResponse_processCDC()
    {
        var results;
        
        if (httpMail.readyState == 4)
        {
            if(httpMail.status == 200)
            {
				//alert('Finished...');
				window.close();
            }
        }
        return;
    }
	
	
	var self_sendIndividualCDC = new Object();
	
	function sendIndividualCDC(fiscalYear, ContractorVendorNo, prg_id, ctrForm, thisPrgName, cdcDueDate)
	{
		var method 	= '301';
		
		if(fiscalYear == 'All') {
			alert("You must select a Fiscal Year");
			return;
		}
		
		if(ctrForm == '') {
			alert("Program MUST have a MH, SA, HHS, HPS, HUH section");
			return;
		}
		
		var cdc_copy_email 		= '';
		
		$(function() {
			$("#sendCDC").dialog({
				dialogClass: 'sendCDC-class',
				bgiframe: true,
				resizable: false,
				height:350,
				width:700,
				modal: true,
				closeOnEscape: false,
				close: function(event, ui) { $("#cdcDueDate").datepicker("hide"); $(this).dialog('destroy') },
				overlay: {
					backgroundColor: '#000',
					opacity: 0.5
				},
				buttons: {
					Cancel: function() {
						$(this).dialog('destroy');
					},
					'Send': function() {
						self_sendIndividualCDC = $(this);
						
						var dueDate = document.getElementById('cdcDueDate').value;
						var dToday	= new Date();
						var dDue	= new Date(dueDate);
						
						if(dDue <= dToday) {
							$(".sendCDC-class div[class=dlgErrorMsg-Div]").html('<img alt="" title="" src="img/warning_yellow_2_256.png" width="24 height="24" style="vertical-align: top;" />&nbsp;' + 'Please enter a Due Date in the future. (' + dueDate + ')');
							return;
						}
						
						$(".sendCDC-class div[class=dlgErrorMsg-Div]").html('<img src="img/waiting.gif" />&nbsp;&nbsp;Sending CDC Form, please wait...');
						
						$(".ui-dialog-titlebar-close").hide();
						
						var buttonSend = jqGetDialogButton( '.sendCDC-class', 'Send' ); 
						if (buttonSend) {
							buttonSend.attr('disabled', 'disabled').addClass( 'ui-state-disabled' ); 
						}
						
						var buttonCancel = jqGetDialogButton( '.sendCDC-class', 'Cancel' ); 
						if ( buttonCancel ) {
							buttonCancel.attr('disabled', 'disabled').addClass( 'ui-state-disabled' ); 
						}
						
						var params 	= "method="   + method + "&ctrForm=" + ctrForm + "&fy=" + fiscalYear + "&cdc_copy_email=" + cdc_copy_email + "&ContractorVendorNo=" + ContractorVendorNo + "&prg_id=" + prg_id + "&dueDate=" + dueDate;
						
						var xReq 	= getHTTPObject();
						
						xReq.open("POST", url_admin, true);
						xReq.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
						xReq.setRequestHeader("Content-length", params.length);
						xReq.setRequestHeader("Connection", "close");
						
						xReq.onreadystatechange = function()
						{
							if (xReq.readyState == 4)
							{
								if(xReq.status == 200)
								{
									var results = xReq.responseText;
									
									switch(results)
									{
										case '0':	//- Error
											$(".sendCDC-class div[class=dlgErrorMsg-Div]").html('Error Sending CDC Form');
											$(".ui-dialog-titlebar-close").show();
											buttonSend.attr('disabled', false).removeClass( 'ui-state-disabled' );
											buttonCancel.attr('disabled', false).removeClass( 'ui-state-disabled' );
											break;
										case '1':	//- Success
											$(".sendCDC-class div[class=dlgErrorMsg-Div]").html('CDC Successfully sent!');
											$(".ui-dialog-titlebar-close").show();
											if(document.getElementById("CDCsGrid")) {
												showAdminMenuDesc('57');
											}
											self_sendIndividualCDC.dialog('destroy');
											break;
										default:
											$(".sendCDC-class div[class=dlgErrorMsg-Div]").html(results);
											$(".ui-dialog-titlebar-close").show();
											alert(results);
											buttonSend.attr('disabled', false).removeClass( 'ui-state-disabled' );
											buttonCancel.attr('disabled', false).removeClass( 'ui-state-disabled' );
											break;
									}
								}
							}
						}
						xReq.send(params);
					}
				}
			});
			
			$('div.program-Name-Div').html(thisPrgName);
			$(".sendCDC-class div[class=dlgErrorMsg-Div]").html('');
			
			//- Reset calendar date
			$("#cdcDueDate").datepicker("destroy").datepicker({
				numberOfMonths: 	1,
				showButtonPanel: 	false,
				showOn: 			'focus'
			});
			
			$("#ui-datepicker-div").css("z-index", "2000" );
			$("#ui-datepicker").css("z-index", "2000" );
			
			$("#cdcDueDate").datepicker("show");
			$("#cdcDueDate").datepicker("refresh");
			$("#cdcDueDate").datepicker("setDate", "+14d");
		});
		
		return;
	}
	
	
	function submitCDCForm(thisForm, cdc_id, email, cdc_ip_submitted)
	{
		var prg_bhsq = '';
		var prg_hivq = '';
		var method 	= '310';
		
		switch(thisForm)
		{
			case 0:
				//- Declaration of Compliance Questionnaire for MH & SA
				for(index = 0; index < 40; index++)
				{
					if (document.getElementById("bhsQ" + index)) {
						prg_bhsq += (index > 0 ? ";" :"") + "bhsQ" + index + '=' + getCheckedValue(document.forms['radioCDCForm'].elements['bhsQ' + index]);
					}
				}
				break;
			case 1:
				//- Declaration of Compliance Questionnaire for HIV
				for(index = 0; index < 40; index++)
				{
					if (document.getElementById("hivQ" + index)) {
						prg_hivq += (index > 0 ? ";" :"") + "hivQ" + index + '=' + getCheckedValue(document.forms['radioCDCHivForm'].elements['hivQ' + index]);
					}
				}
				break;
			default:
				break;
		}
		
		if(confirm('Are you ready to send this form?'))
		{
			var params 	= "method="   + method + "&cdc_id=" + cdc_id + "&email=" + email + "&prg_bhsq=" + prg_bhsq + "&prg_hivq=" + prg_hivq + "&cdc_ip_submitted=" + cdc_ip_submitted;
			
			httpUtl.open("POST", "/lib/cbhsSender.php", true);
			httpUtl.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			httpUtl.setRequestHeader("Content-length", params.length);
			httpUtl.setRequestHeader("Connection", "close");
			httpUtl.onreadystatechange = handleHttpResponse_submitCDCForm;
			httpUtl.send(params);
		}
		return;
	}
	
	
    function handleHttpResponse_submitCDCForm()
    {
        var results;
        
        if (httpUtl.readyState == 4)
        {
            if(httpUtl.status == 200)
            {
                results = httpUtl.responseText.split("~");
				
				if(results[0] == '1') {
					document.getElementById("cdcSubmitDiv").style.display = "none";
					document.getElementById("cdcButtonsDiv").style.display = "block";
					confirmCDCSubmission();
					alert("Your Declaration of Compliance Form has been successfully submitted.  Thank you.");
				} else {
					alert("An error ocurred while submitting your Declaration of Compliance Form.  Please try again.  " + results[1]);
				}
			}
        }
        return;
    }
	
	
	function confirmCDCSubmission()
	{
		var method 	= '320';
		
		var confirmCDCForm	= document.getElementById('confirmCDCForm').value;
		var confirmCDCId	= document.getElementById('confirmCDCId').value;
		var confirmProgram 	= document.getElementById('confirmProgram').value;
		var confirmWebLink 	= document.getElementById('confirmWebLink').value;
		var confirmFName 	= document.getElementById('confirmFName').value;
		var confirmEmail 	= document.getElementById('confirmEmail').value;
		var viewThisFormLink= document.getElementById('viewThisFormLink').value;
		
		var params 	= "method="   + method + "&confirmCDCForm=" + confirmCDCForm + "&confirmCDCId=" + confirmCDCId + "&confirmProgram=" + confirmProgram + "&confirmWebLink=" + confirmWebLink + "&confirmFName=" + confirmFName + "&confirmEmail=" + confirmEmail + "&viewThisFormLink=" + viewThisFormLink;
		
		httpConfirm.open("POST", "/lib/cbhsSender.php", true);
		httpConfirm.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		httpConfirm.setRequestHeader("Content-length", params.length);
		httpConfirm.setRequestHeader("Connection", "close");
		httpConfirm.onreadystatechange = handleHttpResponse_confirmCDCSubmission;
		httpConfirm.send(params);
		return;
	}
	
	
    function handleHttpResponse_confirmCDCSubmission()
    {
        var results;
        
        if (httpConfirm.readyState == 4)
        {
            if(httpConfirm.status == 200)
            {
			}
        }
        return;
    }
	
	
	function selectNewPwd(menu)
	{
		activateActiveArea(menu);
		
		$(function() {
			$("#pwdChangeDiv_jq").dialog('destroy').dialog({
				dialogClass: 'pwdChangeDiv-class',
				bgiframe: true,
				resizable: false,
				height:350,
				width:700,
				modal: true,
				overlay: {
					backgroundColor: '#000',
					opacity: 0.5
				},
				buttons: {
					Cancel: function() {
						$(this).dialog('destroy');
					},
					'Change': function() {
						
						var method 	= '330';
						var prvPwd 	= $(".pwdChangeDiv-class input[id=prvPwd]").val();
						var newPwd 	= $(".pwdChangeDiv-class input[id=newPwd]").val();
						var cnfPwd 	= $(".pwdChangeDiv-class input[id=cnfPwd]").val();
						
						
						if(prvPwd == '' || newPwd == '' || cnfPwd == '') {
							$(".pwdChangeDiv-class div[class=dlgPwdErrorMsg-Div]").html('Please enter your current password as well as your new and confirmation password.');
							$(".pwdChangeDiv-class input[id=prvPwd]").focus();
							$(".pwdChangeDiv-class input[id=prvPwd]").select();
							return;
						}
						
						if(newPwd != cnfPwd) {
							$(".pwdChangeDiv-class div[class=dlgPwdErrorMsg-Div]").html('Your new and confirmation password do not match.  Please try again.');
							$(".pwdChangeDiv-class input[id=newPwd]").focus();
							$(".pwdChangeDiv-class input[id=newPwd]").select();
							return;
						}
						
						var buttonAuthorize = jqGetDialogButton( '.pwdChangeDiv-class', 'Change' ); 
						if (buttonAuthorize) {
							buttonAuthorize.attr('disabled', 'disabled').addClass( 'ui-state-disabled' ); 
						}
						
						var buttonCancel = jqGetDialogButton( '.pwdChangeDiv-class', 'Cancel' ); 
						if ( buttonCancel ) {
							buttonCancel.attr('disabled', 'disabled').addClass( 'ui-state-disabled' ); 
						}
						
						$(".pwdChangeDiv-class div[class=dlgPwdErrorMsg-Div]").html('<img src="img/rel_loading.gif" />&nbsp;&nbsp;Changing your password.  Please wait...');
						
						$(".ui-dialog-titlebar-close").hide();
						
						var params 	= "method="   + method + "&prvPwd=" + prvPwd + "&newPwd=" + newPwd + "&cnfPwd=" + cnfPwd + "&loginUserId=" + document.getElementById('_LoginUser').value;						
						var xReq 	= getHTTPObject();
						
						xReq.open("POST", url_admin, true);
						xReq.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
						xReq.setRequestHeader("Content-length", params.length);
						xReq.setRequestHeader("Connection", "close");
						
						xReq.onreadystatechange = function()
						{
							if (xReq.readyState == 4)
							{
								if(xReq.status == 200)
								{
									var results = xReq.responseText.split("~");
									
									$(".ui-dialog-titlebar-close").show();
									
									switch(results[0])
									{
										case '1':	//- Password changed
											$(".pwdChangeDiv-class div[class=pwdChangeBodyDiv]").css("display", "none");
											$(".pwdChangeDiv-class div[class=pwdChangeSuccessDiv]").css("display", "block");
											$(".pwdChangeDiv-class div[class=pwdChangeSuccessDiv]").html('Your password has been updated.  An e-mail has been sent to confirm this update.');
											buttonCancel.attr('disabled', false).removeClass( 'ui-state-disabled' );
											buttonCancel.text('Close');
											break;
										default:	//- Error
											$(".pwdChangeDiv-class div[class=dlgPwdErrorMsg-Div]").html(results[1]);
											$(".pwdChangeDiv-class input[id=prvPwd]").focus();
											$(".pwdChangeDiv-class input[id=prvPwd]").select();
											
											buttonAuthorize.attr('disabled', false).removeClass( 'ui-state-disabled' );
											buttonCancel.attr('disabled', false).removeClass( 'ui-state-disabled' );
											break;
									}
								}
							}
						}
						
						xReq.send(params);
					}
				}
			});
			
			$(".pwdChangeDiv-class div[class=pwdChangeSuccessDiv]").html('');
			
			$(".pwdChangeDiv-class div[class=pwdChangeBodyDiv]").css("display", "block");
			$(".pwdChangeDiv-class div[class=pwdChangeSuccessDiv]").css("display", "none");
			
			$('div.pwdChangeUserDiv').html(document.getElementById('_LoginUser').value);
			$('div.pwdChangeSuccessDiv').html('');
			
			$(".pwdChangeDiv-class input[id=prvPwd]").val('');
			$(".pwdChangeDiv-class input[id=newPwd]").val('');
			$(".pwdChangeDiv-class input[id=cnfPwd]").val('');
			$(".pwdChangeDiv-class div[class=dlgPwdErrorMsg-Div]").html('');
			
			$(".pwdChangeDiv-class input[id=prvPwd]").focus();
			$(".pwdChangeDiv-class input[id=prvPwd]").select();
		});
		
		activateMenuItem(menu);
		return;
		
	}
	
	
	function cbhsExportLabels(section, menu)
	{
		activateActiveArea(menu);
		
		$(function() {
			$("#cbhsExportLabels_jq").dialog('destroy').dialog({
				dialogClass: 'cbhsExportLabels-class',
				bgiframe: true,
				resizable: false,
				height:350,
				width:700,
				modal: true,
				overlay: {
					backgroundColor: '#000',
					opacity: 0.5
				},
				buttons: {
					Cancel: function() {
						$(this).dialog('destroy');
					},
					'Download': function() {
						
						var buttonDownload = jqGetDialogButton( '.cbhsExportLabels-class', 'Download' ); 
						if (buttonDownload) {
							buttonDownload.attr('disabled', 'disabled').addClass( 'ui-state-disabled' ); 
						}
						
						var buttonCancel = jqGetDialogButton( '.cbhsExportLabels-class', 'Cancel' ); 
						if ( buttonCancel ) {
							buttonCancel.attr('disabled', 'disabled').addClass( 'ui-state-disabled' ); 
						}
						
						$(".cbhsExportLabels-class div[class=exportingMsgDiv]").css("display", "block");
						$(".ui-dialog-titlebar-close").hide();
						
						if(section != 'contractorsEx' && section != 'contractorsAlt') {
							$.download('lib/cbhsDownloadLabels.php','table=programs&section=' + section);
						} else {
							$.download('lib/cbhsDownloadLabels.php','table=' + section);
						}
						
						$(".ui-dialog-titlebar-close").show();
						buttonDownload.attr('disabled', false).removeClass( 'ui-state-disabled' );
						buttonCancel.attr('disabled', false).removeClass( 'ui-state-disabled' );
					}
				}
			});
			
			if(section != 'contractorsEx' && section != 'contractorsAlt') {
				$(".cbhsExportLabels-class div[class=mailingTitleDiv]").html((section == '' ? "All" : section) + ' Community Programs Mailing Labels To Excel Spreadsheet');
			} else {
				$(".cbhsExportLabels-class div[class=mailingTitleDiv]").html('All ' + (section == 'contractorsEx' ? 'Executive Directors' : 'Alternate Contacts') + ' Mailing Labels To Excel Spreadsheet');
			}
			$(".cbhsExportLabels-class div[class=exportingMsgDiv]").css("display", "none");
		});
		
		activateMenuItem(menu);
		return;
	}
	
	
	function cbhsExportTables(table, menu)
	{
		activateActiveArea(menu);
		
		$(function() {
			$("#cbhsExportTables_jq").dialog('destroy').dialog({
				dialogClass: 'cbhsExportTables-class',
				bgiframe: true,
				resizable: false,
				height:350,
				width:700,
				modal: true,
				overlay: {
					backgroundColor: '#000',
					opacity: 0.5
				},
				buttons: {
					Cancel: function() {
						$(this).dialog('destroy');
					},
					'Download': function() {
						
						var buttonDownload = jqGetDialogButton( '.cbhsExportTables-class', 'Download' ); 
						if (buttonDownload) {
							buttonDownload.attr('disabled', 'disabled').addClass( 'ui-state-disabled' ); 
						}
						
						var buttonCancel = jqGetDialogButton( '.cbhsExportTables-class', 'Cancel' ); 
						if ( buttonCancel ) {
							buttonCancel.attr('disabled', 'disabled').addClass( 'ui-state-disabled' ); 
						}
						
						$(".cbhsExportTables-class div[class=exportingMsgDiv]").css("display", "block");
						$(".ui-dialog-titlebar-close").hide();
						
						$.download('reports/cbhsExportData.php','table=' + table);
						
						$(".ui-dialog-titlebar-close").show();
						//buttonDownload.attr('disabled', false).removeClass( 'ui-state-disabled' );
						buttonCancel.attr('disabled', false).removeClass( 'ui-state-disabled' );
					}
				}
			});
			
			$(".cbhsExportTables-class div[class=exportTitleDiv]").html(table + ' Table To Excel Spreadsheet');
			$(".cbhsExportTables-class div[class=exportingMsgDiv]").css("display", "none");
		});
		
		activateMenuItem(menu);
		return;
	}
	
	
	function cbhsProcessEmail()
	{
		var method			= '600';
		
		var emailSenderAddr	= document.getElementById("emailSenderAddr").value;
		var emailRecipient	= document.getElementById("sendTo").getAttribute('val_ext');
		var emailCC			= document.getElementById("sendCC").value;
		var emailSubject	= document.getElementById("sendSubject").value;
		var emailMsg 		= tinyMCE.get('mailContent').getContent();
		
		var destDirectory	= document.getElementById("_destDirectory").value;
		var allAttachedList	= document.getElementById('attachedFileList').value;
		
		allAttachedList.replace(" ", "");
		
		
		$(function() {
			$("#cbhsSendEmail_jq").dialog('destroy').dialog({
				dialogClass: 'cbhsSendEmail-class',
				bgiframe: true,
				resizable: false,
				height:300,
				width:600,
				modal: true,
				overlay: {
					backgroundColor: '#000',
					opacity: 0.5
				},
				buttons: {
					Cancel: function() {
						$(this).dialog('destroy');
					},
					'Send': function() {
						
						var buttonSend = jqGetDialogButton( '.cbhsSendEmail-class', 'Send' ); 
						if (buttonSend) {
							buttonSend.attr('disabled', 'disabled').addClass( 'ui-state-disabled' ); 
						}
						
						var buttonCancel = jqGetDialogButton( '.cbhsSendEmail-class', 'Cancel' ); 
						if ( buttonCancel ) {
							buttonCancel.attr('disabled', 'disabled').addClass( 'ui-state-disabled' ); 
						}
						
						$(".cbhsSendEmail-class div[class=sendEmailMsgDiv]").css("display", "block");
						$(".cbhsSendEmail-class div[class=sendEmailMsgDiv]").html('<img alt="" src="img/rel_loading.gif" /><br />Sending e-Mail.  Please wait...');
						
						$(".ui-dialog-titlebar-close").hide();
						
						var params 	= "method="   + method + "&emailSenderAddr=" + escape(emailSenderAddr) + "&emailRecipient=" + emailRecipient + "&emailCC=" + escape(emailCC) + "&emailSubject=" + escape(emailSubject) + "&emailMsg=" + escape(emailMsg) + "&allAttachedList=" + allAttachedList + "&destDirectory=" + destDirectory;
						var xReq 	= getHTTPObject();
						
						xReq.open("POST", url_admin, true);
						xReq.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
						xReq.setRequestHeader("Content-length", params.length);
						xReq.setRequestHeader("Connection", "close");
						
						xReq.onreadystatechange = function()
						{
							if (xReq.readyState == 4)
							{
								if(xReq.status == 200)
								{
									var results = xReq.responseText.split("~");
									
									$(".ui-dialog-titlebar-close").show();
									
									switch(results[0])
									{
										case '1':	//- E-mail sent
											$(".cbhsSendEmail-class div[class=sendEmailMsgDiv]").html('E-mail successfully sent.');
											buttonCancel.attr('disabled', false).removeClass( 'ui-state-disabled' );
											buttonCancel.text('Close');
											break;
										default:	//- Error
											$(".cbhsSendEmail-class div[class=sendEmailMsgDiv]").html(results[1]);
											buttonSend.attr('disabled', false).removeClass( 'ui-state-disabled' );
											buttonCancel.attr('disabled', false).removeClass( 'ui-state-disabled' );
											break;
									}
								}
							}
						}
						xReq.send(params);
						
					}
				}
			});
			
			$(".cbhsSendEmail-class div[class=sendEmailTitleDiv]").html('Send e-Mail');
			$(".cbhsSendEmail-class div[class=sendEmailMsgDiv]").html('');
			$(".cbhsSendEmail-class div[class=sendEmailMsgDiv]").css("display", "none");
			
			$(".cbhsSendEmail-class").css("font-size", "10px");
			
			$(".cbhsSendEmail-class").css("-moz-border-radius", "8px 8px 8px 8px");
			$(".cbhsSendEmail-class").css("border-radius", "0px 0px 0px 0px");			//- IE9 CSS3
			$(".cbhsSendEmail-class").css("background", "none repeat scroll 0 0 #ffffff");
			
		});
		
		return;
	}
	
	
	
	
	//-----------------------------------------------------------//
	//-- Contractors and Programs Updates
	//-----------------------------------------------------------//
	
	function setObjFocus(thisObj)
	{
		thisObj.focus();
		return;
	}
	
	function clearInputFld(oField)
	{
		oField.className = 'inputFld';
		
		if(document.getElementById("contMsg")) {
			document.getElementById("contMsg").style.display = 'none';
		}
		
		if(document.getElementById("msg_" + oField.id)) {
			document.getElementById("msg_" + oField.id).innerHTML = '';
		}
		
		return;
	}
	
	function clearInputFldSmall(oField)
	{
		oField.className = 'inputFldSmall';
		
		if(document.getElementById("contMsg")) {
			document.getElementById("contMsg").style.display = 'none';
		}
		
		return;
	}
	
	function clearSelectFld(oField)
	{
		oField.className = 'selectFld';
		
		if(document.getElementById("contMsg")) {
			document.getElementById("contMsg").style.display = 'none';
		}
		
		return;
	}
	
	
	
	//-----------------------------------------------------------//
	//-- Phone validation
	//-----------------------------------------------------------//
	
	var zChar = new Array(' ', '(', ')', '-', '.');
	var maxphonelength = 14;
	var phonevalue1;
	var phonevalue2;
	var cursorposition;

	function ParseForNumber1(object){
		phonevalue1 = ParseChar(object.value, zChar);
	}

	function ParseForNumber2(object){
		phonevalue2 = ParseChar(object.value, zChar);
	}

	function backspacerUP(object,e)
	{ 
		if(e){ 
			e = e 
		} else {
			e = window.event 
		}
		
		if(e.which){ 
			var keycode = e.which 
		} else {
			var keycode = e.keyCode 
		}
		
		ParseForNumber1(object)
		
		if(keycode >= 48){
			ValidatePhone(object)
		}
	}
	
	
	function backspacerDOWN(object,e)
	{ 
		if(e){ 
			e = e 
		} else {
			e = window.event 
		}
		
		if(e.which){
			var keycode = e.which 
		} else {
			var keycode = e.keyCode 
		}
		ParseForNumber2(object)
	}
	
	
	function GetCursorPosition()
	{
		var t1 = phonevalue1;
		var t2 = phonevalue2;
		var bool = false
		for (i=0; i<t1.length; i++)
		{
			if (t1.substring(i,1) != t2.substring(i,1)) {
				if(!bool) {
					cursorposition = i
					window.status = cursorposition
					bool = true
				}
			}
		}
	}
	
	
	function ValidatePhone(object)
	{
		var p = phonevalue1
		
		p = p.replace(/[^\d]*/gi,"")
		
		if (p.length < 3) {
			object.value = p
		} else if(p.length == 3){
			pp = p;
			d4 = p.indexOf('(')
			d5 = p.indexOf(')')
			if(d4 == -1){
				pp = "("+pp;
			}
			
			if(d5==-1){
				pp = pp+")";
			}
			object.value = pp;
		} else if(p.length>3 && p.length < 7){
			p = "(" + p; 
			l30 = p.length;
			p30 = p.substring(0,4);
			p30 = p30+") " 
			
			p31 = p.substring(4,l30);
			pp  = p30+p31;
			
			object.value = pp; 
			
		} else if(p.length >= 7){
			p = "(" + p; 
			l30 = p.length;
			p30 = p.substring(0,4);
			p30 = p30+") " 
			
			p31 = p.substring(4,l30);
			pp  = p30+p31;
			
			l40 = pp.length;
			p40 = pp.substring(0,9);
			p40 = p40 + "-"
			
			p41 = pp.substring(9,l40);
			ppp = p40 + p41;
			
			object.value = ppp.substring(0, maxphonelength);
		}
		
		GetCursorPosition()
		
		if(cursorposition >= 0){
			if (cursorposition == 0) {
				cursorposition = 2
			} else if (cursorposition <= 2) {
				cursorposition = cursorposition + 1
			} else if (cursorposition <= 4) {
				cursorposition = cursorposition + 3
			} else if (cursorposition == 5) {
				cursorposition = cursorposition + 3
			} else if (cursorposition == 6) { 
				cursorposition = cursorposition + 3 
			} else if (cursorposition == 7) { 
				cursorposition = cursorposition + 4 
			} else if (cursorposition == 8) { 
				cursorposition = cursorposition + 4
				e1 = object.value.indexOf(')')
				e2 = object.value.indexOf('-')
				if (e1>-1 && e2>-1){
					if (e2-e1 == 4) {
						cursorposition = cursorposition - 1
					}
				}
			} else if (cursorposition == 9) {
				cursorposition = cursorposition + 4
			} else if (cursorposition < 11) {
				cursorposition = cursorposition + 3
			} else if (cursorposition == 11) {
				cursorposition = cursorposition + 1
			} else if (cursorposition == 12) {
				cursorposition = cursorposition + 1
			//} else if (cursorposition >= 13) {
			} else if (cursorposition == 13) {
				cursorposition = cursorposition + 1
			}
			
			 if (object.createTextRange)
			 {
				 /* IE */
				 var txtRange = object.createTextRange();
				 txtRange.moveStart( "character", cursorposition);
				 txtRange.moveEnd( "character", cursorposition - object.value.length);
				 txtRange.select();
				 
			 } else if (object.setSelectionRange) {
				 /* Mozilla, Opera */
				 object.setSelectionRange(cursorposition, object.value.length);
			 }
		}
	}
	
	
	function ParseChar(sStr, sChar)
	{
		if (sChar.length == null) {
			zChar = new Array(sChar);
		} else zChar = sChar;
		
		for (i=0; i<zChar.length; i++)
		{
			sNewStr = "";
			
			var iStart = 0;
			var iEnd = sStr.indexOf(sChar[i]);
			
			while (iEnd != -1)
			{
				sNewStr += sStr.substring(iStart, iEnd);
				iStart = iEnd + 1;
				iEnd = sStr.indexOf(sChar[i], iStart);
			}
			sNewStr += sStr.substring(sStr.lastIndexOf(sChar[i]) + 1, sStr.length);
			
			sStr = sNewStr;
		}
		
		return sNewStr;
	}
	
	
	var Base64 = {
		
		// private property
		_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
		
		// public method for encoding
		encode : function (input) {
			var output = "";
			var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
			var i = 0;
			
			input = Base64._utf8_encode(input);
			
			while (i < input.length) {
				
				chr1 = input.charCodeAt(i++);
				chr2 = input.charCodeAt(i++);
				chr3 = input.charCodeAt(i++);
				
				enc1 = chr1 >> 2;
				enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
				enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
				enc4 = chr3 & 63;
				
				if (isNaN(chr2)) {
					enc3 = enc4 = 64;
				} else if (isNaN(chr3)) {
					enc4 = 64;
				}
				
				output = output +
				this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
				this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
				
			}
			
			return output;
		},
		
		// public method for decoding
		decode : function (input) {
			var output = "";
			var chr1, chr2, chr3;
			var enc1, enc2, enc3, enc4;
			var i = 0;
			
			input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
			
			while (i < input.length) {
				
				enc1 = this._keyStr.indexOf(input.charAt(i++));
				enc2 = this._keyStr.indexOf(input.charAt(i++));
				enc3 = this._keyStr.indexOf(input.charAt(i++));
				enc4 = this._keyStr.indexOf(input.charAt(i++));
				
				chr1 = (enc1 << 2) | (enc2 >> 4);
				chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
				chr3 = ((enc3 & 3) << 6) | enc4;
				
				output = output + String.fromCharCode(chr1);
				
				if (enc3 != 64) {
					output = output + String.fromCharCode(chr2);
				}
				if (enc4 != 64) {
					output = output + String.fromCharCode(chr3);
				}
				
			}
			
			output = Base64._utf8_decode(output);
			
			return output;
			
		},
		
		// private method for UTF-8 encoding
		_utf8_encode : function (string) {
			string = string.replace(/\r\n/g,"\n");
			var utftext = "";
			
			for (var n = 0; n < string.length; n++) {
				
				var c = string.charCodeAt(n);
				
				if (c < 128) {
					utftext += String.fromCharCode(c);
				}
				else if((c > 127) && (c < 2048)) {
					utftext += String.fromCharCode((c >> 6) | 192);
					utftext += String.fromCharCode((c & 63) | 128);
				}
				else {
					utftext += String.fromCharCode((c >> 12) | 224);
					utftext += String.fromCharCode(((c >> 6) & 63) | 128);
					utftext += String.fromCharCode((c & 63) | 128);
				}
				
			}
			
			return utftext;
		},
		
		// private method for UTF-8 decoding
		_utf8_decode : function (utftext) {
			var string = "";
			var i = 0;
			var c = c1 = c2 = 0;
			
			while ( i < utftext.length ) {
				
				c = utftext.charCodeAt(i);
				
				if (c < 128) {
					string += String.fromCharCode(c);
					i++;
				}
				else if((c > 191) && (c < 224)) {
					c2 = utftext.charCodeAt(i+1);
					string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
					i += 2;
				}
				else {
					c2 = utftext.charCodeAt(i+1);
					c3 = utftext.charCodeAt(i+2);
					string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
					i += 3;
				}
				
			}
			
			return string;
		}
	 
	}
	


