/**
New Popup Which Brings in the information from the a tag

*/
function loadPopupNew(item)
{
	// alert($(item).attr('name'));
	
	// Create the html from the attributes of the 'a' tag that has been hovered
	// The title
	html = "<h3>" + $(item).attr('name') + "</h3>\n";
	
	// The image
	html += "<div id=\"activities-popup-image\"><img src=\"http://www.vipadrenaline.com/images/activities/large/" + $(item).attr('image') + "\" /></div>\n";
	
	// The name
	html += "<p><strong>" + $(item).attr('name') + "</strong></p>\n";
	
	// The description
	html += "<p>" + $(item).attr('description') +"</p>\n";
	
	// Now insert this
	$('#activities-popup').html(html);
	
	// And show the div
	$('#activities-popup').show();
}

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;
		
		// Made this work with jQuery
		$('#activities-popup').show();
	}
	
}

function hidePopup()
{
	// This now works with jQuery
	$('#activities-popup').hide();
}

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 - 200;
  	posy = posy + 25;
  	
  	// 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
}
