var tempHref ='';
var doBlur = true;
$(document).ready(function(){
  $(".select_box_sm").mouseover(function () {
      doBlur = false;
  }).mouseout(function () {
      doBlur = true;
  });
  $(".select_box_sm").click(function () {
    $("div.sel_regions").slideToggle("slow");
  });
  $(".sel_regions ul li a").click(function () {
    tempHref = $(this).attr("href");
    setTimeout("moveOn()",1000);
    $(this).attr('href', '#');
    var htmlStr = $(this).html();
    $(".select_box_sm span").text(htmlStr);
    $("div.sel_regions").slideUp("slow");
  });
  $(".sel_regions ul li").mouseover(function () {
    $(this).css("background","#ccc");
  });
  $(".sel_regions ul li").mouseout(function () {
    $(this).css("background","none");
  });
  $("body").click(function () {
    if (doBlur == true) {
      $(".select_box_sm").unbind('click');
      setTimeout("reBind()",900);
      $("div.sel_regions").slideUp("slow");
    }
  });
  $("body").keydown(function(e) {
  if (e.keyCode == 27) {
    $("div.sel_regions").slideUp("slow");
  }
});


});
function moveOn(){
  window.location.href = tempHref;
}
function reBind(){
  $(".select_box_sm").bind('click', function () {
    $("div.sel_regions").slideToggle("slow");
    $(".select_box_sm a").focus();
  });
}