/****************************************
Função utilizada para interagir com o 
o abridor.
***************************************/

function doOnOpener(doit){
  eval("window.opener." + doit);
}


/****************************************
função para abrir janelas filhas
****************************************/

function abrirJanela(urlGo,width,height,scrolling){


  X = screen.width; //recupera a largura da janela
  Y = screen.height; //recupera a altura da janela

  if(height == null) height = 400;

  if(width == null) width = 400;

  if(urlGo == null) urlGo = "error.htm";

  if(scrolling == null) scrolling = "no";

  screenX = ((X/2)-(width/2)); //centraliza o a janela filha no centro da tela
  screenY = ((Y/2)-(height/2)); //centraliza o a janela filha no centro da tela

  url = urlGo;
  windowFeatures  = "directories=no,height="+height+",width="+width+",location=no,";	
  windowFeatures += "menubar=no,resizable=no, left="+screenX+", top="+screenY+",scrollbars="+scrolling+",titlebar=no,";	
  windowFeatures += "status=no,toolbar=no";	
  windowName = "Cliente" ;
  novaJanala = open(url,windowName,windowFeatures);
  novaJanala.focus();

}

/***************************************
Função para chamar URL's
***************************************/

function gotoURL(url,search){
  if(url == null)
    return false;
  else
    location.replace(url+ ((search==null) ? " " : "?"+search));//verifica se a pesquisa está vazia.
}


/***************************************
Função para recarregar a página.
***************************************/

function reload(){
    location.reload();
}


/*****************************************
Funções de popularização de formulários 
******************************************/

function setClearSelect(obj){
 this.el = eval(obj);
 this.el.length = 1;
 this.el.options[0].text = "Outro";
 this.el.options[0].value = "outro";
}

function setNewOption(obj,text,value){
  this.text = text;
  this.value = value;
  this.el = eval(obj);
	  this.option = new Option();
	  this.option.text = this.text;
	  this.option.value = this.value;
	  this.el.add(this.option);
}

function setPopulateSelect(obj,cont){
 this.content = eval(cont);
 this.el = eval(obj);
 for(i=0;i<this.content.length;i++){
   this.option = new Option();
   this.option.text = this.content[i].text;
   this.option.value= this.content[i].value;
   this.el.add(this.option);
 }
}
  
function setMsgSelect(obj,how,msg){
  this.how = how
  this.msg = msg;
  this.el = eval(obj);
  switch (this.how){
    case 0:
      this.el.length = 1;
      this.option = new Option();
      this.option.text = this.msg;
      this.el.options[0].text = this.msg;
      this.el.options[0].value = "noValue";
    break;
    case 1:
      this.el.options[0].text = this.msg;
      this.el.options[0].value = "noValue";
    break;	
  }
} 