// JavaScript Document
	var SunivoTracexmlHttp = false;
	var thisPageTraceId= -1;
	var windowFlag=0;

    createXMLHttpRequest();
	function createXMLHttpRequest(){
		if (window.ActiveXObject) // IE下创建XMLHTTPREQUEST
		{
			SunivoTracexmlHttp = getXMLObj();
		}
		else if (window.XMLHttpRequest) // 其他浏览器创建XMLHTTPREQUEST
		{
			SunivoTracexmlHttp = new XMLHttpRequest();
		}
	}
    function getXMLObj() {
	    var msxmls = ["MSXML3", "MSXML2", "Microsoft"]
		for (var i=0; i < msxmls.length; i++) {
			try {
				return new ActiveXObject(msxmls[i]+".XMLHTTP")
			} 
			catch (e) 
			{ }
		}
		throw new Error("No XML component installed!")
	}		
  
	function callServerEnter(){
		//window.alert("将要进入页面");
	    var purl = document.referrer;
		var nurl = window.location.href;
		var ntitle = window.document.title;
		var url = "/sunivoTrace_en/userTrace/traceAdd.asp?nowUrl="+nurl+"&priveUrl="+purl+"&ntitle="+ntitle;
		SunivoTracexmlHttp.open("GET", url, true);
		SunivoTracexmlHttp.onreadystatechange = updatePageEnter;
		SunivoTracexmlHttp.send(null);
	}
	
	function updatePageEnter() {
		if (SunivoTracexmlHttp.readyState == 4){
		   thisPageTraceId = SunivoTracexmlHttp.responseText;
		   //window.alert(thisPageTraceId);
		   }
	}
  
	function callServerLeave(){
		if(event.clientX>document.body.clientWidth&&event.clientY<0||event.altKey) 
        { 
			windowFlag=1;
        } 
        //alert("将要离开页面");
		var nurl = window.location.href; 
		var url = "/sunivoTrace_en/userTrace/traceAdd.asp?recordId="+thisPageTraceId+"&nowUrl="+nurl+"&windowFlag="+windowFlag;
		SunivoTracexmlHttp.open("GET", url, true);
		SunivoTracexmlHttp.onreadystatechange = updatePageLeave;
		SunivoTracexmlHttp.send(null);	
	}
	
    function updatePageLeave() {
		if (SunivoTracexmlHttp.readyState == 4){
			aaaaa = SunivoTracexmlHttp.responseText;
			//window.alert(aaaaa);
			//window.alert("已经离开页面");
		}
	}

  //  window.onload = callServerEnter;
  	callServerEnter();
    window.onunload =callServerLeave;