
$(document).ready
(
  function(_evt)
  {
    window.MASK_O = $('#reg_box_');
    
//     j_mask_f
//     ( 
//       window.MASK_O,
//       function()
//       {
//       
//       }  
//       , { 
//           close:'.close_mask'
//           , box: '.div'
//           , opacity: 0.0
//           , close_callback: 
//           function()
//           { 
//             /* alert('ok') */
//           } 
//         }
//     );
//     
//     setTimeout
//     (
//       function()
//       {
//         flash_login();
//       }
//       , 100
//     )
//     
//     
//     window.onresize =
//     function()
//     {
//       flash_login();  
//     }
    //flash_login()
    

	// 验证用户名
    $('#username').blur(function(){
        if (this.value!='')
        {
            $.get('http://passport.jzwar.com/ajax.php?callback=?',{action:'checkname',username:this.value},function(json){
                if (json.CODE=='SUCCESS')
                {
                    $('#username').next().css({color:'#006600'}).text(json.TEXT);
                } else {
                    $('#username').next().css({color:'#FF0000'}).text(json.TEXT);
                }
                
            },'json');
        } else {
            $('#username').next().css({color:'#FF0000'}).text('用户名不能为空');
        }
    });
    
    
    $(window).resize
    (
      function()
      {
        var reg_box_ = document.getElementById("reg_box_");
        
        if( reg_box_.style.display!='block' ){return;}
        
        var max_width = document.documentElement.clientWidth;
        var max_height = document.documentElement.clientHeight;
        
        reg_box_.style.left = (max_width - reg_box_.offsetWidth)/2 + 'px';
        reg_box_.style.top = (max_height - $(reg_box_).height())/2+'px';
        
        reg_box_.style.zIndex = 99999;
      }
    );
    
  }
);


function flash_login()
{
  window.MASK_O.click();
  
  var reg_box_ = document.getElementById("reg_box_");
  
  reg_box_.style.display = "block";
  
  var max_width = document.documentElement.clientWidth;
  var max_height = document.documentElement.clientHeight;
  if( max_height > screen.availHeight ) { max_height = screen.availHeight; }
  
  var x = (screen.availHeight - $(reg_box_).height())/2;
  
  reg_box_.style.left = (max_width - reg_box_.offsetWidth)/2 + 'px';
  reg_box_.style.top = (max_height - $(reg_box_).height())/2+'px';
  
  reg_box_.style.zIndex = 99999;
  
  
}


function flash_short_event_f()
{
  //document.title += "11 "+document.title;
  flash_login()
}


/*
    版本: 2009-2-24 21:42:26
    作用: 遮罩层效果
必填参数: mask_

  ext_o
  {
    close: jquery selector, close mask
    box: jquery selector, display popup
    opacity: integer, setting opacity
    close_callback: function, close mask callback
  }
*/
function j_mask_f(mask_, callback_f, ext_o)
{/* shawl.qiu, void return, func: none */
  ext_o = ext_o || {};
  mask_ = $(mask_);  
  
  mask_.click
  (
    function(evt)
    {
      evt.stopPropagation();
      evt.preventDefault();
    
      ext_o.opacity = ext_o.opacity || 0.1;
      
      var ___iframe = $('#___iframe'), ___div = $('#___div');
      
      if(!___iframe.length)
      {
        $('<iframe id="___iframe" style="position:absolute;left:0;top:0; z-index:1000;" frameborder="0"></iframe').appendTo('body');
        $('<div id="___div" style="position:absolute;left:0;top:0;z-index:2000;background:#000;"></div').appendTo('body');
        
      }
        ___iframe = $('#___iframe').fadeTo("fast", ext_o.opacity);
        ___div = $('#___div').fadeTo("fast", ext_o.opacity);
      
      var win_ = $(window), body_ = $('body');  
      var size_ = { width: win_.width() , height: (win_.height()>body_.height()? win_.height() : body_.height() ) };
        
      ___iframe.css(size_).show();
      ___div.css(size_).show();  
      
      if(ext_o.close)
      { 
        $(ext_o.close).click
        ( 
          function(evt)
          {
             ___iframe.hide(); ___div.hide(); 
             if(ext_o.close_callback){ ext_o.close_callback(___iframe, ___div, size_, ext_o); }
             return false;
          } 
        ); 
      }  
      if(ext_o.box){ $(ext_o.box).show().css( {zIndex: 3000} ); }  
      if(callback_f){ callback_f(___iframe, ___div, size_, ext_o); }
      
      return false;
    }
  );
}/* function j_mask_f(mask_, callback_f, ext_o) */
