
	//Deinindo o namespace
	if(typeof(util)=='undefined'){
		var util = {form:{}}
	}else{
		util.form = {}
	}

	util.form.resetForm = function(idForm, fncOpcional){
		$camposForm = getCamposForm(idForm);
		//Limpando todos os campos
		$camposForm.each(function(){
			valorIni = (jQuery(this).attr('inival')) ? jQuery(this).attr('inival') : '';
			jQuery(this).val( valorIni );
		});
		if(typeof(fncOpcional)=='function')fncOpcional.call(); //Executando a função passada como parâmetro
	}

	util.form.json2form = function(idForm, jsonInfos){/**
		* Descrição
		* @param {String} idForm ID do formulário
		* @param {JSON} jsonInfos Estrutura JSON com as informações do form	
		*/
		$camposForm = jQuery('#'+idForm).find('input[type=hidden],input[type=text],select,textarea');

		//Limpando os campos antes do preenchimento com os dados recebidos
		$camposForm.each(function(){
			vlrIniCampo = jQuery(this).attr('inival');				  
			vlrIniCampo = ( vlrIniCampo && vlrIniCampo!='') ? vlrIniCampo : '';
			//console.info('valor inicial do campo "'+jQuery(this).attr('id')+'": '+vlrIniCampo);
			jQuery(this).val(vlrIniCampo);
		});

		//Preenchendo os campos com os valores do json
		$camposForm.each(function(){
			id = jQuery(this).attr('id');
			valor = eval('jsonInfos.'+id);
			if(valor)jQuery(this).val(valor);
		});
	}

	util.form.form2json = function(idForm){
		var strJson = '{';
		$camposForm = getCamposForm(idForm); //jQuery('#'+idForm).find('input[type=hidden],input[type=text],select,textarea');

		$camposForm.each(function(){
			strJson += "'"+ jQuery(this).attr('id') + "':'"+ jQuery(this).val() +"', ";
		});

		//jQuery('input[type=radio]', '#'+idForm).radioSel();

		strJson = strJson.substr(0, strJson.length-2);
		strJson += '}';
		return eval('('+ strJson +')');
	}

	util.form.getCamposForm = function(idForm){
		//Recuperando os campos do formulário;
		return jQuery('input[type=hidden],input[type=text],select,textarea', '#'+idForm);
	}

	util.form.postPage = function(options){
		/* ********************************************************
		// Exemplo do formato recebido como parâmetro nesta função
			postPage({
				destino	  : '../diretorio/arquivo.asp',
				target	  : '_nomeDoFrame',
				variaveis : {
					'nome'  : 'Bruno Souza',
					'login' : 'brunosouza' ,
					'senha' : '1234567890' ,
					'method': 'get' 
				}
			})
		// ***************************************************** */
		var settings = {
			destino		: '',
			variaveis	: '',
			target		: null,
			method		: 'post'
		}
		if(options){
			jQuery.extend(settings, options);
		}else{
			return false;
		}

		var target = (settings.target) ? ' target="'+ settings.target +'"' : '';

		jQuery("body").append('<form id="formDinamicPost" name="formDinamicPost" method="'+ settings.method +'" action="'+ settings.destino +'"'+ target +'></form>');
		jQuery.each(settings.variaveis, function(nome, valor){
			valor = (valor=='') ? valor : (valor).split("'").join("\\'");
			jQuery('#formDinamicPost').append('<input type="hidden" name="'+ nome +'" id="'+ nome +'" value=\''+ valor +'\' />');
		});
		jQuery('#formDinamicPost').submit();
	}