/// URL:
var urlDoRastreamento = 'servicos/rastreamento/';

 function PopUp(theURL,winName,features)
 {
   window.open(theURL,winName,features);
 }
	  
function Validar()
{
   // Valida registro
   if (TirarBrancoFinal(document.download_busca_cep.nome.value) == "")
   {
      alert ("Por favor, informe o seu nome/razão social");
      document.download_busca_cep.nome.focus()
      return false;
   }

   if (TirarBrancoFinal(document.download_busca_cep.tx_url.value) == "")
   {
      alert ("Por favor, informe a sua URL");
      document.download_busca_cep.tx_url.focus()
      return false;
   }

   if (TirarBrancoFinal(document.download_busca_cep.tx_email.value) == "")
   {
      alert ("Por favor, informe o seu e-mail");
      document.download_busca_cep.tx_email.focus()
      return false;
   }

   return true;
}


function TirarBrancoFinal(sValor)
{
   // Tira Brancos no fim da string

   var wI = sValor.length - 1;

   for (; wI > -1; wI--)
   {
      if (sValor.substring(wI, wI + 1) != " ")
      {
         return sValor.substring(0,wI + 1);
      }
   }
   return "";
}

function Redireciona(textArea,idioma){
  		var aux = textArea.value.toUpperCase();
		textArea.value = aux;

  		if(textArea.value != ''){

			if(
				(textArea.value.substr(0,2)=='LC')||(textArea.value.substr(0,2)=='LX')||(textArea.value.substr(0,2)=='LZ')||(textArea.value.substr(0,2)=='LY')&&(textArea.value.substr(10,13)=='US')){

		window.alert ("Código de objeto não rastreável. O rastreamento eletrônico de objetos internacionais é oferecido somente para a modalidade expressa (EMS e Sur postal 24h).");
		textArea.value='';
}else{
if(textArea.value.substr(0,2)=='XM' || textArea.value.substr(0,2)=='VC'){
  				window.open("http://websro.correios.com.br/sro_bin/txect01$.QueryList?P_COD_UNI="+textArea.value.substr(0,13)+"&P_TIPO=001&P_LINGUA="+idioma,"SRO","width=550,height=400,scrollbars=yes,resizable=no,toolbar=no");
  				textArea.value = "";
  			}else{
  				document.busca_obj.submit();
  			}
}
  			
  		}
  	}
	

function Imprime()
   {
      window.print();
   }
   


function enviaForm_Rastreamento(){
		if ( Validar() ){
	
			var f = document.download_busca_cep;
			var getStr = urlDoRastreamento + "Download_servicos_sro_grava.cfm?template=none";
			
			getStr += "&nome=" + f.nome.value;
			getStr += "&tx_url=" + f.tx_url.value;
			getStr += "&tx_email=" + f.tx_email.value;
			getStr += "&endereco=" + f.endereco.value;
			getStr += "&cidade=" + f.cidade.value;
			getStr += "&uf=" + f.uf.value;
			
		   carregaLink(getStr,'','','',f.mode.value);		
		}
		return;
	}   
