window.IE = /*@cc_on!@*/false;
window.UserID=Math.floor(Math.random()*9999999);
window.beforeload = (new Date()).getTime();
window.afterload = "";
window.myTimer=0;
	window.qsParm = new Array();
	var query = window.location.search.substring(1);
	var parms = query.split('&');
	for (var i=0; i<parms.length; i++) {
		var pos = parms[i].indexOf('=');
		if (pos > 0) {
			var key = parms[i].substring(0,pos);
			var val = parms[i].substring(pos+1);
			window.qsParm[key] = val;
		}
	}


function pageloadingtime()
{
  loadingDone = (new Date()).getTime();
  loadingDone = (loadingDone-window.beforeload)/1000;
  return loadingDone;
}
function pad(number, length) {
    var str = '' + number;
    while (str.length < length) {
        str = '0' + str;
    }
    return str;
}

function addIframe(Pos){
	ClickXY="";
  if (window.IE) { // grab the x-y pos.s if browser is IE
    if (event) ClickXY="&ClickXY="+escape((event.clientX + document.body.scrollLeft)+"x"+(event.clientY + document.body.scrollTop));
  } else {  // grab the x-y pos.s if browser is NS
  	if (Pos !== undefined && Pos != "return") ClickXY="&ClickXY="+escape(Pos.pageX+"x"+Pos.pageY);
  }  
	if (!document.body.offsetWidth){
		WindowSize="&WindowSize="+escape(window.innerWidth+"x"+window.innerHeight);
	} else {
		WindowSize="&WindowSize="+escape(document.body.clientWidth+"x"+document.body.clientHeight);
	}
	strReferrer="&Referrer="+document.referrer
	window.strDomain="&Domain="+escape(document.domain)
	strURL="&Page="+escape(document.URL)
	loadTime="&LoadTime="+window.afterload;
	strDate=new Date();
	strDateFixed=strDate.getFullYear()+"-"+pad(strDate.getMonth()+1, 2)+"-"+pad(strDate.getDate(), 2)+" "+pad(strDate.getHours(), 2)+":"+pad(strDate.getMinutes(), 2)+":"+pad(strDate.getSeconds(), 2)
	strDate="&UserTime="+escape(strDateFixed)
		
	ifrm = document.createElement("script");
	if (!window.qsParm['showOverlay']){
		ifrm.setAttribute("src", "http://mobiusrobot.com/liveViewer/live.php?userID="+window.UserID+strDate+"&username="+window.uid+WindowSize+"&TimePage="+window.myTimer+loadTime+ClickXY+window.strDomain+"&ScreenResolution="+screen.width+'x'+screen.height+strURL+strReferrer);
	} else {
		ifrm.setAttribute("src", "http://mobiusrobot.com/liveViewer/live.php?showOverlay=true&userID="+window.UserID+strDate+"&username="+window.uid+"&TimePage="+window.myTimer+loadTime+window.strDomain+WindowSize+ClickXY+"&ScreenResolution="+screen.width+'x'+screen.height+strURL+strReferrer);				
	}
	ifrm.id = "content";
	document.body.appendChild(ifrm);
}
if (document.addEventListener){  
	document.addEventListener('click', addIframe, false);   
} else if (document.attachEvent){  
	document.attachEvent('onclick', addIframe);  
}  
	
function initialize(step, uid) {
	window.afterload=pageloadingtime();
	window.uid=uid
/*
	setTimeout("document.body.innerHTML=document.body.innerHTML+\"<iframe id='info' style='display:none' src='http://mobiusrobot.com/liveViewer/live.php?uid="+UserID+"&username="+uid+strDomain+afterload+"&ScreenResolution="+screen.width+'x'+screen.height+strURL+strReferrer+"'></iframe>\";", 500);
	setInterval("document.body.innerHTML=document.body.innerHTML.substr(0, document.body.innerHTML.lastIndexOf('<iframe'))+\"<iframe style='display:none' src='http://mobiusrobot.com/liveViewer/live.php?uid="+UserID+"&username="+uid+strDomain+afterload+"&ScreenResolution="+screen.width+'x'+screen.height+strURL+strReferrer+"'></iframe>\";", 5000)
*/
	setInterval("addIframe();", 3000);
	if (!window.qsParm['showOverlay']){
		setTimeout("setInterval('d=parent.document.body; d_nested=parent.document.getElementById(\"content\");	throwaway = d.removeChild(d_nested);', 3000)", 1500)
		setInterval("window.myTimer=window.myTimer+1", 1000);
	}
}
