//VALERT
var $valert=false;
function valert(con,til,act,dgb,fnc,lbl_0,lbl_1,lbl_2){ //if two functions (yes/no), send separated by ^ delimeter
	var typ=false;
	shad=ge('page_shade');
	targ=ge('valert');
	act=act?act:'show';
	typ=act;
	if(typ=='yesno' || typ=='input' || typ=='punter'){
		act='show';
	}
	ge('vad_ok0').style.display='none';
	ge('vad_inp').style.display='none';
	ge('vad_yca').style.display='none';
	var bx0=ge('vad_box');bx0.style.display='none';
	var bx1=ge('vad_bx1');bx1.style.display='none';
	var bx2=ge('vad_bx2');bx2.style.display='none';
	var ib0=ge('vai_box');ib0.value='';
	var ib1=ge('vai_bx1');ib1.value='';
	var ib2=ge('vai_bx2');ib2.value='';
	ge('vad_lbl').innerHTML=lbl_0?lbl_0:'';
	ge('vad_lb1').innerHTML=lbl_1?lbl_1:'';
	ge('vad_lb2').innerHTML=lbl_2?lbl_2:'';
	ge('vad_tlr').innerHTML="<div id='vad_clo' onclick=\"valert(0,0,'close',true);\"></div>";	
	var iflag=false;
	switch(act){
		case 'show':
			targ.style.display='block';
			if(typ=='yesno'){				
				var yes=ge('vvv_yes')
				var cancel=ge('vvv_can')
				var fn=fnc.split('^');
				ge('vad_yca').style.display='block';
				if(fn.length==1){fn[1]='';}
				fn[0]+=(right(fn[0],1)!=';')?';':'';
				lbv=lbl_0?'<p>'+lbl_0+'</p>':'<p>YES</p>';
				yes.innerHTML="<div id='vad_yes' class='ibt_M' onclick=\""+fn[0]+"valert(0,0,'close',false);\">"+lbv+"</div>"
				ge('vad_tlr').innerHTML="<div id='vad_clo' onclick=\"valert(0,0,'close',true);"+fn[1]+"\"></div>";								
				lbv=lbl_1?'<p>'+lbl_1+'</p>':'<p>CANCEL</p>';
				cancel.innerHTML="<div id='vad_can' class='ibt_M' onclick=\"valert(0,0,'close',false);"+fn[1]+"\">"+lbv+"</div>"								
			}else if(typ=='input' || typ=='punter'){
				iflag=true;
				bx0.style.display='block';
				if(typ=='punter'){
					bx1.style.display='block';
					if(lbl_2){
						bx2.style.display='block';
					}
				}
				ge('vad_inp').style.display='block';
				ge('vvv_ien').innerHTML="<div id='vad_ien' class='ibt_M' onclick=\""+fnc+"\"><p>ENTER</p></div>";
			}else{
				ge('vad_ok0').style.display='block';
			}
			con+='';
			con=con.replace(/\n/g, '<br>')
			var doc=document.documentElement;
			try{sys_v!=false;}catch(err){sys_v=false;}
			ge('vad_til').innerHTML=til?til:((sys_v=='sav')?$prog:sys_v);
			ge('vad_con').innerHTML=con?con:'<br><br>';			
			var x=doc.clientWidth;
			var y=doc.clientHeight;
			var x_scro=doc.scrollLeft*1;
			var y_scro=doc.scrollTop*1;
			var wid=targ.offsetWidth;
			var hig=targ.offsetHeight;
			//var top=y_scro+(y/2)-(hig/2)-35; ?????
			var top=(y/2)-(hig/2)-35;
			if(top<0){top=y_scro;}
			targ.style.left=(x_scro+(x/2)-(wid/2))+'px';
			targ.style.top=top+'px' ;	
			$valert=true;			
			targ.style.visibility='visible';
			shad.style.display='block';
			if(iflag){ib0.focus();$computer=false;} //convoluted shit because of IE
			break;	
		case 'close':		
			targ.style.display='none';
			targ.style.visibility='hidden';
			shad.style.display='none';
			$drag_block=dgb;
			if($prev_status && status!='03'){frm_status($prev_status);}
			$valert=false;
			if($computer!='!'){if(!$computer && $db!=1){$computer=true;computer();}}
			break;		
	}
}

//FRM
function frm_status(status){
	var targ=gi('db');
	if(targ){
		if(status=='get'){
			return right(targ.className,2);
		}else{
			targ.className ='frm_status_'+status;
		}
	}else{
		return false;
	}
}
