
//####################################################################################################
/*ajax.js*/
var xmlhttp = new Array();

function ajaxload(url,params,e,onComplete){
 
 e = typeof(e)=='string'? document.getElementById(e) : e;
 
 var id = id ? id : randstr() ;
 xmlhttp[id]='';
 
 if(window.XMLHttpRequest){ xmlhttp[id] = new XMLHttpRequest(); }
 else if(window.ActiveXObject){ xmlhttp[id] = new ActiveXObject("Microsoft.XMLHTTP"); }

 xmlhttp[id].onreadystatechange = function(){
  if (xmlhttp[id].readyState==4 && (xmlhttp[id].status==200 || window.location.href.indexOf("http")==-1)){
   if(e!==false){ e.innerHTML = xmlhttp[id].responseText;}
   if(typeof(onComplete)=='string'||isFunction(onComplete)) setTimeout(onComplete,10);
   }
  }
 var method = (!params ? 'GET' : 'POST' );
 params = (!params ? '' : params );
 url = (url.indexOf('?')<0 ? url+'?ajax_unique_id='+randstr(16) : url+'&ajax_unique_id='+randstr(16) );
 xmlhttp[id].open(method, url, true);
 xmlhttp[id].setRequestHeader('Content-Type','application/x-www-form-urlencoded');
 xmlhttp[id].send(params);
 }

function ajaxeval(url,params){
 id = randstr() ;
 xmlhttp[id]='';
 
 if(window.XMLHttpRequest){ xmlhttp[id] = new XMLHttpRequest(); }
 else if(window.ActiveXObject){ xmlhttp[id] = new ActiveXObject("Microsoft.XMLHTTP");}

 xmlhttp[id].onreadystatechange = function(){
  if (xmlhttp[id].readyState==4 && (xmlhttp[id].status==200 || window.location.href.indexOf("http")==-1)){
   var json = eval(xmlhttp[id].responseText);
   }
  }
 xmlhttp[id].open('POST', url, true);
 xmlhttp[id].setRequestHeader('Content-Type','application/x-www-form-urlencoded');
 xmlhttp[id].send(params);
 }

function ajax_formpost(form){
 if(!document.getElementById('ajax_formpost_container')){
  var i = document.createElement('div'); i.id = 'ajax_formpost_container'; i.style.display = 'none'; document.body.appendChild(i);
  }
 else{ var i = document.getElementById('ajax_formpost_container'); }
 
 if(document.getElementById('ajax_formpost_iframe')){ removeElem('ajax_formpost_iframe'); }
 
 i.innerHTML = '<iframe name="ajax_formpost_iframe" src="init.html" id="ajax_formpost_iframe" style="display:none;" onload="setTimeout(function(){ ajax_formpost_iframe_onload(); },1);"></iframe>';
 form.target = 'ajax_formpost_iframe';
 form.submit();
 }
function ajax_formpost_iframe_delete(){ removeElem('ajax_formpost_iframe'); removeElem('ajax_formpost_container'); }
function ajax_formpost_iframe_onload(){ var i = window.frames.ajax_formpost_iframe || document.getElementById('ajax_formpost_iframe').contentWindow ; if( i.init() ){ ajax_formpost_iframe_delete(); } };

