// JavaScript Document
// 调用方式
//<script src="./datareurn.js"></script>
//---------------------------------------------------------------------
var gourl="http://huishu.xplus.com.cn/huishu.htm";
//var gourl="http://getmoney.xplus.com.cn/www/test.php";
var cookname="xplus_guid";
//---------------------------------------------------------------------
//得到cookies
function GetCookie_1(c_name)
{
	var strCookie=document.cookie;
	var arrCookie=strCookie.split(";");
	// 将多cookie切割为多个名/值对
	for(var i=0;i<arrCookie.length;i++)
	{ 
	// 遍历cookie数组，处理每个cookie对
		var arr=arrCookie[i].split("="); 
	// 找到名称为userId的cookie，并返回它的值
		if(arr[0]==c_name)
		{
			return arr[1];
		}
	}
}
//---------------------------------------------------------------------
//得到guid
function GetGuid()
{
	guid="";
	for(i=1;i<=32;i++)
  	{
  		n=Math.floor(Math.random()*16.0).toString(16);
  		guid+=n;
    }
    return guid;
}
//---------------------------------------------------------------------
//抛地址
function OpenUrl(c_guid,gourl,curl)
{
	var showtexthead="<iframe ";
	var showsrc=" src='"+gourl+"?curl=" + curl + "&xplus_guid=" +c_guid + "'";
	var showwidth=" width='0'";
	var showheight=" height='0'";
	var showstyle=" style='display:none'";
	var showtextend=" ></iframe>";
	var showtext= showtexthead + showsrc + showwidth + showheight + showstyle + showtextend;
	document.write(showtext);
}

function OpenUrlAjAx(c_guid,gourl,curl)
{
	/*var ajax;
	ajax=GetXmlRquest();
	if(ajax)
    {
		var url;
		url=gourl+"?curl=" + curl + "&c_guid=" +c_guid;
		ajax.open("GET", url, true); 
		ajax.send();
	}*/
}
function GetXmlRquest()
{
	var ajax=false; 
　  try { 
　　			ajax = new ActiveXObject("Msxml2.XMLHTTP"); 
　		} 
    catch(e)
   		{ 
　　			try { 
　　				　	ajax = new ActiveXObject("Microsoft.XMLHTTP"); 
　				} 
				catch(E)
				{ 
　　　			 ajax = false; 
　　				} 
　		}
　	if (!ajax && typeof XMLHttpRequest!='undefined')
    { 
　　		ajax = new XMLHttpRequest(); 
　  } 
　	return ajax;

}
//---------------------------------------------------------------------
function SetCookie_1(name,value,expires,path,domain,secure)
{
	 //alert(expDate.toGMTString());
	var expDays = expires*24*60*60*1000;
	var expDate = new Date();
	expDate.setTime(expDate.getTime()+expDays);
	var expString = ((expires==null) ? " " :(";expires="+expDate.toGMTString()));
	var pathString = ((path==null) ? " " : (";path="+path) );
	var domainString = ((domain==null) ? " " :(";domain="+domain));
	var secureString = ((secure==true)? ";secure": " ");
	document.cookie = cookname + "=" + guid + expString + pathString + domainString + secureString;
}
//---------------------------------------------------------------------
//得到当前地址
function GetCurrUrl()
{
	var curl=window.location;
	return curl;
}
//----------------------------------------------------------------------
if(GetCookie_1(cookname))
{
	OpenUrl(GetCookie_1(cookname),gourl,GetCurrUrl());
}
else
{
	var guid=GetGuid();
	var expires=10000;
    var path;
	var secure=0;

    var domain=".xplus.com.cn";
	SetCookie_1(cookname,guid,expires,path,domain,secure);

	domain=".xplus.com";
	SetCookie_1(cookname,guid,expires,path,domain,secure);

	OpenUrl(guid,gourl,GetCurrUrl());
}
//------------------------------------------------------------------
//---------------------------------------------------------------------