﻿function initMenu() {
  $('#m1 ul, #m2 ul, #m3 ul, #m4 ul, #m5 ul, #m6 ul, #m7 ul').hide();
//  $('#m1 li a, #m2 li a, #m3 li a, #m4 li a, #m5 li a').click(
//    function() {
//        $(this).next().slideToggle('normal');	
//      }
//    );
  SetEnter('txtSrc', 'cmdSrc');
  }

  //$(document).ready(function() {initMenu();});

  function SrcSite(q) {      
      if (q != '') {
          q = q.replace(' ', '+');
          location.href = 'search?q=' + q;
          return false;
      }
      return false;
  }


  /* UTILITY */
  function SetEnter(id_input, id_cmd) {

      $('#' + id_input).bind('keypress', function(e) {
          var code = (e.keyCode ? e.keyCode : e.which);
          if (code == 13) { //Enter keycode
              $('#' + id_cmd).click();
              return false;
          }
      });
  }
  
  function l(){
  		//$('#loading').fadeIn(200);
  		var myRes = '';
        $('#msgLogin').show();
        var xhr = $.ajax({
            type: 'POST',
            url: 'post.aspx',
            data: { f:'l', u:$('#loginusr').val() , p:$('#loginpwd').val() },
            success: function (data, status) {
                $('#msgLogin').html(data);
                if (data=='') j();
            },
            error: function (data, status) {
                $('#msgLogin').html(data);
            }
        });
    }

    function lg() {
        //$('#loading').fadeIn(200);
        var myRes = '';
        $('#msgLogin').show();
        var xhr = $.ajax({
            type: 'POST',
            url: 'post.aspx',
            data: { f: 'lg' },
            success: function (data, status) {
                $('#msgLogin').html(data);
                if (data == '') jo();
            },
            error: function (data, status) {
                $('#msgLogin').html(data);
            }
        });
    }
  
  function j(){
	  document.location.href="logged?l=y";

}

function jo() {
    document.location.href = "logged?l=n";
}
