/*
	Criado por Felipe Olivaes
	felipe.olivaes/at/terra.com.br
*/
function get(elemento){
	return document.getElementById(elemento);
}

function get_name(elemento){
	return document.getElementsByName(elemento);
}

/*
 *	Array
 */
function in_array(valor,tal_da_array){
	var retorno = false;
	if(typeof(tal_da_array) == 'object'){
		for(ia in tal_da_array){
			if(tal_da_array[ia] == valor){
				retorno = true;
			}
		}
	} else {
		for(var ia=0;ia<tal_da_array.length;ia++){
			if(tal_da_array[ia] == valor){
				retorno = true;
			}
		}
	}
	return retorno;
}

function in_array_key(valor, tal_da_array){
	var retorno = false;
	if(typeof(tal_da_array) == 'object'){
		for(chave in tal_da_array){
			if(chave == valor){
				retorno = true;
			}
		}
	} else {
		for(var ia=0;ia<tal_da_array.length;ia++){
			if(ia == valor){
				retorno = true;
			}
		}
	}
	return retorno;
}

/*
 *	Tratamento de Input
 */
function somente_numero(numero){
	var validos = "0123456789";
	var numero_ok = '';
	for(i=0;i<numero.length;i++){
		if(validos.indexOf(numero.substr(i,1)) != -1){
			numero_ok += numero.substr(i,1);
		}
	}
	return numero_ok;
}

/* Deixando apenas letras em uma variavel */
function somente_letras(letra){
	var validos  = "_abcdefghijklmnopkrstuvxzywçáéíóú ";
	var letra_ok = '';
	
	for(i=0;i<letra.length;i++){
		if(validos.indexOf(letra.substr(i,1)) != -1){
			letra_ok += letra.substr(i,1);
		}
	}
	return letra_ok;
}

/*
 *	Texto
 */
function LTrim(str){
	var whitespace = new String(" \t\n\r");
	var s = new String(str);

	if (whitespace.indexOf(s.charAt(0)) != -1) {
      var j=0, i = s.length;
      while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
         j++;
      s = s.substring(j, i);
   }
   return s;
}

function RTrim(str){
   var whitespace = new String(" \t\n\r");

   var s = new String(str);

   if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
      var i = s.length - 1;
      while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
         i--;
      s = s.substring(0, i+1);
   }
   return s;
}

function trim(str){
   return RTrim(LTrim(str));
}


/*
 * Funcoes auxiliares validacao CNPJ
 */
function cnpj_aux1(c){ 
	if((cx=c.indexOf(","))!=-1){ 
		c = c.substring(0,cx)+"."+c.substring(cx+1); 
	}
	if((parseFloat(c) / c != 1)){ 
		if(parseFloat(c) * c == 0){ 
			return(1); 
   		} else { 
			return(0); 
		} 
 	} else { 
		return(1); 
  	}
} 

function cnpj_aux2(c){ 
	while((cx=c.indexOf("-"))!=-1){ 
		c = c.substring(0,cx)+c.substring(cx+1); 
  	} 
	while((cx=c.indexOf("/"))!=-1){ 
		c = c.substring(0,cx)+c.substring(cx+1); 
	}
	while((cx=c.indexOf(","))!=-1){ 
		c = c.substring(0,cx)+c.substring(cx+1); 
	} 
	while((cx=c.indexOf("."))!=-1){ 
		c = c.substring(0,cx)+c.substring(cx+1); 
	} 
	while((cx=c.indexOf("("))!=-1){ 
		c = c.substring(0,cx)+c.substring(cx+1); 
	} 
	while((cx=c.indexOf(")"))!=-1){ 
		c = c.substring(0,cx)+c.substring(cx+1); 
	} 
	while((cx=c.indexOf(" "))!=-1){ 
		c = c.substring(0,cx)+c.substring(cx+1); 
	} 
	return(c); 
} 

function cnpj_aux3(CNPJ,g){ 
	var VerCNPJ=0; 
	var ind=2; 
	var tam; 
	for(f=g;f>0;f--){ 
		VerCNPJ+=parseInt(CNPJ.charAt(f-1))*ind; 
		if(ind>8){ 
			ind=2; 
		} else { 
			ind++; 
		} 
	} 

	VerCNPJ%=11; 
	if(VerCNPJ==0 || VerCNPJ==1){ 
		VerCNPJ=0; 
	} else { 
		VerCNPJ=11-VerCNPJ; 
	} 
	if(VerCNPJ!=parseInt(CNPJ.charAt(g))){ 
		return(0); 
	} else { 
		return(1); 
	}
} 

/*
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *			C L A S S E    D E    V A L I D A   O
 *
 *
 *
 *
 *
 *
 *
 *
 *
 * */
 
var objBtnSubmit = '';
var classValidacao = function(){
	
	//Nome do formulrio
	this.nome_form	= "";
	
	//Erros encontrados
	this.erro		= [];
	
	//Tipos de dados
	this.datatype	= new Array();
	
	//Elementos utilizados no form
	this.obj_form		 = new Object();
	
	//Se  para enviar os dados por XML_REQUEST
	this.postAjax		 = false;
	
	this.adicionarForm	 = function(idForm, postPorAjax){
		this.iniciar();
		this.obj_form = get(idForm);
		this.obj_form.onsubmit = function(){
			ttrValidacao.verifica_dados(idForm);
			return false;
		};

		if(typeof(postPorAjax) == 'undefined') postPorAjax = false;
		this.postAjax	= postPorAjax;
		this.procura_mascara();
	}
	
	this.iniciar 		= function(){
		this.adiciona_datatype (
			'vr_obrigatorio', 
			'Campo deve ser preenchido / marcado',
			null,
			"Campo deve ser preenchido / marcado",
			'this.valida_obrigatorio'
		);
		this.adiciona_datatype (
			'vr_url', 
			'URL -- endereo de página de internet',
			null,
			"URL invlida",
			'this.valida_url'
		);
		this.adiciona_datatype (
			'vr_dominio', 
			'domínio - Verifica se um domínio ',
			null,
			"domínio inválido",
			'this.valida_dominio'
		);
		this.adiciona_datatype (
			'vr_dominio_sem_www', 
			'domínio - Verifica se um domínio sem www',
			null,
			"domínio inválido, deve ser retirado o www.",
			'this.valida_dominio_sem_www'
		);
		this.adiciona_datatype (
			'vr_email', 
			'Verifica se um e-mail válido',
			null,
			"E-mail inválido",
			'this.valida_email'
		);
		this.adiciona_datatype (
			'vr_nova_senha', 
			'Verifica se as novas senhas conferem',
			null,
			"As senhas digitadas não conferem",
			'this.valida_senha'
		);
		this.adiciona_datatype (
			'vr_minimo', 
			'Verifica se o campo tem um número mínimo de caracteres',
			null,
			"O campo deve conter no mínimo",
			'this.valida_minimo'
		);
		this.adiciona_datatype (
			'vr_maximo', 
			'Verifica se o campo tem um número máximo de caracteres',
			null,
			"O campo deve conter no máximo",
			'this.valida_maximo'
		);
		this.adiciona_datatype (
			'vr_cpf', 
			'Verifica se um CPF  válido',
			null,
			"CPF inválido",
			'this.valida_cpf'
		);
		this.adiciona_datatype (
			'vr_cnpj', 
			'Verifica se um CNPJ  válido',
			null,
			"CNPJ inválido",
			'this.valida_cnpj'
		);
	}
	
	this.adiciona_datatype = function(nome, descricao, regex, error, func) {
		this.datatype[nome] = {
			'nome'		: nome,
			'descricao'	: descricao,
			'regex'		: regex,
			'msg_erro'	: error,
			'func'		: func
		};
	};
	
	this.agrega_funcao	= function(elemento){
		
	}
	
	/*
	 *	Verifica dados antes do post (adicionado ao onSubmit do Form)
	 */
	this.verifica_dados = function(idForm){
		this.obj_form = get(idForm);
		this.erro = [];

		for(vd=0;vd<this.obj_form.elements.length;vd++){
			resultado_validacao = true;
			classes = this.obj_form.elements[vd].className.split(' ');
			for(cl=0;cl<classes.length;cl++){
				resultado_validacao &= this.valida_campo(this.obj_form.elements[vd], classes[cl]);
			}
			
			if(!resultado_validacao){
				this.obj_form.elements[vd].style.backgroundColor = '#FFF2F0';
			} else {
				this.obj_form.elements[vd].style.backgroundColor = '';
			}
		}
		
		if(this.erro.length){
			alert("Favor verificar seguintes erros: \n\t- "+this.erro.join("\n\t- "));
			objBtnSubmit.disabled = false;
		} else {
			if(this.postAjax){
				this.enviarFormAjax();
			} else {
				this.obj_form.submit();
			}
		}
	}
	
	this.enviarFormAjax = function(){
		queryStringAjax = '';
		for(vd=0;vd<this.obj_form.elements.length;vd++){
			queryStringAjax += this.retornaValor(this.obj_form.elements[vd]);
		}
		if(this.obj_form.method.toLowerCase() == 'post'){
			get_url(this.obj_form.action, 'ttr_retorno_ajax' ,queryStringAjax);
		} else {
			get_url(this.obj_form.action+"?"+queryStringAjax, 'ttr_retorno_ajax');
		}
	}
	
	this.retornaValor	= function(obj){
		retValor = '';
		switch(obj.type){
			case 'checkbox':
				if(obj.checked){
					retValor = obj.value;
				}
			break;
			
			case 'radio':
				re = get_name(obj.name);
				for(x=0;x<re.length;x++){
					if(re[x].checked){
						retValor = re[x].value;
					}
				}
			break;
			
			case 'text':
				retValor = trim(obj.value);
			break;
			
			case 'textarea':
				retValor = trim(obj.value);
			break;
			
			case 'password':
				retValor = trim(obj.value);
			break;
			
			case 'select-one':
				if(obj.selectedIndex > -1){
					retValor = obj.options[obj.selectedIndex].value;
				}
			break;

			case 'select-multiple':
				return (obj.selectedIndex == -1);
			break;
			
			case 'hidden':
				retValor = obj.value;
			break;
			
			case 'submit':
				obj.disabled = true;
				objBtnSubmit = obj;
			break;
		}
		
		return obj.name+"="+escape(retValor)+"&";
	}
	
	this.valida_campo	= function(obj, verificacao){
		if(verificacao == '') return true;
		complemento = '';
		if(verificacao.match('=')){
			tmp = verificacao.split("=");
			verificacao = tmp[0];
			complemento = tmp[1];
		}
		erro_campo = false;
		//Vamos verificar se a classe  de validacao
		if(in_array_key(verificacao, this.datatype)){
			eval('r = '+this.datatype[verificacao].func+'(obj, complemento)');
			if(!r){
				msgErro = "Campo "+ obj.title + ": "+ this.datatype[verificacao].msg_erro;
					if(verificacao=='vr_minimo' || verificacao=='vr_maximo'){
						msgErro += " "+complemento+" caracteres";
					}
					
				this.adiciona_erro(msgErro);
				return false;
			}
		} 
		return true;
	}
	

	/*
	 *
	 *	MASCARA
	 *	Meritos para: Otavio Nogueira <ajaxbox.com.br>
	 *
	 */
	this.procura_mascara = function(){
		for(vd=0;vd<this.obj_form.elements.length;vd++){
			classes = this.obj_form.elements[vd].className.split(' ');
			for(cl=0;cl<classes.length;cl++){
				if(classes[cl].match('mascara=')){
					tmp = classes[cl].split("=");
					if(tmp[1] != ''){
						this.obj_form.elements[vd].onkeydown 	= new Function('ttrValidacao.coloca_mascara(this,"'+tmp[1]+'");');
						this.obj_form.elements[vd].onkeypress 	= new Function('ttrValidacao.coloca_mascara(this,"'+tmp[1]+'");');
						this.obj_form.elements[vd].onkeyup 		= new Function('ttrValidacao.coloca_mascara(this,"'+tmp[1]+'");');
						this.obj_form.elements[vd].onblur 		= new Function('ttrValidacao.coloca_mascara(this,"'+tmp[1]+'");');
						this.obj_form.elements[vd].onchange 	= new Function('ttrValidacao.coloca_mascara(this,"'+tmp[1]+'");');
					}
				}
			}
		}
	}
	
	/*
	 *	No onkeyup/onkeypress/onkeydown formata mascara ao campo
	 */
	this.coloca_mascara = function(objCampo, mascara){
		switch(mascara){
			//000.000.000-00
			case 'cpf':
				objCampo.value = somente_numero(objCampo.value);
				pri = objCampo.value.substring(0,3);
				seg = objCampo.value.substring(3,6);
				ter = objCampo.value.substring(6,9);
				qua = objCampo.value.substring(9,11);
							
				objCampo.value = pri+
				((seg!='') ? '.'+seg : '')+
				((ter!='') ? '.'+ter : '')+
				((qua!='') ? '-'+qua : '');
			break;

			//00.000.000/0000-00
			case 'cnpj':
				objCampo.value = somente_numero(objCampo.value);
				pri = objCampo.value.substring(0,2);
				seg = objCampo.value.substring(2,5);
				ter = objCampo.value.substring(5,8);
				qua = objCampo.value.substring(9,12);
				qui = objCampo.value.substring(12,14);
							
				objCampo.value = pri+
				((seg!='') ? '.'+seg : '')+
				((ter!='') ? '.'+ter : '')+
				((qua!='') ? '/'+qua : '')+
				((qui!='') ? '-'+qui : '');
			break;
			
			//(00) 0000-0000
			case 'telefone':
				objCampo.value = somente_numero(objCampo.value);
				
				pri = objCampo.value.substring(0,2);
				seg = objCampo.value.substring(2,6);
				ter = objCampo.value.substring(6,10);
							
				objCampo.value = ((pri!='') ? '('+pri+') ' : '')+
				((seg!='') ? seg : '')+
				((ter!='') ? '-'+ter : '');
			break;
	
			//00000-000
			case 'cep':
				objCampo.value = somente_numero(objCampo.value);
				
				pri = objCampo.value.substring(0,5);
				seg = objCampo.value.substring(5,8);
							
				objCampo.value = pri+
				((seg!='') ? '-'+seg : '');
			break;
	
			//00/00/0000
			case 'data':
				objCampo.value = somente_numero(objCampo.value);
				
				pri = objCampo.value.substring(0,2);
				seg = objCampo.value.substring(2,4);
				ter = objCampo.value.substring(4,8);
				
				objCampo.value = pri+
				((seg!='') ? '/'+seg : '')+
				((ter!='') ? '/'+ter : '')
			break;
			
			//00/0000
			case 'venc_cartao':
				objCampo.value = somente_numero(objCampo.value);
				
				pri = objCampo.value.substring(0,2);
				seg = objCampo.value.substring(2,6);
				
				objCampo.value = pri+
				((seg!='') ? '/'+seg : '')
			break;

			//0000 0000 0000 0000
			case 'cartao':
				objCampo.value = somente_numero(objCampo.value);
				
				pri = objCampo.value.substring(0,4);
				seg = objCampo.value.substring(4,8);
				ter = objCampo.value.substring(8,12);
				qua = objCampo.value.substring(12,16);
				
				objCampo.value = pri+
				((seg!='') ? '-'+seg : '')+
				((ter!='') ? '-'+ter : '')+
				((qua!='') ? '-'+qua : '');
			break;

			case 'numero':
				objCampo.value = somente_numero(objCampo.value);		
			break;
			
			case 'letra':
				objCampo.value = somente_letras(objCampo.value);
			break;
	
			//1.000.000.000.000,00
			case 'moeda':
				len = 20
				cur = objCampo
				n   = '0123456789';
				d   = objCampo.value;
				l   = d.length;
				r   = '';
				
				if ( l > 0 ){
					z = d.substr(0,l);
					s = '';
					a = 0;
					
					for ( i=0; i < l; i++ ){
						c = d.charAt(i);
						if ( n.indexOf(c) > a ){
							a  = -1;
							s += c;
						};
					};
					l = s.length;
					t = len - 1;
					if ( l > t ){
						l = t;
						s = s.substr(0,t);
					}
					if ( l > 2 ){
						r = s.substr(0,l-2)+','+s.substr(l-2,2);
					} else {
						if ( l == 2 ){
							r='0,'+s;
						}else{
							if ( l == 1 ){
								r = '0,0'+s;
							}
						}
					}
					if ( r == '' ){
						r = '0,00';
					} else {
						l=r.length;
						if (l > 6){
							j  = l%3;
							w  = r.substr(0,j);
							wa = r.substr(j,l-j-6);
							wb = r.substr(l-6,6);
							if ( j > 0 ){
								w+='.';
							};
							k = (l-j)/3-2;
							for ( i=0; i < k; i++ ){
								w += wa.substr(i*3,3)+'.';
							};
							r = w + wb;
						}
					}
				}
				if ( cur.value.length == len || cur.value.length > len ){
					cur.value = cur.value.substring(0 ,len);
					return false;
				} else {
						if ( r.length <= len ){
							cur.value = r;
						}else{
							cur.value = z;
						};
				}
			break;
		}
	}

	/*
	 *
	 *
	 *	Validacoes
	 *
	 *
	 */

	/*
	 *	Retorna verdadeiro se o campo estiver preenchido/marcado
	 */
	this.valida_obrigatorio	= function(obj){
		switch(obj.type){
			case 'checkbox':
				return !obj.checked;
			break;
			
			case 'radio':
				tmp_checado = false;
				re = get_name(obj.name);
				for(x=0;x<re.length;x++){
					if(re[x].checked) tmp_checado = true;
				}
				return tmp_checado;
			break;
			
			case 'text':
				obj.value = trim(obj.value);
				return (obj.value != '');
			break;
			
			case 'password':
				return (obj.value != '');
			break;
			
			case 'select-one':
				return (obj.selectedIndex != -1);
			break;

			case 'select-multiple':
				return (obj.selectedIndex == -1);
			break;

			default: 
				//alert(obj.type);
			break;
		}
	}
	
	/*
	 * Valida domínio
	 */
	this.valida_dominio = function(domain){
		if(typeof(domain) != 'string') domain = domain.value;
		if(typeof(domain) != 'string'){
			return false;
		}
		if(domain == ''){
			return true;
		}
	
		for (i = 0; i < domain.length; i++){
			if (domain.charCodeAt(i) > 127){
				return false;
			}
		}
	
		var ipDigit = "(0?0?\\d|[01]?\\d\\d|2[0-4]\\d|25[0-6])";
		var ipRE = new RegExp("^" + ipDigit + "\\." + ipDigit + "\\." + ipDigit + "\\." + ipDigit + "$");
	
		if (ipRE.test(domain)) {
			return true;
		}
	
		var domains = domain.split(".");
		
		if (domains.length < 2) {
			return false;
		}
	
		for (i = 0; i < domains.length - 1; i++) {
			if (!(/^[a-zA-Z0-9\-]+$/).test(domains[i])) {
				return false;
			}
		}
	
		if(domains[domains.length-2].length < 2){
			return false;
		}
	
		if (!(/^[a-zA-Z]{2,}$/).test(domains[domains.length-1])){
			return false;
		}
	
		return true;
	}
	
	this.valida_dominio_sem_www = function(domain){
		if(typeof(domain) != 'string') domain = domain.value;
		if(typeof(domain) != 'string'){
			return false;
		}
		
		if(/^www./.test(domain)){
			return false;	
		}
		
		return this.valida_dominio(domain);
	}

	/*
	 * Valida URL
	 */
	this.valida_url = function(xxx){
		url = xxx.value = trim(xxx.value);
		if(url == ''){
			return false;
		}

		var domain = url;
	
		var protocolSeparatorPos = url.indexOf("://");
		var domainSeparatorPos = url.indexOf("/", protocolSeparatorPos + 3);
	
		if(protocolSeparatorPos == 0){
			return false;
		}
	
		domain = url.substring(
			(protocolSeparatorPos > 0 ? protocolSeparatorPos + 3 : 0),
			(domainSeparatorPos > 0 ? domainSeparatorPos : url.length)
		);
		
		return this.valida_dominio(domain);
	}

	/*
	 *	Valida E-mail
	 */
	this.valida_email = function(email){
		email = email.value = trim(email.value);
		if(email == null){
			return false;
		}

		if(email == ''){
			return true;
		}

		var atPos = email.indexOf("@");
	
		if(
			atPos < 1 ||
			email.indexOf(".", atPos) == -1
		){
			return false
		}
	
		var login = email.substring(0, atPos);
		var domain = email.substring(atPos + 1, email.length);
	
		// Regexp declarations
		var atom = "\[^\\s\\(\\)><@,;:\\\\\\\"\\.\\[\\]\]+";
		var word = "(" + atom + "|(\"[^\"]*\"))";
		var loginRE = new RegExp("^" + word + "(\\." + word + ")*$");
	
		for (i = 0; i < login.length; i++){
			if (login.charCodeAt(i) > 127){
				return false;
			}
		}
	
		if (!login.match(loginRE)){
			return false;
		}
	
		return this.valida_dominio(domain);
	}

	/*
	 * Valida CPF
	 */
	this.valida_cpf = function(valor){
		valor = valor.value = somente_numero(valor.value);
		if(valor == '') return true; //tem que usar como obrigatorio
		teste = new Array();
		obj = valor;
		var D1,D2,D1calc,D2calc,aux;
		var j = 0;
		var counter = 0;
		for(i=0;i<obj.length;i++){
			if(!isNaN(obj.substring(i,i+1))){
				teste[j] = obj.substring(i,i+1);
				j++;
			}
		}
		aux = teste[0];
		for(i=0;i<teste.length;i++){
			if(teste[i] == aux){
				counter++;
			}
		}
		if(counter == teste.length){
			return false;
		}
		D1 = teste[j-2];
		D2 = teste[j-1];
		D1calc = 0;
		D2calc = 0;
		var loop = j-2;
		for(i=0;i<loop;i++){
			D1calc += Number(teste[i])*(10-i);
			D2calc += Number(teste[i])*(11-i);
		}
		D1calc = (D1calc*10)%11;
		if(D1calc == 10){D1calc=0};
			D2calc = ((D2calc+(2*D1calc))*10)%11;
		if(D2calc == 10){D2calc=0};
		if(D1 == D1calc && D2 == D2calc){
			return true;
		} else {
			return false;
		}
	}
	
	/*
	 * Valida CNPJ
	 */
	this.valida_cnpj	= function(CNPJ){
		CNPJ = CNPJ.value = somente_numero(CNPJ.value);
		if(CNPJ == '') return true; //tem que usar como obrigatorio
		CNPJ = cnpj_aux2(CNPJ); 
		if(cnpj_aux1(CNPJ) != 1) { 
			return false; 
		} else { 
			if(CNPJ == 0) { 
				return false; 
			} else { 
				g=CNPJ.length-2; 
				if(cnpj_aux3(CNPJ,g) == 1){ 
					g=CNPJ.length-1; 
					if(cnpj_aux3(CNPJ,g) == 1){ 
						return true; 
					} else { 
						return false; 
					} 
				} else { 
					return false; 
				} 
			} 
		} 
	}
	
	/*
	 * Valida Campo de Senha
	 * -> adicionar somente no campo principal, criar um campo auxiliar para verificar, com o mesmo id+'1' 
	 */
	this.valida_senha	= function(senhaNova){
		outraSenha 	= get(senhaNova.id+'1').value;
		senhaNova 	= senhaNova.value = trim(senhaNova.value);
		
		return (outraSenha == senhaNova);
	}
	
	/*
	 * Verifica se o valor do campo tem nr de caracteres
	 */
	this.valida_minimo	= function(objCampo, valorMinimo){
		valorMinimo = parseInt(valorMinimo);
		return (!(objCampo.value.length < valorMinimo));
	}
	
	/*
	 * Verifica se o valor do campo tem nr de caracteres
	 */
	this.valida_maximo	= function(objCampo, valorMaximo){
		valorMaximo = parseInt(valorMaximo);
		return (!(objCampo.value.length > valorMaximo));
	}
	
	/*
	 * Adiciona erro no preenchimento do form
	 */
	this.adiciona_erro	= function(msgErro){
		this.erro[this.erro.length] = msgErro;
	}
	
}

function ttr_retorno_ajax(retornoString){
	objBtnSubmit.disabled = false;
	var jstr_cmd = new RegExp("##T##");

	if(ttrDebug) {
		alert(retornoString);	
	}

	if(retornoString.match(jstr_cmd)){
		jComandos = retornoString.split("\n");
		for(jc=0;jc<jComandos.length;jc++){
			if(jComandos[jc].match(jstr_cmd)){
				ttr_exec_ajax(jComandos[jc]);
			}
		}
	} 
}

function ttr_exec_ajax(retornoString){
	retornoString = retornoString.split("##T##");
	jComando 	= retornoString[0];
	jArgumento 	= retornoString[1];
	switch(jComando){
		case 'alert':
			alert(unescape(jArgumento));
		break;
		
		case 'msg_box':
			//
		break;
		
		case 'popula_div':
			jArgumento 	= unescape(jArgumento).split("|||");
			get(jArgumento[0]).innerHTML = jArgumento[1];
		break;
	
		case 'eval':
			eval(unescape(jArgumento));
		break;
	}
}

ttrDebug = false;

var ttrValidacao = new classValidacao();