
/*
 */

Module("com.besbello.lib.forms", function (m) {
	Class("autodata", {
		// does: [Joose.Singleton],
		has: {
			version: {
				is:   "r",
				init: "1.0"
			}
			
		},
		classMethods: {
			load: function (  element  ) {
				var elem = $(element );
				if  ( elem.length == 0 ) {
					return ;
				}
				var data = 	com.besbello.lib.metadata.get( elem  ) ;
				for (var i in data ) {
					$( '#' + i, elem).val( data[i]);
					//data[i]
				
				
				
					//alert( data.toString() ) ;
				}
				
			
			} 
			
	    }
	});
	Class("pair", {
		// does: [Joose.Singleton],
		has: {
			version: {
				is:   "r",
				init: "1.0"
			}
			
		},
		classMethods: {
			values: function (  element  ) {
 				var resultado = '';
			 // 	alert( element);
				
				$( 'input, select', element ).each( function() {
					if ( $(this).val() > "") {
				 	if ( $(this).attr('type') != 'submit') {
							
 						//	resultado = resultado + '/' + $(this).attr('id') + ":" + m.pair.urlencode( $(this).val() );
							resultado = resultado + '/' + $(this).attr('id') + ":" +  $(this).val() ;
				 	}  
				
					}
					
				} );
				return resultado; 	
				
			
			},
			urlencode: function(str) {
			return escape(str).replace(/\+/g,'%2B').replace(/%20/g, '+').replace(/\*/g, '%2A').replace(/\//g, '%2F').replace(/@/g, '%40');
			} 
			
	    }
	});

} );