/*------------AJAX POPUP JAVASCRIPT ------ By: Manish Gajjar----*/
siteurl="http://www.nickgregan.com/";
var http = null;
http = getHTTPObject(); // We create the HTTP Object	
function getHTTPObject() 
{
  var xmlhttp=null;
    try 
	{
      xmlhttp = new XMLHttpRequest();
    } catch (e) 
	{
 		try
		{
			xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
    }
  return xmlhttp;
}
function show_overlay(show,content,win_width)
{	
	win_left=0;
	win_left=(screen.width/2)-(win_width/2);	
	/*win_width=560;*/
	if(show)
	{
		document.getElementById("sbox-overlay").style.display='block';
		
		document.getElementById("sbox-overlay").style.visibility='visible';
		
		document.getElementById("sbox-window").style.visibility='visible';

		document.getElementById("sbox-content").style.visibility='visible';
		
		document.getElementById("sbox-btn-close").style.visibility='visible';

		document.getElementById("sbox-content").innerHTML=content;

		if(win_width === undefined)
		{}
		else
		{
			document.getElementById("sbox-window").style.width =win_width+'px';
			document.getElementById("sbox-content").style.width =win_width+'px';
		}

		if (win_left === undefined)

		{}

		else

		{
			document.getElementById("sbox-window").style.left =win_left+'px';
		}
	}
	else
	{
		document.getElementById("sbox-content").innerHTML=content;

		document.getElementById("sbox-overlay").style.visibility='hidden';

		document.getElementById("sbox-window").style.visibility='hidden';

		document.getElementById("sbox-content").style.visibility='hidden';
		
		document.getElementById("sbox-btn-close").style.visibility='hidden';
		
		document.getElementById("sbox-overlay").style.display='none';
	}
}
function handleHttpResponse()
{ 	
	if (http.readyState == 4) 
	{  
	  	var results=http.responseText.split("*^");
		if(results)
		{ 
			show_overlay(1,results[2],results[1]);
		}		
	}
}

function opensession()
{
	var theUL = document.getElementById("sbox-content"); 
	var url=siteurl+'session2.php';
	theUL.innerHTML = '<div>&nbsp;</div><div style=" height:80px" align="center"><img src="'+siteurl+'images/loading.gif"></div><div>&nbsp;</div>';
	show_overlay(1,theUL.innerHTML,400);
	http.open("GET",url, true);
	http.onreadystatechange = handleHttpResponse;
	http.send(null);
}