jQuery(document).ready(function() {
	
	$("#scrollContainer").jScrollPane({
		showArrows:true,
		dragMaxHeight:10,
		scrollbarWidth: 10,
		scrollbarMargin: 0,
		scrollbarOnLeft:true
	});

	// higlighting menu items
	$("#menu img").mouseenter(function(){
		var source = $(this).attr("src");
		source=source.replace(".","_.");
		$(this).attr("src",source);
	}).mouseleave(function(){
		var source = $(this).attr("src");
		source=source.replace("_.",".");
		$(this).attr("src",source);
	});
	
	// finalize content while ajax load is ready
	$("#content").ajaxSuccess(function(){
		   $(this).fadeIn("fast", function(){
			   $("#loading").fadeOut("fast");
		   });
		   $("#scrollContainer").jScrollPane({showArrows:true,dragMaxHeight:20,scrollbarWidth:20});
	});
	
		 
	// run ajax on menu click
	$("#menu img").click(function (){
		apage = $(this).attr("alt");
		$("#loading").css("display","block");
			$("#content").fadeOut("slow",function(){
				$.get("/ajax.php",{city: acity, lang: alang, page: apage} ,function(data){
					$("#content").html(data); 
				});
			});	
	});
	
	// run ajax on side menu click
	$("#side a").click(function (){
		var asubpage = $(this).attr("title");
		
		$("#loading").show(function(){
			$("#content").fadeOut("slow",function(){
				$.get("/ajax.php",{city: acity, lang: alang, page: apage, subpage: asubpage} ,function(data){
					$("#content").html(data);
				});
			});
		});	
	});
	
});
