function fp_colecciondedatos_celltblpos(){
	this.bgcolorsel="#FF0000";
	this.bgcolornorm="";
	this.numelemmultiple=0;
	this.elemm=new Array();
	this.moviendoelem=false;
	this.get_objs =function (){
		this.obj_tbl=fp_get_element_by_id_siexiste(this.id_tbl);
		this.obj_span_x=fp_get_element_by_id_siexiste(this.id_span_x);
		this.obj_span_y=fp_get_element_by_id_siexiste(this.id_span_y);
		this.obj_input_x=fp_get_element_by_id_siexiste(this.id_input_x);
		this.obj_input_y=fp_get_element_by_id_siexiste(this.id_input_y);
		this.obj_despldiv=fp_get_element_by_id_siexiste(this.id_despldiv);
		
	}
	this.cleantbl =function (){
		if (this.obj_tbl){
			for (r=0;r<this.obj_tbl.rows.length;r++){
				for (c=0;c<this.obj_tbl.rows[r].cells.length;c++){
					this.obj_tbl.rows[r].cells[c].style.backgroundColor =this.bgcolornorm;
				}
			}
		}
	}
	this.set_val =function (X,Y){
		this.cleantbl();
		if (this.obj_span_x){
			this.obj_span_x.innerHTML=X+1;
		}
		if (this.obj_input_x){
			this.obj_input_x.value=X;
		}
		if (this.obj_span_y){
			this.obj_span_y.innerHTML=Y+1;
		}
		if (this.obj_input_y){
			this.obj_input_y.value=Y;
		}
		if (this.obj_tbl){
			this.obj_tbl.rows[Y].cells[X].style.backgroundColor =this.bgcolorsel;
		}
		
	}
	this.regelem_multiple =function (iddiv,idinputX,idinputY){
		//alert(iddiv+" "+this.numelemmultiple);
		this.elemm[this.numelemmultiple]=new fp_colecciondedatos_celltblpos_elemm(iddiv,idinputX,idinputY);
		this.numelemmultiple+=1;
	}
	this.set_distribmultiple =function (){
		if (!this.modomultiple){
			return false;	
		}
		if (!this.obj_tbl){
			return false;	
		}
		//alert("D"+this.numelemmultiple);
		for (e=0;e<this.numelemmultiple;e++){
			//alert(e);
			this.elemm[e].colocar(this.obj_tbl.rows[this.elemm[e].posY].cells[this.elemm[e].posX]);
		}
	}
	this.desplazarelemm =function (eindex){
		this.moviendoelem=eindex;
		this.elemm[eindex].colocar(this.obj_despldiv);	
	}
	this.seguirmouse_elemmove =function (evt){
		if (this.moviendoelem!==false){
			fp_seguirmouse_obj(this.obj_despldiv,evt);
		}
	}
	this.soltarelemm =function (){
		if (this.moviendoelem!==false){
			e=this.moviendoelem;
			this.elemm[e].colocar(this.obj_tbl.rows[this.elemm[e].posY].cells[this.elemm[e].posX]);	
		}
		this.moviendoelem=false;
	}
	this.asignarelemm =function (X,Y){
		if (this.moviendoelem!==false){
			e=this.moviendoelem;
			this.elemm[e].set_val(X,Y);
			this.elemm[e].colocar(this.obj_tbl.rows[this.elemm[e].posY].cells[this.elemm[e].posX]);	
		}
		this.moviendoelem=false;
	}

	
	

}
function fp_colecciondedatos_celltblpos_elemm(iddiv,idinputX,idinputY){
	this.divobj=fp_get_element_by_id_siexiste(iddiv);	
	this.inputX=fp_get_element_by_id_siexiste(idinputX);	
	this.inputY=fp_get_element_by_id_siexiste(idinputY);
	this.posX=0;
	this.posY=0;
	if(this.inputX){
		this.posX=this.inputX.value;
	}
	if(this.inputY){
		this.posY=this.inputY.value;
	}
	this.colocar=function(nparent){
		//alert(this.divobj.innerHTML);
		clone=this.divobj.cloneNode(true);
		//alert(clone.innerHTML);
		//alert(this.divobj.parentNode.innerHTML);
		//parent=this.divobj.parentNode;
		this.divobj.parentNode.removeChild(this.divobj);
		//this.divobj=clone;
		nparent.firstChild.appendChild(this.divobj);
		
	}
	this.set_val=function (X,Y){
		this.inputX.value=X;
		this.inputY.value=Y;
		this.posX=this.inputX.value;
		this.posY=this.inputY.value;
	}
	
}
