// very simple ajax function

function makeRequest(url,method,func,arg) {
	var http_request = false;
	
	if(!method) method="GET";
	
	if (window.XMLHttpRequest) { // Mozilla, Safari, ...
	    http_request = new XMLHttpRequest();
	    if (http_request.overrideMimeType) {
	        http_request.overrideMimeType('text/xml');
	        // See note below about this line
	    }
	} else if (window.ActiveXObject) { // IE
	    try {
	        http_request = new ActiveXObject("Msxml2.XMLHTTP");
	    } catch (e) {
	        try {
	            http_request = new ActiveXObject("Microsoft.XMLHTTP");
	        } catch (e) {}
	    }
	}
	
	if (!http_request) {
	    alert('Giving up :( Cannot create an XMLHTTP instance');
	    return false;
	}
	if(func=="") http_request.onreadystatechange = function() { alertContents(http_request); };
	else {
		evalstr="http_request.onreadystatechange = function() { "+func+"(http_request";
		if(arg!="") evalstr+=",arg";
		evalstr+="); };";
		eval(evalstr);
	}
	http_request.open(method, url, true);
	http_request.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=utf-8");
	http_request.send(null);
	
}

function alertContents(http_request) {
	
	if (http_request.readyState == 4) {
	    if (http_request.status == 200) {
	        alert(http_request.responseText);
	    } else {
	        alert('There was a problem with the request.');
	    }
	}
	
}

function get(url,id)
{
	makeRequest(url,"GET","getReturn",id)
}

function getReturn(http_request,id)
{
	document.getElementById(id).innerHTML=http_request.responseText;

	var tabPanel=new WebFXTabPane(document.getElementById("tab-pane-1"),false);
	tabPanel.addTabPage(document.getElementById("tab-page-nl"));
	tabPanel.addTabPage(document.getElementById("tab-page-fr"));
	tabPanel.addTabPage(document.getElementById("tab-page-en"));
	tabPanel.addTabPage(document.getElementById("tab-page-de"));
	setupAllTabs();

	setTimeout("rebuildStuff()",1000);
}

function rebuildStuff()
{
	tinyMCE.idCounter=0;
	tinyMCE.execCommand('mceRemoveControl',true,'text_nl');	
	tinyMCE.execCommand('mceAddControl',true,'text_nl');	
	tinyMCE.execCommand('mceRemoveControl',true,'text_fr');	
	tinyMCE.execCommand('mceAddControl',true,'text_fr');	
	tinyMCE.execCommand('mceRemoveControl',true,'text_en');	
	tinyMCE.execCommand('mceAddControl',true,'text_en');	
	tinyMCE.execCommand('mceRemoveControl',true,'text_de');	
	tinyMCE.execCommand('mceAddControl',true,'text_de');	
}
