	
	//=========================================================================
	// SmartLead - Zip Code Finder
	//=========================================================================

	function RequestZipCodes() 
	{
	var sRequestCode = event.srcElement.id=='cmdFindFromZip'?'From':'To';
	var bValidZipCode = (IsValidZipCode(window.document.getElementById('txt' + sRequestCode + 'ZipCode').value, false).ReturnCode == 0);
	var bValidCityState = (IsEmpty(window.document.getElementById('txt' + sRequestCode + 'City').value).ReturnCode == 0 && window.document.getElementById('cbo' + sRequestCode + 'State').selectedIndex > 0);		

		if (bValidZipCode || bValidCityState) {
			window.fraGetZipCode.frmGetZipCode.txtRequestCode.value = sRequestCode; 

			if (bValidZipCode) {
				window.fraGetZipCode.frmGetZipCode.txtZipCode.value = window.document.getElementById('txt' + sRequestCode + 'ZipCode').value;
				window.fraGetZipCode.frmGetZipCode.txtCity.value = '';
				window.fraGetZipCode.frmGetZipCode.txtStateCode.value = '';
			}
			else {
				window.fraGetZipCode.frmGetZipCode.txtZipCode.value = '';
				window.fraGetZipCode.frmGetZipCode.txtCity.value = window.document.getElementById('txt' + sRequestCode + 'City').value;
				window.fraGetZipCode.frmGetZipCode.txtStateCode.value = window.document.getElementById('cbo' + sRequestCode + 'State').value;
			}
					
			window.fraGetZipCode.frmGetZipCode.submit();
		}
		else 
			alert('In order to find a zip code enter a city name, select a state and then click the Find button.\nIf you want to validate your zip code enter it and click the find button.');
	}


	
	function ReceiveZipCodes(sRequestCode, iResultCount) 
	{
	var hUserError;
	
		//Clear the error messages and the marked fields.
		ResetErrorDisplay(); 

		if (iResultCount > 0) {
			SelectZipCode(0, sRequestCode);
			window.document.getElementById('cmd' + sRequestCode + 'ZipList').disabled = !(iResultCount > 1);
		}
		else {
			hUserError =  new UserError('txt' + sRequestCode + 'ZipCode', 'The zip code you entered was not found.', sRequestCode=='From'?3:4, 2);
			hUserError.DisplayError();
			}  
	}



	function DisplayZipHelp() 
	{
	var iLeftPos = event.srcElement.id=='HelpFromZip'?0:300;
	
		window.winPopupHelpZip.style.left = event.clientX + window.document.body.scrollLeft - iLeftPos;
		window.winPopupHelpZip.style.top =  event.clientY + window.document.body.scrollTop - 145;
		window.winPopupHelpZip.style.display = 'inline';
	}



	function ShowZipList() 
	{
	var iLeftPos = event.srcElement.id=='cmdFromZipList'?0:300;
 
		window.ZipListBlock.innerHTML = window.fraGetZipCode.ZipListBlock.innerHTML;
		window.txtRequest.value = event.srcElement.name.indexOf('From')>0?'From':'To';
			
		window.winPopupZipList.style.left = event.clientX + window.document.body.scrollLeft - iLeftPos;
		window.winPopupZipList.style.top =  event.clientY + window.document.body.scrollTop - 145;
		window.winPopupZipList.style.display = 'inline';
	}



	function GetCityState() 
	{
	var sRequestCode = event.srcElement.name.indexOf('From')>0?'From':'To';

		if (IsValidZipCode(event.srcElement.value, false).ReturnCode == 0) {
			window.fraGetZipCode.frmGetZipCode.txtRequestCode.value = sRequestCode; 
			window.fraGetZipCode.frmGetZipCode.txtZipCode.value = window.document.getElementById('txt' + sRequestCode + 'ZipCode').value;
			window.fraGetZipCode.frmGetZipCode.submit();
		}
	}


	
	function SelectZipCode(iIndex, sRequestCode) 
	{
	var sValue = window.fraGetZipCode.lstZipCodes.options[iIndex].text;
			
		window.winPopupZipList.style.display = 'none'; 	

		window.document.getElementById('txt' + sRequestCode + 'ZipCode').value = sValue.slice(0,5);
		window.document.getElementById('txt' + sRequestCode + 'City').value = sValue.slice(8, sValue.length - 4);
		window.document.getElementById('cbo' + sRequestCode + 'State').value = sValue.slice(sValue.length - 2);
	}


