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").style.visibility = "hidden";
		document.getElementById("dimmer").style.visibility = "hidden";
}


function popUpRequest(phpFile)
{

	xmlHttpdos=getxmlhttp();
	
	 xmlHttpdos.onreadystatechange=function()   //handle when it gets done
	  {
 
 			//alert("change");
 	
 			if(xmlHttpdos.readyState==4)  //complete
 			{
    			document.getElementById("popup").innerHTML = xmlHttpdos.responseText;
    			document.getElementById("popup").style.visibility = "visible";
    		}
    	   if(xmlHttpdos.readyState < 4)  //in progress
		    {
		    	document.getElementById("dimmer").style.visibility = "visible";
    			document.getElementById("popup").innerHTML = "<center><img src='../resources/tiny_red.gif'></center>";
  			  }
	
	}
	
 		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
		    {
    			document.getElementById(div).innerHTML = "<center><img src='../resources/tiny_red.gif'></center>";
  			  }
	
	}
	
 		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;
  
}