var date = new Date();

function processaGet(id, url) {
	url += (strstr(url,"?") ? "&noCache=" : "?noCache=") + date.getTime();
	$.get(url,function(data){ if(id!=""){ $('#'+id).html(data); } });
}

function processaPost(id, url, formulario, emlinha, idName){
	var form = getForm(formulario, emlinha, idName);
	url += (strstr(url,"?") ? "&noCache=" : "?noCache=") + date.getTime();
	$.post(url, form, function(data){ if (id!=""){ $('#'+id).html(data); } });
}

function getForm(form, emlinha, idName){
	var $campos = $('#'+form+' :input');
	var values = emlinha ? "" : {};
	$campos.each(function(){
		if ( ((this.type=="checkbox" || this.type=="radio") && this.checked==true) 
			 || ( this.type=="text" || this.type=="hidden" || this.type=="password"    
				 || this.type=="textarea" || this.type.substr(0,6)=="select" )
		){
									
			if (emlinha)
				values += ( idName=="id" ? this.id : this.name ) +"="+$(this).val()+"&";
			else
				values[( idName=="id" ? this.id : this.name )] = $(this).val();
			
		} // if
	});
	if (emlinha) values = values.substr(0,values.length-1);
	return values;
}

function resetForm(form){
	var $campos = $('#'+form+' :input');
	$campos.each(function(){
		if ( this.type!="button" && this.type!="reset" && this.type!="submit" ){
			if ( (this.type=="checkbox" || this.type=="radio") ) 
				this.checked=false;
			else 
				$(this).val("");
		}
	});
}

