var cookieEnabled=((navigator.cookieEnabled)? true : false);
var ver = 7;

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
} 

var Base64 = {

	_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",

	encode : function (input) {
		var output = "";
		var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
		var i = 0;

		input = Base64._utf8_encode(input);

		while (i < input.length) {

			chr1 = input.charCodeAt(i++);
			chr2 = input.charCodeAt(i++);
			chr3 = input.charCodeAt(i++);

			enc1 = chr1 >> 2;
			enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
			enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
			enc4 = chr3 & 63;

			if (isNaN(chr2)) {
				enc3 = enc4 = 64;
			} else if (isNaN(chr3)) {
				enc4 = 64;
			}

			output = output +
			this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
			this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);

		}

		return output;
	},
	_utf8_encode : function (string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";

		for (var n = 0; n < string.length; n++) {

			var c = string.charCodeAt(n);

			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}

		}

		return utftext;
	}
}




function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

var six='';
if(cookieEnabled == true)
{
	if(readCookie('_ctmb'))
	{
		six = readCookie('_ctmb');
		six = "six="+six+"&";
	}else if(typeof( window[ 'session_pid' ] ) != "undefined")
	{
		six = session_pid;
		six = "six="+six+"&";
	}
	
}


function JSONscriptRequest(fullUrl) {
    this.fullUrl = fullUrl; 
    this.noCacheIE = '';
    this.headLoc = document.getElementsByTagName("head").item(0);
    this.scriptId = 'JscriptId' + JSONscriptRequest.scriptCounter++;
}

JSONscriptRequest.scriptCounter = 1;
JSONscriptRequest.prototype.buildScriptTag = function () {
    this.scriptObj = document.createElement("script");
    this.scriptObj.setAttribute("type", "text/javascript");
    this.scriptObj.setAttribute("charset", "utf-8");
    this.scriptObj.setAttribute("src", this.fullUrl + this.noCacheIE);
    this.scriptObj.setAttribute("id", this.scriptId);
}
JSONscriptRequest.prototype.removeScriptTag = function () {
    this.headLoc.removeChild(this.scriptObj);  
}
JSONscriptRequest.prototype.addScriptTag = function () {
    this.headLoc.appendChild(this.scriptObj);
}

function addScript(table)
{
var str = "";
for (var i in table)
	{
		for(g in table[i]){
			for(h in table[i][g]){
				str += "dat["+g+"]["+h+"]="+table[i][g][h]+"&";
			}
		}
	}
	
	if(cookieEnabled == true)
	{
		if(readCookie('_ctmb'))
		{
			six = readCookie('_ctmb');
			six = "six="+six+"&";
		}else if(typeof( window[ 'session_pid' ] ) != "undefined")
		{
			six = session_pid;
			six = "six="+six+"&";
		}
		
	}
	var parms = 	'prefix=4e5e0a432cc97&jv='+ver+'&cookie='+cookieEnabled+'&'+six+str;
	parms = Base64.encode(parms);
	var obj=new JSONscriptRequest('http://rs1.contentforces.com/ct/ct_base.php?'+parms);
	obj.buildScriptTag();
	obj.addScriptTag(); 
}
function error_(str)
{
	if(cookieEnabled == true)
	{
		if(readCookie('_ctmb'))
		{
			six = readCookie('_ctmb');
			six = "six="+six+"&";
		}else if(typeof( window[ 'session_pid' ] ) != "undefined")
		{
			six = session_pid;
			six = "six="+six+"&";
		}
		
	}
	
  var obj=new JSONscriptRequest('http://rs1.contentforces.com/ct/error.php?prefix=4e5e0a432cc97&jv='+ver+'&cookie='+cookieEnabled+'&'+six+str);
  
  obj.buildScriptTag();
  obj.addScriptTag(); 
}

function path_(el)
{
	var path = [];
	do {
		path.unshift(  (el.id ? el.id + '#' : (el.className ? el.className + '.' : '')) + el.nodeName);
	} while ((el.nodeName.toLowerCase() != 'html') && (el = el.parentNode));
	return path.join(">");
}
	
function flag_obj()
{
	this.value = 1;
}
flag_obj.prototype.zero = function()
{
	this.value = 0;
}
flag_obj.prototype.set = function()
{
	this.value = 1;
}
flag_obj.prototype.value_ = function()
{
	return this.value;
}
	
	var flag1 = new flag_obj();
	var flag2 = new flag_obj();
	
	setInterval ( "flag1.set() ", 500 );
	setInterval ( "flag2.set() ", 100 );


	var table =  {};
	table.o = {};
	var iter = 1;
	var sendVal = 4;

			var tmp0 = {};
			tmp0.x = 0;
			tmp0.y = 0;
			if(window.innerWidth)
			{
				tmp0.width = window.innerWidth;
			}
			else if(document.documentElement.offsetWidth)
			{
				tmp0.width = document.documentElement.offsetWidth;
			}
			tmp0.path = escape(window.location.href);
			tmp0.ref = escape(document.referrer);
			var foo = new Date; 
			var unixtime_ms = foo.getTime(); 
			var unixtime = parseInt(unixtime_ms / 1000);
			tmp0.ct = unixtime;
			tmp0.event = 0;
			table.o[iter] = tmp0;
			addScript(table)
			table =  {};
			table.o = {};
			iter = 0;
	
	
	
	if (document.addEventListener){
			document.addEventListener("mouseover", function(e)
			{
				if(flag1.value == 1)
				{
					var tmp = {};
					tmp.x = e.pageX;
					tmp.y = e.pageY;
					tmp.eid = e.target.id;
					tmp.ex = e.target.offsetLeft;
					tmp.ey = e.target.offsetTop;
					tmp.eh = e.target.offsetHeight;
					tmp.ew = e.target.offsetWidth;
					tmp.eclass = e.target.className;
					tmp.domPath = path_(e.target);
					tmp.path = escape(window.location.href);
					tmp.width = window.innerWidth;
					tmp.event = 1;
					var foo = new Date; 
					var unixtime_ms = foo.getTime(); 
					var unixtime = parseInt(unixtime_ms / 1000);
					tmp.ct = unixtime;
					table.o[iter] = tmp;
					iter = iter +1;
					if (iter  > sendVal )
					{
						addScript(table);		
						table =  {};
						table.o = {};
						iter = 0;
					}
					flag1.zero();		
				}		
			}, true);
		} else if (document.attachEvent){
			document.attachEvent("onmouseover", function(e)
			{
				if(flag1.value == 1)
				{
				var pagey = e.clientY + document.documentElement.scrollTop;
				var pagex = e.clientX + document.documentElement.scrollLeft;
				var tmp = {};
				tmp.x = pagex;
				tmp.y = pagey;
				tmp.width = document.documentElement.offsetWidth;
				tmp.eid = e.toElement.id;
				tmp.ex = e.toElement.offsetLeft;
				tmp.ey = e.toElement.offsetTop;
				tmp.eh = e.toElement.offsetHeight;
				tmp.ew = e.toElement.offsetWidth;
				tmp.domPath = path_(e.toElement);
				tmp.path = escape(window.location.href);
				tmp.event = 1;
				var foo = new Date; 
				var unixtime_ms = foo.getTime(); 
				var unixtime = parseInt(unixtime_ms / 1000);
				tmp.ct = unixtime;
				table.o[iter] = tmp;
				iter = iter +1;
				if (iter  > sendVal )
				{
					addScript(table);		
					table =  {};
					table.o = {};
					iter = 0;
				}
				flag1.zero();		
				}		
			});
		} 
		
		if (document.addEventListener){
			document.addEventListener("mousedown", function(e)
			{
				if(flag2.value == 1)
				{
					var tmp1 = {};
					tmp1.x = e.pageX;
					tmp1.y = e.pageY;
					tmp1.eid = e.target.id;
					tmp1.ex = e.target.offsetLeft;
					tmp1.ey = e.target.offsetTop;
					tmp1.eh = e.target.offsetHeight;
					tmp1.ew = e.target.offsetWidth;
					tmp1.eclass = e.target.className;
					tmp1.domPath = path_(e.target);
					tmp1.path = escape(window.location.href);
					tmp1.ref = escape(document.referrer);
					tmp1.width = window.innerWidth;
					if (e.target.tagName == "A")
					{
						tmp1.html = e.target.innerHTML;
						tmp1.event = 3;
					}
					else
					{
						tmp1.event = 2;
					}
					var foo = new Date; 
					var unixtime_ms = foo.getTime(); 
					var unixtime = parseInt(unixtime_ms / 1000);
					tmp1.ct = unixtime;
					table.o[iter] = tmp1;
					iter = iter +1;
					addScript(table);		
					table =  {};
					table.o = {};
					iter = 0;
					flag2.zero();		
				}		
			}, true);
		} else if (document.attachEvent){
			document.attachEvent("onmousedown", function(e)
			{
				if(flag2.value == 1)
				{
				var pagey = e.clientY + document.documentElement.scrollTop;
				var pagex = e.clientX + document.documentElement.scrollLeft;
				var tmp1 = {};
				tmp1.x = pagex;
				tmp1.y = pagey;
				tmp1.width = document.documentElement.offsetWidth;
				tmp1.eid = e.srcElement.id;
				tmp1.ex = e.srcElement.offsetLeft;
				tmp1.ey = e.srcElement.offsetTop;
				tmp1.eh = e.srcElement.offsetHeight;
				tmp1.ew = e.srcElement.offsetWidth;
				tmp1.domPath = path_(e.srcElement);
				tmp1.path = escape(window.location.href);
				tmp1.ref = escape(document.referrer);
				
					if (e.srcElement.tagName == "A")
					{
						tmp1.html = e.srcElement.innerHTML;
						tmp1.event = 3;
					}
					else
					{
						tmp1.event = 2;
					}
				var foo = new Date; 
				var unixtime_ms = foo.getTime(); 
				var unixtime = parseInt(unixtime_ms / 1000);
				tmp1.ct = unixtime;
				table.o[iter] = tmp1;
				iter = iter +1;
				addScript(table);		
				table =  {};
				table.o = {};
				iter = 0;
				flag2.zero();		
				}		
			});
		}
		
		
		function confirmExit()
		{
			var tmp4 = {};
			tmp4.x = 0;
			tmp4.y = 0;
			if(window.innerWidth)
			{
				tmp4.width = window.innerWidth;
			}
			else if(document.documentElement.offsetWidth)
			{
				tmp4.width = document.documentElement.offsetWidth;
			}
			tmp4.path = escape(window.location.href);
			tmp4.ref = escape(document.referrer);
			var foo = new Date; 
			var unixtime_ms = foo.getTime(); 
			var unixtime = parseInt(unixtime_ms / 1000);
			tmp4.ct = unixtime;
			tmp4.event = 9;
			table.o[iter] = tmp4;
			addScript(table);		
			table =  {};
			table.o = {};
			iter = 0;
		}
		try {
			window.onunload = confirmExit;
		}		
		catch(e) {
			var eline1;
			var eline2;
			if ('number' in e) {
				eline1 = e.number;
				
			}
			if ('lineNumber' in e) {
				eline2 = e.lineNumber;
			}
			var str = "eline1="+eline1+"eline2="+eline2+"&msg1="+e.message+"&msg2="+e.description+"&unload=true1" ;
			error_(str);	
		}
		


