var serverip ="202.108.83.68";
var serverport ="80";

function document_onclick(obj)
{
	if(!ocx.getMAC)
	{
		location='/error/error401.html'
		return;
	}
  if (obj.href.indexOf("/webinfo/")==-1) {	
    var url = "/wygl/wygl/login.jsp?xnwz="+escape(obj.href)+"&wkdz="+escape(ocx.getMAC());
	var wkdz = escape(ocx.getMAC());
    window.open(url);
  }
  else {
    window.open(obj.href);  	
  } 
} 


var oldBody;

function auth(wkdz)
{
	var xmlhttp;
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch (e) {
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch (e) {
			try {
				xmlhttp = new XMLHttpRequest();
			}
			catch (e) {
			}
		}
	}

  var url = '/wygl/wygl/auth.jsp?url='+window.location+"&wkdz="+wkdz;
  //alert('url = ' + url);
  xmlhttp.open("get", url);
  xmlhttp.onreadystatechange=function(){
    if(xmlhttp.readyState==4){
      if(xmlhttp.status==200){
      	var result = xmlhttp.responseText;

		if(result.match("8_"))
		{		
			var strArray = result.split("_");
			if(strArray.length >= 2)
			{
				alert("临时用户，还剩" + strArray[1].replace(/^\s+|\s+$/g,"") + "分钟。");
			}

			var body = document.getElementsByTagName("body");
            if(body.length > 0)
			{
				body[0].innerHTML = oldBody;
			}
		}
		else if(result.match("1"))
		{
                  // alert("验证通过。");
                  var body = document.getElementsByTagName("body");
                  if(body.length > 0)
                  {
                    body[0].innerHTML = oldBody;
                  }
		}
		else if(result.match("4"))
		{
			alert("对不起，您的账户已停用，请电话与我们联系。");
     		window.opener = null;
			window.close();
		}
		else if(result.match("2"))
		{
			alert("用户名或密码不正确，请关闭当前网页，重新打开该页面登陆。");
     		window.opener = null;
			window.close();
		}
		else if(result.match("3"))
		{
			alert("window.location = " + window.location);
			alert("对不起，您尚未订阅此栏目。请关闭当前网页，重新打开该页面登陆。");
     		window.opener = null;
			window.close();
		}
		else if(result.match("5"))
		{
			alert("您的试用时间已过，请加入会员继续使用。");
      		window.opener = null;
			window.close();
		}
		else if(result.match("6"))
		{
			alert("请购买更多的授权数。");
       		window.opener = null;
			window.close();
		}
		else
		{
                  //window.location = 'error1.html';
				window.close();
		}
      }
      // 未输入用户名/密码
      else if(xmlhttp.status == 401){
			alert("请输入用户名和密码");
     		window.opener = null;
			window.close();
      }
	  else if(xmlhttp.status == 500){
			alert("用户名或密码不正确，请重新输入。");
     		window.opener = null;
			window.close();
      }
      else {
        alert('xmlhttp.status = ' + xmlhttp.status);
      }
    }
  }

  xmlhttp.send(null);
}


