	function setActiveForm(frm)
	{
		strActiveForm = frm.name;
	}
	
	function cityCodingValidation(strQQType, strAJAXCoding, frm)
	{
		var objAJAX = new clsAJAX();
		var blnValidation = validateQuickQuoteAJAX(frm);
		var blnAJAXSupport;
		var blnAJAXCoding;
		var objForm;
	   if (frm == "frmQuickQuote"){
		   objForm = document.frmQuickQuote;
		}
		else if (frm == "frmQuickQuote2"){
		   objForm = document.frmQuickQuote2;
		}


		blnAJAXCoding = true;


		try
		{
			if(objAJAX.ajaxRequest != false)
			{
				blnAJAXSupport = true;
			}
			else
			{
				blnAJAXSupport = false;
			}
		}
		catch(e)
		{
			blnAJAXSupport = true;
		}

		if(strQQType == "QQBike")
		{
			blnAJAXSupport = false;
		}

		//If user's browser supports AJAX and form passed JavaScript validation
		if(blnValidation && blnAJAXSupport)
		{
			objAJAX.open("GET", "/AJAX/cityCoding.asp?citycheck=yes&oCity="+objForm.txtFromCity.value+"&oST="+objForm.cboFromState.value+"&oZip="+objForm.txtFromZip.value+"&dCity="+objForm.txtToCity.value+"&dST="+objForm.cboToState.value+"&dZip="+objForm.txtToZip.value+"&date="+Date(), true);
			
			if (gstrSiteView == '1')
			{
				// 800x600
				var strOrigImage = "/images/quote/quickquoten/button2.gif";
				var strAnimImage = "/images/quote/quickquoten/getQuoteAnim2.gif";
			}
			else
			{
				// >=1024x768
				var strOrigImage = "/images/sr/buttons/get-quote-orange.gif";
				var strAnimImage = "/images/sr/buttons/get-quote-orange-ani.gif";
			}

			objAJAX.ajaxRequest.onreadystatechange = function()
			{
				var objQuoteButton;
				if (frm == "frmQuickQuote")
				{
					objQuoteButton = document.getElementById('imgQuoteBtn');
				} 
				else if (frm == "frmQuickQuote2")
				{
					objQuoteButton = document.getElementById('imgQuoteBtn2');
				} 

				//If results returned from the server
				if(objAJAX.ajaxRequest.readyState == 4)
				{
					var objCityCoding = eval('(' + objAJAX.ajaxRequest.responseText + ')');
					if(!blnAJAXCoding)
					{
						objForm.submit();
						return;
					}

					objQuoteButton.src = strOrigImage;

					if(objCityCoding.blnOrigin && objCityCoding.origin.intMatchCount == 0)
					{
						if(objCityCoding.origin.objErrors[0].intErrorCode == 4 || objCityCoding.origin.objErrors[0].intErrorCode == 5)
						{
							alert(objCityCoding.origin.objErrors[0].strMessage);
							setFormFocus(frm,'txtFromZip');
						}
					}
					else if(objCityCoding.blnDest && objCityCoding.dest.intMatchCount == 0)
					{
						if(objCityCoding.dest.objErrors[0].intErrorCode == 4 || objCityCoding.dest.objErrors[0].intErrorCode == 5)
						{
							alert(objCityCoding.dest.objErrors[0].strMessage);
							setFormFocus(frm,'txtToZip');
						}
					}
					else
					{
						if(strAJAXCoding=="false")
						{
							var strDisplayMessage = '';
							if (objCityCoding.blnOrigin)
							{
								strDisplayMessage = "There is an error in your Moving From information:\r\n" + objCityCoding.origin.strMessage;
							}
							if (objCityCoding.blnOrigin && objCityCoding.blnDest)
							{
								strDisplayMessage += "\r\n\r\n";
							}

							if (objCityCoding.blnDest)
							{
								strDisplayMessage += "There is an error in your Moving To information:\r\n" + objCityCoding.dest.strMessage;
							}

							if (objCityCoding.blnDest || objCityCoding.blnOrigin)
							{
								alert(strDisplayMessage);
							}

						}

						//If didn't need city coding then submit the form.
						if(!handleCityCoding(objCityCoding, strQQType, strAJAXCoding, frm))
						{
							objQuoteButton.src = strAnimImage;
							objForm.submit();
						}
						else
						{
							if (strAJAXCoding == "true1")
							{
								trackWebAnalyticEvent(13, "AJAX OVERLAY A");
								trackWebEventsEvent("CITY CODING TEST", "AJAX OVERLAY A");
							}
							else if(strAJAXCoding == "true2")
							{
								trackWebAnalyticEvent(13, "AJAX OVERLAY B");
								trackWebEventsEvent("CITY CODING TEST", "AJAX OVERLAY B")
							}
							else if(strAJAXCoding == "false")
							{
								trackWebAnalyticEvent(13, "AJAX NO OVERLAY");
								trackWebEventsEvent("CITY CODING TEST", "AJAX NO OVERLAY")
							}

							EnteredOnce = false;
							if(strQQType=="QQLarge")
							{
								if(strAJAXCoding=="true1" || strAJAXCoding=="true2")
								{
									document.getElementById('quote').style.position = "relative";
									document.getElementById('quote').style.zIndex = "112";
								}
							}
							else if(strQQType=="QQSmall")
							{
								if(strAJAXCoding=="true1" || strAJAXCoding=="true2")
								{
									document.getElementById('quotesmall').style.position = "relative";
									document.getElementById('quotesmall').style.zIndex = "112";
								}
							}
							else if(strQQType=="QQHoriz")
							{
								if(strAJAXCoding=="true1" || strAJAXCoding=="true2")
								{
									document.getElementById('horizontal-quote').style.position = "relative";
									document.getElementById('horizontal-quote').style.zIndex = "112";
								}
							}
						}
					}
				}
				else if(objAJAX.ajaxRequest.readyState == 1)
				{
					objQuoteButton.src = strAnimImage;
				}
			}

			objAJAX.send(null);
		}
		else
		{
			var objQuoteButton;
			if (frm == "frmQuickQuote")
			{
				objQuoteButton = document.getElementById('imgQuoteBtn');
			} 
			else if (frm == "frmQuickQuote2")
			{
				objQuoteButton = document.getElementById('imgQuoteBtn2');
			} 
			if (gstrSiteView == '1')
			{
				// 800x600
				var strAnimImage = "/images/quote/quickquoten/getQuoteAnim2.gif";
			}
			else
			{
				// >=1024x768
				var strAnimImage = "/images/sr/buttons/get-quote-orange-ani.gif";
			}
			if(blnValidation)
			{
				objQuoteButton.src = strAnimImage;

				objForm.submit();
			}
		}
	}



	function handleCityCoding(objCityCoding, strForm, strAJAXCoding, frm)
	{
		var strBody;
		var strQuoteMain;
		var strFromORLbl;
		var strToORLbl;
		var strID;
		var strFromWidth;
		var strToWidth;
		if(strForm == "QQLarge")
		{
			strBody = "quotebody";
			strQuoteMain = "quote";
			strFromORLbl = 'divFromOR';
			strToORLbl = 'divToOR';
			strFromID = 'fromCity';
			strToID = 'toCity';
			strFromWidth = '160px';
			strToWidth = '160px';
		}
		else if(strForm == "QQSmall")
		{
			strBody = 'quotebodysmall';
			strQuoteMain = "quotesmall";
			strFromORLbl = 'divFromOR';
			strToORLbl = 'divToOR';
			strFromID = 'fromCity';
			strToID = 'toCity';
			strFromWidth = '160px';
			strToWidth = '160px';
		}
		else if(strForm == "QQHoriz")
		{
			strBody = 'quotebodywide';
			strQuoteMain = "horizontal-quote";
			strFromORLbl = 'lblFromOR';
			strToORLbl = 'lblToOR';
			strFromID = 'fromCityWide';
			strToID = 'toCityWide';
			strFromWidth = '538px';
			strToWidth = '515px';
		}

		if(objCityCoding.blnOrigin || objCityCoding.blnDest)
		{
			if(strForm == "QQLarge" || strForm == "QQBike")
			{
				window.scrollTo(0,0);
			}
			else
			{
				window.scrollTo(0,document.getElementById(strQuoteMain).offsetTop);
			}


			if(objCityCoding.blnOrigin)
			{
				if(objCityCoding.origin.intMatchCount > 0)
				{
					createCityCodingSelect(frm, strFromID, 'txtFromCity', 'cboFromState', strFromORLbl, 'txtFromZip', objCityCoding.origin, strFromWidth, strBody, '20px');
				}
			}

			if(objCityCoding.blnDest)
			{
				if(objCityCoding.dest.intMatchCount > 0)
				{
					createCityCodingSelect(frm, strToID, 'txtToCity', 'cboToState', strToORLbl, 'txtToZip', objCityCoding.dest, strToWidth, strBody, '20px');
				}
			}


			/* AJAX black out test*/
			if(strAJAXCoding=="true1" || strAJAXCoding=="true2")
			{
				displayTransparentOverlay();
				Event.add(transOverlay, 'click',
					function()
					{
						hideTransparentOverlay();
						document.getElementById(strQuoteMain).style.position = "";
					}
				);
			}


			return true;
		}
		else
		{
			return false;
		}
	}

	function createCityCodingSelect(frm, strID, strCityDestinationID, strStateDestinationID, strORID, strZipDestinationID, objCityCoding, strWidth, strQuoteBody, strHeight)
	{
		var objForm;
		var objQuoteBody;
		var objZipDestination;
	   if (frm == "frmQuickQuote"){
		   objForm = document.frmQuickQuote;
			objZipDestination = eval('objForm.'+strZipDestinationID+'.parentNode.parentNode');
		}
		else if (frm == "frmQuickQuote2"){
		   objForm = document.frmQuickQuote2;
			objZipDestination = eval('objForm.'+strZipDestinationID);
		}
		var objOR = document.getElementById(strORID);
		var objCityDestination = eval('objForm.'+strCityDestinationID+'.parentNode');
		var objStateDestination = eval('objForm.'+strStateDestinationID+'.parentNode');
		var objCityTextBox = eval('objForm.'+strCityDestinationID);
		var objStateSelectBox = eval('objForm.'+strStateDestinationID);
		var objZipTextBox = eval('objForm.'+strZipDestinationID);
		var objQuoteBody = eval(document.getElementById(strQuoteBody));

		var blnImageFound = false;

		//Stop duplicate select boxes from being displayed
		if(document.getElementById(strID))
		{
			Dom.remove(document.getElementById(strID));
		}
		//Stop duplicate error images from being displayed
		if(getElementsByClassName("AJAXQQError", "div", objStateDestination).length > 0)
		{
			blnImageFound = true;

			var arrItems = getElementsByClassName("AJAXQQError", "div", objStateDestination);
			for(var i = 0; i < arrItems.length; i++)
			{
				Dom.remove(arrItems[i], frm);
			}
		}
		var objErrorImage = document.createElement('div');
		objErrorImage.className = "AJAXQQError";

		var objCityDropDown = document.createElement('select');
		objCityDropDown.id = strID;

		if(strQuoteBody == "quotebodysmall")
		{
			objErrorImage.style.left = "-8px";
			objErrorImage.style.top = "9px";
		}
		
		if (frm == "frmQuickQuote2")
		{
			if(strID == "fromCityWide")
			{
				document.getElementById('fromEntryArea').style.width = strWidth;
				document.getElementById('fromEntryArea').style.height = strHeight;
			}
			else
			{
				document.getElementById('toEntryArea').style.width = strWidth;
				document.getElementById('toEntryArea').style.height = strHeight;
			}
		}

		objCityDropDown[objCityDropDown.length] = new Option("(Please Select One)");
		for(var i = 0; i < objCityCoding.objMatch.length; i++)
		{
			if(objCityCoding.objMatch[i].strState != "" && objCityCoding.objMatch[i].strZip != "")
			{
				if(objCityCoding.strType=="ZIPS")
				{

					if(objCityCoding.objMatch[i].strZip.substr(0, 1) == "@")
					{
						objCityDropDown[objCityDropDown.length] = new Option(objCityCoding.objMatch[i].strZip.substr(1,objCityCoding.objMatch[i].strZip.length), "@"+objCityCoding.objMatch[i].strCity+', '+objCityCoding.objMatch[i].strState);
					}
					else
					{
						objCityDropDown[objCityDropDown.length] = new Option(objCityCoding.objMatch[i].strCity + ', ' + objCityCoding.objMatch[i].strState, objCityCoding.objMatch[i].strCity);
					}
				}
				else
				{
					objCityDropDown[objCityDropDown.length] = new Option(objCityCoding.objMatch[i].strCity + ', ' + objCityCoding.objMatch[i].strState, objCityCoding.objMatch[i].strCity);
				}
			}
			else
			{
				objCityDropDown[objCityDropDown.length] = new Option(objCityCoding.objMatch[i].strCity, "");
			}
		}

		var strEnterNewCity = "--Enter New City--";
		objCityDropDown[objCityDropDown.length] = new Option(strEnterNewCity);

		objCityTextBox.style.display = "none";
		objStateSelectBox.style.display = "none";
		if (objOR != null) {objOR.style.display = "none";}
		objZipDestination.style.display = "none";
		
	   if (frm == "frmQuickQuote2"){
			objCityDropDown.style.marginLeft = "5px";
			if(navigator.appName == "Microsoft Internet Explorer") {
				objErrorImage.style.display = "inline";
				objErrorImage.style.top = "0px";
			}
			else{
				objErrorImage.style.display = "inline-block";
				objErrorImage.style.top = "2px";
			}
		}
		Dom.add(objErrorImage, objStateDestination, frm);
		Dom.add(objCityDropDown, objStateDestination, frm);

		var objErrorDiv = document.createElement('div');
		Event.add(objErrorImage, 'mouseover',
			function()
			{
				objErrorDiv.style.position = "absolute";
				objErrorDiv.style.zIndex = "202";
				objErrorDiv.style.background = "#FDFFE0";
				objErrorDiv.style.border = "1px solid black";
				objErrorDiv.style.fontSize = "1.2em";
				objErrorDiv.style.width = "180px";
				objErrorDiv.style.fontWeight = "bold";
				objErrorDiv.style.padding = "5px";
				objErrorDiv.innerHTML = objCityCoding.strMessage;

				objErrorDiv.style.left = objErrorImage.offsetLeft + objErrorImage.offsetWidth;
				objErrorDiv.style.top = objErrorImage.offsetTop;

				Dom.add(objErrorDiv, objStateDestination, frm);
			}
		);

		Event.add(objErrorImage, 'mouseout',
			function()
			{
				Dom.remove(objErrorDiv, frm);
			}
		);



		blinkYellow(objCityDropDown, 1, 5);

		if(!blnImageFound)
		{
			if(strQuoteBody == "quotebodysmall")
			{
				objQuoteBody.style.height = objQuoteBody.offsetHeight - 10;
			}
			else
			{
				if (frm != "frmQuickQuote2")
				{
					if (gstrSiteView == '1')
					{
						// 800x600
						objQuoteBody.style.height = objQuoteBody.offsetHeight - 14;
					}
					else
					{
						// >=1024x768
						objQuoteBody.style.height = objQuoteBody.offsetHeight + 6;
					}
				}
			}
		}

		Event.add(objCityDropDown, 'change',
			function()
			{
				var objSelectedItem = objCityDropDown.options[objCityDropDown.selectedIndex];
				if(objSelectedItem.text == strEnterNewCity)
				{
					Dom.remove(objCityDropDown, frm);
					Dom.remove(objErrorImage, frm);

					objCityTextBox.style.display = "";
					objStateSelectBox.style.display = "";
					if (objOR != null) {objOR.style.display = "";}
					objZipDestination.style.display = "";

					if(strQuoteBody == "quotebodysmall")
					{
						objQuoteBody.style.height = objQuoteBody.offsetHeight + 10;
					}
					else
					{
						if (gstrSiteView == '1')
						{
							// 800x600
							objQuoteBody.style.height = objQuoteBody.offsetHeight + 14;
						}
						else
						{
							// >=1024x768
							objQuoteBody.style.height = objQuoteBody.offsetHeight - 14;
						}
					}


					blinkYellow(objCityTextBox, 3, 5);
				}
				else
				{
					var strTempCity, strTempState, strTempZip

					if(objCityCoding.strType=="ZIPS")
					{
						if(objSelectedItem.text.search(",") != -1)
						{
							strTempCity = objSelectedItem.value;
							strTempState = objSelectedItem.text.substr(objSelectedItem.text.length-2, 2);

							selectItem(objStateSelectBox, strTempState);

							objCityTextBox.value = strTempCity;

							if(objCityCoding.strMessage.search("conflicts") != -1)
							{
								objZipTextBox.value = '';
							}
						}
						else if(objSelectedItem.value.search("@") != -1)
						{
							strTempZip = objSelectedItem.text.substr(0,5);

							strTempCity = objSelectedItem.value.substr(1, objSelectedItem.value.length-5);
							strTempState = objSelectedItem.value.substr(objSelectedItem.value.length-2, objSelectedItem.value.length);


							objCityTextBox.value = strTempCity
							selectItem(objStateSelectBox, strTempState);
							objZipTextBox.value = strTempZip;
						}
					}
					else
					{
						if(objSelectedItem.text.search(",") != -1)
						{
							strTempCity = objSelectedItem.value;
							strTempState = objSelectedItem.text.substr(objSelectedItem.text.length-2, 2);

							selectItem(objStateSelectBox, strTempState);

							objCityTextBox.value = objSelectedItem.value;

							if(objCityCoding.strMessage.search("conflicts") != -1)
							{
								objZipTextBox.value = '';
							}
						}
					}
				}
			});
	}
	
function setFormFocus(strForm, strField) {
	if (eval('document.'+strForm))
	{
		if (eval('document.'+strForm+'.'+strField))
		{
			var field;
			field = eval('document.'+strForm+'.'+strField);
			field.focus();
		}
	}
	else
	{
		if (eval("document.getElementById('"+strField+"')"))
		{
			eval("document.getElementById('"+strField+"').focus()");
		}
	}
}