	// If the browser supports getElementById (ie. has JS) allow this function and disable the css hover
	if (document.getElementById) {
		ovrlay = document.getElementById('lbox_overlay');
		if (ovrlay == null)
		{	
			//document.write('<style type="text/css"> #lbox1, #lbox2, #lbox3, #lbox4 {display:none;position:relative;}</style>');
			document.write('<style type="text/css"> #lboxcontainer {position:absolute;top:0;left:0;width:100%;height:auto;z-index:9001;}</style>');
			document.write('<style type="text/css"> #lbox_overlay {display:none;background:black;width:100%;position:absolute;top:0;left:0;zindex:-1;opacity:0.7;filter:alpha(opacity=70);mozopacity:0.7; KhtmlOpacity:0.7;}</style>');
			var zzlbox = null;
			var objBody = document.getElementsByTagName("body").item(0);
			
			// create overlay div and hardcode some functional styles (aesthetic styles are in CSS file)
			var lboxOverlay = document.createElement("div");
			lboxOverlay.setAttribute('id','lbox_overlay');
			lboxOverlay.onclick = function(){togglelbox();return false;}
			lboxOverlay.style.display = "none";
			// set height of Overlay to take up whole page and show
			var arrayPageSize = getPageSize();
			lboxOverlay.style.height = (arrayPageSize[1] + 'px');
			objBody.insertBefore(lboxOverlay, objBody.firstChild);
			
	//		var lboxContainer = document.getElementById("lboxcontainer");
	//		if (lboxContainer != null) lboxContainer.onclick = function(){togglelbox();return false;}
			var lboxContainer = document.createElement("div");
			lboxContainer.setAttribute('id','lboxcontainer');
			lboxContainer.style.top = '50px';
			lboxContainer.style.left = '250px';
			lboxContainer.style.width = '600px';
			objBody.insertBefore(lboxContainer, objBody.firstChild);
		}
	};


	function togglelbox(id){
		var arrayPageSize = getPageSize();
		var lboxOverlay = document.getElementById("lbox_overlay");
		lboxOverlay.style.height = (arrayPageSize[1] + 'px');		// make sure to cover entire window
		if (id != null) zzlbox = document.getElementById(id);
		zzlbox.onclick = function(){}

		if (zzlbox.style.display == "block")
		{
			zzlbox.style.display = "none";
			lboxOverlay.style.display = "none";
			zzlbox.style.zIndex = '-2';
			lboxOverlay.style.zIndex = '-1';
		}
		else
		{
			lboxOverlay.style.display = "block";
			zzlbox.style.display = "block";
			zzlbox.style.zIndex = '9002';
			lboxOverlay.style.zIndex = '9000';
		}
	};
		
	// getPageSize()
	// Returns array with page width, height and window width, height
	// Core code from - quirksmode.org
	// Edit for Firefox by pHaez
	function getPageSize(){
		
		var xScroll, yScroll;
		
		if (window.innerHeight && window.scrollMaxY) {	
			xScroll = document.body.scrollWidth;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
		
		var windowWidth, windowHeight;
		if (self.innerHeight) {	// all except Explorer
			windowWidth = self.innerWidth;
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { // other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}	
		
		// for small pages with total height less then height of the viewport
		if(yScroll < windowHeight){
			pageHeight = windowHeight;
		} else { 
			pageHeight = yScroll;
		}

		// for small pages with total width less then width of the viewport
		if(xScroll < windowWidth){	
			pageWidth = windowWidth;
		} else {
			pageWidth = xScroll;
		}

		arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
		return arrayPageSize;
	}


	// ajax section to load popup

	var req;
	var tcid;
	
  	function showlbox(slot, id)		// name of text control to load
	{
		tcid = id;
		var foo = document.getElementById(tcid);

		if (foo == null || foo.innerHTML == "" || foo.innerHTML.length < 6)  //allow for a little white space - see if it's already loaded
		{
			loadlbox("/learn/learningcenters/lbox_ajax.aspx?slot=" + slot + "&title=" + tcid);
		}
		else
		{
			togglelbox(tcid);
		}
	}
	
	function getHTTPlboxObject() 
	{
		var xmlhttp;
	/*@cc_on
	@if (@_jscript_version >= 5)
		try {
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (E) {
				xmlhttp = false;
			}
		}
	@else
		xmlhttp = false;
	@end @*/

		if (!xmlhttp && typeof XMLHttpRequest != 'undefined') 
		{
			try 
			{
				xmlhttp = new XMLHttpRequest();
			} catch (e) {
				xmlhttp = false;
			}
		}
		return xmlhttp;
	}

	function loadlbox(url) 
	{
		req = getHTTPlboxObject(); // We create the HTTP Object
		if ( req )
		{
			req.open("GET", url, true);
			req.onreadystatechange = processlbox;
			req.send(null);
			}
		else
		{
			//handle an http error
		}
	}

	function processlbox()
	{
		//if request is complete
		if (req.readyState == 4)
		{
			//Check HTTP status
			if (req.status == 200)
			{
				//put the Text object response
				response = req.responseText
				var objBody = document.getElementById("lboxcontainer");
		
				var lboxdiv = document.createElement("div");
				lboxdiv.setAttribute('id', tcid);
				lboxdiv.innerHTML = response;
				lboxdiv.style.display = 'none';
				lboxdiv.style.position = 'relative';
				lboxdiv.style.background = 'white';
				objBody.insertBefore(lboxdiv, objBody.firstChild);
				togglelbox(tcid);		// display it after we know it's loaded
			}
			else
			{
				//handle an http error
			}
		}
	}



