/* Load the Top Panel */
function LoadTopPanel() {

	/*
	$("#ps-top-sliding-panel-btn-slide").click(function(){
		  $("#ps-top-sliding-panel").slideToggle("slow");
		  $(this).toggleClass("active");
		});
	*/

	var speed = 400;

	var pstoppanelshow = "no";
	var ps_top_panel = jQuery("#ps-top-sliding-panel-container");

	// slideup on page load
	if(pstoppanelshow == 'yes') {
		jQuery("#ps-top-sliding-panel-container").css({top:"-96px"});
		jQuery(this).removeClass("ajax-close-ps-top-slide").addClass("ajax-open-ps-top-slide");
	} else {
		jQuery(this).removeClass("ajax-open-ps-top-slide").addClass("ajax-close-ps-top-slide");
		jQuery("#ps-top-sliding-panel-container").animate({top:"-1px"}, 900);
		jQuery("#ps-top-sliding-panel-container").animate({top:"-1px"}, 2000);
		jQuery("#ps-top-sliding-panel-container").animate({top:"-96px"}, 900);
		jQuery(this).removeClass("ajax-close-ps-top-slide").addClass("ajax-open-ps-top-slide");
		//document.cookie = "pstoppanelshow=yes; path=/";
	}
	jQuery(this).removeClass("ajax-close-ps-top-slide").addClass("ajax-open-ps-top-slide");

	//slid up/down top panel
	jQuery("#ps-top-sliding-panel-container #ps-top-sliding-panel-btn-slide").click(function(){
		//document.cookie = "pstoppanelshow=yes; path=/";
		if( jQuery(this).hasClass("ajax-open-ps-top-slide") ) {
			jQuery("#ps-top-sliding-panel-container").animate({top:"-1px"}, speed);
			jQuery(this).removeClass("ajax-open-ps-top-slide").addClass("ajax-close-ps-top-slide");
		} else if( jQuery(this).hasClass("ajax-close-ps-top-slide") ) {
			jQuery("#ps-top-sliding-panel-container").animate({top:"-96px"}, speed);
			jQuery(this).removeClass("ajax-close-ps-top-slide").addClass("ajax-open-ps-top-slide");
		}
	});

	//slide up when click outside
	jQuery("#ps-top-sliding-panel-container").hover(
			function() {
				jQuery('body').unbind('click');
			},
			function() {
				if( jQuery("#ps-top-sliding-panel-container #ps-top-sliding-panel-btn-slide").hasClass("ajax-close-ps-top-slide") ) {
					jQuery('body').one('click',function() {
						jQuery(this).unbind('click');
						jQuery("#ps-top-sliding-panel-container").animate({top:"-96px"}, speed);
						jQuery("#ps-top-sliding-panel-container #ps-top-sliding-panel-btn-slide").removeClass("ajax-close-ps-top-slide").addClass("ajax-open-ps-top-slide");
					});
				}
			}
	);

	// slide up/down themes/styles list
	jQuery(".ps-top-sliding-panel-dropdown dt a").click(function() {
		var dropID = $(this).closest("dl").attr("id");
		jQuery("#"+dropID+" dd ul").slideToggle(200);
		jQuery("#"+dropID).mouseleave(function() {
			jQuery("#"+dropID+" dd ul").slideUp(200);
		});
	});
	
	// show thumbinals
	jQuery(".ps-top-sliding-panel-tooltips").hover(
			function() { jQuery(this).contents(".ps-top-sliding-panel-tip").css({ display: "block" }); },
			function() { jQuery(this).contents(".ps-top-sliding-panel-tip").css({ display: "none" }); }
	);
	
	jQuery(".ps-top-sliding-panel-tooltips").mousemove(function(c) {
		var offset = jQuery(".ps-top-sliding-panel-tooltips").offset();
		var mouseX = c.pageX - offset.left + 20;
		var mouseY = c.pageY - offset.top + 20;
		jQuery(this).contents(".ps-top-sliding-panel-tip").css({ top: mouseY, left: mouseX });
	});

}
