
var ERROR = "FILE NOT FOUND";
var serviceUrl = "http://www.plugins.gov.on.ca/exploregovernment/exploregovt.php";

$(function (){
	serviceUrl += "?format=json&lang="+lang;
	$.ajax({
		'url': serviceUrl,
		'type': 'GET',
		'dataType': 'jsonp', // this adds &callback=? by design
		'cache': true,
		'success': function(data) { formatData(data); }
	});
});

function formatData(jsonResponse){
	if(jsonResponse==ERROR || jsonResponse==null){
		return;
	}
	eval(jsonResponse);
	var itemArray = jsonResponse.ministry;
	
	$.each(itemArray, function(index,value){
		$("<li><a href='"+value["@attributes"].link+"'>"+value.name+"</a></li>").appendTo('div#exploreGovt > ul.menu');
	});

}
