
var queueFila=new Array();var queueExec=true;function queueRequest(){var request;try{request=new ActiveXObject("Microsoft.XMLHTTP");}catch(e){try{request=new ActiveXObject("Msxml2.XMLHTTP");}catch(ex){try{request=new XMLHttpRequest();}catch(exc){alert("Esse browser não tem recursos para uso do Ajax");request=null;}}}
return request;}
var queueAjax=function(json){queueFila.push(json);executeQueue(queueExec);}
var queueAjaxInterpreter=function(current){Ajax=queueRequest();Ajax.onreadystatechange=function(){if(Ajax.readyState==4){if(Ajax.status==200){try{current.sucess(Ajax);}catch(err){}
if(queueFila.length>0){executeQueue(true);}else{queueExec=true;}}else if(Ajax.status==404){try{current.error(Ajax);}catch(e){}
queueExec=true;}}}
if(current.method=="GET"){Ajax.open("GET",current.url,true);Ajax.send(null);}else if(current.method=="POST"){Ajax.open("POST",current.url,true);Ajax.setRequestHeader("Content-type","application/x-www-form-urlencoded");Ajax.setRequestHeader("Content-length",current.parameter.length);Ajax.setRequestHeader("Connection","close");Ajax.send(current.parameter);}}
var executeQueue=function(_queueExec){if(_queueExec){queueExec=false;var current=queueFila.shift();queueAjaxInterpreter(current);}}
var jfAjaxHTML=function(_element,_url,_options){queueAjax({element:_element,url:_url,method:"GET",sucess:function(_Ajax){try{document.getElementById(_element).innerHTML=_Ajax.responseText;if((typeof _options)=='object'){if((typeof _options.focus)=='string'){document.getElementById(_options.focus).focus();}else if((typeof _options.focus)=='element'){_options.focus.focus();}
if((typeof _options.script)=='string'){eval(_options.script);}}}catch(err){alert(err);}},error:function(_Ajax){document.getElementById(_element).innerHTML="Erro...";}});}
var ajaxHTML=jfAjaxHTML;var jfAjaxEval=function(_url){queueAjax({url:_url,method:"GET",sucess:function(_Ajax){try{eval(_Ajax.responseText);}catch(err){alert(err);}}});}
function doRMI(_url,_methods,_timeout){try{queueAjax({url:_url,method:"GET",sucess:function(_Ajax){try{var i=parseInt(_Ajax.responseText);if(i>=0&&i<_methods.length){_methods[i]();}}catch(e){}}});setTimeout(doRMI,_timeout,_url,_methods,_timeout);}catch(e){}}
