
function loadPopup(id)
{
	// Load content
	request = getHTTPObject();
	request.open("get", "/activities/popup.php?id=" + id, true);
	request.onreadystatechange = showPopup;
	request.send(null);
}

function showPopup()
{
	if(request.readyState == 4)
	{
		// Get element by ID
		element = document.getElementById('activities-popup');
		element.innerHTML = request.responseText;
		element.style.display = "block";
	}
	
}

function hidePopup()
{
	// Get element
	element = document.getElementById('activities-popup');
	element.style.display = "none";
}

function getScrollingPosition()
{
	//var position = [0, 0];
	var y = 0;
	if (typeof window.pageYOffset != 'undefined')
	{
		/*position = [
		window.pageXOffset,
		window.pageYOffset
		];
		*/
		y = pageYOffset;
	}
	else if (typeof document.documentElement.scrollTop != 'undefined' && document.documentElement.scrollTop > 0)
	{
		/*position = [
		document.documentElement.scrollLeft,
		document.documentElement.scrollTop
		];*/
		y = document.documentElement.scrollTop;
	}
	else if (typeof document.body.scrollTop != 'undefined')
	{
		/*position = [
		document.body.scrollLeft,
		document.body.scrollTop
		];*/
		y = document.body.scrollTop;
	}
	return y;
}


function movePopup(e) 
{
	var posx = 0;
	var posy = 0;
	
	if (!e) var e = window.event;
	if (e.pageX || e.pageY) 
	{
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY) 
	{
		posx = e.clientX + document.body.scrollLeft	+ document.documentElement.scrollLeft;
		posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
	}
	
	// posx and posy contain the mouse position relative to the document
	
	// Do something with this information
	
	// Get element by Id
  	element = document.getElementById('activities-popup');
	
	// Move mouse positioning
  	posx = posx + 50;
  	posy = posy - 100;
  	
  	// Apply to the inline styles
  	element.style.left = posx + "px";
  	element.style.top = posy + "px";
}

function movePopupOld(evt)
{
	// Get mouse position
	mouseX=evt.pageX?evt.pageX:evt.clientX;
  	mouseY=evt.pageY?evt.pageY:evt.clientY;
	
	alert(getScrollingPosition());
  	
  	// Move mouse positioning
  	mouseX = mouseX + 50;
  	mouseY = mouseY - 100;
	
	// Work out the window scrolling placement
	/*
	if (navigator.appName == "Microsoft Internet Explorer")
	{
		scrollY = document.body.scrollTop;
	}
	else
	{
		scrollY = window.pageYOffset;
	}
	alert(scrollY);
	
	// Make up mouseY
	mouseY = mouseY + scrollY;
	*/
  	
  	// Get element by Id
  	element = document.getElementById('activities-popup');
  	
  	// Apply to the inline styles
  	element.style.left = mouseX + "px";
  	element.style.top = mouseY + "px";

}

function updateBox(evt) 
{
	//mouseX=evt.pageX?evt.pageX:evt.clientX;
	//mouseY=evt.pageY?evt.pageY:evt.clientY;
    document.getElementById('mydiv').style.left="100px;";
    document.getElementById('mydiv').style.top="100px;";
}

function getHTTPObject()
{
	if(window.ActiveXObject)
	{
		var waystation = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else if(window.XMLHttpRequest)
	{
		var waystation = new XMLHttpRequest();
	}
	else
	{
		var waystation = false;
	}
	return waystation;
}

window.onscroll = doThis;
function doThis(e){
//do
// e is the event
}