function getxmlhttp() //for every AJAX action we need to make the object
{
var xmlHttp;
  try
    { xmlHttp=new XMLHttpRequest(); }
  catch (e)
    {
    try
      { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }
    catch (e)
      {
      try
        { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }
      catch (e)
        {  alert("Your browser does not support AJAX!"); }
      }
    }

	return xmlHttp;
}



function closePopup()
{

		
		 
 	document.getElementById("popup").innerHTML= "";
		document.getElementById("popup").style.display = "none";
		document.getElementById("dimmer").style.display = "none";
		return false;
	
		
}


function popUpRequest(phpFile)
{

		 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 - 575) / 2;
 	     var topOffset = scrolledY + (centerY - 360) / 2;
 
 
 		 document.getElementById("popup").style.top = topOffset + "px";
 		 document.getElementById("popup").style.left = leftOffset + "px";
 
 
 
	xmlHttpdos=getxmlhttp();
	
	 xmlHttpdos.onreadystatechange=function()   //handle when it gets done
	  {
 
 			//alert("change");
 	
 			if(xmlHttpdos.readyState==4)  //complete
 			{
    			document.getElementById("popup").innerHTML = xmlHttpdos.responseText;
    			
    		}
    	   if(xmlHttpdos.readyState < 4)  //in progress
		    {
		    	document.getElementById("dimmer").style.display = "block";
		    	document.getElementById("popup").style.display = "block";
    			document.getElementById("popup").innerHTML = "<p>loading...</p>";
  			  }
	
	}
	
 		var phpcall=phpFile;

 	 xmlHttpdos.open("GET",phpcall,true);
	xmlHttpdos.send(null);



}

function getRequest(phpFile,div)
{
	//alert(div);
	
	xmlHttpaux=getxmlhttp();
	
	 xmlHttpaux.onreadystatechange=function()   //handle when it gets done
	  {
 
 			//alert("change");
 	
 			if(xmlHttpaux.readyState==4)  //complete
 			{
    			document.getElementById(div).innerHTML = xmlHttpaux.responseText;
    		}
    	   if(xmlHttpaux.readyState < 4)  //in progress
		    {
    			
    			
  			  }
	
	}
	
 		var phpcall=phpFile;

 	 xmlHttpaux.open("GET",phpcall,true);
	xmlHttpaux.send(null);
}

function getRequestAux(phpFile,div)
{
	//alert(div);
	
	xmlHttpdos=getxmlhttp();
	
	 xmlHttpdos.onreadystatechange=function()   //handle when it gets done
	  {
 
 			//alert("change");
 	
 			if(xmlHttpdos.readyState==4)  //complete
 			{
    			document.getElementById(div).innerHTML = xmlHttpdos.responseText;
    		}
    	   if(xmlHttpdos.readyState < 4)  //in progress
		    {
    			
  			  }
	
	}
	
 		var phpcall=phpFile;

 	 xmlHttpdos.open("GET",phpcall,true);
	xmlHttpdos.send(null);
}

function getRequestByObject(phpFile,div) //div object instead of div name
{
	xmlHttpdos=getxmlhttp();
	
	 xmlHttpdos.onreadystatechange=function()   //handle when it gets done
	  {
 
 			//alert("change");
 	
 			if(xmlHttpdos.readyState==4)  //complete
 			{
    			document.div.innerHTML = xmlHttpdos.responseText;
    		}
    	
	
	}
	
 		var phpcall=phpFile;

 	 xmlHttpdos.open("GET",phpcall,true);
	xmlHttpdos.send(null);
}


function postRequest(phpFile,parameters,div) //post
  { 
	xmlHttp=getxmlhttp();
	
	 xmlHttp.onreadystatechange=function()   //handle when it gets done
	  {
 
 			//alert("change");
 	
 			if(xmlHttp.readyState==4)  //complete
 			{
    			document.getElementById(div).innerHTML = xmlHttp.responseText;
    			
    		}
    	   if(xmlHttp.readyState < 4)  //in progress
		    {
    			//document.getElementById(div).innerHTML= "<p>saving...</p>";	
  			  }
	
	}
	
 			var phpcall=phpFile;
 		//	var parameters= "description=" + encodeURIComponent(form.description.value) + "&title=" + encodeURIComponent(form.title.value) + "&url=" + encodeURIComponent(form.url.value);

	//alert(phpcall);
	 //return false;
 	 xmlHttp.open("POST",phpcall,true);
 	 
	 xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      xmlHttp.setRequestHeader("Content-length", parameters.length);
	xmlHttp.send(parameters);
	
	
 return false;
  
}