// this is managing the css block toggles
function toggle(id){
if (document.getElementById){
var el = document.getElementById(id);
el.style.display = (el.style.display == 'none') ? 'block' : 'none';
}
}

//this was working on hiding the otherMaps block; no longer needed.
/*
window.onload = function(){
toggle('otherMaps');
}
*/



// removing bad crap from strings
function strValidation(string) {
    for (var i=0, output='', valid="123456789abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ"; i<string.length; i++)
       if (valid.indexOf(string.charAt(i)) != -1)
          output += string.charAt(i)
    return output;
} 

//this is the main xml parsing function
function getCities(){ 
	var cityHolder = '';
	var urlstr="public/poi/mappa.xml";
	//firefox and safari should fall for this one
	if(window.XMLHttpRequest && !(window.ActiveXObject)) {
		var request = new XMLHttpRequest();
	//ie6 and such should fall for this one
	}else if(window.ActiveXObject) {
       	try {
			//extra stuff here for older browsers
        	request = new ActiveXObject("Msxml2.XMLHTTP");
      	}catch(e){
			try {
				request = new ActiveXObject("Microsoft.XMLHTTP");
        	}catch(e){
          		request = false;
        	}
		}
	}
	if(request){
		request.open("GET", urlstr, true); 
  		request.onreadystatechange = function() {
			if (request.readyState == 4) {
				if (request.status == 200){
					var xmlDoc = request.responseXML;
					// obtain the array of cities and loop through it
					var thecities = xmlDoc.documentElement.getElementsByTagName("city");

					for (var i = 0; i < thecities.length; i++) {
						// obtain the attribues of each candidate
						var name = thecities[i].firstChild.nodeValue;
						var id = thecities[i].getAttribute("id");
						var lat = thecities[i].getAttribute("lat");
						var lng = thecities[i].getAttribute("lng");	
						var dist = thecities[i].getAttribute("dist");
						var zoom = thecities[i].getAttribute("zoom");
						var real = thecities[i].getAttribute("real");	
						
						
					}
				}else{ //the status didn't turn up to be 200.  404 is another status code, 200 is OK.
					alert("There was a problem retrieving the XML data:\n" + request.statusText);
				}
			}							
		}
		request.send(null);
	}
}
