$(document).ready(function() {


  if($('input#btnLogin')){
     $('input#btnLogin').bind("click", function(e){
      var status = "";
      var message = "";
	  var gender = "";
	  
      $.ajax({
        type: "POST",
        url: "/member-login.aspx?op=login",
        data: "login="+$('input#txtLogin')[0].value+"&pass="+$('input#txtPass')[0].value,
        success: function(xml){
          var data = "";
          jQuery.each($("message", xml),function(){
            status = $(this).attr("status");
            gender = $(this).attr("gender");
			 message = $(this)[0].firstChild.nodeValue;

            if(status == "1"){
              // $('#lblLoginError').css('display','none');
              // $('#lblLoginError').replaceWith(""); 
			  //alert(gender);
              window.location = window.location;
            }
            else if(status == "-1"){
              // $('#lblLoginError').css('display','block');
              // $('#lblLoginError').text(message);
              // alert("Invalid Login");
              $('#fail-login').show('slow');
            }

          });
        }
      }); 
        
    });
  
     $('input#txtPass').attr('autocomplete', 'off').keyup(function(event) { 
    
if (event.keyCode == 13) { 
      var status = "";
      var message = "";
	  var gender = "";
      $.ajax({
        type: "POST",
        url: "/member-login.aspx?op=login",
        data: "login="+$('input#txtLogin')[0].value+"&pass="+$('input#txtPass')[0].value,
        success: function(xml){
          var data = "";
          jQuery.each($("message", xml),function(){
            status = $(this).attr("status");
            gender = $(this).attr("gender");
			 message = $(this)[0].firstChild.nodeValue;
            if(status == "1"){
              $('#lblLoginError').css('display','none');
              $('#lblLoginError').replaceWith(""); 
			  //alert(gender);
              window.location = window.location;
            }
            else if(status == "-1"){
              $('#lblLoginError').css('display','block');
              $('#lblLoginError').text(message);
            }
          
          });
        }
      }); 
      }     
    });
  }
  if($('#welcome a')){
    $('#welcome a').bind("click", function(e){
      var status = "";
      var message = "";
      $.ajax({
        type: "GET",
        url: "/member-login.aspx?op=logout",
        success: function(xml){
          var data = "";
          jQuery.each($("message", xml),function(){
            status = $(this).attr("status");
            message = $(this)[0].firstChild.nodeValue;
            
            if(status == "0"){
              $('#lblLoginError').replaceWith("");
              window.location = window.location;
            }
             
          });
        }
      });      
    });
  }
});