$(function() {
	
		var x = 20;
		var y = 10;
	
		$("#agenda").datepicker({
			onSelect: function (date) {
			$(".eventos").html("<img src='images/ajax-loader.gif' id='loading' alt='...Carregando...' />").show();
			$(".eventos").load("content.php", { datePicked: date, method: "calendar" }, 
			function() {
		                $("#loading").remove();
      			});
			return false;
		}	
		});
		
		$('a.leader').click(function () {
			$('#nameEdit').html("<img src='images/ajax-loader.gif' id='loading' alt='...Carregando...' />").show();
			var t = $(this).attr('title');
			$.post("query.php", { method: "ministry", id: t },
			function(data) {			
				$('#nameEdit').html(data);
			});
			return false;
		});
		
		$("a.leaderslink").click(function () {
			//$(".inner2").append("<img src='images/ajax-loader.gif' align='center' id='loading' alt='...Carregando...' />").show();
			var name = $(this).children("img").attr("name");
			var pic = $(this).children("img").attr("href");
			var title = $(this).children("img").attr("title");
			var desc = $(this).children("img").attr("desc");
			$("#leaderpic").attr("src",pic);
			$("#leadername").html(name+"(<i>"+title+"</i>)");
			$("#leaderdesc").html(desc);
			return false;
		});
		
		$("#test").click(function() {
			var href = $(this).attr("href");
			$(".inner").html("test").load(href);
			return false;
		});
		
		/*$("img.leadersimage").hover(
		function(e) {
		//mouse on
			var href = $(this).attr("href");
			$('<img id="leaders" src="' + href + '" alt="' + $(this).attr("name") + '" />')
			.css('top', e.pageY + y)
			.css('left', e.pageX + x)
			.appendTo("div.inner3");
		},
		function (e) {
		//mouse off
			$("#leaders").remove();
			
		});
		
		$("img.leadersimage").mousemove(function (e) {
			$("#leaders").css('top', e.pageY + y)
						 .css('left', e.pageX + x);
		});*/
		
		$("a.section").click(function() {
			$("div.center").append("<img src='images/ajax-loader.gif' id='loading' alt='...Carregando...' />").show();
			var title = $(this).attr("title");
			var id = $(this).attr("id");
			$("div.inner4").load("content.php", { method: title, id: id }, function () {
				$("#loading").remove();
			});
			return false;
		});
	});