

var myTTimer = setTimeout('loadDefault()',110);

function loadDefault() {
//alert(location.search);
tmpstr= location.search.substr(1);
//alert(tmpstr);

 
	if ((location.search=="") || (tmpstr=="RoS=S")) 
		{
		//alert("goingt to sales");
			populateCounties(document.sales,"S");
		} 
	else 
		{	
		//alert("goingt to rentals");
		//alert(location.search);
		  populateCounties(document.rentals,"RoS=R");
		}

}




function Repage(theROS, NID)
{
var tempname;
tempname = "";
tempname = tempname + "quicksearch.asp?RoS=";
tempname = tempname + theROS;

 

//parent.window.location.href= tempname;
window.location.target="_self";
window.location.href= tempname;

}



 
if (!RegionData) {
	var RegionData = new Array();
	
	RegionData[0] = new Array(47001,157,157,"All - Anderson",0,0,0,0,0,0);
	RegionData[1] = new Array(47009,158,158,"All - Blount",0,0,0,0,0,0);
	RegionData[2] = new Array(47013,159,159,"All - Campbell",0,0,0,0,0,0);
	RegionData[3] = new Array(47025,160,160,"All - Claiborne",0,0,0,0,0,0);
	RegionData[4] = new Array(47029,161,161,"All - Cocke",0,0,0,0,0,0);
	RegionData[5] = new Array(47035,162,162,"All - Cumberland",0,0,0,0,0,0);
	RegionData[6] = new Array(47049,163,163,"All - Fentress",0,0,0,0,0,0);
	RegionData[7] = new Array(47057,164,164,"All - Grainger",0,0,0,0,0,0);
	RegionData[8] = new Array(47063,165,165,"All - Hamblen",0,0,0,0,0,0);
	RegionData[9] = new Array(47089,166,166,"All - Jefferson",0,0,0,0,0,0);
	RegionData[10] = new Array(47093,167,167,"All - Knox",0,0,0,0,0,0);
	RegionData[11] = new Array(47105,168,168,"All - Loudon",0,0,0,0,0,0);
	RegionData[12] = new Array(47107,169,169,"All - McMinnn",0,0,0,0,0,0);
	RegionData[13] = new Array(47121,170,170,"All - Megs",0,0,0,0,0,0);
	RegionData[14] = new Array(47123,171,171,"All - Monroe",0,0,0,0,0,0);
	RegionData[15] = new Array(47129,172,172,"All - Morgan",0,0,0,0,0,0);
	RegionData[16] = new Array(47143,173,173,"All - Rhea",0,0,0,0,0,0);
	RegionData[17] = new Array(47145,174,174,"All - Roane",0,0,0,0,0,0);
	RegionData[18] = new Array(47151,175,175,"All - Scott",0,0,0,0,0,0);
	RegionData[19] = new Array(47155,176,176,"All - Sevier",0,0,0,0,0,0);
	RegionData[20] = new Array(47173,177,177,"All - Union",0,0,0,0,0,0);
}

//KJS: added this to make the Counties dropdown dynamic

function populateCounties(theForm,ROS) {
	var C = theForm.PCounties;
	var tempValueHolder = "";
	var countiesArray = new Array();
		countiesArray = RegionData;
	var tempCount=2;
	C.options.length = 100;
	C.options.selectedIndex = 0;
	C.options[0].text = "-- Select County --";
	C.options[0].value = 0;
	C.options[1].text = "All Counties";
	C.options[1].value = 0;
	

	
	
	
	for(i=0;i<countiesArray.length;i++) {
		if (countiesArray[i][1] == countiesArray[i][2]) {
		//KJS: we are going to list all counties, not just the ones that have listings
		//	if (ROS=="S") 
		//		{
							 
			//		C.options[tempCount].text = countiesArray[i][3].substring(4); //substring cuts off the unessary "all"
			//	}
			//	else
			//	{
					
				//	C.options[tempCount].text = countiesArray[i][3].substring(4); //substring cuts off the unessary "all"
			//	}

						C.options[tempCount].text = countiesArray[i][3].substring(4); //substring cuts off the unessary "all"
			
				
			C.options[tempCount].value = countiesArray[i][1];
			C.options[1].value = C.options[1].value + "," + countiesArray[i][1];
			tempCount++;

		}
	}
	C.options.length = tempCount;

}




function loadRegions(theForm,pickedSubCounty) {
	var R = theForm.RegionIds;
	var C = theForm.PCounties;
	var L = RegionData;
	var thisCNT = 0;
	var allCountyCNT = 0;	

	var typeIndex = 0;
//alert(R);
	
	R.disabled = false;
	R.className = 'enabled';
	R.selectedIndex = 0;
	R.length = 200;	
	var tempCount;
	tempCount = 1;

if (pickedSubCounty.length > 4){ //then we have the all counties selected
	//alert(pickedSubCounty);
	R[0].text = "All Cities";
	R[0].value = pickedSubCounty;
	R.length = 1;
	
}

else
{
  if (pickedSubCounty == 0) { // then the user selected --pick a county--
	R[0].text = " ";
	R[0].value = 0;
	R.className = 'disabled';
	R.disabled = true;
   }
   else
   {
  

	
	for (x=0;x<L.length;x++) {
		if (L[x][1] == pickedSubCounty) { // then we have found a region in this county
			if (L[x][1] == L[x][2]) { //then we have the ALL regions in county

				if (theForm.passROS.value == "S") {
						if (theForm.filterby[0].checked) {
						allCountyCNT = L[x][8] + L[x][5];  /* ---- CLASSIFIED + BROKER - Sales - All ---- */

					
					} 
				
				
					if (theForm.filterby[1].checked) {
						allCountyCNT = L[x][8];  /* ---- CLASSIFIED - Sales - All ---- */
						//alert('Chronicle Sales All ' + allCountyCNT);
					
					} 
					
					if (theForm.filterby[2].checked) {
						allCountyCNT = L[x][5];  /* ---- BROKER - Sales - All ---- */
						//alert('Chronicle Sales All ' + allCountyCNT);
					
					} 
										 

			}


				if (theForm.passROS.value == "R") {
					if (theForm.filterby[0].checked) {
						allCountyCNT = L[x][7] + L[x][4];  /* ---- CLASSIFIED + BROKER - Rentals - All ---- */
					}
					 
					if (theForm.filterby[1].checked) {
						allCountyCNT = L[x][7];  /* ---- CLASSIFIED - Rentals - All ---- */
					} 
				
					if (theForm.filterby[2].checked) {
						allCountyCNT = L[x][4];  /* ---- BROKER - Rentals - All ---- */
					} 
					
					if (theForm.filterby[3].checked) {
						allCountyCNT = L[x][11];  /* ---- BROKER - Rentals - All ---- */
					} 
				
			}
			
			
	
				if (allCountyCNT > 0) 
				{
				allCountyCNT = addCommas(allCountyCNT);
					R[0].value = L[x][1];
					R[0].text = "*" + L[x][3] + " (" + allCountyCNT + ")";
				
				} else {
				//allCountyCNT = addCommas(allCountyCNT);
					//R[0].value = L[x][1];
					//R[0].text = "*0*" + L[x][3] + " (" + allCountyCNT + ")";
							R[0].text = "No Available Listings";
							R[0].value = 0;
							R.className = 'disabled';
							R.disabled = true;
						
				}

				
									
			}
			else // we are not in the ALL regions of this county
			    {			
			    
			    if (theForm.passROS.value == "S") {
			    
			    	if (theForm.filterby[0].checked) {
						thisCNT = L[x][8] + L[x][5];  /* ---- CLASSIFIED + Broker - Sales - All ---- */

					
					} 
					
					if (theForm.filterby[1].checked) {
						thisCNT = L[x][8];  /* ---- CLASSIFIED - Sales - All ---- */
						//alert('Chronicle Sales All ' + allCountyCNT);
					
					} 
					
					if (theForm.filterby[2].checked) {
						thisCNT = L[x][5];  /* ---- BROKER - Sales - All ---- */
						//alert('Chronicle Sales All ' + allCountyCNT);
					
					} 
										 

				}


				if (theForm.passROS.value == "R") {
					if (theForm.filterby[0].checked) {
						thisCNT = L[x][7] + L[x][4];  /* ---- CLASSIFIED +Broker - Rentals - All ---- */
					} 
					
					if (theForm.filterby[1].checked) {
						thisCNT = L[x][7];  /* ---- CLASSIFIED - Rentals - All ---- */
					} 
				
					if (theForm.filterby[2].checked) {
						thisCNT = L[x][4];  /* ---- BROKER - Rentals - All ---- */
					} 
				
					if (theForm.filterby[3].checked) {
						thisCNT = L[x][11];  /* ---- BROKER - Rentals - All ---- */
					} 
				}
					    
			    
		    
			    
					R[tempCount].value = L[x][2]; 
					R[tempCount].text = L[x][3] + " (" + addCommas(thisCNT) + ")" ;
					tempCount = tempCount + 1;
				}
	
		}
	}

R.length = tempCount;	
 } //end user selected --pick county--
} //end if not all counties selected

}



function doSearch(theForm) {
	var R = theForm.RegionIds;
	var C = theForm.PCounties;
	var L = RegionData;
	
	
	if (C.selectedIndex == 0) {
		window.alert("Please select a county to begin your search.");
		C.focus();
		return;
	}
	if (R.options[R.selectedIndex].value == 0) {
		window.alert("Sorry, there are no listings available in your selection at this time. \n\nPlease choose another area to begin your search.");
		C.focus();
		return;
	}
	if (C.selectedIndex > 0 || C.length == 1) {
	
		C.disabled = false;
		R.disabled = false;
		theForm.PC.value = C.selectedIndex-1;
		checkFilters(theForm);
		theForm.submit();
		
	} else {
		/* ---- 	to search in an entire county, the sub-county IDS need to be gathered.  ---- */
		var tempSubCounties = '';
		var theCounty = C.options[C.selectedIndex].value;
		theCounty = Math.round(theCounty); /* ----  we convert the county to a number dropping the leading zero  ---- */
		for (x=0;L[x][2]<100;x++) { /* ----  we only need counties, so we only loop until the countyID threshhold has been reached in RegionID  ---- */
			loopCounty = L[x][0];
			if (theCounty == loopCounty) {
				tempSubCounties += L[x][1] + ',';
			}
		}

		R.options[0].value = tempSubCounties;
		R.selectedIndex = 0;
		R.disabled = false;
		
		theForm.PC.value = C.selectedIndex-1;
		checkFilters(theForm);
		theForm.submit();
	}
}
 
 
function checkFilters(theForm) {
	var theGoType;
	
	if (theForm.filterby[0].checked) { // then we want all results
	 theForm.CType.value = 'A';
	//theForm.cid.value = '999';
	} 
	
	if (theForm.filterby[1].checked) {// then we want classified results only
		 theForm.CType.value = 'C';

	} 
	
	if (theForm.filterby[2].checked) {
		 theForm.CType.value = 'B'; // then we want broker results only

	} 
	
	if (theForm.filterby[3].checked) {
		 theForm.CType.value = 'M'; // then we want community results only

	} 

	
		if (theForm.passROS.value == 'R') {
			theGoType= "Rentals";
		} else {
			theGoType= "Sales";
		}


	switch(theForm.GoNid.value) {

	case '101': 
  		theForm.action="../" + theGoType + "/SearchResults.asp";
  		break;
	case '102': 
	  	theForm.action="http://realestate.venturacountystar.com/RealEstate/" + theGoType + "/SearchResults.asp";
  		break;
	case '103': 
 		theForm.action="http://realestate.caller.com/RealEstate/" + theGoType + "/SearchResults.asp";
  		break;
	case '104': 
  		theForm.action="http://realestate.courierpress.com/RealEstate/" + theGoType + "/SearchResults.asp";
  		break;
	case '105': 
  		theForm.action="http://realestate.reporter-news.com/RealEstate/" + theGoType + "/SearchResults.asp";
  		break;
	case '106': 
 		 theForm.action="http://realestate.kitsapsun.com/RealEstate/" + theGoType + "/SearchResults.asp";
  		break;
	case '107': 
  		theForm.action="http://realestate.tcpalm.com/RealEstate/" + theGoType + "/SearchResults.asp";
  		break;
	case '108': 
  		theForm.action="http://realestate.naplesnews.com/RealEstate/" + theGoType + "/SearchResults.asp";
	  	break;
	case '109': 
  		theForm.action="http://realestate.timesrecordnews.com/RealEstate/" + theGoType + "/SearchResults.asp";
 	 	break;
	case '110': 
 		theForm.action="http://realestate.redding.com/RealEstate/" + theGoType + "/SearchResults.asp";
  		break;
	case '111': 
  		theForm.action="http://realestate.dailycamera.com/RealEstate/" + theGoType + "/SearchResults.asp";
  		break;
	case '112': 
 		theForm.action="http://realestate.sanangelostandardtimes.com/RealEstate/" + theGoType + "/SearchResults.asp";
  		break;
	case '113': 
  		theForm.action="http://realestate.independentmail.com/RealEstate/" + theGoType + "/SearchResults.asp";
  		break;
	case '114': 
		  theForm.action="http://realestate.knoxnews.com/RealEstate/" + theGoType + "/SearchResults.asp";
		  break;
	case '115': 
  		theForm.action="http://realestate.marconews.com/RealEstate/" + theGoType + "/SearchResults.asp";
  		break;
  	default:
		  alert("Please select a newspaper!");
			break;
	}	


}



function addCommas(theNumber) {
	theNumber = '' + theNumber;
	if (theNumber.length > 3) {
		var mod = theNumber.length % 3;
		var formattedNumber = (mod > 0 ? (theNumber.substring(0,mod)) : '');
		for (i=0;i<Math.floor(theNumber.length/3);i++) {
			if ((mod == 0) && (i == 0)) {
				formattedNumber += theNumber.substring(mod+ 3 * i, mod + 3 * i + 3);
			} else {
				formattedNumber+= ',' + theNumber.substring(mod + 3 * i, mod + 3 * i + 3);
			}
		}
		return (formattedNumber);
	} else {
		return theNumber;
	}
}

function resetRegions(theForm) {
	var R = theForm.RegionIds;
	var P = theForm.PCounties;
	
		
		R.length = 1;
		R.options[0].value = '';
		R.options[0].text = '';
		R.selectedIndex = 0;
		R.disabled = true;
		R.className = 'disabled';
		
		theForm.PCounties.selectedIndex = 0;
		
}


function searchType(searchType) {
	hideAllSearchType();
	eval("document.getElementById('" + searchType + "').className = 'Search-Live';");
}

function hideAllSearchType() {
	var mySearches = new Array('ByCounty','ByCity','ByAddress','ByZipcode','ByMLS');
	for (x=0;x<mySearches.length;x++) {
		document.getElementById(mySearches[x]).className = 'Search-Dead';
	}
}

function trim(str){ 
	return str.replace(/^\s+|\s+$/gm,''); 
}

function doCitySearch(goType,goNID) {
	
	var theForm = document.citysearch;
	
	if (trim(theForm.searchby.value).length < 1) {
		window.alert("Please enter a search term for your city search");
		theForm.searchby.value = trim(theForm.searchby.value);
		theForm.searchby.focus();
		return;
	}
	theForm.target="_parent";
	theForm.submit();
}

function doAddressSearch(goType,goNID) {
	
	var theForm = document.searchAddress;
		switch(goNID) {

	case '101': 
  		theForm.action="../" + goType + "/SearchResults.asp";
  		break;
	case '102': 
	  	theForm.action="http://realestate.venturacountystar.com/RealEstate/" + goType + "/SearchResults.asp";
  		break;
	case '103': 
 		theForm.action="http://realestate.caller.com/RealEstate/" + goType + "/SearchResults.asp";
  		break;
	case '104': 
  		theForm.action="http://realestate.courierpress.com/RealEstate/" + goType + "/SearchResults.asp";
  		break;
	case '105': 
  		theForm.action="http://realestate.reporter-news.com/RealEstate/" + goType + "/SearchResults.asp";
  		break;
	case '106': 
 		 theForm.action="http://realestate.kitsapsun.com/RealEstate/" + goType + "/SearchResults.asp";
  		break;
	case '107': 
  		theForm.action="http://realestate.tcpalm.com/RealEstate/" + goType + "/SearchResults.asp";
  		break;
	case '108': 
  		theForm.action="http://realestate.naplesnews.com/RealEstate/" + goType + "/SearchResults.asp";
	  	break;
	case '109': 
  		theForm.action="http://realestate.timesrecordnews.com/RealEstate/" + goType + "/SearchResults.asp";
 	 	break;
	case '110': 
 		theForm.action="http://realestate.redding.com/RealEstate/" + goType + "/SearchResults.asp";
  		break;
	case '111': 
  		theForm.action="http://realestate.dailycamera.com/RealEstate/" + goType + "/SearchResults.asp";
  		break;
	case '112': 
 		theForm.action="http://realestate.sanangelostandardtimes.com/RealEstate/" + goType + "/SearchResults.asp";
  		break;
	case '113': 
  		theForm.action="http://realestate.independentmail.com/RealEstate/" + goType + "/SearchResults.asp";
  		break;
	case '114': 
		  theForm.action="http://realestate.knoxnews.com/RealEstate/" + goType + "/SearchResults.asp";
		  break;
	case '115': 
  		theForm.action="http://realestate.marconews.com/RealEstate/" + goType + "/SearchResults.asp";
  		break;
  	default:
		  alert("Please select a newspaper!");
			break;
	}
	
	
	if (trim(theForm.searchby.value).length < 1) {
		window.alert("Please enter a search term for your address search");
		theForm.searchby.value = trim(theForm.searchby.value);
		theForm.searchby.focus();
		return;
	}
	theForm.target="_parent";
	theForm.submit();
}


function doMLSSearch(goType,goNID) {

	var theForm = document.searchMLS;
		switch(goNID) {

	case '101': 
  		theForm.action="../" + goType + "/SearchResults.asp";
  		break;
	case '102': 
	  	theForm.action="http://realestate.venturacountystar.com/RealEstate/" + goType + "/SearchResults.asp";
  		break;
	case '103': 
 		theForm.action="http://realestate.caller.com/RealEstate/" + goType + "/SearchResults.asp";
  		break;
	case '104': 
  		theForm.action="http://realestate.courierpress.com/RealEstate/" + goType + "/SearchResults.asp";
  		break;
	case '105': 
  		theForm.action="http://realestate.reporter-news.com/RealEstate/" + goType + "/SearchResults.asp";
  		break;
	case '106': 
 		 theForm.action="http://realestate.kitsapsun.com/RealEstate/" + goType + "/SearchResults.asp";
  		break;
	case '107': 
  		theForm.action="http://realestate.tcpalm.com/RealEstate/" + goType + "/SearchResults.asp";
  		break;
	case '108': 
  		theForm.action="http://realestate.naplesnews.com/RealEstate/" + goType + "/SearchResults.asp";
	  	break;
	case '109': 
  		theForm.action="http://realestate.timesrecordnews.com/RealEstate/" + goType + "/SearchResults.asp";
 	 	break;
	case '110': 
 		theForm.action="http://realestate.redding.com/RealEstate/" + goType + "/SearchResults.asp";
  		break;
	case '111': 
  		theForm.action="http://realestate.dailycamera.com/RealEstate/" + goType + "/SearchResults.asp";
  		break;
	case '112': 
 		theForm.action="http://realestate.sanangelostandardtimes.com/RealEstate/" + goType + "/SearchResults.asp";
  		break;
	case '113': 
  		theForm.action="http://realestate.independentmail.com/RealEstate/" + goType + "/SearchResults.asp";
  		break;
	case '114': 
		  theForm.action="http://realestate.knoxnews.com/RealEstate/" + goType + "/SearchResults.asp";
		  break;
	case '115': 
  		theForm.action="http://realestate.marconews.com/RealEstate/" + goType + "/SearchResults.asp";
  		break;
  	default:
		  alert("Please select a newspaper!");
			break;
	}
	
	if (trim(theForm.searchby.value).length < 1) {
		window.alert("Please enter a sWeb ID or MLS ID");
		theForm.searchby.value = trim(theForm.searchby.value);
		theForm.searchby.focus();
		return;
	}
	theForm.target="_parent";
	theForm.submit();

}

function doAdvancedSearch(goType,goNID, numbADV) {
var tempstring = "searchADV" + numbADV;
//alert(tempstring);
	var theForm = document.forms[tempstring];
	
	switch(goNID) {

	case '101': 
	  		theForm.action="../" + goType + "/SearchIndex.asp";
  		break;
	case '102': 
	  	window.location="http://realestate.venturacountystar.com/RealEstate/" + goType + "/";
  		break;
	case '103': 
 		window.location="http://realestate.caller.com/RealEstate/" + goType + "/";
  		break;
	case '104': 
  		window.location="http://realestate.courierpress.com/RealEstate/" + goType + "/";
  		break;
	case '105': 
  		window.location="http://realestate.reporter-news.com/RealEstate/" + goType + "/";
  		break;
	case '106': 
 		 window.location="http://realestate.kitsapsun.com/RealEstate/" + goType + "/";
  		break;
	case '107': 
  		window.location="http://realestate.tcpalm.com/RealEstate/" + goType + "/";
  		break;
	case '108': 
  		window.location="http://realestate.naplesnews.com/RealEstate/" + goType + "/";
	  	break;
	case '109': 
  		window.location="http://realestate.timesrecordnews.com/RealEstate/" + goType + "/";
 	 	break;
	case '110': 
 		window.location="http://realestate.redding.com/RealEstate/" + goType + "/";
  		break;
	case '111': 
  		window.location="http://realestate.dailycamera.com/RealEstate/" + goType + "/";
  		break;
	case '112': 
 		window.location="http://realestate.sanangelostandardtimes.com/RealEstate/" + goType + "/";
  		break;
	case '113': 
  		window.location="http://realestate.independentmail.com/RealEstate/" + goType + "/";
  		break;
	case '114': 
		  window.location="http://realestate.knoxnews.com/RealEstate/" + goType + "/";
		  break;
	case '115': 
  		window.location="http://realestate.marconews.com/RealEstate/" + goType + "/";
  		break;
  	default:
		  alert("Please select a newspaper!");
			break;
	}
			theForm.target="_parent";
			//alert(theForm.target);
			theForm.submit();

}


function doZipcodeSearch(goType,goNID) {
	

	var theForm = document.searchZipcode;
	
			switch(goNID) {

	case '101': 
  		theForm.action="../" + goType + "/SearchResults.asp";
  		break;
	case '102': 
	  	theForm.action="http://realestate.venturacountystar.com/RealEstate/" + goType + "/SearchResults.asp";
  		break;
	case '103': 
 		theForm.action="http://realestate.caller.com/RealEstate/" + goType + "/SearchResults.asp";
  		break;
	case '104': 
  		theForm.action="http://realestate.courierpress.com/RealEstate/" + goType + "/SearchResults.asp";
  		break;
	case '105': 
  		theForm.action="http://realestate.reporter-news.com/RealEstate/" + goType + "/SearchResults.asp";
  		break;
	case '106': 
 		 theForm.action="http://realestate.kitsapsun.com/RealEstate/" + goType + "/SearchResults.asp";
  		break;
	case '107': 
  		theForm.action="http://realestate.tcpalm.com/RealEstate/" + goType + "/SearchResults.asp";
  		break;
	case '108': 
  		theForm.action="http://realestate.naplesnews.com/RealEstate/" + goType + "/SearchResults.asp";
	  	break;
	case '109': 
  		theForm.action="http://realestate.timesrecordnews.com/RealEstate/" + goType + "/SearchResults.asp";
 	 	break;
	case '110': 
 		theForm.action="http://realestate.redding.com/RealEstate/" + goType + "/SearchResults.asp";
  		break;
	case '111': 
  		theForm.action="http://realestate.dailycamera.com/RealEstate/" + goType + "/SearchResults.asp";
  		break;
	case '112': 
 		theForm.action="http://realestate.sanangelostandardtimes.com/RealEstate/" + goType + "/SearchResults.asp";
  		break;
	case '113': 
  		theForm.action="http://realestate.independentmail.com/RealEstate/" + goType + "/SearchResults.asp";
  		break;
	case '114': 
		  theForm.action="http://realestate.knoxnews.com/RealEstate/" + goType + "/SearchResults.asp";
		  break;
	case '115': 
  		theForm.action="http://realestate.marconews.com/RealEstate/" + goType + "/SearchResults.asp";
  		break;
  	default:
		  alert("Please select a newspaper!");
			break;
	}
	
	if (trim(theForm.searchby.value).length < 1) {
		window.alert("Please enter a Zip code");
		theForm.searchby.value = trim(theForm.searchby.value);
		theForm.searchby.focus();
		return;
	}
	
	
	var kj = "";
	var numbcheck=/(^\d+$)|(^\d+\.\d+$)/;
	var kjArray = theForm.searchby.value.split(",");
		for(var i = 0; i < kjArray.length; i++)
		        {
       			kjArray[i] = kjArray[i].substring(0,5);
			    if (numbcheck.test(kjArray[i])) 
			        {
			         if (kj =="") // first time through do not add the comma
			          {
			          kj = kjArray[i];
			          }
			          else
			          {
			           kj = kj + ", " + kjArray[i];
			          }
			        }
			        else 
			        {
			        kjArray = theForm.searchby.value.split(","); //
			        kj = kjArray[i] + " is not a valid zip code!" ; //one of the zipcodes was not a number
			        i = (kjArray.length -1);
			        kjArray[0] = -1;
			        
					}    
			
			
		        }

 
	if (kjArray[0]== -1) // let the user know that they typed something in wrong
	    {
	    alert("Error: " +kj);
	    }
	    else
	      {
	//alert("sub " +kj);
	theForm.searchby.value = kj;
	theForm.RegionIds.value = theForm.searchby.value; 
	theForm.target="_parent";
	theForm.submit();
	      }

	

	
	
	
	
	

}

