function checkCookie(parm_to_paste)
{
	var i = parm_to_paste.indexOf("=");
	var magID = parm_to_paste.substring(i+1 );
	//alert(magID);
	//alert(GetCookie("c_userid"));
	if (GetCookie("xplus_inst")==null)
	{
		//alert("cookie lost");
		//window.location="../Xplus_Mini.exe";
		window.location="http://www.xplus.com.cn/inc/download_note.php";	
	}
	else
	{
		if ((GetCookie("c_userid")==null)||(GetCookie("c_pwd")==null))
		{
			//alert("ï¿½ï¿½Cookie");
//			clipboardData.setData("text",parm_to_paste);
		//window.location="../products/myLogin.sulpx?magID="+magID;
		window.location="http://www.xplus.com.cn/inc/download_note.php";
		}
		else
		{
			//alert(GetCookie("userid"));
			window.location="http://www.xplus.com.cn/inc/subscribe_xin.php?uid="+GetCookie("c_userid")+"&pwd="+GetCookie("c_pwd")+"&magID="+magID;
		}
	}
	return false;		//this prevent link runs
}

function getCookieVal (offset)
{
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
	{
		endstr = document.cookie.length;
	}
	return unescape(document.cookie.substring(offset, endstr));
}

//
//	??ookies
//

function GetCookie (name)
{
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	
	while(i < clen)
	{
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg)
		{
			return getCookieVal (j);
		}
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0)
		{
			break;
		}
	}
	return null;
}

//
//	ï¿½ï¿½Cookies
//

function SetCookie (name, value)
{
	var argv = SetCookie.arguments;
	var argc = SetCookie.arguments.length;

	var expires = (argc > 2) ? argv[2] : null;
	//var path = (argc > 3) ? argv[3] : null;
	//var domain = (argc > 4) ? argv[4] : null;
	//var domain = "127.0.0.1";
	//var secure = (argc > 5) ? argv[5] : false;

	var path = "/";
	//var domain = ".xplus.com.cn";
	var domain = ".xplus.com";
	var secure = false;
	
	document.cookie = name + "=" + escape (value) + 
		((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
		((path == null) ? "" : ("; path=" + path)) +
		((domain == null) ? "" : ("; domain=" + domain)) +
		((secure == true) ? "; secure" : "");
}

function setLastlastVisitCookie ()
{
	var rightNow = new Date();
	var expdate = new Date();
	
	expdate.setTime (expdate.getTime() + 1 * (24 * 60 * 60 * 1000)); //+1 day
	SetCookie ("xplus_inst", rightNow.getTime(), expdate, "/");
}

//
//	?Cookies
//



function ResetCookie()
{
	SetCookie("xplus_inst", 0, null, "/");
}

var xmlHttp;                    //ajaxÈ¡Êý¾Ýº¯Êý
var magdata;
var in_parm;
	function createXMLHttpRequest(){
		if(window.ActiveXObject){
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		else if (window.XMLHttpRequest){
			xmlHttp = new XMLHttpRequest();
		}
	}
	
function listCallback()
{
   if(xmlHttp.readyState == 4)
   {
	  if(xmlHttp.status == 200)
	 {
        magdata=xmlHttp.responseText;
   
	    try
	    {
			var activeXObj = new ActiveXObject("XplusAgent.XplusActiveX.1");
			var i = in_parm.indexOf("=");
			var a =in_parm.indexOf("&");
			var magID = in_parm.substring( i+1,a );
			
			var type;
			if(magID<10000000)
			{
				type=0;
			}
			else
			{
				type=1;
			}
			//alert("1");
			//threadList(magID);
			//alert("2");
			//listCallback();
			//alert("id="+magID+"data="+magdata+"t="+type);
			
			if(magdata == "111" || magdata == 111)//ÊÇÖÜÉ½ÈÕ±¨
			{
			   window.open("http://epaper.zhoushan.cn");
			}
			else if(activeXObj.TaskAdd(magID, magdata, type)==2)
			{
			   alert("ÄúÕýÔÚÏÂÔØ»òÒÑÏÂÔØ¹ý´ËÔÓÖ¾");
			}
			
		 }
		 catch(err)
		 {
			 
			    if(magdata == "111" || magdata == 111)//ÊÇÖÜÉ½ÈÕ±¨
				{
				   window.open("http://epaper.zhoushan.cn");
				}
			 
				else if (GetCookie("xplus_inst")==null)
				{
					//alert("cookie lost");
					//var rightNow = new Date();
					var expdate = new Date();
					expdate.setTime (expdate.getTime() + 1 * (24 * 60 * 60 * 365));
					//SetCookie("p3", magID, getTime()+60*60*24*90, "/", "127.0.0.1");
					SetCookie ("p3", magID, expdate, "/");
					//window.open("http://www.xplus.com.cn/inc/download_note.php");
					
				    var paper=magdata.split("\t");
					window.open("http://paper-down.xplus.com/papers/"+paper[0]+"/"+paper[0]+"_"+paper[4]+".exe");
				}
				else
				{
					clipboardData.setData("text",in_parm);
				}
		 }
	   }
	   else
	   {
	    	    alert("¶Ô²»Æð£¬Ó¦ÓÃ²úÉú´íÎó£¬ÇëÉÔºóÔÙÊÔ£¡");
	   }
	 }
}

function threadList(imagID){
		createXMLHttpRequest();	
		//var i = parm.indexOf("=");
		//var a =parm.indexOf("&");
		//var magID = parm.substring( i+1,a );
		var URL = "../www/ajax_php.php?magid="+imagID;
		
		xmlHttp.onreadystatechange = listCallback;
		xmlHttp.open("GET",URL,true);
		xmlHttp.send(null);
	}      

function callClient(parm)
{
	  in_parm=parm;
	  var expdate = new Date();
		var i = parm.indexOf("=");
		var a =parm.indexOf("&");
		var magID = parm.substring( i+1,a );
		//alert(GetCookie("xplus_inst"));
		threadList(magID);
	
	//return false;
}


//£­£­×¨ÎªdetailÒ³ÓÃ¿ªÊ¼
function callClient_d(parm)//×¨ÎªdetailÒ³ÓÃ
{
	    in_parm=parm;
	    var expdate = new Date();
		var i = parm.indexOf("=");
		var a =parm.indexOf("&");
		var magID = parm.substring( i+1,a );
		threadList_d(magID);//×¨ÎªdetailÒ³ÓÃ
}
function threadList_d(imagID)//×¨ÎªdetailÒ³ÓÃ
{
		createXMLHttpRequest();	
		//var i = parm.indexOf("=");
		//var a =parm.indexOf("&");
		//var magID = parm.substring( i+1,a );
		var URL = "../www/ajax_php.php?magid="+imagID;
		
		xmlHttp.onreadystatechange = listCallback_d;//×¨ÎªdetailÒ³ÓÃ
		xmlHttp.open("GET",URL,true);
		xmlHttp.send(null);
}  
function listCallback_d()//×¨ÎªdetailÒ³ÓÃ
{
   if(xmlHttp.readyState == 4)
   {
	  if(xmlHttp.status == 200)
	 {
        magdata=xmlHttp.responseText;
	    try
	    {
			var activeXObj = new ActiveXObject("XplusAgent.XplusActiveX.1");
			var i = in_parm.indexOf("=");
			var a =in_parm.indexOf("&");
			var magID = in_parm.substring( i+1,a );
			
			var type;
			
			
			if(magID<10000000)
			{
				type=0;
			}
			else
			{
				type=1;
			}
			
			
			
			if(magdata == "111" || magdata == 111)//ÊÇÖÜÉ½ÈÕ±¨
			{
			   window.open("http://epaper.zhoushan.cn");
			}
			else if(activeXObj.TaskAdd(magID, magdata, type)==2)
			{
			   alert("ÄúÕýÔÚÏÂÔØ»òÒÑÏÂÔØ¹ý´ËÔÓÖ¾");
			}
			
		 }
		 catch(err)
		 {
				if(magdata == "111" || magdata == 111)//ÊÇÖÜÉ½ÈÕ±¨
				{
				   window.open("http://epaper.zhoushan.cn");
				}
				else if (GetCookie("xplus_inst")==null)
				{
					var expdate = new Date();
					expdate.setTime (expdate.getTime() + 1 * (24 * 60 * 60 * 365));
					//SetCookie("p3", magID, getTime()+60*60*24*90, "/", "127.0.0.1");
					SetCookie ("p3", magID, expdate, "/");
					window.open("http://www.xplus.com.cn/inc/download_note.php");
				}
				else
				{
					clipboardData.setData("text",in_parm);
				}
		 }
	   }
	   else
	   {
	    	    alert("¶Ô²»Æð£¬Ó¦ÓÃ²úÉú´íÎó£¬ÇëÉÔºóÔÙÊÔ£¡");
	   }
	 }
}
//£­£­×¨ÎªdetailÒ³ÓÃ½áÊø



function callClient1(parm)
{
	if (GetCookie("xplus_inst")==null)
	{
		window.location="http://www.xplus.com.cn/inc/download_note.php";
	}else
		clipboardData.setData("text",parm);
	//return false;
}
function callClientTop(parm)
{
	//alert("YEs");
	if (GetCookie("xplus_inst")==null)
	{
		//alert("cookie lost");
		//var rightNow = new Date();
		var expdate = new Date();
		var i = parm.indexOf("=");
		var a =parm.indexOf("&");
		var magID = parm.substring( i+1,a );
		
		expdate.setTime (expdate.getTime() + 1 * (24 * 60 * 60 * 365));
		//SetCookie("p3", magID, getTime()+60*60*24*90, "/", "127.0.0.1");
		SetCookie ("p3", magID, expdate, "/");
		//alert("è¯·å?è£???·ç?");
//		window.location="http://www.xplus.com.cn/inc/download_note.php";
		window.open("http://www.xplus.com.cn/inc/download_note.php");
		return false;
	}else
		clipboardData.setData("text",parm);
	return false;
}
/**
*  è®¢é?é¡µé???
*/
function checkCookieSub(parm_to_paste)
{
	var i = parm_to_paste.indexOf("=");
	//var url = parm_to_paste.substring( i+1 );
//	alert(magID);
	
	if (GetCookie("xplus_inst")==null)
	{
		//alert("cookie lost");
		window.location="http://www.xplus.com.cn/inc/download_note.php";
	}
	else
	{
		//alert(GetCookie("c_userid"));
		//alert(GetCookie("c_pwd"));
		if ((GetCookie("c_userid")==null)||(GetCookie("c_pwd")==null))
		{
			//alert("ï¿½ï¿½Cookie");
//			clipboardData.setData("text",parm_to_paste);
			window.location="http://www.xplus.com.cn/inc/download_note.php";
//			window.location=parm_to_paste;
		}
		else
		{
			//alert(GetCookie("userid"));
			window.location="../products/subscribe.php?uid="+GetCookie("c_userid")+"&pwd="+GetCookie("c_pwd");
		}
	}
	return false;		//this prevent link runs
}
function checkCookieSub_new()
{
	if (GetCookie("xplus_inst")==null)
	{
		//alert("cookie lost");
		window.open("http://www.xplus.com.cn/inc/download_note.php");
	}
	else
	{
	try{
	      var xplus_Obj40 = new ActiveXObject("XplusAgent.XplusActiveX.1");
	      var userinfo=xplus_Obj40.UserInfo;
		  //document.writeln(userinfo);
		  user_arr=userinfo.split(" ");
		  //alert(user_arr.length);
		  //u_arr1=user_arr[0];
		  //u_arrz=u_arr1.split("	");
		  //alert(u_arrz[0]);
		  //alert(user_arr[0]);
		  //alert(user_arr[1]);
		  //alert(user_arr[2]);
		  if(user_arr[0]!="" && user_arr[2]=="3")
		   {
		     window.open("http://www.xplus.com.cn/inc/mag_cate.php?uid="+user_arr[0]);
		     }
			else{
			     alert("ÇëÄúÏÈÔÚ¿Í»§½øÐÐµÇÂ¼,²ÅÄÜÊ¹ÓÃ±¾¹¦ÄÜ,Ð»Ð»!");
			     window.open("../index.php");
			      }
		  }
	    catch(e)
		  {
		if ((GetCookie("c_userid")==null)||(GetCookie("c_pwd")==null))
		{
			window.open("http://www.xplus.com.cn/inc/download_note.php");
			//alert("ÇëÄúÏÈÔÚ¿Í»§½øÐÐµÇÂ¼,²ÅÄÜÊ¹ÓÃ±¾¹¦ÄÜ,Ð»Ð»!");
			//window.open("../index.php");
		}
		else
		{
			window.open("http://www.xplus.com.cn/inc/mag_cate.php?uid="+GetCookie("c_userid"));
		}
		     }
	}
	return false;		//this prevent link runs
}

function checkCookieBBS(parm_to_paste)
{
	var i = parm_to_paste.indexOf("=");
	
	if (GetCookie("xplus_inst")==null)
	{
		//alert("cookie lost");
		window.location="http://xp-bbs.xplus.com.cn/";
	}
	else
	{
		//alert(GetCookie("c_userid"));
		//alert(GetCookie("c_pwd"));
		if ((GetCookie("c_userid")==null)||(GetCookie("c_pwd")==null))
		{
			//alert("ï¿½ï¿½Cookie");
//			clipboardData.setData("text",parm_to_paste);
//			window.location=parm_to_paste;
			window.open("http://xp-bbs.xplus.com.cn/");
		}
		else
		{
			//alert(GetCookie("userid"));
			window.open("http://xp-bbs.xplus.com.cn/bbslogin.php?ver=3.0&uid="+GetCookie("c_userid")+"&pwd="+GetCookie("c_pwd"));
		}
	}
	return false;		//this prevent link runs
}
//var c_ver="3.0";
try{
     X_Obj = new ActiveXObject("XplusAgent.XplusActiveX.1");
	 user_info=X_Obj.UserInfo;
	 user_arr=user_info.split(" ");
	 //alert(user_arr[3]);
	 //c_ver="4.0";
	 if(user_arr[0]!="" && user_arr[2]=="3")
	  {
	    SetCookie("c_userid",user_arr[0]);
		SetCookie("c_pwd",user_arr[4]);
	   }
     }
	catch(e)
	  {
	   //alert("err");
	   }

