﻿// JScript 文件
function JM_cc(url)
{
    window.clipboardData.setData("Text",url); 
    alert("Copy successfully! You can introduce this page to your friends or forum for reading! ");
}

function MM_findObj(n, d) { //v4.01
var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_showHideLayers() { //v6.0
var i,p,v,obj,args=MM_showHideLayers.arguments;
for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
obj.visibility=v; }
}

var initObj = null;
function popMenu(objId) 
{ 
    var obj = document.getElementById(objId);
    //alert(initObj + " " + objId);
    //obj.style.display =  showType;
    if(initObj ==null)
    {  
        if (obj.style.display == 'none') 
        {
            obj.style.display = 'block';
        } 
        else 
        {
            obj.style.display = 'none';
        } 
        initObj = objId;
    }
    else
    {  
        document.getElementById(initObj).style.display = "none";
        initObj = null;
    }
}

/////////////////////////////check user login
function checkUserLogin()
{
    if(!document.getElementById("HeadControl1_txtLoginUserName").value)
    {
         alert("Please Input Your Login UserName!");
         document.getElememtById("HeadControl1_txtLoginUserName").focus();
         return;
    }
    if(!document.getElementById("HeadControl1_txtLoginPassword").value)
    {
         alert("Please Input The Correct Login Password!");
         document.getElememtById("HeadControl1_txtLoginPassword").focus(); 
         return;
    } 
    if(!document.getElementById("HeadControl1_txtValidete").value)
    {
         alert("Please Input The Correct Validete!");
         document.getElememtById("HeadControl1_txtValidete").focus();  
         return;
    }
}

/////////////////////////////ajax
//实例化 XMLHttpRquest对象
var http_request=false;
var ajax_obj;
function createRequest()
{ 
   
    try//IE
    {
        http_request=new ActiveXObject("Msxml2.XMLHTTP");
    } 
    catch (e) 
    {
        try 
        {
            http_request = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch (e2) 
        {
            http_request = false;
        }
    }
    if (!http_request && typeof XMLHttpRequest != 'undefined') //FireFox
    {
        http_request = new XMLHttpRequest();
    }
}
function callserver(obj,url)
{
    createRequest();
    ajax_obj=obj;
    var strText=document.getElementById(obj).value;
    if(strText==""||strText==null)
        return ;
    http_request.onreadystatechange=updatepage;
    http_request.open("GET",url,true);
    http_request.send(null); 
}
function updatepage()
{   
    var obj=document.getElementById("div_"+ajax_obj);
    if(http_request.readyState == 4)
    {
        if(http_request.status==200)
        {
            var response=http_request.responseText;
            if(response.indexOf("NO")!=-1)
            {
                obj.className="Right";
                obj.innerHTML='This '+ajax_obj.substr(3)+' Can Be Registered';
                document.getElementById("btnUserRegister").disabled = false;

            }
           else if(response.indexOf("YES")!=-1)
           {
               obj.className="Error";
               obj.innerHTML='This '+ajax_obj.substr(3)+' has been registered';
               document.getElementById("btnUserRegister").disabled = true;
           }
           else if(response.indexOf("Invaild")!=-1)
           {
               obj.className="Error";
               obj.innerHTML='This '+ajax_obj.substr(3)+' Invalid';
               document.getElementById("btnUserRegister").disabled = true;
           }
        }
    }
}

