// JavaScript Document
var xmlHttp
var myDiv
var myUrl

function ShowData(page_id,thisDiv,thisUrl,no_cache){

	myDiv = thisDiv
	myUrl = thisUrl

xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
var url=thisUrl
url=url+"?section="+myDiv
url=url+"&page_id="+page_id

if(no_cache==true){
url=url+"&sid="+Math.random()
}

xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 {
document.getElementById(myDiv).innerHTML=xmlHttp.responseText
 }
}

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 saveData(page_id,update_id,thisDiv,thisUrl,thisEditor){


	xmlHttp=GetXmlHttpObject();

	if (xmlHttp==null){ // If it cannot create a new Xmlhttp object.
		alert ("Browser does not support HTTP Request");
		return;
	}

	var FCK = FCKeditorAPI.GetInstance(thisEditor);
	var strValue = FCK.GetXHTML();

	strValue = encodeMyHtml(strValue);

//Opnieuw tonen van gewijzigde data op pagina
	myDiv = thisDiv

	xmlHttp.onreadystatechange=stateChanged

	xmlHttp.open('POST', thisUrl);
	xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlHttp.send(thisEditor+'='+strValue+'&editor_name='+thisEditor+'&update_id='+update_id+'&section='+thisDiv+'&page_id='+page_id);



	//strValue = unescape(strValue);

	//strValue = strValue + '<br><input type="button" name="edit_section" Value="Wijzig" onClick="ShowData(1,\''+thisDiv+'\',\'show_edit_box.php\',true);">'


	//Data opnieuw tonen
	//document.getElementById(thisDiv).innerHTML = strValue;
	//ShowData(page_id,thisDiv,'show_data.php',true);


}

function encodeMyHtml(strToEncode) {
     strToEncode = escape(strToEncode);
     strToEncode = strToEncode.replace(/\//g,"%2F");
     strToEncode = strToEncode.replace(/\?/g,"%3F");
     strToEncode = strToEncode.replace(/=/g,"%3D");
     strToEncode = strToEncode.replace(/&/g,"%26");
     strToEncode = strToEncode.replace(/@/g,"%40");

     return strToEncode
}