// Dropdown control for inline sidebars.
$(document).ready(
	function(){
    // New latteral folding code.
    $('.panel').width(parseInt($('.mask').width() * $('.panel div').length));
  	$('.panel>div').width($('.mask').width());
  	$('a[rel=panel]').click(function(e){e.preventDefault();movePanel($(this))});
	  $('.mask').height($($(this).children('panel')).height());

    // Image Map Hover.
    $('#Map area').tooltip({
      delay:0, showURL: false
    });

    // Old folding code.
	  var definition = $("#definitions").find("tr.uniqueKey").find(".definition").text();
	  $("body").addClass("script");
	  $(".dropdownclick").toggle(
		  function(){
		    $(this).siblings("div").slideDown("fast");
		    $(this).children("span").html("&uarr;");
		    $(this).attr("title","Click to hide content ...");
		    setTimeout("resizePanel($(this))",100);
		  },
		  function(){
			  $(this).siblings("div").slideUp("fast");
			  $(this).children("span").html("&darr;");
		    $(this).attr("title","Click to show content ...");
		    setTimeout("resizePanel($(this))",100);
		});
		$("#bubble").toggle(
			function(){
				$("#loginslider").slideDown("medium",function(){$("#user_login").focus()});
				$("#sidebar").animate({top:"+=65"},"medium");
			},
			function(){
				$("#loginslider").slideUp("medium");
				$("#sidebar").animate({top:"-=65"},"medium");
			});
	  $("abbr").hover(
		  function(){
			  $(this).css("cursor","help");
			  var currentClass = $(this).attr("class");
			  var definition = $("#definitions").find("tr." + currentClass).find(".definition").text();
              var word = $("table").find("tr." + currentClass).find(".word").text();
			//$(this).attr("title",word + ": " + definition);
			  $(this).tooltip({
				  bodyHandler: function() { 
				    return word + ": " + definition;
				  },
				delay: 0
				});
			},
			function(){}
		);
});
// Horizontal and folding JavaScript.
function movePanel(t) {
	var panelHeight = $(t.attr('href')).height();
	$('a[rel=panel]').removeClass('selected');
	var currentSlider = t.attr('class');
	$('#' + currentSlider + ' .mask').stop().animate({'height':panelHeight},{queue:false, duration:500});
	$('#' + currentSlider + ' .mask').scrollTo(t.attr('href'), 600);
	return false;
}
// Horizontal and folding JavaScript.
function resizePanel(t) {
  var parentFrame = t.parents('.frame').attr('id');
	var parentSliderID = t.parents('.slider').attr('id');
	var panelHeight = $("#" + parentSliderID + " #" + parentFrame).height();
	$('#' + parentSliderID + ' .mask').stop().animate({'height':panelHeight},{queue:false, duration:500});
	return false;
}

