$(document).ready(function () {
	$("#crd-dropdown-menu, #crd-dropdown-year, #crd-dropdown-category").each(function () {
		if($(this).is(":visible")) {
			$(this).sSelect();
		}
	});
	$("#crd-dropdown-menu, #crd-dropdown-year, #crd-dropdown-category").change(function (o) {
		var $elm = $(this);
		document.location.href = '/'+$elm.val();
	});
	
	$(".selectedTxt").mouseenter(function(Element) {
		$(this).next().show();
	});
	$(".newList").mouseleave(function() {
		$(".newList").hide();
	});
	
	$(".hiLite").click(function() {
		$(".newList").hide();
		document.location.href = document.location.href;
	});	
});



/*
* Obsolete old code.

 $(document).ready(function () {
	$("#crd-dropdown-menu").sSelect();
	if($("#crd-dropdown-year").is(":visible")){
		$("#crd-dropdown-year").sSelect();
	}
	if($("#crd-dropdown-category").is(":visible")){
		$("#crd-dropdown-category").sSelect();
	}
	$("#crd-dropdown-menu, #crd-dropdown-year, #crd-dropdown-category").change(function (o) {
		var $elm = $(this);
		if($elm.attr("id") == "crd-dropdown-menu") {
			//hide the last select box if visible
			if($("#crd-dropdown-year").next().is("div.newListSelected")) {
				$("#crd-dropdown-year").removeSS();
			}
			var temp = $elm.val().split(":");
			if(temp[2] == 0) {
				document.location.href = '/'+temp[0];
			} else if (temp[2] >= 1) {
				//fill next select box
				//poll for children to fill the select box
				$("#crd-dropdown-category").html("");
				$("#crd-dropdown-menu").attr("disabled", true);
				$.getJSON("/includes/menuajax.php?m="+temp[1],
					function(data){
						if(data.menu != 184) {
							$("#crd-dropdown-category").append("<option disabled='disabled' selected='selected' value=''>Worktype</option>");
						}
					  $.each(data.children, function(i,item){
						$("#crd-dropdown-category").append("<option value='"+temp[0]+"/"+item.sitetitle+":"+item.id+":"+item.children+"'>"+item.title+"</option>");
					  });
					  $("#crd-dropdown-menu").attr("disabled", false);
					}
				);
				$(document).ajaxComplete(function(event,request, settings){
					if($("#crd-dropdown-category").next().is("div.newListSelected")) {
						$("#crd-dropdown-category").resetSS();
					} else {
						$("#crd-dropdown-category").sSelect();
					}
				});
				
			}
		} else if ($elm.attr("id") == "crd-dropdown-category") {
			//hide the last select box if visible
			if($("#crd-dropdown-year").next().is("div.newListSelected")) {
				$("#crd-dropdown-year").removeSS();
			}
			var temp = $elm.val().split(":");
			if(temp[2] == 0) {
				document.location.href = '/'+temp[0];
			} else if (temp[2] >= 1) {
				//fill next select box
				//poll for children to fill the select box
				$("#crd-dropdown-year").html("");
				$("#crd-dropdown-category").attr("disabled", true);
				$.getJSON("/includes/menuajax.php?m="+temp[1],
					function(data){
					  $("#crd-dropdown-year").append("<option disabled='disabled' selected='selected' value=''>Year</option>");
					  $.each(data.children, function(i,item){
						$("#crd-dropdown-year").append("<option value='"+temp[0]+"/"+item.sitetitle+"'>"+item.title+"</option>");
					  });
					  $("#crd-dropdown-category").attr("disabled", false);
					}
				);
				$(document).ajaxComplete(function(event,request, settings){
					if($("#crd-dropdown-year").next().is("div.newListSelected")) {
						$("#crd-dropdown-year").resetSS();
					} else {
						$("#crd-dropdown-year").sSelect();
					}
				});
			}
		} else if ($elm.attr("id") == "crd-dropdown-year") {
			document.location.href = '/'+$elm.val();
		}
	});
});
*/