<!--
function MLSSearchPreloadImages( rpmZone ) {
  if (document.images)
  {
    if (rpmZone == 1)
    {
    //preload the edmonton pictures.
    map_level1_edmonton = new Image; map_level1_edmonton.src		="../resources/searchpicsthin/map_level1_edmonton.jpg";
    map_level2_edmonton = new Image; map_level2_edmonton.src		="../resources/searchpicsthin/map_level2_edmonton.jpg";
    map_level2_ruralnortheast = new Image; map_level2_ruralnortheast.src="../resources/searchpicsthin/map_level2_ruralnortheast.jpg";
    map_level2_ruralnorthwest = new Image; map_level2_ruralnorthwest.src="../resources/searchpicsthin/map_level2_ruralnorthwest.jpg";
    map_level2_ruralsoutheast = new Image; map_level2_ruralsoutheast.src="../resources/searchpicsthin/map_level2_ruralsoutheast.jpg";
    map_level2_ruralsouthwest = new Image; map_level2_ruralsouthwest.src="../resources/searchpicsthin/map_level2_ruralsouthwest.jpg";
    map_level3_central = new Image; map_level3_central.src		="../resources/searchpicsthin/map_level3_central.jpg";
    map_level3_northeast = new Image; map_level3_northeast.src		="../resources/searchpicsthin/map_level3_northeast.jpg";
    map_level3_northwest = new Image; map_level3_northwest.src		="../resources/searchpicsthin/map_level3_northwest.jpg";
    map_level3_southeast = new Image; map_level3_southeast.src		="../resources/searchpicsthin/map_level3_southeast.jpg";
    map_level3_southwest = new Image; map_level3_southwest.src		="../resources/searchpicsthin/map_level3_southwest.jpg";
    map_level3_west = new Image; map_level3_west.src			="../resources/searchpicsthin/map_level3_west.jpg";
    }
    if (rpmZone == 2)
    {
    //preload the calgary pictures.
    map_level1_calgary = new Image; map_level1_calgary.src	="../resources/searchpicsthin/map_level1_calgary.jpg";
    map_level2_calgary = new Image; map_level2_calgary.src	="../resources/searchpicsthin/map_level2_calgary.jpg";
    map_level3_districta = new Image; map_level3_districta.src	="../resources/searchpicsthin/map_level3_districta.jpg";
    map_level3_districtb = new Image; map_level3_districtb.src	="../resources/searchpicsthin/map_level3_districtb.jpg";
    map_level3_districtc = new Image; map_level3_districtc.src	="../resources/searchpicsthin/map_level3_districtc.jpg";
    map_level3_districtd = new Image; map_level3_districtd.src	="../resources/searchpicsthin/map_level3_districtd.jpg";
    }
    if (rpmZone == 4) {
	//Preload the vancouver pictures.
	map_level1_sw_bc 		= new Image; map_level1_sw_bc.src		="../resources/searchpicsthin/vancouver/southwesternbc.jpg";
	map_level2_chilliwack_area 	= new Image; map_level2_chilliwack_area.src	="../resources/searchpicsthin/vancouver/chilliwackarea.jpg";
	map_level3_chilliwack		= new Image; map_level3_chilliwack.src		="../resources/searchpicsthin/vancouver/chilliwack.jpg";

	map_level3_chilliwack_from_fraser_valley = new Image; map_level3_chilliwack_from_fraser_valley.src ="../resources/searchpicsthin/vancouver/chilliwack.jpg";

	map_level2_fraser_valley		= new Image; map_level2_fraser_valley.src		="../resources/searchpicsthin/vancouver/fraservalley.jpg";
	map_level3_fraser_valley_abbotsford 	= new Image; map_level3_fraser_valley_abbotsford.src	="../resources/searchpicsthin/vancouver/abbotsford.jpg";
	map_level3_fraser_valley_cloverdale 	= new Image; map_level3_fraser_valley_cloverdale.src	="../resources/searchpicsthin/vancouver/cloverdale.jpg";
	map_level3_fraser_valley_langley 	= new Image; map_level3_fraser_valley_langley.src	="../resources/searchpicsthin/vancouver/langley.jpg";
	map_level3_fraser_valley_mission 	= new Image; map_level3_fraser_valley_mission.src	="../resources/searchpicsthin/vancouver/mission.jpg";
	map_level3_fraser_valley_north_delta 	= new Image; map_level3_fraser_valley_north_delta.src	="../resources/searchpicsthin/vancouver/northdelta.jpg";
	map_level3_fraser_valley_north_surrey 	= new Image; map_level3_fraser_valley_north_surrey.src	="../resources/searchpicsthin/vancouver/northsurrey.jpg";
	map_level3_fraser_valley_surrey 	= new Image; map_level3_fraser_valley_surrey.src	="../resources/searchpicsthin/vancouver/surrey.jpg";
	map_level3_fraser_valley_white_rock 	= new Image; map_level3_fraser_valley_white_rock.src	="../resources/searchpicsthin/vancouver/whiterock.jpg";

	map_level2_gtr_van			= new Image; map_level2_gtr_van.src			="../resources/searchpicsthin/vancouver/greatervancouver.jpg";
	map_level3_gtr_van_burnaby		= new Image; map_level3_gtr_van_burnaby.src		="../resources/searchpicsthin/vancouver/burnaby.jpg";
	map_level3_gtr_van_coquitlam		= new Image; map_level3_gtr_van_coquitlam.src		="../resources/searchpicsthin/vancouver/coquitlam.jpg";
	map_level3_gtr_van_ladner		= new Image; map_level3_gtr_van_ladner.src		="../resources/searchpicsthin/vancouver/ladner.jpg";
	map_level3_gtr_van_maple_ridge		= new Image; map_level3_gtr_van_maple_ridge.src	="../resources/searchpicsthin/vancouver/mapleridge.jpg";
	map_level3_gtr_van_north_van		= new Image; map_level3_gtr_van_north_van.src	="../resources/searchpicsthin/vancouver/northvancouver.jpg";
	map_level3_gtr_van_new_westminster	= new Image; map_level3_gtr_van_new_westminster.src	="../resources/searchpicsthin/vancouver/newwestminster.jpg";
	map_level3_gtr_van_port_coquitlam	= new Image; map_level3_gtr_van_port_coquitlam.src	="../resources/searchpicsthin/vancouver/portcoquitlam.jpg";
	map_level3_gtr_van_port_moody		= new Image; map_level3_gtr_van_port_moody.src	="../resources/searchpicsthin/vancouver/portmoody.jpg";
	map_level3_gtr_van_richmond		= new Image; map_level3_gtr_van_richmond.src	="../resources/searchpicsthin/vancouver/richmond.jpg";
	map_level3_gtr_van_tsawwassen		= new Image; map_level3_gtr_van_tsawwassen.src	="../resources/searchpicsthin/vancouver/tsawwassen.jpg";
	map_level3_gtr_van_van_east		= new Image; map_level3_gtr_van_van_east.src	="../resources/searchpicsthin/vancouver/vancouvereast.jpg";
	map_level3_gtr_van_van_west		= new Image; map_level3_gtr_van_van_west.src	="../resources/searchpicsthin/vancouver/vancouverwest.jpg";
	map_level3_gtr_van_west_van		= new Image; map_level3_gtr_van_west_van.src	="../resources/searchpicsthin/vancouver/westvancouver.jpg";

	map_level2_sunshine_coast		= new Image; map_level2_sunshine_coast.src	="../resources/searchpicsthin/vancouver/sunshinecoast.jpg";

	map_level2_vancouver_island		= new Image; map_level2_vancouver_island.src	="../resources/searchpicsthin/vancouver/vancouverisland.jpg";
	map_level3_vancouver_island_campbell_river	= new Image; map_level3_vancouver_island_campbell_river.src	="../resources/searchpicsthin/vancouver/campbellriver.jpg";
	map_level3_vancouver_island_comox_valley	= new Image; map_level3_vancouver_island_comox_valley.src	="../resources/searchpicsthin/vancouver/comoxvalley.jpg";
	map_level3_vancouver_island_duncan		= new Image; map_level3_vancouver_island_duncan.src		="../resources/searchpicsthin/vancouver/duncan.jpg";
	map_level3_vancouver_island_nanaimo		= new Image; map_level3_vancouver_island_nanaimo.src		="../resources/searchpicsthin/vancouver/nanaimo.jpg";
	map_level3_vancouver_island_north_island	= new Image; map_level3_vancouver_island_north_island.src	="../resources/searchpicsthin/vancouver/northisland.jpg";
	map_level3_vancouver_island_parksville		= new Image; map_level3_vancouver_island_parksville.src		="../resources/searchpicsthin/vancouver/parksville.jpg";
	map_level3_vancouver_island_port_alberni	= new Image; map_level3_vancouver_island_port_alberni.src	="../resources/searchpicsthin/vancouver/portalberni.jpg";

	
    }
    if (rpmZone == 5) {
	//Preload the Okanagan pictures.
	map_level1_ok = new Image; map_level1_ok.src	="../resources/searchpicsthin/oka/okanagan.jpg";

	map_level2_sh = new Image; map_level2_sh.src	="../resources/searchpicsthin/oka/shuswap.jpg";
	map_level3_re = new Image; map_level3_re.src	="../resources/searchpicsthin/oka/revelstoke.jpg";
	map_level3_sa = new Image; map_level3_sa.src	="../resources/searchpicsthin/oka/salmonarm.jpg";

	map_level2_no = new Image; map_level2_no.src	="../resources/searchpicsthin/oka/northokanagan.jpg";
	map_level3_ve = new Image; map_level3_ve.src	="../resources/searchpicsthin/oka/vernon.jpg";

	map_level2_co = new Image; map_level2_co.src	="../resources/searchpicsthin/oka/centralokanagan.jpg";
	map_level3_ke = new Image; map_level3_ke.src	="../resources/searchpicsthin/oka/kelowna.jpg";
	map_level3_we = new Image; map_level3_we.src	="../resources/searchpicsthin/oka/westside.jpg";
    }

    if (rpmZone == 6) {
	map_level1_rd = new Image; map_level1_rd.src	="../resources/searchpicsthin/red_deer/reddeer1.jpg";
	map_level2_rd = new Image; map_level2_rd.src	="../resources/searchpicsthin/red_deer/reddeer2.jpg";
   	
    }
  }
}

// initialize first search things
// -----------------------------------------
function MLSSearchInitializeDocument() {
  MLSSearchChangeCheckBoxTable( 'level1_edmonton' );
}

// processes dynamic search content
// backArrowOnOffStatus is a boolean describing whether or not the back arrow is functional or not.
// -----------------------------------------
function MLSSearchProcessor(imgName, newObject) {
   if (document.images)
   {
     document.images[imgName].src = eval("map_" + newObject + ".src");
     document.images[imgName].setAttribute('useMap', '#'+"ImageMap_"+newObject, 0);

     var sHTML = "";

     switch( newObject ) {
        case 'level1_edmonton':
           sHTML = "<input type=\"button\" onclick=\"javascript:MLSSearchProcessor('SearchImg', 'level1_edmonton');\" class=\"mod_input_submit\" value=\"No Zoom\">";
           break;

        case 'level2_edmonton':
           sHTML = "<input type=\"button\" onclick=\"javascript:MLSSearchProcessor('SearchImg', 'level1_edmonton');\" class=\"mod_input_submit\" value=\"Zoom Out\">";
           break;

        case 'level3_central':
        case 'level3_northwest':
        case 'level3_northeast':
        case 'level3_west':
        case 'level3_southeast':
        case 'level3_southwest':
           sHTML = "<input type=\"button\" onclick=\"javascript:MLSSearchProcessor('SearchImg', 'level2_edmonton');\" class=\"mod_input_submit\" value=\"Zoom Out\">";
           break;

        case 'level2_ruralnortheast':
        case 'level2_ruralnorthwest':
        case 'level2_ruralsoutheast':
        case 'level2_ruralsouthwest':
           sHTML = "<input type=\"button\" onclick=\"javascript:MLSSearchProcessor('SearchImg', 'level1_edmonton');\" class=\"mod_input_submit\" value=\"Zoom Out\">";
           break;

	case 'level1_calgary':
           sHTML = "<input type=\"button\" onclick=\"javascript:MLSSearchProcessor('SearchImg', 'level1_calgary');\" class=\"mod_input_submit\" value=\"No Zoom\">";
           break;

        case 'level2_calgary':
           sHTML = "<input type=\"button\" onclick=\"javascript:MLSSearchProcessor('SearchImg', 'level1_calgary');\" class=\"mod_input_submit\" value=\"Zoom Out\">";
           break;

        case 'level3_districta':
        case 'level3_districtb':
        case 'level3_districtc':
        case 'level3_districtd':
           sHTML = "<input type=\"button\" onclick=\"javascript:MLSSearchProcessor('SearchImg', 'level2_calgary');\" class=\"mod_input_submit\" value=\"Zoom Out\">";
           break;

	case 'level1_sw_bc':
	   sHTML = "<input type=\"button\" onclick=\"javascript:MLSSearchProcessor('SearchImg', 'level1_sw_bc');\" class=\"mod_input_submit\" value=\"No Zoom\">";
           break;

	case 'level2_chilliwack_area':
	   sHTML = "<input type=\"button\" onclick=\"javascript:MLSSearchProcessor('SearchImg', 'level1_sw_bc');\" class=\"mod_input_submit\" value=\"Zoom Out\">";
           break;
           
           
	case 'level3_chilliwack':
	   sHTML = "<input type=\"button\" onclick=\"javascript:MLSSearchProcessor('SearchImg', 'level2_chilliwack_area');\" class=\"mod_input_submit\" value=\"Zoom Out\">";
           break;

	case 'level2_fraser_valley':
	   sHTML = "<input type=\"button\" onclick=\"javascript:MLSSearchProcessor('SearchImg', 'level1_sw_bc');\" class=\"mod_input_submit\" value=\"Zoom Out\">";
           break;
	
	case 'level3_fraser_valley_abbotsford':
	case 'level3_fraser_valley_cloverdale':
	case 'level3_chilliwack_from_fraser_valley':
	case 'level3_fraser_valley_langley':
	case 'level3_fraser_valley_mission':
	case 'level3_fraser_valley_north_delta':
	case 'level3_fraser_valley_north_surrey':
	case 'level3_fraser_valley_surrey':
	case 'level3_fraser_valley_white_rock':
	   sHTML = "<input type=\"button\" onclick=\"javascript:MLSSearchProcessor('SearchImg', 'level2_fraser_valley');\" class=\"mod_input_submit\" value=\"Zoom Out\">";
           break;
	
	case 'level2_gtr_van':
	   sHTML = "<input type=\"button\" onclick=\"javascript:MLSSearchProcessor('SearchImg', 'level1_sw_bc');\" class=\"mod_input_submit\" value=\"Zoom Out\">";
           break;
	
	case 'level3_gtr_van_burnaby':
	case 'level3_gtr_van_coquitlam':
	case 'level3_gtr_van_ladner':
	case 'level3_gtr_van_maple_ridge':
	case 'level3_gtr_van_north_van':
	case 'level3_gtr_van_new_westminster':
	case 'level3_gtr_van_port_coquitlam':
	case 'level3_gtr_van_port_moody':
	case 'level3_gtr_van_richmond':
	case 'level3_gtr_van_tsawwassen':
	case 'level3_gtr_van_van_east':
	case 'level3_gtr_van_van_west':
	case 'level3_gtr_van_west_van':
	   sHTML = "<input type=\"button\" onclick=\"javascript:MLSSearchProcessor('SearchImg', 'level2_gtr_van');\" class=\"mod_input_submit\" value=\"Zoom Out\">";
           break;

	case 'level2_sunshine_coast':
	   sHTML = "<input type=\"button\" onclick=\"javascript:MLSSearchProcessor('SearchImg', 'level1_sw_bc');\" class=\"mod_input_submit\" value=\"Zoom Out\">";
           break;
        
        case 'level2_vancouver_island':
	   sHTML = "<input type=\"button\" onclick=\"javascript:MLSSearchProcessor('SearchImg', 'level1_sw_bc');\" class=\"mod_input_submit\" value=\"Zoom Out\">";
           break;   
          
	case 'level3_vancouver_island_campbell_river':	
	case 'level3_vancouver_island_comox_valley':	
	case 'level3_vancouver_island_duncan':	
	case 'level3_vancouver_island_nanaimo':	
	case 'level3_vancouver_island_north_island':	
	case 'level3_vancouver_island_parksville':		
	case 'level3_vancouver_island_port_alberni':
	   sHTML = "<input type=\"button\" onclick=\"javascript:MLSSearchProcessor('SearchImg', 'level2_vancouver_island');\" class=\"mod_input_submit\" value=\"Zoom Out\">";
           break;	

	//Okanagan
	case 'level1_ok':
	   sHTML = "<input type=\"button\" onclick=\"javascript:MLSSearchProcessor('SearchImg', 'level1_ok');\" class=\"mod_input_submit\" value=\"No Zoom\">";
           break;	

	case 'level2_sh':
	case 'level2_no':
	case 'level2_co':
	   sHTML = "<input type=\"button\" onclick=\"javascript:MLSSearchProcessor('SearchImg', 'level1_ok');\" class=\"mod_input_submit\" value=\"Zoom Out\">";
	   break;

	case 'level3_re':
	case 'level3_sa':
	   sHTML = "<input type=\"button\" onclick=\"javascript:MLSSearchProcessor('SearchImg', 'level2_sh');\" class=\"mod_input_submit\" value=\"Zoom Out\">";
	   break;

	case 'level3_ve':
	   sHTML = "<input type=\"button\" onclick=\"javascript:MLSSearchProcessor('SearchImg', 'level2_no');\" class=\"mod_input_submit\" value=\"Zoom Out\">";
	   break;

	case 'level3_ke':
	case 'level3_we':
	   sHTML = "<input type=\"button\" onclick=\"javascript:MLSSearchProcessor('SearchImg', 'level2_co');\" class=\"mod_input_submit\" value=\"Zoom Out\">";
	   break;
	
	//Red Deer
	case 'level1_rd':
	   sHTML = "<input type=\"button\" onclick=\"javascript:MLSSearchProcessor('SearchImg', 'level1_rd');\" class=\"mod_input_submit\" value=\"No Zoom\">";
           break;	
	
	case 'level2_rd':
           sHTML = "<input type=\"button\" onclick=\"javascript:MLSSearchProcessor('SearchImg', 'level1_rd');\" class=\"mod_input_submit\" value=\"Zoom Out\">";
           break;	
	
     }  
     //Update the back arrow with the proper code.
     document.getElementById('BackArrow').innerHTML = sHTML;
   }
}

function MLSSearchToggleChecked( listItem ) {

   //Select the item.
   if( eval("document.locationForm.searchAreas.options[" + listItem + "].selected == true") )
      eval("document.locationForm.searchAreas.options[" + listItem + "].selected = false");
   else
      eval("document.locationForm.searchAreas.options[" + listItem + "].selected = true");
}

function MLSSearchTurnOffChecked(listItem){  //To unselect region when a sub-region is clicked on map
	var row = getListItemRow(listItem);
	if(document.locationForm.searchAreas.options[row].selected == true){
		document.locationForm.searchAreas.options[row].selected = false;
	}
}

function MLSSearchTurnOnChecked(listItem){  //For regions only when it is clicked on map
	var row = getListItemRow(listItem);
	if(document.locationForm.searchAreas.options[row].selected == false){
		document.locationForm.searchAreas.options[row].selected = true;
	}
}

function getListItemRow(listItem){
	var pos = -1;
	for(i = 0; i < document.locationForm.searchAreas.length; i++) {
		if(document.locationForm.searchAreas.options[i].value == listItem){
			pos = i;
			break;
		}
	}
	return pos;
}

function MLSSearchToggleCheckedByName( listItem ) {

	//run through the list
	for(i = 0; i < document.locationForm.searchAreas.length; i++) {
		//If the value is equal to the one given toggle it.
		if( eval("document.locationForm.searchAreas.options[" + i + "].value == '" + listItem + "'")) {
			MLSSearchToggleChecked(i);
		}
	}
}

// Builds the list of cities and zones
// -----------------------------------------
function MLSSearchBuildList( cityName, backArrowPointer, backArrowOnOffStatus ) {

}

// adds item to list for MLS number search
// -----------------------------------------

function addNumber(listName,passValue,showText){
	
	//Check for any commas.
	if(showText.indexOf(",") != -1) {
		//Call again removing the comma.
		addNumber(listName,passValue,showText.substr(showText.indexOf(",")+1));
		showText = showText.substring(0,showText.indexOf(","));
	}
	
	if(showText != "") {
		if(showText.charCodeAt(0) >= "48" && showText.charCodeAt(0) <= "57") {
			//It starts with a digit do nothing.
		} else {
			//Starts with a char get rid of the first one.
			showText = showText.substring(1,showText.length);
		}
	}
		
	if(showText != "") {
		listName.length++;
		listName.options[listName.length-1].value = passValue;
		listName.options[listName.length-1].text = showText;
		document.getElementById("locationForm").MLSNumber.value = "";
	}
}
function removeNumber(listName) {
	if ( listName.length == -1) {  // If the list is empty
	}else{
		var selected = listName.selectedIndex;
		if (selected == -1) {
		} else {  // Build arrays with the text and values to remain
			var replaceTextArray = new Array(listName.length-1);
			var replaceValueArray = new Array(listName.length-1);
			for (var i = 0; i < listName.length; i++) {
				// Put everything except the selected one into the array
				if ( i < selected) { replaceTextArray[i] = listName.options[i].text; }
				if ( i > selected ) { replaceTextArray[i-1] = listName.options[i].text; }
				if ( i < selected) { replaceValueArray[i] = listName.options[i].value; }
				if ( i > selected ) { replaceValueArray[i-1] = listName.options[i].value; }
			}
			listName.length = replaceTextArray.length;
			for (i = 0; i < replaceTextArray.length; i++) {
				listName.options[i].value = replaceValueArray[i];
				listName.options[i].text = replaceTextArray[i];
			}
		}
	}
}
function resetList(listName) {
	if (listName.length == -1) {  // If the list is empty
	}else{
		var replaceTextArray = new Array(0);
		var replaceValueArray = new Array(0);
		listName.length = replaceTextArray.length;
		for (i = 0; i < replaceTextArray.length; i++) {
			listName.options[i].value = replaceValueArray[i];
			listName.options[i].text = replaceTextArray[i];
		}
	}
}
function createMLS() {
	var submitString = "";
	if (document.locationForm.MLSNumbers.length == -1) {  // If the list is empty
	}else{
		var submitString = "";
		for (i = 0; i < document.locationForm.MLSNumbers.length; i++) {
			if(i == 0){
				submitString =  document.locationForm.MLSNumbers.options[i].text;
			}else{
				submitString = submitString+","+document.locationForm.MLSNumbers.options[i].text;
			}
		}
	}
	document.locationForm.MLSNumberString.value = submitString;
	document.locationForm.submit();
}

//-->