function GetXmlHttpObject()
{
  var xmlHttp=null;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    }
  return xmlHttp;
}

function updateEntry(intid,type)
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="./ajax/actions/editEntry.php?passedid=" + intid + "&type=" + type;
xmlHttp.onreadystatechange=function(){stateChanged(intid, type);};
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function updateDb(intid,type)
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var maincontent = encodeURIComponent(FCKeditorAPI.GetInstance('FCKeditor' + type + intid).GetXHTML(true));
var url="./ajax/actions/updateDb.php";
xmlHttp.onreadystatechange=function(){stateChanged(intid, type);};
xmlHttp.open("POST",url,true);
xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
xmlHttp.send('content=' + maincontent + '&passedid=' + intid + '&type=' + type); 
alert ("This item has successfully updated");
}

function newEntry(type)
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="./ajax/actions/newEntry.php?type=" + type;
xmlHttp.onreadystatechange=function(){stateNewChanged(type);};
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function updateDbNew(type)
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
	var maincontent = encodeURIComponent(FCKeditorAPI.GetInstance('FCKeditor' + type).GetXHTML(true));
	var url="./ajax/actions/updateDbNew.php";
	var title = document.getElementById(type + "title").value;
	xmlHttp.onreadystatechange=function(){stateNewChanged(type);};
	xmlHttp.open("POST",url,true);
	xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
	xmlHttp.send('content=' + maincontent + '&title=' + title + '&type=' + type); 
	alert ("This item has successfully updated");
	
}

function stateNewChanged(type) 
{ 
	if (xmlHttp.readyState==4)
	{ 
	document.getElementById(type + "NewEntry").innerHTML=xmlHttp.responseText;
	}
}


function stateChanged(newid, type) 
{ 
	if (xmlHttp.readyState==4)
	{ 
	document.getElementById(type + "Update" + newid).innerHTML=xmlHttp.responseText;
	}
}

