function mx_Grid_v2(t){
	this.table=t;
	this.blur=mx_Grid_v2_blur;
	this.focus=mx_Grid_v2_focus;
	this.find_id=mx_Grid_v2_find_id;
	this.current_row=-1;
	this.current_control=null;
	this.get_row=mx_Grid_v2_get_row;
	this.get_form=mx_Grid_v2_get_form;
}
function mx_Grid_v2_blur(e){
	var r=this.get_row(e);
	//alert("b"+r+" "+this.current_row);
	//if(r!=this.current_row){
		if(this.current_control!=null){
			if(r!="new"){
				var id="h_"+this.table+"-"+r;
				document.getElementById(id).innerHTML="<img src='images/saving.gif' alt='Guardando' />";
				var ajax = new mx_AJAX("h_"+this.table+"-"+r);
				ajax.send_form(this.get_form(this.current_control));
			}
			
			//this.get_form(this.current_control).submit();
		}
	//}
}
function mx_Grid_v2_focus(e){
	var r=this.get_row(e);

	this.current_control=e;
	this.current_row = r;
	
}
function mx_Grid_v2_find_id(e){
	if(e.id!=""){
		return e.id;
	}else{
		return this.find_id(e.parentNode);
	}
}
function mx_Grid_v2_get_row(e){
	var id = this.find_id(e);
	var a = id.split("-");
	return(a[1]);
}
function mx_Grid_v2_get_form(e){

	/*if(e.tagName=="FORM"){
		return e;
	}else{
		return this.get_form(e.parentNode);
	}*/
	return e.form;
	
}
