

var myTTimer = setTimeout('loadDefault()',110);

function loadDefault() {
	tmpstr= location.search.substr(1);

	if ((location.search=="") || (tmpstr.indexOf("RoS=S")>-1)) 
	{
		//alert("goingt to sales");
		populateCounties(document.sales,"S");
	} 
	else 
	{	
		//alert("goingt to rentals");
		populateCounties(document.rentals,"R");
	}
}

function Repage(theROS, NID)
{
	var tempname;
	tempname = "";
	tempname = tempname + "quicksearch.asp?RoS=";
	tempname = tempname + theROS;

	window.location.target="_self";
	window.location.href= tempname;
}

if (!RegionData) {
	var RegionData = new Array();
	
	RegionData[0] = new Array('All Benton County',10,10,'All Benton County',0,0,0,0,0,0,0,0);
	RegionData[1] = new Array('All Buchanan County',11,11,'All Buchanan County',0,0,0,0,0,0,0,0);
	RegionData[2] = new Array('All Cedar County',12,12,'All Cedar County',0,0,0,0,0,0,0,0);
	RegionData[3] = new Array('All Delaware County',13,13,'All Delaware County',0,0,0,0,0,0,0,0);
	RegionData[4] = new Array('All Iowa County',14,14,'All Iowa County',0,0,0,0,0,0,0,0);
	RegionData[5] = new Array('All Johnson County',15,15,'All Johnson County',0,0,0,0,0,0,0,0);
	RegionData[6] = new Array('All Jones County',16,16,'All Jones County',0,0,0,0,0,0,0,0);
	RegionData[7] = new Array('All Linn County',17,17,'All Linn County',0,0,0,0,0,0,0,0);
	RegionData[8] = new Array('All Washington County',18,18,'All Washington County',0,0,0,0,0,0,0,0);
	RegionData[9] = new Array('All Tama County',20,20,'All Tama County',0,0,0,0,0,0,0,0);
	RegionData[10] = new Array('All Black Hawk County',21,21,'All Black Hawk County',0,0,0,0,0,0,0,0);
	RegionData[11] = new Array('All Other Counties',99,99,'All Other Counties',0,0,0,0,0,0,0,0);
	RegionData[12] = new Array('Atkins',10,1000,'Atkins',0,0,0,0,0,0,0,0);
	RegionData[13] = new Array('Belle Plaine',10,1010,'Belle Plaine',0,0,0,0,0,0,0,0);
	RegionData[14] = new Array('Blairstown',10,1020,'Blairstown',0,0,0,0,0,0,0,0);
	RegionData[15] = new Array('Garrison',10,1030,'Garrison',0,0,0,0,0,0,0,0);
	RegionData[16] = new Array('Keystone',10,1040,'Keystone',0,0,0,0,0,0,0,0);
	RegionData[17] = new Array('Newhall',10,1070,'Newhall',0,0,0,0,0,0,0,0);
	RegionData[18] = new Array('Walford',10,1080,'Walford',0,0,0,0,0,0,0,0);
	RegionData[19] = new Array('Shellsburg',10,1090,'Shellsburg',0,0,0,0,0,0,0,0);
	RegionData[20] = new Array('Van Horne',10,1100,'Van Horne',0,0,0,0,0,0,0,0);
	RegionData[21] = new Array('Vinton',10,1110,'Vinton',0,0,0,0,0,0,0,0);
	RegionData[22] = new Array('Aurora',11,1130,'Aurora',0,0,0,0,0,0,0,0);
	RegionData[23] = new Array('Independence',11,1170,'Independence',0,0,0,0,0,0,0,0);
	RegionData[24] = new Array('Lamont',11,1190,'Lamont',0,0,0,0,0,0,0,0);
	RegionData[25] = new Array('Quasqueton',11,1200,'Quasqueton',0,0,0,0,0,0,0,0);
	RegionData[26] = new Array('Rowley',11,1210,'Rowley',0,0,0,0,0,0,0,0);
	RegionData[27] = new Array('Winthrop',11,1230,'Winthrop',0,0,0,0,0,0,0,0);
	RegionData[28] = new Array('Clarence',12,1250,'Clarence',0,0,0,0,0,0,0,0);
	RegionData[29] = new Array('Lowden',12,1270,'Lowden',0,0,0,0,0,0,0,0);
	RegionData[30] = new Array('Mechanicsville',12,1280,'Mechanicsville',0,0,0,0,0,0,0,0);
	RegionData[31] = new Array('Tipton',12,1300,'Tipton',0,0,0,0,0,0,0,0);
	RegionData[32] = new Array('West Branch',12,1310,'West Branch',0,0,0,0,0,0,0,0);
	RegionData[33] = new Array('Delhi',13,1340,'Delhi',0,0,0,0,0,0,0,0);
	RegionData[34] = new Array('Earlville',13,1360,'Earlville',0,0,0,0,0,0,0,0);
	RegionData[35] = new Array('Hopkinton',13,1380,'Hopkinton',0,0,0,0,0,0,0,0);
	RegionData[36] = new Array('Manchester',13,1390,'Manchester',0,0,0,0,0,0,0,0);
	RegionData[37] = new Array('Ryan',13,1410,'Ryan',0,0,0,0,0,0,0,0);
	RegionData[38] = new Array('Amana',14,1420,'Amana',0,0,0,0,0,0,0,0);
	RegionData[39] = new Array('Conroy',14,1430,'Conroy',0,0,0,0,0,0,0,0);
	RegionData[40] = new Array('Homestead',14,1440,'Homestead',0,0,0,0,0,0,0,0);
	RegionData[41] = new Array('Ladora',14,1450,'Ladora',0,0,0,0,0,0,0,0);
	RegionData[42] = new Array('Marengo',14,1460,'Marengo',0,0,0,0,0,0,0,0);
	RegionData[43] = new Array('Millersburg',14,1480,'Millersburg',0,0,0,0,0,0,0,0);
	RegionData[44] = new Array('North English',14,1490,'North English',0,0,0,0,0,0,0,0);
	RegionData[45] = new Array('Parnell',14,1500,'Parnell',0,0,0,0,0,0,0,0);
	RegionData[46] = new Array('South Amana',14,1510,'South Amana',0,0,0,0,0,0,0,0);
	RegionData[47] = new Array('Williamsburg',14,1530,'Williamsburg',0,0,0,0,0,0,0,0);
	RegionData[48] = new Array('Coralville',15,1540,'Coralville',0,0,0,0,0,0,0,0);
	RegionData[49] = new Array('Iowa City',15,1550,'Iowa City',0,0,0,0,0,0,0,0);
	RegionData[50] = new Array('Lone Tree',15,1560,'Lone Tree',0,0,0,0,0,0,0,0);
	RegionData[51] = new Array('North Liberty',15,1570,'North Liberty',0,0,0,0,0,0,0,0);
	RegionData[52] = new Array('Oxford',15,1580,'Oxford',0,0,0,0,0,0,0,0);
	RegionData[53] = new Array('Solon',15,1590,'Solon',0,0,0,0,0,0,0,0);
	RegionData[54] = new Array('Swisher',15,1600,'Swisher',0,0,0,0,0,0,0,0);
	RegionData[55] = new Array('Tiffin',15,1610,'Tiffin',0,0,0,0,0,0,0,0);
	RegionData[56] = new Array('Anamosa',16,1620,'Anamosa',0,0,0,0,0,0,0,0);
	RegionData[57] = new Array('Martelle',16,1640,'Martelle',0,0,0,0,0,0,0,0);
	RegionData[58] = new Array('Monticello',16,1650,'Monticello',0,0,0,0,0,0,0,0);
	RegionData[59] = new Array('Olin',16,1660,'Olin',0,0,0,0,0,0,0,0);
	RegionData[60] = new Array('Alburnett',17,1700,'Alburnett',0,0,0,0,0,0,0,0);
	RegionData[61] = new Array('Cedar Rapids',17,1710,'Cedar Rapids',0,0,0,0,0,0,0,0);
	RegionData[62] = new Array('Center Point',17,1720,'Center Point',0,0,0,0,0,0,0,0);
	RegionData[63] = new Array('Central City',17,1730,'Central City',0,0,0,0,0,0,0,0);
	RegionData[64] = new Array('Ely',17,1750,'Ely',0,0,0,0,0,0,0,0);
	RegionData[65] = new Array('Fairfax',17,1760,'Fairfax',0,0,0,0,0,0,0,0);
	RegionData[66] = new Array('Hiawatha',17,1770,'Hiawatha',0,0,0,0,0,0,0,0);
	RegionData[67] = new Array('Lisbon',17,1780,'Lisbon',0,0,0,0,0,0,0,0);
	RegionData[68] = new Array('Marion',17,1790,'Marion',0,0,0,0,0,0,0,0);
	RegionData[69] = new Array('Mount Vernon',17,1800,'Mount Vernon',0,0,0,0,0,0,0,0);
	RegionData[70] = new Array('Palo',17,1810,'Palo',0,0,0,0,0,0,0,0);
	RegionData[71] = new Array('Prairieburg',17,1820,'Prairieburg',0,0,0,0,0,0,0,0);
	RegionData[72] = new Array('Robins',17,1830,'Robins',0,0,0,0,0,0,0,0);
	RegionData[73] = new Array('Springville',17,1840,'Springville',0,0,0,0,0,0,0,0);
	RegionData[74] = new Array('Toddville',17,1850,'Toddville',0,0,0,0,0,0,0,0);
	RegionData[75] = new Array('Walker',17,1860,'Walker',0,0,0,0,0,0,0,0);
	RegionData[76] = new Array('Ainsworth',18,1870,'Ainsworth',0,0,0,0,0,0,0,0);
	RegionData[77] = new Array('Crawfordsville',18,1890,'Crawfordsville',0,0,0,0,0,0,0,0);
	RegionData[78] = new Array('Kalona',18,1900,'Kalona',0,0,0,0,0,0,0,0);
	RegionData[79] = new Array('Riverside',18,1910,'Riverside',0,0,0,0,0,0,0,0);
	RegionData[80] = new Array('Wellman',18,1930,'Wellman',0,0,0,0,0,0,0,0);
	RegionData[81] = new Array('Dysart',20,1960,'Dysart',0,0,0,0,0,0,0,0);
	RegionData[82] = new Array('La Porte City',21,1970,'La Porte City',0,0,0,0,0,0,0,0);
	RegionData[83] = new Array('Traer',20,1980,'Traer',0,0,0,0,0,0,0,0);
	RegionData[84] = new Array('Other Areas',99,9999,'Other Areas',0,0,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 = 1;
	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]) {
			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;
	
	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
		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.value == "none") {
								allCountyCNT = L[x][8] + L[x][5];  /* ---- CLASSIFIED + BROKER - Sales - All ---- */
							} 
					
							if (theForm.filterby.value == "classified") {
								allCountyCNT = L[x][8];  /* ---- CLASSIFIED - Sales - All ---- */
							} 
						
							if (theForm.filterby.value == "broker") {
								allCountyCNT = L[x][5];  /* ---- BROKER - Sales - All ---- */
							} 
											 
							if (theForm.filterby.value == "openhouse") {
								allCountyCNT = L[x][6];  /* ---- BROKER - Sales - Openhouse ---- */
							} 										
						}
	
	
						if (theForm.passROS.value == "R") {
							if (theForm.filterby.value == "none") {
								allCountyCNT = L[x][7] + L[x][4];  /* ---- CLASSIFIED + BROKER - Rentals - All ---- */
							}
							 
							if (theForm.filterby.value == "classified") {
								allCountyCNT = L[x][7];  /* ---- CLASSIFIED - Rentals - All ---- */
							} 
						
							if (theForm.filterby.value == "broker") {
								allCountyCNT = L[x][4];  /* ---- BROKER - Rentals - All ---- */
							} 		
						}
				
				
		
						if (allCountyCNT > 0) 
						{
							allCountyCNT = addCommas(allCountyCNT);
							R[0].value = L[x][1];
							R[0].text = "*" + L[x][3] + " (" + allCountyCNT + ")";
						
						} 
						else 
						{
							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.value == "none") {
								thisCNT = L[x][8] + L[x][5];  /* ---- CLASSIFIED + Broker - Sales - All ---- */
							} 
							
							if (theForm.filterby.value == "classified") {
								thisCNT = L[x][8];  /* ---- CLASSIFIED - Sales - All ---- */
							} 
						
							if (theForm.filterby.value == "broker") {
								thisCNT = L[x][5];  /* ---- BROKER - Sales - All ---- */
							} 
											 
							if (theForm.filterby.value == "openhouse") {
								allCountyCNT = L[x][6];  /* ---- BROKER - Sales - Openhouse ---- */
							} 										
						}
	
						if (theForm.passROS.value == "R") {
							if (theForm.filterby.value == "none") {
								thisCNT = L[x][7] + L[x][4];  /* ---- CLASSIFIED +Broker - Rentals - All ---- */
							} 
							
							if (theForm.filterby.value == "classified") {
								thisCNT = L[x][7];  /* ---- CLASSIFIED - Rentals - All ---- */
							} 
						
							if (theForm.filterby.value == "broker") {
								thisCNT = L[x][4];  /* ---- 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.value == "none") { // then we want all results
	 theForm.CType.value = 'A';
	//theForm.cid.value = '999';
	} 
	
	if (theForm.filterby.value == "broker") {// then we want classified results only
		 theForm.CType.value = 'B';

	} 
	
	if (theForm.filterby.value == "classified") {
		 theForm.CType.value = 'C'; // then we want broker results only

	} 
	
	if (theForm.filterby.value == "openhouse") {
		 theForm.CType.value = 'A'; // then we want community results only
		 theForm.OH.value = 'Y';
	} 

	
	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 = '0,10,11,12,13,14,15,16,17,18,99';
		R.options[0].text = 'All Cities';
		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
	{
		theForm.searchby.value = kj;
		theForm.RegionIds.value = theForm.searchby.value; 
		theForm.target="_parent";
		theForm.submit();
	}
}