var target=document;

function f(type,et)
{
	var userID;
	if (document.cookie.length>0)
	{
		c_start=document.cookie.indexOf("userSessionID=")
		if(c_start!=-1)
	    { 
			c_start=c_start+14;
			c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1) 
				c_end=document.cookie.length;
			userID=document.cookie.substring(c_start,c_end)
	    } 
	 }
	if(userID==null)
	{
		var strID=new Date().getTime().toString()+Math.random();
		document.cookie="userSessionID="+strID;
		userID=strID;
	}
	et=et?et:window.event;
	var e=et.target?et.target:et.srcElement;
	var element=e;
	var position;
	var p=e.parentNode;
	child=p.firstChild;
	j=1;
	for(;child!=e;)
	{
		if(child.nodeType==1)
		{
			j=j+1;
		}
		child=child.nextSibling;
	}
	position=j;
	for(;p.tagName.toLowerCase()!="body";)
	{
		e=p;
		p=p.parentNode;
		child=p.firstChild;
		j=1;
		for(;child!=e;)
		{
			if(child.nodeType==1)
			{
				j=j+1;
			}
			child=child.nextSibling;
		}
		position=j+"-"+position;
	}
	var page=encodeURIComponent(encodeURIComponent(location.href));
	var nju_head=("http:" == location.protocol)?"http://nju.bizark.cn:8080":"https://nju.bizark.cn:8443";
	var url=nju_head+'/JSTest/eventReceiver?'+'userID='+userID+'&position='+position+"&time="+new Date().getTime()+"&page="+page+"&type="+type;
	if(element.tagName.toLowerCase()=="input")
		url=url+"&value="+element.value;
	var oScript = document.createElement('script');
	oScript.src =url;
	oScript.charset = "utf-8";                       
	document.getElementsByTagName("head")[0].appendChild(oScript);
	document.getElementsByTagName("head")[0].removeChild(document.getElementsByTagName("head")[0].lastChild); 
}

function f1(et)
{
	f("onclick",et);
}

function f2(et)
{
	f("onchange",et);
}
