function createRequestObject() {
    try {
		ajax = new ActiveXObject("Microsoft.XMLHTTP");
	} catch(e) {
		try {
            ajax = new ActiveXObject("Msxml2.XMLHTTP");
		} catch(ex) {
            try {
				ajax = new XMLHttpRequest();
			} catch(exc) {
				alert("Esse browser não tem recursos para uso do Ajax");
				ajax = null;
			}
		}
	}
	return ajax;
}

var http1 = createRequestObject(); var http2 = createRequestObject(); var http3 = createRequestObject();
var http4 = createRequestObject(); var http5 = createRequestObject(); var http6 = createRequestObject();
var http7 = createRequestObject(); var http8 = createRequestObject(); var http9 = createRequestObject();


var gFoco = null;
var FCKeditorAPI = null;

/* funcoes fixas */

function ajaxOpen(obj,action,handler,foco) {
	// global variables
	gFoco = foco;
	
//	alert('index.php?action=' + action);
	// ajax
	if (eval(obj)) {
    	eval(obj + ".open('get', 'index.php?action=' + action)");
    	eval(obj + ".onreadystatechange = " + handler);
    	eval(obj + ".send(null)");
	}
}

function ajaxOpen2(obj,div,action,handler,foco) {
	gFoco = foco;
	gDiv = div;

	if (gDiv.substr(0,4) == 'menu') {
		if (document.getElementById(div).innerHTML != "") {
			document.getElementById(div).innerHTML = "";
			document.getElementById(div).style.display = 'none';
			return;						
		}
	}
	document.getElementById(div).style.display = '';
	document.getElementById(div).innerHTML = "Carregando...";	
	handlerFunction('iframe',handler,'index.php?action=' + action);
	
}

function ajaxOpen3(obj,div,action,handler,foco) {
	gFoco = foco;
	gDiv = div;

	if (gDiv.substr(0,4) == 'menu') {
		if (document.getElementById(div).innerHTML != "") {
			document.getElementById(div).innerHTML = "";
			document.getElementById(div).style.display = 'none';
			return;						
		}
	}
	document.getElementById(div).style.display = '';
	document.getElementById(div).innerHTML = "Carregando...";	
	if (eval(obj)) {	
    	eval(obj + ".open('get', 'index.php?action=' + action)");
    	eval(obj + ".onreadystatechange = " + handler);
    	eval(obj + ".send(null)");
	}
	
}
function ajaxFormSubmit(formID,handler) {
	if (http9) {
		var oForm = document.getElementById(formID);

		if (document.all) {
			var page = 'index.php' + oForm.action;
		} else {
			var page = oForm.action;
		}
		var param = retornaParametros(oForm);
    	http9.open('post', page);
    	http9.setRequestHeader("Content-type","application/x-www-form-urlencoded;");
    	eval("http9.onreadystatechange = " + handler);
    	http9.send(param);
	}
}

function ajaxUploadFormSubmit(btn,handler) {
	// carregando
	btn.value = 'Processando...';
	btn.disabled = true;
	// chama a funcao que manipulará o resultado
	handlerFunction('iframe',handler,null);
	btn.form.submit();
}

function ajaxConfirm(msg, action, handler) {
	if (confirm(msg)) {
		ajaxOpen("http9",action, handler, null);
	}
}


