$(document).ready(function() {

	//controls category and subcategory drop down menus on search pages
	var menuhover = false;
	 
	$(".t-selectmenu").blur(function(){
		if (menuhover == false){
			$(this).find("ul").hide();
		}
	});
	 
	$(".t-selectmenu").click(function(){
		$(this).find("ul").toggle();
		$(this).focus();
	});
	
	$(".t-selectmenu").find("ul").hide();
	
	$(".t-selectmenu").keydown(function(e){
		switch(e.keyCode) {
			case 9:
				menuhover = true;
			break;
			case 27:
				$(this).click();
				$(this).focus();
			break;
		}
	});

	$(".t-selectmenu ul").hover(
		function(){
			menuhover = true;
		},
		function(){
			menuhover = false;
	});
	 
	$(".t-selectmenu ul").focus(function(){
		menuhover = true;
	});
	
	$(".t-selectmenu ul li a").focus(function(){
		$(this).css({color: "highlighttext", "background-color":"highlight"});
	});
	
	$(".t-selectmenu ul li a").blur(function(){
		$(this).css({color: "", "background-color":""});
	});
	
	$(".t-selectmenu ul").bgiframe();
	
});
