var $ajo,$aji='',$ajj='',$ajx=false,$ajxx=false;
function qjax(ix,pdat,msg,gdat){
	if(!ix){
		var f=arguments.callee.caller.toString();
		ix=rip(f,'function ','(');
	}
	$aji=ix;
	if(!gdat){gdat='';}
	if(!pdat){pdat='';}
	if(msg){
		$ajx="alert(rsp)";
	}else{
		$ajx=ix+"('rsp',rsp)";
	}
	ajax_post('a_data.php',pdat,gdat);		
}
function ajax_reaction(rsp){
	ajax_processing(0);
	if($ajxx){$ajx=$ajxx;$ajxx=false;};
	if($ajx){
		if(rsp.substring(0,1)=='!'){
			hourglass(false);
			valert(rsp.substring(1,rsp.length));
		}else if(rsp=='%'){		
			if($prev_status && status!='03'){frm_status($prev_status);}
		}else{
			if($ajx!='%'){eval($ajx);}
		}		
	}else{
		valert('dude');
	}
	$aji='';$ajj='';
}
function ajax_state(){ 
  if ($ajo.readyState==4 || $ajo.readyState=='complete'){ 
		ajax_reaction($ajo.responseText);
	}
} 
function set_ajax_object(){ 
  var obj=null;
  if (window.XMLHttpRequest){
    obj=new XMLHttpRequest();
  }else if (window.ActiveXObject){
    obj=new ActiveXObject('Microsoft.XMLHTTP');
  }
  if (obj==null){
    valert ('Browser does not support HTTP Request');
    return;
  }else{
    return obj;
  } 
}
function ajax_fetch(url,dat){ 
	ajax_processing(1);
  $ajo=set_ajax_object();
  $ajo.onreadystatechange=ajax_state;
  $ajo.open('GET',url+'?i='+$aji+'&j='+$ajj+'&'+dat,true);
  $ajo.send(null);
}
function ajax_post(url,pdat,gdat){
	if(!gdat){gdat='';}
	ajax_processing(1);
  $ajo=set_ajax_object();
  $ajo.onreadystatechange=ajax_state;
  $ajo.open('POST',url+'?i='+$aji+'&j='+$ajj+gdat, true);
  $ajo.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
  $ajo.setRequestHeader('Content-length', pdat.length);
  $ajo.setRequestHeader('Connection', 'close');
  $ajo.send(pdat);
}
function ajax_processing(show){
	if(show){
		is_ie6=(document.all && window.external && (typeof document.documentElement.style.maxHeight === 'undefined')) ? true : false;	
		var shade=ge('page_shade');
		var wait=ge('page_wait');
		scro_top = window.pageYOffset || document.documentElement.scrollTop;
		scro_lft = window.pageXOffset || document.documentElement.scrollLeft;
		var top=(self.innerHeight || (document.documentElement.clientHeight || document.body.clientHeight)) / 2 + scro_top - 16 + 'px';
		var lft=(self.innerWidth || (document.documentElement.clientWidth || document.body.clientWidth)) / 2 + scro_lft - 16 + 'px';
		if(!shade){
			var shade=document.createElement('div');
			shade.id='page_shade';				
			shade.onclick=ajax_processing;		
			shade.style.height=((document.documentElement.clientHeight > document.documentElement.scrollHeight) ? document.documentElement.clientHeight : document.documentElement.scrollHeight) + 'px';
			shade.style.width=document.documentElement.scrollWidth + 'px';
			if(!this.isIE6){
				//shade.style.background = 'url(valert/tp2.png)';
			}
			shade.style.position='absolute';
			shade.style.left='0px';
			shade.style.top='0px';
			shade.style.zIndex=998;		
			var wait=document.createElement('div');
			wait.id='page_wait';				
			wait.style.position='absolute';
			wait.style.height='32px';
			wait.style.width='32px';
			wait.style.backgroundImage='url(images/ajax_loader.gif)';
			wait.style.top=top;
			wait.style.left=lft;
			wait.style.zIndex=999;
			shade.appendChild(wait);
			document.body.appendChild(shade);
		}else{
			wait.style.top=top;
			wait.style.left=lft;
			shade.style.display='block';
		}
	}else{
		var shade=ge('page_shade');
		shade.style.display='none';
		//shade.innerHTML='';
		//document.body.removeChild(shade);
	}
}

