/* 获取浏览器版本 */
function GetNavigator()
{
   try
   {
      if(navigator.userAgent.indexOf('MSIE') > 0)
      {
         return 1;
      }
      if(navigator.userAgent.indexOf('Firefox') > 0)
      {
         return 2;
      }
      return 0;
   }
   catch(e)
   {
      // alert(e.description);
   }
}

/* 设为首页 */
function setHomePageS(obj, url)
{
   try
   {
      obj.style.behavior = 'url(#default#homepage)';
      obj.setHomePage(url);
      return false;
   }
   catch(e)
   {
      // alert(e.description);
   }
}
;

/* 添加到收藏夹 */
function AddFavoriteS(url, str)
{
   try
   {
      switch(GetNavigator())
      {

         case 1 :
            window.external.AddFavorite(url, str);
            break;
         case 2 :
            window.sidebar.AddPanel(str, url, '');
            break;
         case 0 :
            alert('加入收藏失败，您使用的浏览器不支持这个功能。');
            break;
      }
   }
   catch(e)
   {
      // alert(e.description);
   }
}
;

/* iframe 自适用高度 */
function iframeAutoHight()
{
   try
   {
      if (document.body.scrollHeight > 661)
      {
         parent.document.all.mdiframe.height = document.body.scrollHeight + 50 + 'px';
      }
   }
   catch(e)
   {
      // alert(e.description);
   }
}
;

/* 检测长度是否为空 */
function isLength(sid, str)
{
   try
   {
      if($(sid).value == '')
      {
         alert(str);
         $(sid).focus();
         $(sid).select();
         return false;
      }
      return true;
   }
   catch(e)
   {
      // alert(e.description);
   }
}
;

/* Email正则检测 */
function isEmail(sid, msg)
{
   try
   {
      var regm = /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;
      var strm = $(sid).value;
      if ( ! strm.match(regm) || strm == '')
      {
         alert(msg);
         $(sid).focus();
         $(sid).select();
         return false;
      }
      return true;
   }
   catch(e)
   {
      // alert(e.description);
   }
}
;

/* 产生随机字符串 */
function Guid ()
{
   var strDate, strTime;
   strDate = new Date();
   strTime = strDate.getTime();
   return strTime;
}

/* 获取下拉列表选中属性值 */
function getOptions(sid)
{
   try
   {
      return $(sid) ? $(sid).options[$(sid).selectedIndex].value : '';
   }
   catch(e)
   {
      // alert(e.description);
   }
}
;

/* 获取下拉列表选中文本值 */
function getOptionsText(sid)
{
   try
   {
      return $(sid) ? $(sid).options[$(sid).selectedIndex].text : '';
   }
   catch(e)
   {
      // alert(e.description);
   }
}
;

/* 获取单选框选中值 */
function getRadioBoxValue(radioName)
{
   try
   {
      var obj = document.getElementsByName(radioName);
      for(i = 0; i < obj.length; i ++ )
      {
         if(obj[i].checked)
         {
            return obj[i].value;
         }
      }
      return 'undefined';
   }
   catch(e)
   {
      // alert(e.description);
   }
}
;


/* 绑定事件 */
window.onload = function()
{
   try
   {
      var arrAll = document.getElementsByTagName('input');
      for (i = 0; i < arrAll.length; i ++ )
      {
         switch(arrAll[i].className)
         {
            case 'reg_inp1' :
            {
               $(arrAll[i].id).onmouseover = function()
               {
                  this.style.backgroundColor = '#c0ddfc';
                  this.style.border = '1px double #3399ff';
               }
               $(arrAll[i].id).onmouseout = function()
               {
                  this.style.backgroundColor = '#fff';
                  this.style.border = '1px double #ccc';
               }
               break;
            }
            case 'password_inp1':
            {
               $(arrAll[i].id).onmouseover = function()
               {
                  this.style.backgroundColor = '#c0ddfc';
                  this.style.border = '1px double #3399ff';
               }
               $(arrAll[i].id).onmouseout = function()
               {
                  this.style.backgroundColor = '#fff';
                  this.style.border = '1px double #ccc';
               }
               break;
            }
            case 'LoginInp' :
            {
               $(arrAll[i].id).onmouseover = function()
               {
                  this.className = 'LoginInp1';
               }
               $(arrAll[i].id).onmouseout = function()
               {
                  this.className = 'LoginInp';
               }
               break;
            }
         }
         switch(arrAll[i].id)
         {
            case 'username' :
            {
               $(arrAll[i].id).onblur = function()
               {
                  Reg.checkusername();
               }
               break;
            }
            case 'password' :
            {
               $(arrAll[i].id).onblur = function()
               {
                  Reg.checkpassword();
               }
               break;
            }
            case 'password2' :
            {
               $(arrAll[i].id).onblur = function()
               {
                  Reg.checkpassword2();
               }
               break;
            }
            case 'zsname' :
            {
               $(arrAll[i].id).onblur = function()
               {
                  Reg.checkzsname();
               }
               break;
            }
            case 'email' :
            {
               $(arrAll[i].id).onblur = function()
               {
                  Reg.checkemail();
               }
               break;
            }
         }
      }
   }
   catch(e)
   {
      // alert(e.description);
   }
}
