loadMap = function (id_entity,id,mapWidth,mapHeight,CurrentQuery,page) {
	page = typeof(page) != 'undefined' ? page : 'default';
	//currentType = typeof(currentType) != 'undefined' ? page : 'default';

	$.get("/map.php", { 'id_entity': id_entity, 'id' : id, 'reload' : 1, width: mapWidth, height: mapHeight, query : CurrentQuery, page: currentPage,type: currentType }, 
			function(data){
 					updateMap(data,mapWidth,mapHeight);
			}, 'json');
}

function updateMap(data,weight,height) {
	//var mapObj = getMapFromId("Maps");
	//console.log(mapObj);
	//getMapFromId("Maps").setDataXML(data);	

	//Instantiate the Maps	
	var Maps_Maps = new FusionMaps("/Maps/"+data.map, "Maps", weight, height, "0", "1");
	//Provide entire XML data using dataXML method
	Maps_Maps.setDataXML(data.xml);
	// Set transparent
	Maps_Maps.setTransparent (true);
	//Finally, render the Maps.
	Maps_Maps.render("MapsDiv");
	
	$('.map_parents').empty().html(data.link_parents);
	$('.map_parents').show();


//	if (data.level == 2) {
//		$("#fcountryName").val(data.name);
//		$("#fcountryName").slideDown('slow');

//		$("#fcountryID").val(data.country_id);
//	}
//	if (data.level == 3) {
//		$("#fstateName").val(data.name);
//		$("#fstateName").slideDown('slow');

//		$("#fstateID").val(data.state_id);
//	}


}


// Fill out the field "Where do you want to go" on the home page once you click on the map
function fillSearchField(name) {
	if (name != '') {
		$('#basedOnLocation').val('true');
		$("#locationString").val(name);
	}
}