if (document.images)
{
	checkit= new Image(); 
	checkit.src="../images/maps/checkit.gif"; 
}
/**************************************  CALGARY RESIDENTIAL MAPS  *********************************/
// Each map is sectioned off, containing its own variables, functions and data.  There is a section at the end that contains common functions
// among all three maps.

//These variables position the title layer and the side panel layer
var mapCalgRES_titleposx = 115;  //351
var mapCalgRES_titleposy = 0;  //410 520
var mapCalgRES_sidelayerposx = 20;
var mapCalgRES_sidelayerposy = 120;

// Multidimensional Arrays are created to store all the information for the different Calgary regions to 
//	display titles, side panels and selecting different areas.

var mapCalgRES_titleOfArea = new Array();
var mapCalgRES_nameOfRegion = new Array();
var mapCalgRES_idOfRegion = new Array();
var mapCalgRES_valueOfRegion = new Array();

// 0 Sask
// 1 Saskatoon 


//Data for the Titles and the Regions.
mapCalgRES_titleOfArea[0] = "Saskatoon";
mapCalgRES_nameOfRegion[0] = new Array();
mapCalgRES_idOfRegion[0] = new Array();
mapCalgRES_valueOfRegion[0] = new Array();

intReg = 0;
mapCalgRES_idOfRegion[intReg][0]="6";  mapCalgRES_nameOfRegion[intReg][0]="S6 Saskatoon NW"; mapCalgRES_valueOfRegion[intReg][0]="S6 Saskatoon NW";
mapCalgRES_idOfRegion[intReg][1]="7";  mapCalgRES_nameOfRegion[intReg][1]="S7 Saskatoon NE"; mapCalgRES_valueOfRegion[intReg][1]="S7 Saskatoon NE";
mapCalgRES_idOfRegion[intReg][2]="8";  mapCalgRES_nameOfRegion[intReg][2]="S8 Saskatoon SE"; mapCalgRES_valueOfRegion[intReg][2]="S8 Saskatoon SE";
mapCalgRES_idOfRegion[intReg][3]="9";  mapCalgRES_nameOfRegion[intReg][3]="S9 Saskatoon SW"; mapCalgRES_valueOfRegion[intReg][3]="S9 Saskatoon SW";
//mapCalgRES_idOfRegion[intReg][4]="10";  mapCalgRES_nameOfRegion[intReg][4]="All Saskatoon"; mapCalgRES_valueOfRegion[intReg][4]="All Saskatoon";



mapCalgRES_titleOfArea[1] = "Saskatoon";
mapCalgRES_nameOfRegion[1] = new Array();
mapCalgRES_idOfRegion[1] = new Array();
mapCalgRES_valueOfRegion[1] = new Array();

intReg = 1;
mapCalgRES_idOfRegion[intReg][0]="1";  mapCalgRES_nameOfRegion[intReg][0]="S1 Area 01"; mapCalgRES_valueOfRegion[intReg][0]="S1 Area 01";
mapCalgRES_idOfRegion[intReg][1]="2";  mapCalgRES_nameOfRegion[intReg][1]="S2 Area 02"; mapCalgRES_valueOfRegion[intReg][1]="S2 Area 02";
mapCalgRES_idOfRegion[intReg][2]="3";  mapCalgRES_nameOfRegion[intReg][2]="S3 Area 03"; mapCalgRES_valueOfRegion[intReg][2]="S3 Area 03";
mapCalgRES_idOfRegion[intReg][3]="4";  mapCalgRES_nameOfRegion[intReg][3]="S4 Area 04"; mapCalgRES_valueOfRegion[intReg][3]="S4 Area 04";
mapCalgRES_idOfRegion[intReg][4]="5";  mapCalgRES_nameOfRegion[intReg][4]="S5 Area 05"; mapCalgRES_valueOfRegion[intReg][4]="S5 Area 05";



// Example Further Detail Arrays
var intNum = 0;
var intMax = 2;



var mapCalgRES_strList= new Array(4);
var mapCalgRES_strOptions = new Array(4);

//Populates strings with the entire list to be used for larger areas, such as all of the north east.  It will add all the regions in the northeast into
//the string to be submitted.
for (var n=0; n < mapCalgRES_titleOfArea.length; n++){
	mapCalgRES_strList[n] = new Array();
	mapCalgRES_strOptions[n] = new Array();
	for (var i=0; i < mapCalgRES_nameOfRegion[n].length; i++){
		//alert (mapCalgRES_titleOfArea[i]);
		if (mapCalgRES_nameOfRegion[n][i]){
			mapCalgRES_strList[n] = mapCalgRES_strList[n] + '"' + mapCalgRES_valueOfRegion[n][i] + '",';
			mapCalgRES_strOptions[n] = mapCalgRES_strOptions[n] + '<option value=\'\"'+mapCalgRES_valueOfRegion[n][i]+'\"\'>'+mapCalgRES_nameOfRegion[n][i]+'</option>';
		}
	}
	mapCalgRES_strList[n] = mapCalgRES_strList[n].substring(0,mapCalgRES_strList[n].length-1);
	//alert(mapCalgRES_strList);
}
//Function : to show the title and the side panel
function mapCalgRES_showAt(id,mapCalgRES_titleLayer,mapCalgRES_sideLayer,region,strPosition) {
    var x=y=0;
	var sidebarhtml="";
	var titlexinsert = 0;
	
	if (strPosition == "center")
		titlexinsert = 0;
	else if (strPosition == "right")
		titlexinsert = 50;
	else if (strPosition == "rightfarther")
		titlexinsert = 67;

	var blnValueSelected = false;
	var strSelectBox = getSelectBox();
	for (var i = 0; i < strSelectBox.options.length; i++) {
			if(strSelectBox.options[i].value==('"'+mapCalgRES_valueOfRegion[id][region]+'"')){
				//alert(strSelectBox.options[i].value);
				if (strSelectBox.options[i].selected)
					blnValueSelected = true;
			}
	}

	//if ((region)||(region==0))
	if (region>=0){

		if (blnValueSelected)
		{

			mapCalgRES_changeContent (mapCalgRES_titleLayer, '<img name="checkit" src="../images/maps/checkit.gif" border="0" align="bottom"> ' + mapCalgRES_nameOfRegion[id][region]);
		}
		else
		{

			mapCalgRES_changeContent (mapCalgRES_titleLayer, mapCalgRES_nameOfRegion[id][region]);
		}

	}else {

		mapCalgRES_changeContent (mapCalgRES_titleLayer, mapCalgRES_titleOfArea[id]);
	}
	
	var strMainLayer = "mainLayer";
	
	if (document.getElementById) {//netscape 6 and above
		//alert("BEFORE \nmain_top:" + document.getElementById(strMainLayer).style.top + "\n title_top:" + document.getElementById(mapCalgRES_titleLayer).style.top);	
		document.getElementById(mapCalgRES_titleLayer).style.left = mapCalgRES_titleposx+titlexinsert;
//		document.getElementById(mapCalgRES_titleLayer).style.top = document.getElementById(strMainLayer).style.top + mapCalgRES_titleposy;
		document.getElementById(mapCalgRES_titleLayer).style.top = mapCalgRES_titleposy;
		
		document.getElementById(mapCalgRES_titleLayer).style.visibility = 'visible';
		document.getElementById('mainLayer').style.visibility = 'visible';		
		//alert("AFTER \nmain_top:" + document.getElementById(strMainLayer).style.top + "\n title_top:" + document.getElementById(mapCalgRES_titleLayer).style.top);
	}
    else if (document.layers && document.layers[mapCalgRES_titleLayer] != null) {//netscape 4
        document.layers[mapCalgRES_titleLayer].left = mapCalgRES_titleposx+titlexinsert;
        document.layers[mapCalgRES_titleLayer].top = mapCalgRES_titleposy;
        document.layers[mapCalgRES_titleLayer].visibility = 'visible';
		document.layers['mainLayer'].visibility = 'visible';
    }
    else if (document.all) { //internet explorer
        document.all[mapCalgRES_titleLayer].style.posLeft = mapCalgRES_titleposx+titlexinsert;
        document.all[mapCalgRES_titleLayer].style.posTop = mapCalgRES_titleposy;
        document.all[mapCalgRES_titleLayer].style.visibility = 'visible';
        document.all['mainLayer'].style.visibility = 'visible';		
    }
   return
}
//Function to change the content in the layer
function mapCalgRES_changeContent(layerid,shtml) {
	var newshtml = shtml;
	//newshtml =  addanewline(shtml, " ", "<BR>",15);
   if (document.getElementById || document.all) {
      var el = document.getElementById? document.getElementById(layerid): document.all[layerid];
      if (el && typeof el.innerHTML != "undefined") el.innerHTML = newshtml;
   }
   return
}
//function hides the layer
function mapCalgRES_hide(mapCalgRES_titleLayer,mapCalgRES_sideLayer) {
	//mapCalgRES_hide title layer
	if (document.getElementById)	
		document.getElementById(mapCalgRES_titleLayer).style.visibility = 'hidden';
    else if (document.layers && document.layers[mapCalgRES_titleLayer] != null)
        document.layers[mapCalgRES_titleLayer].visibility = 'hidden';
    else if (document.all)
        document.all[mapCalgRES_titleLayer].style.visibility = 'hidden';

	//mapCalgRES_hide side layer
	if (mapCalgRES_sideLayer) {
		if (document.getElementById)	
			document.getElementById(mapCalgRES_sideLayer).style.visibility = 'hidden';
		else if (document.layers && document.layers[mapCalgRES_sideLayer] != null)
			document.layers[mapCalgRES_sideLayer].visibility = 'hidden';
		else if (document.all)
			document.all[mapCalgRES_sideLayer].style.visibility = 'hidden';
	}
   return
}
//This function is used for selecting areas from a map.  It populates a select box based on what region is selected.
function mapSaskRES_selectRegion(id,region,area,strPosition) {
	//alert('region:'+region);
	var strSelectBox = getSelectBox();
	for (var i = 0; i < strSelectBox.options.length; i++) {
		if (area){
			if(strSelectBox.options[i].value==mapCalgRES_strList[id]){
				//alert(strSelectBox.options[i].value);
				if (strSelectBox.options[i].selected)
					strSelectBox.options[i].selected = false;
				else
					strSelectBox.options[i].selected = true;
			}
		} else {
			
			if(strSelectBox.options[i].value==('"'+mapCalgRES_valueOfRegion[id][region]+'"')){
				//alert(strSelectBox.options[i].value);
				if (strSelectBox.options[i].selected)
					strSelectBox.options[i].selected = false;
				else
					strSelectBox.options[i].selected = true;

				mapCalgRES_hide('mapCalgRES_titleLayer',false);	
				mapCalgRES_showAt(id,'mapCalgRES_titleLayer',false,region,strPosition);
			}
		}
	}
}

function mapSaskRES_selectFirst() 
{
	//alert('region:'+region);
	var strSelectBox = getSelectBox();
	if (strSelectBox.options.length > 0)
	{
		strSelectBox.options[0].selected = true;
	}
	
	for (var i = 1; i < strSelectBox.options.length; i++) 
	{	
		strSelectBox.options[i].selected = false;	
	}
}

//This function is used when the form is submitted.  IT does nothing else but display in an alert box the values of the select box.
// NOTE: This function can be omitted.  It is for debug purposes only.
function mapCalgRES_submitFrm () {
	var strSelectBox = getSelectBox();
	var mapCalgRES_strList = "";
	for (var i = 0; i < strSelectBox.options.length; i++) {
		if(strSelectBox.options[i].selected){
			mapCalgRES_strList = mapCalgRES_strList + strSelectBox.options[i].value +',';
		}
	}
	mapCalgRES_strList = mapCalgRES_strList.substring(0,mapCalgRES_strList.length-1);
	alert ('Zones : '+mapCalgRES_strList);
//	
	return false
	//return true
}
// This function displays an additoinal layer with the quadrant title.
function mapSaskRES_changeMapLayer(mapLayer,quadranttitle) {
//alert (" "+document.all[mapLayer].style.visibility);	

		if (document.getElementById) 
		{//netscape 6 and above

			document.getElementById('LethbridgeRural').style.visibility = 'hidden';
			document.getElementById('LethbridgeCounty').style.visibility = 'hidden';													
			document.getElementById('LethbridgeCity').style.visibility = 'hidden';													
			document.getElementById('Taber').style.visibility = 'hidden';				
											
			document.getElementById(mapLayer).style.visibility = 'visible';

		}
		else if (document.layers && document.layers[mapLayer] != null) {
			document.layers['LethbridgeRural'].style.visibility = 'hidden';
			document.layers['LethbridgeCounty'].style.visibility = 'hidden';
			document.layers['LethbridgeCity'].style.visibility = 'hidden';
			document.layers['Taber'].style.visibility = 'hidden';

			document.layers[mapLayer].style.visibility = 'visible';
		}
		else if (document.all) {
			document.all['LethbridgeRural'].style.visibility = 'hidden';
			document.all['LethbridgeCounty'].style.visibility = 'hidden';			
			document.all['LethbridgeCity'].style.visibility = 'hidden';			
			document.all['Taber'].style.visibility = 'hidden';																

			document.all[mapLayer].style.visibility = 'visible';
		}

		
//alert('mapLayer=#' + mapLayer + '#' + 'quadranttitle=#' + quadranttitle + '# , visibility ::' + document.getElementById(mapLayer).style.visibility);

}

/**************************************  RURAL MAPS  *********************************/
// These maps differ from the residential maps in that they show a side panel with a listing of all the regions.  So when you select an area on the
// map, it selects all the regions within that area.

//positions the title and the side panel.
var mapSA_RURAL_titleposx = 125;
var mapSA_RURAL_titleposy = -553;
var mapSA_RURAL_sidelayerposx = 20;
var mapSA_RURAL_sidelayerposy = -330;

var mapSA_RURAL_titleOfArea = new Array();
var mapSA_RURAL_nameOfRegion = new Array();
var mapSA_RURAL_idOfRegion = new Array();

//Data for the Titles and the Regions.
mapSA_RURAL_titleOfArea[0] = "Banff";
mapSA_RURAL_nameOfRegion[0] = new Array();
mapSA_RURAL_idOfRegion[0] = new Array();
mapSA_RURAL_idOfRegion[0][0] = "9164";
mapSA_RURAL_nameOfRegion[0][0] = "Rural Banff I.D.";
mapSA_RURAL_idOfRegion[0][1] = "0387";
mapSA_RURAL_nameOfRegion[0][1] = "BANFF";
mapSA_RURAL_idOfRegion[0][2] = "9164";
mapSA_RURAL_nameOfRegion[0][2] = "Castle Mountain";
mapSA_RURAL_idOfRegion[0][3] = "0757";
mapSA_RURAL_nameOfRegion[0][3] = "Lake Louise";
mapSA_RURAL_idOfRegion[0][4] = "9164";
mapSA_RURAL_nameOfRegion[0][4] = "Saskatchewan River Crossing";

mapSA_RURAL_titleOfArea[1] = "Bighorn";
mapSA_RURAL_nameOfRegion[1] = new Array();
mapSA_RURAL_idOfRegion[1] = new Array();
mapSA_RURAL_idOfRegion[1][0] = "9382";
mapSA_RURAL_nameOfRegion[1][0] = "Rural Bighorn M.D.";
mapSA_RURAL_idOfRegion[1][1] = "0623";
mapSA_RURAL_nameOfRegion[1][1] = "Benchlands";
mapSA_RURAL_idOfRegion[1][2] = "0050";
mapSA_RURAL_nameOfRegion[1][2] = "CANMORE";
mapSA_RURAL_idOfRegion[1][3] = "0698";
mapSA_RURAL_nameOfRegion[1][3] = "Exshaw";
mapSA_RURAL_idOfRegion[1][4] = "0123";
mapSA_RURAL_nameOfRegion[1][4] = "GHOST LAKE";
mapSA_RURAL_idOfRegion[1][5] = "0724";
mapSA_RURAL_nameOfRegion[1][5] = "Harvie Heights";
mapSA_RURAL_idOfRegion[1][6] = "0755";
mapSA_RURAL_nameOfRegion[1][6] = "Lac des Arcs";
mapSA_RURAL_idOfRegion[1][7] = "0834";
mapSA_RURAL_nameOfRegion[1][7] = "Seebe";
mapSA_RURAL_idOfRegion[1][8] = "0380";
mapSA_RURAL_nameOfRegion[1][8] = "WAIPAROUS";

mapSA_RURAL_titleOfArea[2] = "Kananskis";
mapSA_RURAL_nameOfRegion[2] = new Array();
mapSA_RURAL_idOfRegion[2] = new Array();
mapSA_RURAL_idOfRegion[2][0] = "9373";
mapSA_RURAL_nameOfRegion[2][0] = "Rural Kananskis I.D.";
mapSA_RURAL_idOfRegion[2][1] = "9373";
mapSA_RURAL_nameOfRegion[2][1] = "Kananskis Village";

mapSA_RURAL_titleOfArea[3] = "Mountain View";
mapSA_RURAL_nameOfRegion[3] = new Array();
mapSA_RURAL_idOfRegion[3] = new Array();
mapSA_RURAL_idOfRegion[3][0] = "9226";
mapSA_RURAL_nameOfRegion[3][0] = "Rural Mountain View County";
mapSA_RURAL_idOfRegion[3][2] = "BEB";
mapSA_RURAL_nameOfRegion[3][2] = "Bearberry";
mapSA_RURAL_idOfRegion[3][3] = "9226";
mapSA_RURAL_nameOfRegion[3][3] = "Bergen";
mapSA_RURAL_idOfRegion[3][4] = "0056";
mapSA_RURAL_nameOfRegion[3][4] = "CARSTAIRS";
mapSA_RURAL_idOfRegion[3][5] = "0078";
mapSA_RURAL_nameOfRegion[3][5] = "CREMONA";
mapSA_RURAL_idOfRegion[3][6] = "0088";
mapSA_RURAL_nameOfRegion[3][6] = "DIDSBURY";
mapSA_RURAL_idOfRegion[3][7] = "0689";
mapSA_RURAL_nameOfRegion[3][7] = "Eagle Hill";
mapSA_RURAL_idOfRegion[3][8] = "9226";
mapSA_RURAL_nameOfRegion[3][8] = "Elkton";
mapSA_RURAL_idOfRegion[3][9] = "0239";
mapSA_RURAL_nameOfRegion[3][9] = "OLDS";
mapSA_RURAL_idOfRegion[3][10] = "0307";
mapSA_RURAL_nameOfRegion[3][10] = "SUNDRE";
mapSA_RURAL_idOfRegion[3][11] = "0873";
mapSA_RURAL_nameOfRegion[3][11] = "Water Valley";
mapSA_RURAL_idOfRegion[3][12] = "0879";
mapSA_RURAL_nameOfRegion[3][12] = "Westward Ho";

mapSA_RURAL_titleOfArea[4] = "Kneehill";
mapSA_RURAL_nameOfRegion[4] = new Array();
mapSA_RURAL_idOfRegion[4] = new Array();
mapSA_RURAL_idOfRegion[4][0] = "9191";
mapSA_RURAL_nameOfRegion[4][0] = "Rural Kneehill County";
mapSA_RURAL_idOfRegion[4][1] = "0002";
mapSA_RURAL_nameOfRegion[4][1] = "ACME";
mapSA_RURAL_idOfRegion[4][2] = "0051";
mapSA_RURAL_nameOfRegion[4][2] = "CARBON";
mapSA_RURAL_idOfRegion[4][3] = "0731";
mapSA_RURAL_nameOfRegion[4][3] = "Huxley";
mapSA_RURAL_idOfRegion[4][4] = "0205";
mapSA_RURAL_nameOfRegion[4][4] = "LINDEN";
mapSA_RURAL_idOfRegion[4][5] = "0855";
mapSA_RURAL_nameOfRegion[4][5] = "Swalwell";
mapSA_RURAL_idOfRegion[4][6] = "0316";
mapSA_RURAL_nameOfRegion[4][6] = "THREE HILLS";
mapSA_RURAL_idOfRegion[4][7] = "0319";
mapSA_RURAL_nameOfRegion[4][7] = "Torrington";
mapSA_RURAL_idOfRegion[4][8] = "0320";
mapSA_RURAL_nameOfRegion[4][8] = "TROCHO";
mapSA_RURAL_idOfRegion[4][9] = "0881";
mapSA_RURAL_nameOfRegion[4][9] = "Wimborne";

mapSA_RURAL_titleOfArea[5] = "Rocky View";
mapSA_RURAL_nameOfRegion[5] = new Array();
mapSA_RURAL_idOfRegion[5] = new Array();
mapSA_RURAL_idOfRegion[5][0] = "9269";
mapSA_RURAL_nameOfRegion[5][0] = "Rural Rocky View County";
mapSA_RURAL_idOfRegion[5][2] = "0987";
mapSA_RURAL_nameOfRegion[5][2] = "Balzac";
mapSA_RURAL_idOfRegion[5][3] = "0022";
mapSA_RURAL_nameOfRegion[5][3] = "BEISEKER";
mapSA_RURAL_idOfRegion[5][4] = "0988";
mapSA_RURAL_nameOfRegion[5][4] = "Bottrel";
mapSA_RURAL_idOfRegion[5][5] = "0631";
mapSA_RURAL_nameOfRegion[5][5] = "Bragg Creek";
mapSA_RURAL_idOfRegion[5][6] = "0356";
mapSA_RURAL_nameOfRegion[5][6] = "CHESTERMERE";
mapSA_RURAL_idOfRegion[5][7] = "0070";
mapSA_RURAL_nameOfRegion[5][7] = "COCHRANE";
mapSA_RURAL_idOfRegion[5][8] = "0665";
mapSA_RURAL_nameOfRegion[5][8] = "Cochrane Lake";
mapSA_RURAL_idOfRegion[5][9] = "0672";
mapSA_RURAL_nameOfRegion[5][9] = "Conrich";
mapSA_RURAL_idOfRegion[5][10] = "0079";
mapSA_RURAL_nameOfRegion[5][10] = "CROSSFIELD";
mapSA_RURAL_idOfRegion[5][11] = "0675";
mapSA_RURAL_nameOfRegion[5][11] = "Dalemead";
mapSA_RURAL_idOfRegion[5][12] = "0676";
mapSA_RURAL_nameOfRegion[5][12] = "Dalroy";
mapSA_RURAL_idOfRegion[5][13] = "0989";
mapSA_RURAL_nameOfRegion[5][13] = "Delacour";
mapSA_RURAL_idOfRegion[5][14] = "EBV";
mapSA_RURAL_nameOfRegion[5][14] = "Elbow Valley";
mapSA_RURAL_idOfRegion[5][15] = "0734";
mapSA_RURAL_nameOfRegion[5][15] = "Indus";
mapSA_RURAL_idOfRegion[5][16] = "0183";
mapSA_RURAL_nameOfRegion[5][16] = "IRRICANA";
mapSA_RURAL_idOfRegion[5][17] = "0990";
mapSA_RURAL_nameOfRegion[5][17] = "Janet";
mapSA_RURAL_idOfRegion[5][18] = "0743";
mapSA_RURAL_nameOfRegion[5][18] = "Kathyrn";
mapSA_RURAL_idOfRegion[5][19] = "0747";
mapSA_RURAL_nameOfRegion[5][19] = "Keoma";
mapSA_RURAL_idOfRegion[5][20] = "0758";
mapSA_RURAL_nameOfRegion[5][20] = "Langdon";
mapSA_RURAL_idOfRegion[5][21] = "0773";
mapSA_RURAL_nameOfRegion[5][21] = "Madden";
mapSA_RURAL_idOfRegion[5][22] = "0631";
mapSA_RURAL_nameOfRegion[5][22] = "Redwood Meadows";
mapSA_RURAL_idOfRegion[5][23] = "0837";
mapSA_RURAL_nameOfRegion[5][23] = "Shepard";

mapSA_RURAL_titleOfArea[6] = "Wheatland";
mapSA_RURAL_nameOfRegion[6] = new Array();
mapSA_RURAL_idOfRegion[6] = new Array();
mapSA_RURAL_idOfRegion[6][0] = "9349";
mapSA_RURAL_nameOfRegion[6][0] = "Rural Wheatland County";
mapSA_RURAL_idOfRegion[6][2] = "9349";
mapSA_RURAL_nameOfRegion[6][2] = "Ardenode";
mapSA_RURAL_idOfRegion[6][3] = "0651";
mapSA_RURAL_nameOfRegion[6][3] = "Carseland";
mapSA_RURAL_idOfRegion[6][4] = "0655";
mapSA_RURAL_nameOfRegion[6][4] = "Chancellor";
mapSA_RURAL_idOfRegion[6][5] = "0656";
mapSA_RURAL_nameOfRegion[6][5] = "Cheadle";
mapSA_RURAL_idOfRegion[6][6] = "0067";
mapSA_RURAL_nameOfRegion[6][6] = "Cluny";
mapSA_RURAL_idOfRegion[6][7] = "9349";
mapSA_RURAL_nameOfRegion[6][7] = "Dalum";
mapSA_RURAL_idOfRegion[6][8] = "0126";
mapSA_RURAL_nameOfRegion[6][8] = "Gleichen";
mapSA_RURAL_idOfRegion[6][9] = "0154";
mapSA_RURAL_nameOfRegion[6][9] = "HUSSAR";
mapSA_RURAL_idOfRegion[6][10] = "0771";
mapSA_RURAL_nameOfRegion[6][10] = "Lyalta";
mapSA_RURAL_idOfRegion[6][11] = "0795";
mapSA_RURAL_nameOfRegion[6][11] = "Namaka";
mapSA_RURAL_idOfRegion[6][12] = "0270";
mapSA_RURAL_nameOfRegion[6][12] = "ROCKYFORD";
mapSA_RURAL_idOfRegion[6][13] = "0827";
mapSA_RURAL_nameOfRegion[6][13] = "Rosebud";
mapSA_RURAL_idOfRegion[6][14] = "0295";
mapSA_RURAL_nameOfRegion[6][14] = "STANDARD";
mapSA_RURAL_idOfRegion[6][15] = "0303";
mapSA_RURAL_nameOfRegion[6][15] = "STRATHMORE";

mapSA_RURAL_titleOfArea[7] = "Foothills";
mapSA_RURAL_nameOfRegion[7] = new Array();
mapSA_RURAL_idOfRegion[7] = new Array();
mapSA_RURAL_idOfRegion[7][0] = "9111";
mapSA_RURAL_nameOfRegion[7][0] = "Rural Foothills M.D.";
mapSA_RURAL_idOfRegion[7][1] = "0606";
mapSA_RURAL_nameOfRegion[7][1] = "Aldersyde";
mapSA_RURAL_idOfRegion[7][2] = "0030";
mapSA_RURAL_nameOfRegion[7][2] = "BLACK DIAMOND";
mapSA_RURAL_idOfRegion[7][3] = "0032";
mapSA_RURAL_nameOfRegion[7][3] = "Blackie";
mapSA_RURAL_idOfRegion[7][4] = "0059";
mapSA_RURAL_nameOfRegion[7][4] = "Cayley";
mapSA_RURAL_idOfRegion[7][5] = "0678";
mapSA_RURAL_nameOfRegion[7][5] = "De Winton";
mapSA_RURAL_idOfRegion[7][6] = "0971";
mapSA_RURAL_nameOfRegion[7][6] = "Heritage Pointe";
mapSA_RURAL_idOfRegion[7][7] = "0148";
mapSA_RURAL_nameOfRegion[7][7] = "HIGH RIVER";
mapSA_RURAL_idOfRegion[7][8] = "0208";
mapSA_RURAL_nameOfRegion[7][8] = "LONGVIEW";
mapSA_RURAL_idOfRegion[7][9] = "0786";
mapSA_RURAL_nameOfRegion[7][9] = "Millarville";
mapSA_RURAL_idOfRegion[7][10] = "0238";
mapSA_RURAL_nameOfRegion[7][10] = "OKOTOKS";
mapSA_RURAL_idOfRegion[7][11] = "0972";
mapSA_RURAL_nameOfRegion[7][11] = "Priddis";
mapSA_RURAL_idOfRegion[7][12] = "0973";
mapSA_RURAL_nameOfRegion[7][12] = "Priddis Greens";
mapSA_RURAL_idOfRegion[7][13] = "0321";
mapSA_RURAL_nameOfRegion[7][13] = "TURNER VALLEY";

mapSA_RURAL_titleOfArea[8] = "Vulcan";
mapSA_RURAL_nameOfRegion[8] = new Array();
mapSA_RURAL_idOfRegion[8] = new Array();
mapSA_RURAL_idOfRegion[8][0] = "9334";
mapSA_RURAL_nameOfRegion[8][0] = "Rural Vulcan County.";
mapSA_RURAL_idOfRegion[8][1] = "0010";
mapSA_RURAL_nameOfRegion[8][1] = "ARROWWOOD";
mapSA_RURAL_idOfRegion[8][2] = "0632";
mapSA_RURAL_nameOfRegion[8][2] = "Brant";
mapSA_RURAL_idOfRegion[8][3] = "0054";
mapSA_RURAL_nameOfRegion[8][3] = "CARMANGAY";
mapSA_RURAL_idOfRegion[8][4] = "0061";
mapSA_RURAL_nameOfRegion[8][4] = "CHAMPION";
mapSA_RURAL_idOfRegion[8][5] = "0695";
mapSA_RURAL_nameOfRegion[8][5] = "Ensign";
mapSA_RURAL_idOfRegion[8][6] = "1051";
mapSA_RURAL_nameOfRegion[8][6] = "Herronton";
mapSA_RURAL_idOfRegion[8][7] = "1052";
mapSA_RURAL_nameOfRegion[8][7] = "Kirkcaldy";
mapSA_RURAL_idOfRegion[8][8] = "0207";
mapSA_RURAL_nameOfRegion[8][8] = "LOMOND";
mapSA_RURAL_idOfRegion[8][9] = "0220";
mapSA_RURAL_nameOfRegion[8][9] = "MILO";
mapSA_RURAL_idOfRegion[8][10] = "0790";
mapSA_RURAL_nameOfRegion[8][10] = "Mossleigh";
mapSA_RURAL_idOfRegion[8][11] = "0808";
mapSA_RURAL_nameOfRegion[8][11] = "Queenstown";
mapSA_RURAL_idOfRegion[8][12] = "1053";
mapSA_RURAL_nameOfRegion[8][12] = "Shouldice";
mapSA_RURAL_idOfRegion[8][13] = "1054";
mapSA_RURAL_nameOfRegion[8][13] = "Travers";
mapSA_RURAL_idOfRegion[8][14] = "0333";
mapSA_RURAL_nameOfRegion[8][14] = "VULCAN";

mapSA_RURAL_titleOfArea[9] = "Ranchlands";
mapSA_RURAL_nameOfRegion[9] = new Array();
mapSA_RURAL_idOfRegion[9] = new Array();
mapSA_RURAL_idOfRegion[9][0] = "0361";
mapSA_RURAL_nameOfRegion[9][0] = "Rural Ranchlands County";

mapSA_RURAL_titleOfArea[10] = "Willow Creek";
mapSA_RURAL_nameOfRegion[10] = new Array();
mapSA_RURAL_idOfRegion[10] = new Array();
mapSA_RURAL_idOfRegion[10][0] = "9353";
mapSA_RURAL_nameOfRegion[10][0] = "Rural Willow Creek County";
mapSA_RURAL_idOfRegion[10][2] = "0065";
mapSA_RURAL_nameOfRegion[10][2] = "CLARESHOLM";
mapSA_RURAL_idOfRegion[10][3] = "0115";
mapSA_RURAL_nameOfRegion[10][3] = "FORT MACLEOD";
mapSA_RURAL_idOfRegion[10][4] = "0135";
mapSA_RURAL_nameOfRegion[10][4] = "GRANUM";
mapSA_RURAL_idOfRegion[10][5] = "0232";
mapSA_RURAL_nameOfRegion[10][5] = "NANTON";
mapSA_RURAL_idOfRegion[10][6] = "9353";
mapSA_RURAL_nameOfRegion[10][6] = "Parkland";
mapSA_RURAL_idOfRegion[10][7] = "0297";
mapSA_RURAL_nameOfRegion[10][7] = "STAVLEY";

mapSA_RURAL_titleOfArea[11] = "Lethbridge";
mapSA_RURAL_nameOfRegion[11] = new Array();
mapSA_RURAL_idOfRegion[11] = new Array();
mapSA_RURAL_idOfRegion[11][0] = "9204";
mapSA_RURAL_nameOfRegion[11][0] = "Rural Lethbridge County";
mapSA_RURAL_idOfRegion[11][2] = "0013";
mapSA_RURAL_nameOfRegion[11][2] = "Barons";
mapSA_RURAL_idOfRegion[11][3] = "0069";
mapSA_RURAL_nameOfRegion[11][3] = "COALDALE";
mapSA_RURAL_idOfRegion[11][4] = "0360";
mapSA_RURAL_nameOfRegion[11][4] = "Coalhurst";
mapSA_RURAL_idOfRegion[11][5] = "0682";
mapSA_RURAL_nameOfRegion[11][5] = "Diamond City";
mapSA_RURAL_idOfRegion[11][6] = "0735";
mapSA_RURAL_nameOfRegion[11][6] = "Iron Springs";
mapSA_RURAL_idOfRegion[11][7] = "0203";
mapSA_RURAL_nameOfRegion[11][7] = "Lethbridge";
mapSA_RURAL_idOfRegion[11][8] = "0787";
mapSA_RURAL_nameOfRegion[11][8] = "Monarch";
mapSA_RURAL_idOfRegion[11][9] = "0236";
mapSA_RURAL_nameOfRegion[11][9] = "Nobleford";
mapSA_RURAL_idOfRegion[11][10] = "0249";
mapSA_RURAL_nameOfRegion[11][10] = "PICTURE BUTTE";
mapSA_RURAL_idOfRegion[11][11] = "0836";
mapSA_RURAL_nameOfRegion[11][11] = "Shaughnessy";
mapSA_RURAL_idOfRegion[11][12] = "0864";
mapSA_RURAL_nameOfRegion[11][12] = "Turin";

mapSA_RURAL_titleOfArea[12] = "Crowsnest Pass";
mapSA_RURAL_nameOfRegion[12] = new Array();
mapSA_RURAL_idOfRegion[12] = new Array();
mapSA_RURAL_idOfRegion[12][0] = "0361";
mapSA_RURAL_nameOfRegion[12][0] = "Rural Municipality of Crowsnest Pass";
mapSA_RURAL_idOfRegion[12][1] = "BV";
mapSA_RURAL_nameOfRegion[12][1] = "Bellevue";
mapSA_RURAL_idOfRegion[12][2] = "BL";
mapSA_RURAL_nameOfRegion[12][2] = "Blairmore";
mapSA_RURAL_idOfRegion[12][3] = "CO";
mapSA_RURAL_nameOfRegion[12][3] = "Coleman";
mapSA_RURAL_idOfRegion[12][4] = "FR";
mapSA_RURAL_nameOfRegion[12][4] = "Frank";
mapSA_RURAL_idOfRegion[12][5] = "HC";
mapSA_RURAL_nameOfRegion[12][5] = "Hillcrest Mines";

mapSA_RURAL_titleOfArea[13] = "Airdrie";
mapSA_RURAL_nameOfRegion[13] = new Array();
mapSA_RURAL_idOfRegion[13] = new Array();
mapSA_RURAL_idOfRegion[13][0] = "0003";
mapSA_RURAL_nameOfRegion[13][0] = "Airdrie";

mapSA_RURAL_titleOfArea[14] = "Drumheller";
mapSA_RURAL_nameOfRegion[14] = new Array();
mapSA_RURAL_idOfRegion[14] = new Array();
mapSA_RURAL_idOfRegion[14][0] = "0532";
mapSA_RURAL_nameOfRegion[14][0] = "Drumheller";

mapSA_RURAL_titleOfArea[15] = "Lethbridge";
mapSA_RURAL_nameOfRegion[15] = new Array();
mapSA_RURAL_idOfRegion[15] = new Array();
mapSA_RURAL_idOfRegion[15][0] = "0203";
mapSA_RURAL_nameOfRegion[15][0] = "Lethbridge";

//this function shows the title and side panel
function mapSA_RURAL_showAt(id,mapSA_RURAL_titleLayer,mapSA_RURAL_sideLayer) {
    var x=y=0;
	var sidebarhtml="";

	var blnValueSelected = false;
	var strSelectBox = getSelectBox();
	if(strSelectBox.options[id].selected){
			blnValueSelected = true;
	}

	if (blnValueSelected)
		mapSA_RURAL_changeContent (mapSA_RURAL_titleLayer, '<img name="checkit" src="../images/maps/checkit.gif" border="0" align="bottom"> ' + mapSA_RURAL_titleOfArea[id]);
	else
		mapSA_RURAL_changeContent (mapSA_RURAL_titleLayer, mapSA_RURAL_titleOfArea[id]);

	if (document.getElementById) {//netscape 6 and above
		document.getElementById(mapSA_RURAL_titleLayer).style.left = mapSA_RURAL_titleposx;
		document.getElementById(mapSA_RURAL_titleLayer).style.top = mapSA_RURAL_titleposy-5;
		document.getElementById(mapSA_RURAL_titleLayer).style.visibility = 'visible';
	
	}
    else if (document.layers && document.layers[mapSA_RURAL_titleLayer] != null) {//netscape 4
        document.layers[mapSA_RURAL_titleLayer].left = mapSA_RURAL_titleposx;
        document.layers[mapSA_RURAL_titleLayer].top = mapSA_RURAL_titleposy;
        document.layers[mapSA_RURAL_titleLayer].visibility = 'visible';

    }
    else if (document.all) { //internet explorer
        document.all[mapSA_RURAL_titleLayer].style.posTop = mapSA_RURAL_titleposy;
        document.all[mapSA_RURAL_titleLayer].style.posLeft = mapSA_RURAL_titleposx;
        document.all[mapSA_RURAL_titleLayer].style.visibility = 'visible';
    }

	for(var i=0; i<mapSA_RURAL_nameOfRegion[id].length; i++){
		if (mapSA_RURAL_nameOfRegion[id][i]){
			if (mapSA_RURAL_nameOfRegion[id][i].length>=20){
				var lastSpace = mapSA_RURAL_nameOfRegion[id][i].lastIndexOf(" ",28);
				var newName = mapSA_RURAL_nameOfRegion[id][i].substring(0,lastSpace)  + "<BR>&nbsp;&nbsp;" + mapSA_RURAL_nameOfRegion[id][i].substring(lastSpace);
				pad_total = 18 - (mapSA_RURAL_nameOfRegion[id][i].length - lastSpace);
				if (pad_total > 0) {
					for (var counter = 1; counter < pad_total; counter++){ 
						newName += ".";
					}
				}
			}else{
				pad_total = 20 - mapSA_RURAL_nameOfRegion[id][i].length;
				var newName = mapSA_RURAL_nameOfRegion[id][i];
				if (pad_total > 0) {
					for (var counter = 1; counter < pad_total; counter++){ 
						newName += ".";
					}
				}
			}
			newName =  newName + mapSA_RURAL_idOfRegion[id][i] + '';
			sidebarhtml = sidebarhtml + newName + "<BR>";
		}
	}

	mapSA_RURAL_changeContent (mapSA_RURAL_sideLayer, sidebarhtml);

	if (document.getElementById) {//netscape 6 and above
		document.getElementById(mapSA_RURAL_sideLayer).style.left = mapSA_RURAL_sidelayerposx;
		document.getElementById(mapSA_RURAL_sideLayer).style.top = mapSA_RURAL_sidelayerposy-5;
		document.getElementById(mapSA_RURAL_sideLayer).style.visibility = 'visible';
	
	}
    else if (document.layers && document.layers[mapSA_RURAL_sideLayer] != null) {
        document.layers[mapSA_RURAL_sideLayer].left = mapSA_RURAL_sidelayerposx;
        document.layers[mapSA_RURAL_sideLayer].top = mapSA_RURAL_sidelayerposy;
        document.layers[mapSA_RURAL_sideLayer].visibility = 'visible';
    }
    else if (document.all) {
        document.all[mapSA_RURAL_sideLayer].style.posTop = mapSA_RURAL_sidelayerposy;
        document.all[mapSA_RURAL_sideLayer].style.posLeft = mapSA_RURAL_sidelayerposx;
        document.all[mapSA_RURAL_sideLayer].style.visibility = 'visible';
    }

   return

}

//this function changes the content of the html in the layer (it changes the title).
function mapSA_RURAL_changeContent(layerid,shtml) {
	
   if (document.getElementById || document.all) {
      var el = document.getElementById? document.getElementById(layerid): document.all[layerid];
      if (el && typeof el.innerHTML != "undefined") el.innerHTML = shtml;
   }
   return
}

//this function is for the mouseout action.  It hides the titles and side info when the mouse is taken off the image.
function mapSA_RURAL_hide(mapSA_RURAL_titleLayer,mapSA_RURAL_sideLayer) {
	
	//mapSA_RURAL_hide title layer
	if (document.getElementById)	
		document.getElementById(mapSA_RURAL_titleLayer).style.visibility = 'hidden';
    else if (document.layers && document.layers[mapSA_RURAL_titleLayer] != null)
        document.layers[mapSA_RURAL_titleLayer].visibility = 'hidden';
    else if (document.all)
        document.all[mapSA_RURAL_titleLayer].style.visibility = 'hidden';

	//mapSA_RURAL_hide side layer
	if (document.getElementById)	
		document.getElementById(mapSA_RURAL_sideLayer).style.visibility = 'hidden';
    else if (document.layers && document.layers[mapSA_RURAL_sideLayer] != null)
        document.layers[mapSA_RURAL_sideLayer].visibility = 'hidden';
    else if (document.all)
        document.all[mapSA_RURAL_sideLayer].style.visibility = 'hidden';

   return

}
//this function selects an image map, and populates the correct select box with the values.
function mapSA_RURAL_selectRegion(id) {
	var strSelectBox = getSelectBox();
	var frmField = strSelectBox.options[id];
	
	if (frmField.selected)
	frmField.selected = false;
	else
	frmField.selected = true;

	mapSA_RURAL_hide('mapSA_RURAL_titleLayer','mapSA_RURAL_sideLayer')
	mapSA_RURAL_showAt(id,'mapSA_RURAL_titleLayer','mapSA_RURAL_sideLayer');

}



//this function is used when the form is submitted.  it does nothing but display an alert box with the submitted values from the maps.  
//NOTE: this function is not needed for implementation.
function mapSA_RURAL_fillValues() {
	var strSelectBox = getSelectBox();
	var rural_strList = "";

	for (var i = 0; i < strSelectBox.options.length; i++) {
		if(strSelectBox.options[i].selected){
			rural_strList = rural_strList + strSelectBox.options[i].value +',';
			//alert ('Zones:'+strSelectBox.options[i].value);
		}
	}
	rural_strList = rural_strList.substring(0,rural_strList.length-1);
	alert ('Zones : '+rural_strList);
	
	return false

}

var mapSA_MobilePark_titleposx = 40;
var mapSA_MobilePark_titleposy = -160;
var mapSA_MobilePark_sidelayerposx = 20;
var mapSA_MobilePark_sidelayerposy = -320;

var mapSA_MobilePark_titleOfArea = new Array();
var mapSA_MobilePark_nameOfRegion = new Array();
var mapSA_MobilePark_idOfRegion = new Array();

//Data for the Titles and the Regions.
mapSA_MobilePark_titleOfArea[0] = "Abbeydale";
mapSA_MobilePark_nameOfRegion[0] = "Abbeydale";
mapSA_MobilePark_idOfRegion[0] = "664";

mapSA_MobilePark_titleOfArea[1] = "Acadia";
mapSA_MobilePark_nameOfRegion[1] = "Acadia";
mapSA_MobilePark_idOfRegion[1] = "215";

mapSA_MobilePark_titleOfArea[2] = "Arbour Lake";
mapSA_MobilePark_nameOfRegion[2] = "Arbour Lake";
mapSA_MobilePark_idOfRegion[2] = "443";

mapSA_MobilePark_titleOfArea[3] = "Blackfoot Mobile Park";
mapSA_MobilePark_nameOfRegion[3] = "Blackfoot Mobile Prk";
mapSA_MobilePark_idOfRegion[3] = "217";

mapSA_MobilePark_titleOfArea[4] = "Bowness";
mapSA_MobilePark_nameOfRegion[4] = "Bowness";
mapSA_MobilePark_idOfRegion[4] = "478";

mapSA_MobilePark_titleOfArea[5] = "Forest Lawn";
mapSA_MobilePark_nameOfRegion[5] = "Forest Lawn";
mapSA_MobilePark_idOfRegion[5] = "764";

mapSA_MobilePark_titleOfArea[6] = "Greenwood Village";
mapSA_MobilePark_nameOfRegion[6] = "Greenwood Village";
mapSA_MobilePark_idOfRegion[6] = "479";

mapSA_MobilePark_titleOfArea[7] = "Monterey Park";
mapSA_MobilePark_nameOfRegion[7] = "Monterey Park";
mapSA_MobilePark_idOfRegion[7] = "670";

mapSA_MobilePark_titleOfArea[8] = "Old Town";
mapSA_MobilePark_nameOfRegion[8] = "Old Town";
mapSA_MobilePark_idOfRegion[8] = "";

mapSA_MobilePark_titleOfArea[9] = "Parkridge Estates";
mapSA_MobilePark_nameOfRegion[9] = "Parkridge Estates";
mapSA_MobilePark_idOfRegion[9] = "671";

mapSA_MobilePark_titleOfArea[10] = "Points West Resort";
mapSA_MobilePark_nameOfRegion[10] = "Points West Resort";
mapSA_MobilePark_idOfRegion[10] = "";

mapSA_MobilePark_titleOfArea[11] = "Redcarpet Mountview";
mapSA_MobilePark_nameOfRegion[11] = "Redcarpet_Mountview";
mapSA_MobilePark_idOfRegion[11] = "770";

mapSA_MobilePark_titleOfArea[12] = "South Hill";
mapSA_MobilePark_nameOfRegion[12] = "South Hill";
mapSA_MobilePark_idOfRegion[12] = "306";

mapSA_MobilePark_titleOfArea[13] = "Winston Heights Mountview";
mapSA_MobilePark_nameOfRegion[13] = "Winston Heights_Mountview";
mapSA_MobilePark_idOfRegion[13] = "490";

mapSA_MobilePark_titleOfArea[14] = "Not Specified";
mapSA_MobilePark_nameOfRegion[14] = "None";
mapSA_MobilePark_idOfRegion[14] = "";

mapSA_MobilePark_strList = "";
for (var n=0; n < mapSA_MobilePark_titleOfArea.length; n++){
		//alert (mapCalgRES_titleOfArea[i]);
		if (mapSA_MobilePark_titleOfArea[n]){
			mapSA_MobilePark_strList = mapSA_MobilePark_strList + '"' + mapSA_MobilePark_nameOfRegion[n] + '",';
		}
}
mapSA_MobilePark_strList =mapSA_MobilePark_strList.substring(0,mapSA_MobilePark_strList.length-1);
//alert('mobile park list:' + mapSA_MobilePark_strList);



//This function shows the title and side panel on mouseover action
function mapSA_MobilePark_showAt(id,mapSA_MobilePark_titleLayer,mapSA_MobilePark_sideLayer) {
    var x=y=0;
	var sidebarhtml="";

	var blnValueSelected = false;
	var strSelectBox = getSelectBox();
	if(strSelectBox.options[id].selected){
			blnValueSelected = true;
	}

	if (blnValueSelected)
		mapSA_MobilePark_changeContent (mapSA_MobilePark_titleLayer, '<img name="checkit" src="../images/maps/checkit.gif" border="0" align="bottom"> ' + mapSA_MobilePark_titleOfArea[id]);
	else
		mapSA_MobilePark_changeContent (mapSA_MobilePark_titleLayer, mapSA_MobilePark_titleOfArea[id]);


	if (document.getElementById) {//netscape 6 and above
		document.getElementById(mapSA_MobilePark_titleLayer).style.left = mapSA_MobilePark_titleposx;
		document.getElementById(mapSA_MobilePark_titleLayer).style.top = mapSA_MobilePark_titleposy-5;
		document.getElementById(mapSA_MobilePark_titleLayer).style.visibility = 'visible';
	
	}
    else if (document.layers && document.layers[mapSA_MobilePark_titleLayer] != null) {//netscape 4
        document.layers[mapSA_MobilePark_titleLayer].left = mapSA_MobilePark_titleposx;
        document.layers[mapSA_MobilePark_titleLayer].top = mapSA_MobilePark_titleposy;
        document.layers[mapSA_MobilePark_titleLayer].visibility = 'visible';

    }
    else if (document.all) { //internet explorer
        document.all[mapSA_MobilePark_titleLayer].style.posTop = mapSA_MobilePark_titleposy;
        document.all[mapSA_MobilePark_titleLayer].style.posLeft = mapSA_MobilePark_titleposx;
        document.all[mapSA_MobilePark_titleLayer].style.visibility = 'visible';
    }

   return

}
//This function changes the content for the title or sidepanel
function mapSA_MobilePark_changeContent(layerid,shtml) {
	
   if (document.getElementById || document.all) {
      var el = document.getElementById? document.getElementById(layerid): document.all[layerid];
      if (el && typeof el.innerHTML != "undefined") el.innerHTML = shtml;
   }
   return
}
//This function hides the title and sidepanel layers.
function mapSA_MobilePark_hide(mapSA_MobilePark_titleLayer,mapSA_MobilePark_sideLayer) {
	//mapSA_MobilePark_hide title layer
	if (document.getElementById)	
		document.getElementById(mapSA_MobilePark_titleLayer).style.visibility = 'hidden';
    else if (document.layers && document.layers[mapSA_MobilePark_titleLayer] != null)
        document.layers[mapSA_MobilePark_titleLayer].visibility = 'hidden';
    else if (document.all)
        document.all[mapSA_MobilePark_titleLayer].style.visibility = 'hidden';
   return

}
//This function allows the map to be clicked and the select box values are selected.
function mapSA_MobilePark_selectRegion(id) {
	var strSelectBox = getSelectBox();
	//var frmField = strSelectBox.options[id];
	for (var i = 0; i < strSelectBox.options.length; i++) {
		if(strSelectBox.options[i].value==('"'+mapSA_MobilePark_nameOfRegion[id]+'"') ){
			//alert ('Zones:'+strSelectBox.options[i].value);
			if (strSelectBox.options[i].selected)
				strSelectBox.options[i].selected = false;
			else
				strSelectBox.options[i].selected = true;
		}
	}
	mapSA_MobilePark_hide('mapSA_MobilePark_titleLayer','mapSA_MobilePark_sideLayer');
	mapSA_MobilePark_showAt(id,'mapSA_MobilePark_titleLayer','mapSA_MobilePark_sideLayer');

}
//this function is used when the form is submitted.  it does nothing but display an alert box with the submitted values from the maps.  
//NOTE: this function is not needed for implementation.
function mapSA_MobilePark_fillValues() {
	var strSelectBox = getSelectBox();
	var rural_strList = "";
	for (var i = 0; i < strSelectBox.options.length; i++) {
		if(strSelectBox.options[i].selected){
			rural_strList = rural_strList + strSelectBox.options[i].value +',';
			//alert ('Zones:'+strSelectBox.options[i].value);
		}
	}
	rural_strList = rural_strList.substring(0,rural_strList.length-1);
	alert ('Zones : '+rural_strList);
	return false
}

/* *****************STANDARD FUNCTIONS ************************************************/

// This function adds a new line to the title if it is too long.
function addanewline(s, t, u,startIndex) {
  /*
  **  Replace a token in a string
  **    s  string to be processed
  **    t  token to be found and removed
  **    u  token to be inserted
  **  returns new String
  */
  i = s.indexOf(t,startIndex);
  r = "";
  if (i == -1) return s;
  
  r += s.substring(0,i) + u;
	//alert (r);
  
    r += s.substring(i);
  return r;
}
// This function changes between the overall maps.  Currently it swaps between the 3 maps, Residential, Rural and Mobile Park.  
function changeMap(frmField) {
//	alert('HERE2');
	var mapLayer = "";

			for (var n = 0; n < frmField.options.length; n++) {
				if(frmField.options[n].selected){
					for (var i = 0; i < document.forms.length; i++) {
						if (document.forms[i].name == "newlistingsearch"){
							if ((frmField.options[n].value==4)||(frmField.options[n].value==8)||(frmField.options[n].value==12)){
								mapLayer = "mapSA_RURAL_mapLayer";
							}
							else if (frmField.options[n].value==16){
								mapLayer = "mapSA_MobilePark_mapLayer";
							}
							else {
								mapLayer = "CalgaryMapLayer";
							}
						}
						if (document.forms[i].name == "lowpaymentsearch"){
							 
							if ((frmField.options[n].value==4)||(frmField.options[n].value==8)||(frmField.options[n].value==12)){
								mapLayer = "mapSA_RURAL_mapLayer";
							}
							else {
								mapLayer = "CalgaryMapLayer";
							}
						}


					}		

				}
			}


			//mapLayer = "CalgaryMapLayer";
		
		
		if (document.getElementById) {//netscape 6 and above
			document.getElementById('CalgaryMapLayer').style.visibility = 'hidden';
			document.getElementById('nwLayer').style.visibility = 'hidden';
			document.getElementById('neLayer').style.visibility = 'hidden';
			document.getElementById('seLayer').style.visibility = 'hidden';
			document.getElementById('swLayer').style.visibility = 'hidden';
			document.getElementById('mapSA_RURAL_mapLayer').style.visibility = 'hidden';
			document.getElementById('mapSA_MobilePark_mapLayer').style.visibility = 'hidden';
			document.getElementById('mapCalgRES_quadranttitle').style.visibility = 'hidden';
			
			document.getElementById(mapLayer).style.visibility = 'visible';
		}
		else if (document.layers && document.layers[mapLayer] != null) {
			document.layers['CalgaryMapLayer'].style.visibility = 'hidden';
			document.layers['nwLayer'].style.visibility = 'hidden';
			document.layers['neLayer'].style.visibility = 'hidden';
			document.layers['seLayer'].style.visibility = 'hidden';
			document.layers['swLayer'].style.visibility = 'hidden';
			document.layers['mapSA_RURAL_mapLayer'].style.visibility = 'hidden';
			document.layers['mapSA_MobilePark_mapLayer'].style.visibility = 'hidden';
			document.layers['mapCalgRES_quadranttitle'].style.visibility = 'hidden';

			document.layers[mapLayer].style.visibility = 'visible';
		}
		else if (document.all) {
			document.all['CalgaryMapLayer'].style.visibility = 'hidden';
			document.all['nwLayer'].style.visibility = 'hidden';
			document.all['neLayer'].style.visibility = 'hidden';
			document.all['seLayer'].style.visibility = 'hidden';
			document.all['swLayer'].style.visibility = 'hidden';
			document.all['mapSA_RURAL_mapLayer'].style.visibility = 'hidden';
			document.all['mapSA_MobilePark_mapLayer'].style.visibility = 'hidden';
			document.all['mapCalgRES_quadranttitle'].style.visibility = 'hidden';

			document.all[mapLayer].style.visibility = 'visible';
		}
}
// Function to get the select box name from the forms on the page.
function getSelectBox() {
		//alert("here");
	for (var i = 0; i < document.forms.length; i++) {
		//alert (document.forms[i].name);
		if (document.forms[i].name=="housesearch")
		{
			return document.housesearch.NEIGHBOURHOOD;
		}
		else if (document.forms[i].name=="condosearch")
			return document.condosearch.NEIGHBOURHOOD;
			
		else if (document.forms[i].name=="acreagehomesearch")
			return document.acreagehomesearch.ACE_AREA;

			
		else if (document.forms[i].name=="commercialsearch")
			return document.commercialsearch.COM_AREA;
			
		else if (document.forms[i].name=="newhousesearch")
			return document.newhousesearch.AREA;		
			
		else if (document.forms[i].name=="newlistingsearch")
			return document.newlistingsearch.AREA;
	}
}


function getForm() {
		

	for (var i = 0; i < document.forms.length; i++) 
	{
		//alert (document.forms[i].name);
		if (document.forms[i].name=="housesearch")
		{
			return document.housesearch;
		}
		else if (document.forms[i].name=="condosearch")
			return document.condosearch;
			
		else if (document.forms[i].name=="acreagehomesearch")
			return document.acreagehomesearch;

			
		else if (document.forms[i].name=="commercialsearch")
			return document.commercialsearch;
			
		else if (document.forms[i].name=="newhousesearch")
			return document.newhousesearch;		
			
		else if (document.forms[i].name=="newlistingsearch")
			return document.newlistingsearch;
	}
}




var loadingImage = false;
function LoadImage(imageName,imageFile)
{
	var loadingImage = false;
	
  if ((!document.images) || loadingImage) return;
  loadingImage = true;
  
imgTmp = new Image();
imgTmp.src = imageFile;


document.images[imageName] = imgTmp; 

/*  
	if (document.images[imageName].src.indexOf(imageFile)<0)
	{
		document.images[imageName].src = imageFile;
	}
*/  
  loadingImage = false;
}
LoadImage('checkit','images/maps/checkit.gif');
