///////////////////////////////////////////////////
//      mFloat Interface by MarkWillis.co.uk     //
/*************************************************/

// Settings
var mFloatRoot = 'http://www.mlwgames.com/mw2exp/inc/calc/'; // Where are the files (which you load into the floater) located?


/*************************************************
  DO NOT EDIT ANYTHING BELOW UNLESS YOU'RE SURE!
*************************************************/

window.onmouseover = TrackingMousePosition;
//document.onmousemove = TrackingMousePosition;
scanViewport();

function mFloatOpen(useMouse, useY, command, query, keepSize)
{	
	/* Key
		useMouse: Set to 1 if you want floating window to popup at client's mouse location (centered). Set to 0 if you want manual Y Position.
		useY: Manual Y co-ord location of floating window. (Vertical position.)
		command: the file you wish to load.
		query: any variables to pass to the file loading into floating window
		keepSize: keep the window size when loading a new file? Makes transitions between floating windows look nicer.
	*/
	
	var x = 0; var y = 0;
	var oY = useY;
	if(MouseX)
	{
		x = MouseX;
		
		if(useMouse == 1){
		//scroll(0,(MouseY - 110));
		y = MouseY - 100;
		}else{
		scroll(0,(oY - 10));
		y = oY;
		}
	}
	else
	{
		x = window.event.clientX+document.documentElement.scrollLeft;
		if(useMouse == 1){
		y = window.event.clientY+document.documentElement.scrollTop;
		}else{
		scroll(0,(oY - 10));
		y = oY;
		}
	}
	
	// Cloak
	var wrapHeight = document.getElementById('mFloatWrap').offsetHeight;
	var cloakHeight = document.documentElement.clientHeight;
	
	if(cloakHeight < wrapHeight)
	{
		cloakHeight = wrapHeight;
	}
	document.getElementById('mFloatCloak').style.height = cloakHeight + "px";
	document.getElementById('mFloatCloak').style.width = mFloatViewportWidth + "px";
	document.getElementById('mFloatCloak').style.display = "block";
	
	
	if(keepSize == 1)
	{
		var goheight = document.getElementById('mFloatInner').clientHeight;
		if(goheight == "")
		{
			goheight = document.getElementById('mFloatInner').offsetHeight;
		}
	}
	
	document.getElementById('mFloatBlock').style.left = ((mFloatViewportWidth / 2) - 440) + "px";
	document.getElementById('mFloatBlock').style.top = (y + 10) + "px";
	document.getElementById('mFloatBlock').innerHTML = '<div class="mFloat-inner" id="mFloatInner"><div class="mFloat-close"><a href="#" onclick="return mFloatClose();"><!-- close --></a></div><div class="mFloat-main"> <div class="mFloatAreaLoading"><!-- --></div> </div></div>';
	
	if(keepSize == 1)
	{
		document.getElementById('mFloatInner').style.height = goheight + "px";
	}
	
	document.getElementById('mFloatBlock').className = 'mFloatBlock-on';
	document.getElementById('mFloatBlock').style.display = "block";
	var d = new Date();
	var tsec = d.getSeconds();
	var ajaxRequest;
	try{ajaxRequest = new XMLHttpRequest(); } catch (e){try{ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");} catch (e) {try{ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");} catch (e){return true;}}}
	ajaxRequest.onreadystatechange = function()
	{
	if(ajaxRequest.readyState == 4){
		document.getElementById('mFloatBlock').innerHTML = ajaxRequest.responseText;
	}
	}
	var addQuery = query.replace(/\[amp\]/g, '&');
	var queryString = mFloatRoot + command + '?time=' + tsec + addQuery + "&pos=" + y;
	ajaxRequest.open("GET", queryString, true);
	ajaxRequest.send(null);
	return false;
}
function mFloatClose()
{
	// Cloak
	document.getElementById('mFloatCloak').style.height = "1px";
	document.getElementById('mFloatCloak').style.width = "1px";
	document.getElementById('mFloatCloak').style.display = "none";
	document.getElementById('mFloatBlock').innerHTML = ''; document.getElementById('mFloatBlock').className = 'mFloatBlock-off'; document.getElementById('mFloatBlock').style.display = "none";
	return false;
}