function UnicefMapData (unicefMapReference)	{
//alert("CURRENT_DIRECTORY: " + CURRENT_DIRECTORY);
        this.getZonesURL = CURRENT_DIRECTORY+"/data/xml/zones_by_cat/";
//alert("getZonesURL: " + this.getZonesURL);
        this.getArticleListURL = CURRENT_DIRECTORY+"/data/functions/getArticleList.php?";
//alert("getArticleListURL: " + this.getArticleListURL);
        this.getArticleDetailURL = CURRENT_DIRECTORY+"/data/functions/getArticleById.php?";
//alert("getArticleDetailURL: " + this.getArticleDetailURL);

	// So we can call methods on the main object
	this.unicefMapRef = unicefMapReference;
	
	this.xmlDataInProgress = 0;
		
	this.dataLocation = "data/";
	
	this.getZones = function (cat)	{	
		this.getData(this.getZonesURL+cat+'.xml',this.parseZoneData);
	}
	
	this.getData = function (url, callback)	{
		if (!this.xmlDataInProgress)
		{
			this.xmlDataInProgress = 1;
			var unicefMap = this.unicefMapRef;
	
			var req = GXmlHttp.create();
			req.open("GET", url, true);
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					unicefMap.markerData.xmlDataInProgress = 0;
					callback(req.responseText, unicefMap);
				}
			}
			req.send(null);
		}
	}
	
	this.parseZoneData = function (data,unicefMap) {	
		var xmlDom = GXml.parse(data);
		
		var zonesNode = xmlDom.documentElement;
		var zones = zonesNode.getElementsByTagName("zone");
		var numZones = zones.length;
		
		var markers = [];
		
		for (var i = 0; i < numZones; i++) {
			var zone = zones[i];
			
			var id = zone.getAttribute("id");
			var geo = zone.getAttribute("geo").split(",");
			var ggeo = new GLatLng(geo[0],geo[1]);
			
			markers.push([id,ggeo])
		}
		
		unicefMap.setMarkerData(markers);
	}
	
	this.getArticleListByID = function (id)	{
		var cat = this.unicefMapRef.currentCategory;
		
		this.getData(this.getArticleListURL+'cat='+cat+'&zone='+id,this.unicefMapRef.updateCurrentWindow);
	}
	
	this.getArticleByID = function (id,zone) {
		var cat = this.unicefMapRef.currentCategory;	
	
		this.getData(this.getArticleDetailURL+'cat='+cat+'&zone='+zone+'&id='+id,this.unicefMapRef.updateCurrentWindow);
	}
}

