$(document).ready(function(){
  var SShow=true,SBShow=true,SBSet=true;
  $("#SInS").hover(function(){SBShow=false;},function(){SBShow=true;$("#SInP").focus();if (($('#SInD').length)&&!$('#SInD').is(':hidden')) SIShow();});
  $("#SInP").hover(function(){if (!SShow) {SBShow=true;$("#SInP").focus();if (($('#SInD').length)&&!$('#SInD').is(':hidden')) SIShow();}});
  $("#SInP").focus(function(){
    if (SShow) {
      l=$(this).position().left;
      $(this).css('position','absolute').css('left',l-420).css('width','400px').css('border-right','none');
      $('#SInS').css('position','absolute').css('left',l+18);
      if ($('#SInS').html()=='') $('#SInS').html('<div onclick="SIShow()" id="SInT">'+SiL['p']+'</div>'); else $('#SInS').show();
      $('#SInD').remove();
      $('#SInT').css('border-bottom','1px solid #aaa');
      var a='<div id="SInD">';
      for(tip in SiL) {a+='<a href="javascript:SiSel(\''+tip+'\')">'+SiL[tip]+'</a>';}
      $(a+'</div>').appendTo('#SInS');
      SShow=false;
      if (SBSet) {
        $("#SInP").blur(function(){
          if (($(this).val()=='')&&SBShow&&!SShow) {
            $(this).css('position','relative').css('left','0').css('width','130px').css('border-right','1px solid #aaa');
            $('#SInS').css('position','relative').hide();
            SShow=true; SBShow=true;
          }
        });
        SBSet=false;
      }
      SBShow=false;
    } else SBShow=true;
  });
});
function SIShow() {
  if ($('#SInD').is(':hidden')){$('#SInT').css('border-bottom','none').css('color','#333');$('#SInD').slideDown('slow');}
    else $('#SInD').slideUp('slow',function(){$('#SInT').css('border-bottom','1px solid #aaa').css('color','#999');});
}
function SiSel(tip){$('#SInT').text(SiL[tip]);SIShow();$('#SInV').val(tip);}
function PtSow(p){$('#TpMenu').css('left',$('#TpMore').offset().left-10).slideToggle("slow");}