
var WARDMAP = {
	'ward_data':{},
	'out_top':0,
	'out_left':0,
	'title':null,
	'title_style':'display:block;background-color:#d6e7f9;padding:2px;text-align:center;font-weight:bold;',
	'text':null,
	'ward':null,
	'load_data':function(obj){
		var ward = unescape(((obj.toString()).split('&'))[1].split('=')[1]);
		//get the title
		this.title = '<div class="title" style="'+this.title_style+'">'+ward+'</div>';
		this.ward = (ward.toLowerCase()).replace(/\s/g,"");
		if(typeof this.ward_data[this.ward] != "undefined"){
			this.text = unescape(this.ward_data[this.ward]).replace(/\+/g," ");
			this.text = (this.text).replace(/(\<)(\/)?(strong)(\>)/,'');
		}//end if
	},
	'setData':function(data){
		$.each(data, function(){
			WARDMAP.ward_data[this.title] = this.text;
		});
		
		$('#wardmap area').mouseover(function(){
			WARDMAP.load_data(this);
			$(this).mousemove(function(e){
				WARDMAP.out_top = e.pageY;
				WARDMAP.out_left = e.pageX;
				WARDMAP.mover();
			});
		});
		
		$('#wardmap').mouseout(function(){
			$("#map_data").hide();
		});
		 	
	},
	'mover':function(){
		$("#map_data").html(this.title+'<div class="data" style="padding:5px;background:#ffffff;">'+this.text+"</div>")
		.css({
			'display':"block",
			'position':"absolute",
			'top':(this.out_top+20)+"px",
			'left':(this.out_left)+"px"
		})
	}
};

$(document).ready(function(){
	$.getJSON("/packages/php/php_classes/wardmap/load_data.php" ,WARDMAP.setData);
});
