	function var_dump(element, limit, depth){
		depth = depth?depth:0;
		limit = limit?limit:1;
		returnString = '<ol>';
		for(property in element)
		{
			//Property domConfig isn't accessable
			if (property != 'domConfig')
			{
				returnString += '<li><strong>'+ property + '</strong> <small>(' + (typeof element[property]) +')</small>';
				if (typeof element[property] == 'number' || typeof element[property] == 'boolean')
					returnString += ' : <em>' + element[property] + '</em>';
				if (typeof element[property] == 'string' && element[property])
					returnString += ': <div style="background:#C9C9C9;border:1px solid black; overflow:auto;"><code>' +
										element[property].replace(/</g, '<').replace(/>/g, '>') + '</code></div>';
				if ((typeof element[property] == 'object') && (depth <limit))
					returnString += var_dump(element[property], limit, (depth + 1));
				returnString += '</li>';
			}
		}
		returnString += '</ol>';
		if(depth == 0)
		{
			winpop = window.open("", "","width=800,height=600,scrollbars,resizable");
			winpop.document.write('<pre>'+returnString+ '</pre>');
			winpop.document.close();
		}
		return returnString;
	}
  
  function osm_getTileURL(bounds) {
      var res = this.map.getResolution();
      var x = Math.round((bounds.left - this.maxExtent.left) / (res * this.tileSize.w));
      var y = Math.round((this.maxExtent.top - bounds.top) / (res * this.tileSize.h));
      var z = this.map.getZoom();
      var limit = Math.pow(2, z);

      if (y < 0 || y >= limit) {
          return OpenLayers.Util.getImagesLocation() + "404.png";
      } else {
          x = ((x % limit) + limit) % limit;
          return this.url + z + "/" + x + "/" + y + "." + this.type;
      }
  }
  
  function mousemover(e) {
  	mousemove++;
  	var IE = document.all?true:false;
	    if (IE) { // grab the x-y pos.s if browser is IE
		    mousex = event.clientX + document.body.scrollLeft;
		    mousey = event.clientY + document.body.scrollTop;
		  } else {  // grab the x-y pos.s if browser is NS
		    mousex = e.pageX;
		    mousey = e.pageY;
		  } 
	  // show the position values in the form named Show
	  // in the text fields named MouseX and MouseY
	  toolx = mousex + 10;
	 	tooly = mousey + 10;
	 	if (fixed_tooltiper == true){
	 		 $("#tooltiper").css("top","0px");
  		 $("#tooltiper").css("left","0px");
  	}else{
  	
  		if ((window.innerWidth / 2 < mousex) && mouse_left_side == true){
  			mouse_left_side = false;
  			$("#tooltiper").css("left",null);
  		}
  		
  		if ((window.innerWidth / 2 > mousex) && mouse_left_side == false){
  			mouse_left_side = true;
  			$("#tooltiper").css("right",null);
  		}  		
  		
  		if (mouse_left_side) 	$("#tooltiper").css("left",toolx);
  		else 									$("#tooltiper").css("right",window.innerWidth - toolx);
  	
  		if (window.innerHeight - tooly < $("#tooltiper").height() ){
  			$("#tooltiper").css("top",window.innerHeight - $("#tooltiper").height());
  		}else{ 
	  		$("#tooltiper").css("top",tooly);
  		}
  	
  	}
  	
  	if ((isie() == false && mousemove >= 2) && (map.getZoom() < kml_zoom_swtich)){
  		mousemove = 0;
  		
    	mouselonlat = map.getLonLatFromViewPortPx(new OpenLayers.Pixel(mousex , mousey));
    	
    	var mousepoint = new OpenLayers.Geometry.Point(mouselonlat.lon, mouselonlat.lat);
    	
    	var feature_names = [];
    	var newly_selected_features = [];
    	var j = 0;
    	for (var i = 0; i < kml.features.length; i++) {
    		if ((kml.features[i].attributes.status == 'contemporary' && contemp_on == true) || (kml.features[i].attributes.status == 'sleeping' && sleeping_on == true)){
    			if (kml.features[i].geometry.intersects(mousepoint)){
	    			feature_names[j] = kml.features[i].attributes.name;
	    			newly_selected_features[j] = i;
	    			j++;
    			}
    		}
    	}
    	
			if (areArraysEqual(newly_selected_features, selected_features) == false){
				
      	for (var i = 0; i < selected_features.length; i++) {
      			hoverControl.unselect(kml.features[selected_features[i]]);
      	}
      	
      	selected_features = newly_selected_features;
      	
      	for (var i = 0; i < selected_features.length; i++) {
      		hoverControl.select(kml.features[selected_features[i]]);
      	}

      	if (feature_names.length == 0 && (nation_selected == false && point_selected == false)){
      		$("#tooltiper").css('display','none');
      	}
      	if (feature_names.length == 0){
      		$("#language_tooltip").html('');
      	}else {
      		var label_html = '';
      		
      		if (feature_names.length == 1) label_html = "<b>Language: </b>";
      		else label_html = "<b>Languages: </b>";
      		
      		label_html = label_html + feature_names[0];
      		for (var i = 1; i < feature_names.length; i++) {
      			label_html = label_html + ", " + feature_names[i];
      		}
      		label_html = label_html + "<br/>";
      		
      		$("#language_tooltip").html(label_html);
      		$("#tooltiper").css('display','block');
      	}
    	}
  	}
	  return true;
	}
	
	function mouseclicked(e){
			if (kml.selectedFeatures.length == 0 && (nation_selected == false && point_selected == false)) return true;
			if (kml.selectedFeatures.length == 1 && (nation_selected == false && point_selected == false)){
				var lang_name = kml.selectedFeatures[0].attributes.name;
				var full_url = "http://maps.fphlcc.ca/fphlcc/" + kml.selectedFeatures[0].attributes.url;
				var confirm_html = "<center><b><a style='color:blue; cursor:pointer' onclick=\"jump_to_link('"+full_url+ "')\" >Click to visit the "+lang_name+" language page</a><b></center><img src='closeX.gif' style='position:absolute; top:0px; right:0px' onclick=\"$('#multiconfirm').css('display','none');\" />";
			}else if (kml.selectedFeatures.length == 0 && point_selected != false){
					var point_name = point_selected.marker_name;
					var point_nid = point_selected.marker_nid;
					var full_url = "http://maps.fphlcc.ca/fphlcc/node/" + point_nid;
					var confirm_html = "<center><b><a style='color:blue; cursor:pointer' onclick=\"jump_to_link('"+full_url+ "')\" >Click to visit the "+point_name+" information page</a><b></center><img src='closeX.gif' style='position:absolute; top:0px; right:0px' onclick=\"$('#multiconfirm').css('display','none');\" />";	
			}else if (kml.selectedFeatures.length == 0 && nation_selected != false){
					var nation_name = nation_selected.marker_name;
					if (nation_name.match("Nation") == null && nation_name.match("Band") == null) nation_name = nation_name + " First Nation";
					var nation_nid = nation_selected.marker_nid;
					var full_url = "http://maps.fphlcc.ca/fphlcc/node/" + nation_nid;
					var confirm_html = "<center><b><a style='color:blue; cursor:pointer' onclick=\"jump_to_link('"+full_url+ "')\" >Click to visit the "+nation_name+" information page</a><b></center><img src='closeX.gif' style='position:absolute; top:0px; right:0px' onclick=\"$('#multiconfirm').css('display','none');\" />";
			}else{
				var confirm_html = "<center><b>Which information page would you like to visit?<b></center><img src='closeX.gif' style='position:absolute; top:0px; right:0px' onclick=\"$('#multiconfirm').css('display','none');\" />";
				for (var i = 0; i < kml.selectedFeatures.length; i++) {	
					var lang_name = kml.selectedFeatures[i].attributes.name;
					var url_name = kml.selectedFeatures[i].attributes.url;
					var full_url = "http://maps.fphlcc.ca/fphlcc/" + url_name;
					confirm_html = confirm_html + "<br/><a style='color:blue; cursor:pointer' onclick=\"jump_to_link('"+full_url+ "')\" >" + lang_name + " Language</a>";
				}
				if (nation_selected != false){
					var nation_name = nation_selected.marker_name;
					if (nation_name.match("Nation") == null && nation_name.match("Band") == null) nation_name = nation_name + " First Nation";
					var nation_nid = nation_selected.marker_nid;
					var full_url = "http://maps.fphlcc.ca/fphlcc/node/" + nation_nid;
					confirm_html = confirm_html + "<br/><a style='color:blue; cursor:pointer' onclick=\"jump_to_link('"+full_url+ "')\" >" + nation_name + "</a>";
				}
				if (point_selected != false){
					var point_name = point_selected.marker_name;
					var point_nid = point_selected.marker_nid;
					var full_url = "http://maps.fphlcc.ca/fphlcc/node/" + point_nid;
					confirm_html = confirm_html + "<br/><a style='color:blue; cursor:pointer' onclick=\"jump_to_link('"+full_url+ "')\" >" + point_name + "</a>";
				}
			}
			$("#multiconfirm").html(confirm_html);
			$("#multiconfirm").css('display','block');
		return true;
	}
	
	function jump_to_link(full_url){
		$("#multiconfirm").css('display','none');
		window.open(full_url);
	}
	
	function getVisibleCentroid(geometry){
		var adjustedGeometry = geometry.clone();
		var bounds = map.getExtent();
		if (adjustedGeometry.CLASS_NAME == "OpenLayers.Geometry.Collection") adjustedGeometry = adjustedGeometry.components[0];
		if (adjustedGeometry.CLASS_NAME == "OpenLayers.Geometry.Polygon") adjustedGeometry = adjustedGeometry.components[0];
		
		var j=0;
		var componentsToRemove = Array();
		for (var i = 0; i < adjustedGeometry.components.length; i++) { 
     		if (bounds.contains(adjustedGeometry.components[i].x, adjustedGeometry.components[i].y, true) == false){
     			
     			if (adjustedGeometry.components[i].y > bounds.top) var move_to_y = bounds.top;
     			else move_to_y = bounds.bottom;
     			
	     		if (adjustedGeometry.components[i].x > bounds.right) var move_to_x = bounds.right;
     			else move_to_x = bounds.left;			     			
     			
     			adjustedGeometry.components[i].x = move_to_x;
     			adjustedGeometry.components[i].y = move_to_y;
     				     			
     			j++;
     		}
   	}
   	
   	if ((i - j) < 3) return false;
   	
   	//we have adjusted everything, so actually it's not even visible;
    			   	
		if (adjustedGeometry.components && (adjustedGeometry.components.length > 2)) { 
    	var sumX = 0.0; 
     	var sumY = 0.0; 
     	for (var i = 0; i < adjustedGeometry.components.length - 1; i++) { 
         var b = adjustedGeometry.components[i]; 
         var c = adjustedGeometry.components[i+1]; 
         sumX += (b.x + c.x) * (b.x * c.y - c.x * b.y); 
         sumY += (b.y + c.y) * (b.x * c.y - c.x * b.y); 
     	}
     	var x = sumX / (6 * Math.abs(adjustedGeometry.getArea())); 
     	var y = sumY / (6 * Math.abs(adjustedGeometry.getArea())); 
		}else{
			return false;
		}
		return new OpenLayers.LonLat(-x,-y);
	}
	
	function displayPermaLabels(vectorLayer){
		$(".poly_labels").remove();
			
		for (var i = 0; i < vectorLayer.features.length; i++) {
			if ((vectorLayer.features[i].geometry.getBounds().intersectsBounds(map.getExtent())) && ((kml.features[i].attributes.status == 'contemporary' && contemp_on == true) || (kml.features[i].attributes.status == 'sleeping' && sleeping_on == true))){
				centroid = getVisibleCentroid(vectorLayer.features[i].geometry);
			} else {
				centroid = false;
			}
			if (centroid != false){
				//centroid = vectorLayer.features[i].geometry.getBounds().getCenterLonLat();
				pixels = map.getPixelFromLonLat(centroid);
				var lang_name = kml.features[i].attributes.name;
				var full_url = "http://maps.fphlcc.ca/fphlcc/" + kml.features[i].attributes.url;
				var confirm_html = "<center><b><a style=\\'color:blue; cursor:pointer\\' id=\\'langlink"+i+"\\'>Click to visit the "+lang_name+" language page</a><b></center><img class=\\'closeX\\' src=\\'closeX.gif\\' style=\\'position:absolute; top:0px; right:0px\\' />";
        var append_code = "<div class='poly_labels' onclick=\"$('#multiconfirm').html('"+confirm_html+"'); $('#multiconfirm').css('display','block'); $('#langlink"+i+"').click(function(){jump_to_link('"+full_url+ "')}); $('.closeX').click(function(){$('#multiconfirm').css('display','none');}); \" style='z-index:998; cursor:pointer; position:absolute; width:16em; margin-left:-13px; font-weight:bold; top:"+pixels.y+";left:"+pixels.x+"'>"+OutIt(vectorLayer.features[i].data.name, 1, "black", "white")+"</div>";
        $("body").append(append_code);
			}
		}
		
		if (kml.getVisibility()) $(".poly_labels").css('font-size','smaller');
		
		$(".poly_labels").css('display','block');
		
	}
	
	function calculateOffset(div) {
  	return new OpenLayers.Pixel(-23, -10);
	}
	
	function areArraysEqual(array1, array2) {
   var temp = new Array();
   if ( (!array1[0]) || (!array2[0]) ) { // If either is not an array
      return false;
   }
   if (array1.length != array2.length) {
      return false;
   }
   // Put all the elements from array1 into a "tagged" array
   for (var i=0; i<array1.length; i++) {
      key = (typeof array1[i]) + "~" + array1[i];
   // Use "typeof" so a number 1 isn't equal to a string "1".
      if (temp[key]) { temp[key]++; } else { temp[key] = 1; }
   // temp[key] = # of occurrences of the value (so an element could appear multiple times)
   }
   // Go through array2 - if same tag missing in "tagged" array, not equal
   for (var i=0; i<array2.length; i++) {
      key = (typeof array2[i]) + "~" + array2[i];
      if (temp[key]) {
         if (temp[key] == 0) { return false; } else { temp[key]--; }
      // Subtract to keep track of # of appearances in array2
      } else { // Key didn't appear in array1, arrays are not equal.
         return false;
      }
   }
   // If we get to this point, then every generated key in array1 showed up the exact same
   // number of times in array2, so the arrays are equal.
   return true;
}
			
			function OutIt(message, thickness, color1, color2) {	
				var x = -thickness;
				var y = -thickness;
			 	
			 	var output = '';
			 	
				while (y<=thickness) {
					while (x<=thickness) {
						output = ("<span style='color:"+color2+"; position:absolute; left:"+x+"; top:"+(-y)+";'>"+message+"</span>");
						output = output + ("<span style='color:"+color2+"; position:absolute; left:"+x+"; top:0;'>"+message+"</span>");
						output = output + ("<span style='color:"+color2+"; position:absolute; left:"+x+"; top:"+y+";'>"+message+"</span>");
						output = output + ("<span style='color:"+color2+"; position:absolute; left:"+(-x)+"; top:0;'>"+message+"</span>");
						x=x+1;
					}
					y=y+1;
				} 	

				return (output + "<span style='color:"+color1+"; position:absolute; left:0; top:0;'>"+message+"</span>");
		}
		
    function featureHovered(feature){
        $("#language_tooltip").html("<b>Language: </b> "+ feature.attributes.name);
     		$("#tooltiper").css("display","block");
     }
        
     function featureUnhovered(feature) {
    		$("#language_tooltip").html("");
    		$("#tooltiper").css("display","none");
    		kml.redraw();
     }
 
     function reserveHovered(feature){
     		$("#reserve_tooltip").html("<b>Reserve: </b> "+ feature.attributes.name);
     		$("#tooltiper").css("display","block");
     }
        
     function reserveUnhovered(feature) {
    		$("#reserve_tooltip").html("");
    		$("#tooltiper").css("display","none");
     }
     
     function isie(){
     	if (navigator.appName == "Microsoft Internet Explorer") return true;
     	else return false;
     }
     
     function map_zoomed(){
     		if (map.getZoom() > 15 && map.baseLayer.name == "Google Physical") switch_base('sat');
				if (map.getZoom() < 5) map.zoomTo(5);
				if (map.getZoom() >= kml_zoom_swtich){
					if (kml.getVisibility() == true) {
						kml.setVisibility(false);
						for (var i = 0; i < selected_features.length; i++) {
      				hoverControl.unselect(kml.features[selected_features[i]]);
      			}
      			selected_features = [];
					}
					if (contemp_on == true){
						if (kml_lines.getVisibility() == false) kml_lines.setVisibility(true);
					}else{
						if (kml_lines.getVisibility() == true) kml_lines.setVisibility(false);
					}
					$("#language_tooltip").html('');
					$("#tooltiper").css('display','none');
		 		} else{
		 		 	if (kml.getVisibility() == false) kml.setVisibility(true);
		 		 	if (kml_lines.getVisibility() == true) kml_lines.setVisibility(false);
		 		 	$("#tooltiper").css('display','none');
		 		}	
				if (map.getZoom() >= nation_zoom_swtich){
					if (nation_markers.getVisibility() == false){
						nation_markers.setVisibility(true);
						interest_markers.setVisibility(true);
					}
					updatePoints();
		 		} else{
		 		 	if (nation_markers.getVisibility() == true){
		 		 		nation_markers.setVisibility(false);
		 		 		interest_markers.setVisibility(false);
		 		 	}
		 		}
		 		
		 		if (map.getZoom() >= reserve_zoom_swtich) updateReserves();
		 		if (map.getZoom() >= reserve_zoom_swtich){
					if (reserves.getVisibility() == false) {
						reserves.setVisibility(true);
					}
		 		} else{
		 		 	if (reserves.getVisibility() == true){
		 		 		reserves.setVisibility(false);
		 		 	}
		 		}
    }
    
    function switch_connectivity(){
    	if (connectivity_markers.getVisibility() == true){
    		connectivity_markers.setVisibility(false);
    		$("#connectivity_switcher").css("font-weight","normal");
    	}else{	
    		connectivity_markers.setVisibility(true);
    		$("#connectivity_switcher").css("font-weight","bold");
    	}
    	
    }
    
    function switch_sleeping(){
    	if (sleeping_on == false) turn_sleeping_on();
			else turn_sleeping_off();
			map_moved();
    }
    
    function turn_sleeping_on(){
    	sleeping_on = true;
    	for (var i = 0; i < kml.features.length; i++) {
    		if (kml.features[i].attributes.status == 'sleeping') kml.features[i].style.fillOpacity = 0.8;
    	}
    	kml.redraw();
    	$("#sleeping_switcher").css("font-weight","bold");
    }

    function turn_sleeping_off(){
    	sleeping_on = false;
    	for (var i = 0; i < kml.features.length; i++) {
    		if (kml.features[i].attributes.status == 'sleeping') kml.features[i].style.fillOpacity = 0;
    	}
    	kml.redraw();
    	$("#sleeping_switcher").css("font-weight","normal");
    }

    function switch_contemp(){
    	if (contemp_on == false) turn_contemp_on();
			else turn_contemp_off();
			map_moved();
			map_zoomed();
    }
    
    function turn_contemp_on(){
    	contemp_on = true;
    	for (var i = 0; i < kml.features.length; i++) {
    		if (kml.features[i].attributes.status == 'contemporary') kml.features[i].style.fillOpacity = 0.8;
    	}
    	kml.redraw();
    	$("#contemp_switcher").css("font-weight","bold");
    }

    function turn_contemp_off(){
    	contemp_on = false;
    	for (var i = 0; i < kml.features.length; i++) {
    		if (kml.features[i].attributes.status == 'contemporary') kml.features[i].style.fillOpacity = 0;
    	}
    	kml.redraw();
    	$("#contemp_switcher").css("font-weight","normal");
    }
    
    
    function nation_hovered(feature){
    	setTimeout("$('#tooltiper').css('display','block')",50);
    	tootip_html = "<b>First Nation:</b> " + feature.marker_name;
    	$("#marker_tooltip").html(tootip_html);
    	nation_selected = feature;
    }
    
    function nation_unhovered(feature){
    	if (kml.getVisibility() == false) $("#tooltiper").css('display','none');
    	$("#marker_tooltip").html('');
    	nation_selected = false;
    }

    function point_hovered(feature){
    	setTimeout("$('#tooltiper').css('display','block')",50);
    	tootip_html = "<b>Point of Interest:</b> " + feature.marker_name;
    	$("#marker_tooltip").html(tootip_html);
    	point_selected = feature;
    }
    
    function point_unhovered(feature){
    	if (kml.getVisibility() == false) $("#tooltiper").css('display','none');
    	$("#marker_tooltip").html('');
    	point_selected = false;
    }
    
    function connectivity_hovered(feature){
    	if (kml.getVisibility() == false){
    		setTimeout("$('#tooltiper').css('display','block')",100);
    		var tootip_html = '';
    	}else{
    		var tootip_html = '<br/>';
    	}
    	tootip_html = tootip_html + "<b>Connectivity Information:</b> <br/>Band Name: "+feature.marker_band_name + "<br/>Community: "+feature.marker_community + "<br/>Band Office Connectivity: "+feature.marker_band_office + "<br/>Health Office Connectivity: "+feature.marker_health_office +"<br/>School Connectivity: "+feature.marker_school;
    	$("#connectivity_tooltip").html(tootip_html);
    }
    
    function connectivity_unhovered(feature){
    	if (kml.getVisibility() == false) $("#tooltiper").css('display','none');
    	$("#connectivity_tooltip").html('');
    }
    
    function populate_permacentroids(){
    	for (var i = 0; i < kml.features.length; i++) {
    		permacentroids[i] = getVisibleCentroid(kml.features[i].geometry);
    	}
    }
    
function switch_base(setbase){
	if (setbase == 'ter'){
		map.setBaseLayer(gphy);
		$("#ter_button").css("font-weight","bold");
		$("#sat_button").css("font-weight","normal");
		$("#str_button").css("font-weight","normal");
	}
	if (setbase == 'sat'){
		map.setBaseLayer(gsat);
		$("#ter_button").css("font-weight","normal");
		$("#sat_button").css("font-weight","bold");
		$("#str_button").css("font-weight","normal");
	}
	if (setbase == 'str'){
		map.setBaseLayer(gmap);
		$("#ter_button").css("font-weight","normal");
		$("#sat_button").css("font-weight","normal");
		$("#str_button").css("font-weight","bold");
	}
}

function updateReserves(){
	var mapextent = map.getExtent().transform(map.getProjectionObject(), proj);
	var map_proj = map.getProjectionObject();
	var mapextent_raw = map.getExtent();
	
	$.ajax({
	url: "ajax_control.php?request=reserves&top="+mapextent.top+"&bottom="+mapextent.bottom+"&left="+mapextent.left+"&right="+mapextent.right,
	async: false,
	beforeSend: function(){$("#loading_data").css("display","block");},
	complete: function(){$("#loading_data").css("display","none");},
	success: function(xml){
				
		var features_to_add = [];
		var i=0;
	  $(xml).find('marker').each(function(){
	  	
	  	var reserve_ir_key = $(this).attr('ir_key');
	  	
	  	var new_addition = true;
	  	
	  	//Check to see if this feature is already drawn, and if it is, then don't draw it again!
	  	if (reserves.features.length > 0){
		  	for (var f = 0; f < reserves.features.length && new_addition == true; f++) {
		  		if (reserves.features[f].attributes.reserve_ir_key == reserve_ir_key){
		  			new_addition = false;
		  		}
		  	}
	  	}
	  	
	  	if (new_addition == true){
		  	var wkt_ob = wkt.read($(this).attr('geom'));
		  	wkt_ob.attributes.reserve_gid = $(this).attr('gid');
		  	wkt_ob.attributes.reserve_band_name = $(this).attr('band_name');
		  	wkt_ob.attributes.name = $(this).attr('ir_name');
		  	wkt_ob.attributes.reserve_ir_key = $(this).attr('ir_key');
		    wkt_ob.geometry.transform(proj, map_proj);
		    features_to_add.push(wkt_ob);
	  	}
	    
	    i++;
	  });
	  if (features_to_add.length != 0){
	  	reserves.addFeatures(features_to_add);
	  }
	}
	});
	
	if (reserves.features.length > 0){
		var layers_to_remove = [];
		j=0;
	
		for (var i = 0; i < reserves.features.length; i++) {
	   if (reserves.features[i].geometry.getBounds().intersectsBounds(mapextent_raw) == false){
	   	layers_to_remove[j] = reserves.features[i];
	   	j++;
	   	}
	  }
	  reserves.destroyFeatures(layers_to_remove);
	}
}

function updatePoints(){
	var point_size = new OpenLayers.Size(16,16);
  var point_offset = new OpenLayers.Pixel(-(point_size.w/2), -point_size.h);
	var mapextent = map.getExtent().transform(map.getProjectionObject(), proj);
	var map_proj = map.getProjectionObject();
	var mapextent_raw = map.getExtent();
	
	$.ajax({
	url: "ajax_control.php?request=points&top="+mapextent.top+"&bottom="+mapextent.bottom+"&left="+mapextent.left+"&right="+mapextent.right,
	async: false,
	beforeSend: function(){$("#loading_data").css("display","block");},
	complete: function(){$("#loading_data").css("display","none");},
	success: function(xml){
			
		var i=0;
	  $(xml).find('marker').each(function(){
	  	
	  	var nid = $(this).attr('nid');
	  	
	  	var new_addition = true;
	  	
	  	//Check to see if this feature is already drawn, and if it is, then don't draw it again!
	  	if (interest_markers.markers.length > 0){
		  	for (var f = 0; f < interest_markers.markers.length && new_addition == true; f++) {
		  		if (interest_markers.markers[f].marker_nid == nid){
		  			new_addition = false;
		  		}
		  	}
	  	}
	  	
	  	if (new_addition == true){
		  	var marker_name = $(this).attr('name');
				var marker_loc_x = $(this).attr('loc_x');
				var marker_loc_y = $(this).attr('loc_y');
				var marker_nid = $(this).attr('nid');
				var map_icon = $(this).attr('map_icon');
						    	
				var marker_icon = new OpenLayers.Icon('icons/'+ map_icon,point_size,point_offset);
				var marker_location = new OpenLayers.LonLat(marker_loc_x, marker_loc_y);
        marker_location = marker_location.transform(proj, new OpenLayers.Projection("EPSG:900913"));
				
        var new_feature = new OpenLayers.Marker(marker_location,marker_icon);            			
        new_feature.marker_name = marker_name;
				new_feature.marker_nid = marker_nid;
				new_feature.events.register('mouseover', new_feature, 	function() {point_hovered(this);});
				new_feature.events.register('mouseout', new_feature, 	function() {point_unhovered(this);});
				new_feature.events.register('mousedown', new_feature, 	function() {mouseclicked(this);});
        interest_markers.addMarker(new_feature);
	  	}
	    
	    i++;
	  });
	  
	  if (interest_markers.markers.length > 0){
			for (var i = 0; i < interest_markers.markers.length; i++) {
		   if (mapextent_raw.containsLonLat(interest_markers.markers[i].lonlat) == false){
		   	interest_markers.removeMarker(interest_markers.markers[i]);
		   	}
		  }
		}
	}
	});
}



function map_moved(){
	if ((map.zoom >= 7 || always_show_labels == true) && never_show_labels == false) displayPermaLabels(kml);
	if (map.zoom >= reserve_zoom_swtich) updateReserves();
	if (map.getZoom() >= nation_zoom_swtich) updatePoints();    	
}
