function getNextCOStep(divID, section) {
	switch (section) {
		case 'zipcode':
			var zipValue = $(LOCATE_ZIP).value;
			vZipInfo = new zipcodeUtil(zipValue);
			if (vZipInfo.isValid){
				zipDialogLocation = new Location();
				zipDialogLocation.zipcode = zipValue;
				if (vZipInfo.isMultiCounty) {
					$(LOCATE_COUNTY).style.display="block";
					$(LOCATE_REGION).style.display="none";
					getCountyCombo();
				}else{
					if(vZipInfo.isMultiRegion){
						$(LOCATE_COUNTY).style.display="none";
						$(LOCATE_REGION).style.display="block";
						var regions = vZipInfo.getRegions();
						getRegionsCombo(regions);
					}else{
						return false;
					}
				}
			}else{
				alert(LOCATE_ERROR_INVALID_ZIPCODE);
				$(LOCATE_ZIP).value = '';
				$(LOCATE_ZIP).focus();
			}
			break;
		case 'county':
			$(LOCATE_SELECT_REGION).length = 0;
			$(LOCATE_REGION).style.display="none";
			var countyCode = $(LOCATE_SELECT_CONTY).value;
			var countyDescription = getSelectText(LOCATE_SELECT_CONTY);
			zipDialogLocation.county = new County(countyCode, countyDescription);
			if (vZipInfo.isMultiRegion) {
				var regions = vZipInfo.getRegions(zipDialogLocation.county != null ? zipDialogLocation.county.code : undefined);
				$(LOCATE_REGION).style.display="block";
				getRegionsCombo(regions);
			} else {
				return false;
			}
			break;
	}
}

function getCountyCombo() {
	removeAllOptions(LOCATE_SELECT_CONTY);
	var counties = vZipInfo.getCounties();
	for ( var i = 0; i < counties.length; i++) {
		county = counties[i];
		addOpt(LOCATE_SELECT_CONTY, county.code, county.description);
	}
	//$(ZIP_LOCATE_BUTTON).value="GO";
	//Change submit button action to show region data.
	$(ZIP_LOCATE_BUTTON).onclick = function (event){
			getNextCOStep('dlDialog','county');
	}
}

function getRegionsCombo(regions) {
	removeAllOptions(LOCATE_SELECT_REGION);
	for ( var i = 0; i < regions.length; i++) {
		region = regions[i];
		addOpt(LOCATE_SELECT_REGION, region.code, region.description);
	}
	//Revert the action once Region is selected.
	$(ZIP_LOCATE_BUTTON).onclick = function (event){
			loadinglocate();
	}
}

function locateChange(){
	$(LOCATE_SELECT_CONTY).length = 0;
	$(LOCATE_SELECT_REGION).length = 0;
	$(LOCATE_COUNTY).style.display="none";
	$(LOCATE_REGION).style.display="none";
}

function removeAllOptions(selectbox) {
	$(selectbox).length = 0;
}

//Not used, this requeriment was eliminate( But it can work fine )
function saveDefaultLocationRaq(zipCode,countyCode,countyDesc,regionCode,regionDesc){
	vZipInfo = new zipcodeUtil(zipCode);
	if (vZipInfo.isValid) {
		zipDialogLocation = new Location();
		var counties = vZipInfo.getCounties();
		if(countyCode==null){
			countyCode = counties[0].code;
		}
		var regions = vZipInfo.getRegions(countyCode);
		zipDialogLocation.zipcode = zipCode;
		if(countyDesc==null){
			countyDesc = counties[0].description;
		}
		zipDialogLocation.county = new County(countyCode,countyDesc);
		if(regionDesc==null){
			regionDesc = regions[0].description;
		}
		if(regionCode==null){
			regionCode = regions[0].code;
		}
		zipDialogLocation.region = new Region(regionCode,regionDesc, vZipInfo.getDmaByRegion(regionCode));
		saveDefaultLocation(zipDialogLocation.zipcode,zipDialogLocation.region, zipDialogLocation.county);
	}else{
		alert(LOCATE_ERROR_INTERNAL_COOKIE);
	}
}

