	
	//=========================================================================
	// SmartLead - Zip Code Finder
	//=========================================================================

	function RequestZipCodes(sRequestCode) 
	{
	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);		
	var theform = 
		(document.getElementById('fraGetZipCode').document == null) ?
			document.getElementById('fraGetZipCode').contentDocument.getElementById('frmGetZipCode') :
			document.frames['fraGetZipCode'].document.getElementById('frmGetZipCode');

		if (bValidZipCode || bValidCityState) {
			theform.txtRequestCode.value = sRequestCode; 

			if (bValidZipCode) {
				theform.txtZipCode.value = window.document.getElementById('txt' + sRequestCode + 'ZipCode').value;
				theform.txtCity.value = '';
				theform.txtStateCode.value = '';
			}
			else {
				theform.txtZipCode.value = '';
				theform.txtCity.value = window.document.getElementById('txt' + sRequestCode + 'City').value;
				theform.txtStateCode.value = window.document.getElementById('cbo' + sRequestCode + 'State').value;
			}
					
			theform.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(e) 
	{
	var src;
		if (e.srcElement) src = e.srcElement;
		else if (e.target) src = e.target;	
	var iLeftPos = src.id=='cmdFromZipList'?0:300;
 	var thedoc = 
		(document.getElementById('fraGetZipCode').document == null) ?
			document.getElementById('fraGetZipCode').contentDocument :
			document.frames['fraGetZipCode'].document;

		document.getElementById('ZipListBlock').innerHTML = thedoc.getElementById('ZipListBlock').innerHTML;
		document.getElementById('txtRequest').value = src.name.indexOf('From')>0?'From':'To';
			
		document.getElementById('winPopupZipList').style.left = e.clientX + window.document.body.scrollLeft - iLeftPos;
		document.getElementById('winPopupZipList').style.top =  e.clientY + window.document.body.scrollTop - 145;
		document.getElementById('winPopupZipList').style.display = 'inline';
	}



	function GetCityState() 
	{
	var src;
		if (e.srcElement) src = e.srcElement;
		else if (e.target) src = e.target;
			
	var sRequestCode = src.name.indexOf('From')>0?'From':'To';
	var theform = 
		(document.getElementById('fraGetZipCode').document == null) ?
			document.getElementById('fraGetZipCode').contentDocument.getElementById('frmGetZipCode') :
			frames['fraGetZipCode'].document.getElementById('frmGetZipCode');
	
		if (IsValidZipCode(src.value, false).ReturnCode == 0) {
			theform.txtRequestCode.value = sRequestCode; 
			theform.txtZipCode.value = window.document.getElementById('txt' + sRequestCode + 'ZipCode').value;
			theform.submit();
		}
	}


	
	function SelectZipCode(iIndex, sRequestCode) 
	{
	var thedoc = 
		(document.getElementById('fraGetZipCode').document == null) ?
			document.getElementById('fraGetZipCode').contentDocument :
			document.frames['fraGetZipCode'].document;
			
	var sValue = thedoc.getElementById('lstZipCodes').options[iIndex].text;
			
		document.getElementById('winPopupZipList').style.display = 'none'; 	

		document.getElementById('txt' + sRequestCode + 'ZipCode').value = sValue.slice(0,5);
		document.getElementById('txt' + sRequestCode + 'City').value = sValue.slice(8, sValue.length - 4);
		document.getElementById('cbo' + sRequestCode + 'State').value = sValue.slice(sValue.length - 2);
	}

