var xhttp;
var catch_respond;
var modul;
var opt1;
var opt2;
var tmp;

function createXMLHttpRequest() {
	if (window.ActiveXObject) { 
		try { 
			// IE 6 and higher
			xhttp = new ActiveXObject("MSXML2.XMLHTTP");
		} catch (e) {
			try {
				// IE 5
				xhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
				xhttp=false;
			}
		}
	}
	else if (window.XMLHttpRequest) {
		try {
			// Mozilla, Opera, Safari ...
			xhttp = new XMLHttpRequest();
		} catch (e) {
			xhttp=false;
		}
	}
}		
		
function ajax_send(modul_,option1,option2,from){
	if (!xhttp) {
		alert("An Error occured when trying to initialize XMLHttpRequest!");
		return;
	}
	modul = modul_;
	opt1 = option1;
	opt2 = option2;
	if(option1 == 'get_subfolder' || option1 == 'get_fileinfo'){
		from.src = 'bin/img/minus.gif';
		from.onclick = new Function("clear_path('"+modul+"', '"+opt1+"', '"+opt2+"', this);");
	}
	if( option1 == 'get_fileinfo'){
		document.getElementById(modul_).className = 'dokufile_a';
	}
	xhttp.open("GET", "bin/handle_a.php?action="+opt1+"&opt="+opt2 ,true);
	xhttp.onreadystatechange=sendRequest_callback;
	xhttp.send(null);
}

function sendRequest_callback() {
	if (xhttp.readyState==4){
		setting = 0;
		catch_respond = xhttp.responseText;
		document.getElementById(modul).innerHTML = catch_respond;
	}
}

function clear_path(modul_, option1, option2, from){
		if( option1 == 'get_fileinfo'){
			document.getElementById(modul_).className = 'dokufile';
			from.src = 'bin/img/fileicon/text_plain.gif';
		}else{
			from.src = 'bin/img/plus.gif';
		}
		from.onclick = new Function("ajax_send('"+modul_+"','"+option1+"','"+option2+"', this);");
		document.getElementById(modul_).innerHTML = '';
}

createXMLHttpRequest();
