﻿$(function()
{
    $(".select_js ul li").hover(
        function()
        {
            $(this).addClass('search_nonce');
        },
        function()
        {
            $(this).removeClass();
        }
    );
    
    $(".select_js").click(block_fn);
    $(".select_js ul li").click(function(){
        var text = $(this).text();
        $(".select_js p").text(text);
        var act  = $(this).attr("ectype");
        $(".select_js input").val(act);       
    });
    $(".username").click(
      function()
          {
              $(".username").val('');}
          ) ;
    $("#regname").click(
      function()
          {
              $("#regname").val('');}
          ) ;	
});

function block_fn()
{
    $(".select_js ul").toggle();
}
function mouseLocation(e)
{
    if (e.pageX < $('.select_js').position().left ||
        e.pageX > $('.select_js').position().left + $('.select_js').outerWidth() ||
        e.pageY < $('.select_js').position().top ||
        e.pageY > $('.select_js').position().top + $('.select_js').outerHeight())
    {
        $('.select_js ul').hide();
    }
}
function indexLogin(uname,pwd,check)
{
    if($.trim(uname)=="")
    {
        alert("请填写用户名！");
        return;
    }
    if($.trim(pwd)=="")
    {
        alert("请填写密码！");
        return;
    }
     
      $.get("/ajax/ajax.aspx?no-cache="+Math.random(),{Action:"indexlogin",uname:$.trim(uname),pwd:$.trim(pwd),check:check}, function (returnvalue, textStatus){
            var urlStr=returnvalue.split('@');            
            if(urlStr[1]!="")
            {
                $('#login').html(urlStr[0]);
                alert("用户名或密码错误！");
                window.location.href=(urlStr[1]);                
            }
            else 
            {         
                  $('#login').fadeOut("slow");                                           
                  $('#login1').fadeIn("slow");  
                  $('#login1').html(urlStr[0]);                             
            }
      });
    
}
function checkuname(uname,check)
{
    if(!check)
    {
        alert("请阅读服务条款");
        return;
    }
     if($.trim(uname)=="")
    {
        alert("请填写用户名！");
        return;
    }
    $.get("/ajax/ajax.aspx?no-cache="+Math.random(),{Action:"checkuname",uname:$.trim(uname)}, function (returnvalue, textStatus){
    if(returnvalue=='yes')
    {
        $("#tip").html("该用户名已经被人注册");        
    }
    else
    {
       window.location.href="/passport/Register.aspx?uname="+escape(uname);
    }
    });
}