var ajaxform = {
    
    view : function(uri, data, id, myCallback) {
         $.ajax({
         		 type: "POST",
                  url: uri,
                 data: data,
              success: function(html){
              		if(id != ""){
              			$(id).html(html);
              		}
        			if(myCallback instanceof Function){
        				myCallback(html);
        			}
        		} 
         });
    },  
    parceForm: function(idForm) {
        var data = '';
        $(idForm+' input').each(function(i) {
        		if(($(this).attr("type") == "checkbox" || $(this).attr("type") == "radio")){
        			if($(this).attr("checked")){
                		data += this.name + '=' + this.value + '&';
        			}
        		}
        		else {
                	data += this.name + '=' + this.value + '&';
                }       
        });
        $(idForm+' select').each(function(i) {
                data += this.name + '=' + this.value + '&';       
        });
        $(idForm+' textarea').each(function(i) {
                data += this.name + '=' + this.value + '&';       
        });
    	data = data.substr(0, data.length-1);
        return data;
    },
    
    sendForm : function(uri, idForm, idResult, myCallback) {
    	data = this.parceForm(idForm);
    	this.view(uri, data, idResult, myCallback);
    }
}