$(document).ready(function(){
	$('.scroll-pane').jScrollPane();

	$(".dropdown dt a").click(function() {
		$(".dropdown dd ul").toggle();
	});
				
	$(".dropdown dd ul li a").click(function() {
		var text = $(this).html();
		$(".dropdown dt a span").html(text);
		$(".dropdown dd ul").hide();
		$("#result").html("Selected value is: " + getSelectedValue("sample"));
	});
				
	function getSelectedValue(id) {
		return $("#" + id).find("dt a span.value").html();
	}

	$(document).bind('click', function(e) {
		var $clicked = $(e.target);
		if (! $clicked.parents().hasClass("dropdown"))
			$(".dropdown dd ul").hide();
	});

	$(".catdrop dt a").click(function() {
		$(".catdrop dd ul").toggle();
	});
				
	$(".catdrop dd ul li a").click(function() {
		var text = $(this).html();
		$(".catdrop dt a span").html(text);
		$(".catdrop dd ul").hide();
		$("#result").html("Selected value is: " + getSelectedValue("sample"));
	});
				
	function getSelectedValue(id) {
		return $("#" + id).find("dt a span.value").html();
	}

	$(document).bind('click', function(e) {
		var $clicked = $(e.target);
		if (! $clicked.parents().hasClass("catdrop"))
			$(".catdrop dd ul").hide();
	});
	
});