function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}

//Code for popup window::

function fireMyPopup(popupwin,popwidth,popheight) 
{

	var scrolledX, scrolledY;

	if( self.pageYOffset ) 
	{
	  scrolledX = self.pageXOffset;
	  scrolledY = self.pageYOffset;
	} 
	else if( document.documentElement && document.documentElement.scrollTop ) 
	{
	  scrolledX = document.documentElement.scrollLeft;
	  scrolledY = document.documentElement.scrollTop;
	} 
	else if( document.body ) 
	{
	  scrolledX = document.body.scrollLeft;
	  scrolledY = document.body.scrollTop;
	}

	// Determine the coordinates of the center of the page

	var centerX, centerY;

	if( self.innerHeight ) 
	{
	  centerX = self.innerWidth;
	  centerY = self.innerHeight;
	} 
	else if( document.documentElement && document.documentElement.clientHeight ) 
	{
	  centerX = document.documentElement.clientWidth;
	  centerY = document.documentElement.clientHeight;
	} 
	else if( document.body ) 
	{
	  centerX = document.body.clientWidth;
	  centerY = document.body.clientHeight;
	}

	var leftOffset = scrolledX + (centerX - popwidth) / 2;
	var topOffset = scrolledY + (centerY - popheight) / 2;

	document.getElementById(popupwin).style.top = topOffset + "px";
  	document.getElementById(popupwin).style.left = leftOffset + "px";
	document.getElementById(popupwin).style.width = popwidth;
	document.getElementById(popupwin).style.height = popheight;
	document.getElementById(popupwin).style.background = "#F0F0F0";
  	document.getElementById(popupwin).style.display = "block";
}

//Close popup window
function CloseMyPopup(popupwin) 
{
	document.getElementById(popupwin).style.display = "none";	
}
function sitelogin()
      {

         xmlhttp=GetXmlHttpObject();
			if (xmlhttp==null)
  			{
			  alert ("Your browser does not support XMLHTTP!");
			  return;
		  	}
			var url="functions/logincheck.php";
			url=url+"?sid="+Math.random();
			url=url+"&uname="+ document.getElementById("UserName").value;
			url=url+"&pswd="+ document.getElementById("lgnbxPassword").value;
			xmlhttp.onreadystatechange=stateChangedlogin;
			xmlhttp.open("GET",url,true);
			xmlhttp.send(null);
		}

		//This function will update content for "Up Coming Events"
      function stateChangedlogin()
		{
			if (xmlhttp.readyState==4)
  			{
  				if(xmlhttp.responseText == 0)
  				{
  				  alert("User Name / Password entered is incorrect. Please click on forgot password to retrive your password");
  				}
  				else
  				{
  				
                  checkforsession();
  				}
			}
		}
		
		function checkforsession()
		{
		
         xmlhttp=GetXmlHttpObject();
			if (xmlhttp==null)
  			{
			  alert ("Your browser does not support XMLHTTP!");
			  return;
		  	}
		  	
		  	
			var url="functions/loginstatuscheck.php";
			url=url+"?sid="+Math.random();
			xmlhttp.onreadystatechange=stateChangedBx;
			xmlhttp.open("GET",url,true);
			xmlhttp.send(null);
		
		}
		
		function stateChangedBx()
		{
 		   if (xmlhttp.readyState==4)
  			{

                  alert(xmlhttp.responseText);
	           	   if(xmlhttp.responseText == 0)
		            {
		             document.getElementById('loginbx').style.display = 'block';
	                document.getElementById('loggedinbox').style.display = 'none';	
		            }
		            else
		            {
		             document.getElementById('loginbx').style.display = 'none';
                   document.getElementById('loggedinbox').style.display = 'block';
                   document.getElementById("loggedinbox").innerHTML = xmlhttp.responseText;
                  }	
		   }
		}
		
		//Code for popup window with location to display::

function fireMyPopuploc(popupwin,popwidth,popheight,top,left)
{

	var scrolledX, scrolledY;

	if( self.pageYOffset )
	{
	  scrolledX = self.pageXOffset;
	  scrolledY = self.pageYOffset;
	}
	else if( document.documentElement && document.documentElement.scrollTop )
	{
	  scrolledX = document.documentElement.scrollLeft;
	  scrolledY = document.documentElement.scrollTop;
	}
	else if( document.body )
	{
	  scrolledX = document.body.scrollLeft;
	  scrolledY = document.body.scrollTop;
	}

	// Determine the coordinates of the center of the page

	var centerX, centerY;

	if( self.innerHeight )
	{
	  centerX = self.innerWidth;
	  centerY = self.innerHeight;
	}
	else if( document.documentElement && document.documentElement.clientHeight )
	{
	  centerX = document.documentElement.clientWidth;
	  centerY = document.documentElement.clientHeight;
	}
	else if( document.body )
	{
	  centerX = document.body.clientWidth;
	  centerY = document.body.clientHeight;
	}

	var leftOffset = scrolledX + (centerX - popwidth) / 2;
	var topOffset = scrolledY + (centerY - popheight) / 2;

	document.getElementById(popupwin).style.top = "0px";
  	document.getElementById(popupwin).style.left = leftOffset + "px";
	document.getElementById(popupwin).style.width = popwidth;
	document.getElementById(popupwin).style.height = popheight;
	document.getElementById(popupwin).style.background = "#F0F0F0";
  	document.getElementById(popupwin).style.display = "block";
}

