
var LogRecorder = function()
{ this.additionNum = 1;
  var yesdata;
}
LogRecorder.prototype={
egg_getCookie:function(objName){
    //The space after ';' is essential.
	var arrStr = document.cookie.split("; ");
	for(var i = 0; i < arrStr.length; i++){
		var temp = arrStr[i].split("=");
		if(temp[0] == objName){
		    return unescape(temp[1]);
		    }
	} 
	return null;
},
egg_addCookie:function(objName,objValue,objHours,objPath){
	var str = objName + "=" + escape(objValue);
	if(objHours > 0){
		var date = new Date();
		var ms = objHours*3600*1000;
		date.setTime(date.getTime() + ms);
		str += ";expires=" + date.toGMTString() +";path=" + objPath;
	}
	document.cookie = str;
},

egg_cck:function()
{
var y_e=new Date();
var yesvisitor=1000*3600;
var yesctime=y_e.getTime();

var yesiz=document.cookie.indexOf("cck_lasttime");
if(yesiz==-1)
{
this.egg_addCookie("cck_lasttime",yesctime,24,"/");
this.egg_addCookie("cck_count",0,24,"/");
return 0;
}
else
{
var y_c1=this.egg_getCookie("cck_lasttime");
var y_c2=this.egg_getCookie("cck_count");
y_c1=parseInt(y_c1);
y_c2=parseInt(y_c2);
y_c3=yesctime-y_c1; 

if(y_c3>yesvisitor)
{
y_c2=y_c2+1;
this.egg_addCookie("cck_lasttime",yesctime,24,"/");
this.egg_addCookie("cck_count",y_c2,24,"/");
}
return y_c2;
}
},

sendLog:function(){
  var sc=document.createElement('script');
  sc.type='text/javascript';
  sc.src='http://210.14.67.143:8182/LogRecorderFP/servlet/SetLogServlet?'+this.yesdata;
  document.getElementsByTagName('head')[0].appendChild(sc); 
},

getReferrer:function(){
    var referrer;
    referrer = document.referrer;
	if (referrer=="")
	{
		if(window.opener!=null && window.opener!=self && typeof(window.opener.location) != 'unknown'){
			referrer = window.opener.location;
		}
	}
/*if(window.opener==null || window.opener==self || document.referrer || typeof(window.opener.location) != 'unknown'){ 
   referrer = document.referrer;
}
else{  
   referrer = window.opener.location;
}*/
return encodeURIComponent(referrer);
},

getStandardInfo:function(){
this.yesdata='date='+new Date().getTime()+'&ref='+this.getReferrer()+'&location='+encodeURIComponent(document.location)+'&color='+screen.colorDepth+'x&resolution='+screen.width+'x'+screen.height+'&language='+navigator.systemLanguage+'&ua='+escape(navigator.userAgent);
var cusidx=document.cookie.indexOf("CustomerId");
if(cusidx==-1){
this.yesdata = this.yesdata + '&cusName=';
}
else{
var customerName = this.egg_getCookie("CustomerId");
this.yesdata = this.yesdata + '&cusName=' + encodeURIComponent(customerName);
}

var cusnox=document.cookie.indexOf("CustomerSysNo");
if(cusnox==-1){
 this.yesdata = this.yesdata + '&cusSysNo=';
}
else{
var customerSysNo = this.egg_getCookie("CustomerSysNo");
this.yesdata = this.yesdata + '&cusSysNo=' + customerSysNo;
}
}
}
window.LogRecorder = new LogRecorder();
LogRecorder.getStandardInfo();

function initLogInfo(){
	LogRecorder.yesdata = null;
	LogRecorder.additionNum = 1;
	LogRecorder.getStandardInfo();
}

function appendItem(item,columnName){
    LogRecorder.yesdata = LogRecorder.yesdata + '&addition'+LogRecorder.additionNum+'='+encodeURIComponent(item)+'{.add.}'+encodeURIComponent(columnName);
    LogRecorder.additionNum = LogRecorder.additionNum+1;
  
}

function setLogType(item){
  LogRecorder.yesdata = LogRecorder.yesdata + "&LogType=" + item;
}

function sendLog(){
  LogRecorder.sendLog();
}
