var Action =
{
    action : null, // action del form
    container: null, // 
    id_dom:null,// dom del form
    temp:null,
    data_send:'', //datos a ser enviados
    actions:new Array(), // action collections
    get:function(json){ // search by  attribute , valor
			for(var i in Action.actions )
			{
				if(json.val == Action.actions[i][json.attr])
				{
					return Action.actions[i];
					break;
				}
			}
			
	},
    create: function ()
    {
     		var self = $.extend( new Object(), this);
     		Action.actions.push(self);
     		return self;
    },
    init: function(param){
    	
       this.data_send = '';
        if(param){
            this.action     = param.action;
            this.container  = param.container;
            this.id_dom     = param.id_dom;
         };
    $('#'+this.id_dom).bind( "submit" , {me:this}, ( function(e){
        	
                        e.data.me.submit(); // this "instance of Action"
                        return false;
                        }));
    },
    // crea una instancia de si mismo
    each:function (){
    	Action.element_active.data_send += this.name+'='+escape(this.value)+'&';
 	},
    submit : function(){
        this.temp = $("#"+this.id_dom).find(':input');
        Action.element_active = this;
        this.temp.each( 
        		this.each
        );
        Action.element_active = "";
        this.send();
    },
    
    send : function(){
            $.post(this.action,this.data_send, this.succes ,'html');
            $('#'+this.container).bind( "ajaxComplete" , {me:this}, ( 
            		function(event,request, settings)
            		{  	$(this).html(request.responseText);
                        var a = Action.get({'val':this.id,'attr':'container'});
                        a.init();
                        $('#'+this.id).unbind("ajaxComplete");}
            		))
        }
}