/* Popup Style Functions
 *----------------------------------------------------------------------*/

includedata = "";

function blackoutStd() {
	// Blacks out the window and puts a popup style box in there!
	bo = document.createElement('div')
	bo.id = "blackout";
    var dims = new WindowDimensions();		// use screen.js to get browser screen dimensions
	bo.style.width = dims.viewport.inner.width+"px";	
	bo.style.height = dims.viewport.inner.height+"px";
	bo.style.top = dims.window.scroll.top+"px";
	// Add popup style box
	var pop = document.createElement('div');
	pop.id = "popupstyle";
	pop.innerHTML = includedata;
	putleft = (dims.viewport.inner.width)/2-(300);
	pop.style.left = putleft+"px";
	pop.style.top = (50+dims.window.scroll.top)+"px";
	// Now add both elements
	document.body.appendChild(bo)
	document.body.appendChild(pop)
}

function cancelPopup() {
	bo = document.getElementById('blackout');
	pop = document.getElementById('popupstyle');
	document.body.removeChild(bo);	
	document.body.removeChild(pop);	
}


// Ajax Bits and bobs
//-------------------------------------------------------------------------
var oXmlHttp;
var data;								//holder for any returned ajax data
var includedata;						//holder for any returned ajax data

if (window.XMLHttpRequest) {oXmlHttp = new XMLHttpRequest();} 
else  {oXmlHttp = new ActiveXObject("Microsoft.XMLHTTP");}

function myRand() {	return parseInt(Math.random()*99999999);}
  
function getIncludeText(url,act) {		// url to retrieve data and action to run if data fetch is successful
oXmlHttp.open("get",url,true);
oXmlHttp.onreadystatechange = function () {
	if(oXmlHttp.readyState == 4) {
		if(oXmlHttp.status == 200) {
			includedata = oXmlHttp.responseText
			eval(act)
		} else {
			alert('Whoops! The AJAX call did not complete, please try again');
		}
	}
}
oXmlHttp.send(null);
}

