$(document).ready(function() {
	var tabLoadInProgress = false;
	// tabs
	$(".HorizontalMenuBarWidget_menu a").click(function() {
		if(tabLoadInProgress) {
			return false;
		}
		tabLoadInProgress = true;

		var $link = $(this);
		$.ajax({
		  url: $(this).attr("href"),
		  success: function(data) {
				var effect = "slide";
				// nice takeoff
				$("#contentArea").hide(effect, { direction: "right" }, 600, function() {
					$(this).html(data);
					
					// off left technique => scroller
					$(this).css("left", "-1000px").show();
					makeScrollPane();
					$(this).css("left", "").hide();
					
					// nice come back
					$(this).show(effect, { direction: "left" }, 600, function() {
						tabLoadInProgress = false	;
					});
				});
				
				$(".current").removeClass("current");
				$link.addClass("current");
				
	  	  },
		  dataType: "html"
		});

		return false;
	});
	
	// scroller
	makeScrollPane();
	
	function makeScrollPane() {
		$('#scrollableContent').jScrollPane({
			showArrows: true,
			dragMaxHeight: 10,
			reinitialiseOnImageLoad: true
		});	
	}
	
	
	
	// menu
	$(".HorizontalMenuBarWidget_menu li").css("cursor", "pointer").click(function(e){
		$("a", $(this)).click(e);
	}).append('<img src="/images/frontend/menuBg.png" class="menuNiceBg" />').find("a").addClass("menuNiceLink");
	$(".HorizontalMenuBarWidget_menu li").hover(function(){
		$(".menuNiceBg", $(this)).animate({
			opacity: 1
		}, {
			queue:false,
			duration: 1000
		});
	}, function() {
		$(".menuNiceBg", $(this)).animate({
			opacity: 0
		}, {
			queue:false,
			duration: 1000
		});
	});
});



