// JavaScript Document
//'form_busca_detalhada','cot_id','pis_id','1'
function carregar(select_a,select_b,tp,titulo){ 
  Combo1 = $(select_a);
  Combo2 = $(select_b); 
  tit_combo = titulo;
  var url; 
  url = 'remote.asp?id='+Combo1[Combo1.selectedIndex].value+'&tp='+tp; 
  Combo2.options.length = 0; 
  addItem(Combo2,"Aguarde...","",false,Combo2.length) 
  myIframe.location = url; 
  Combo2.focus() 
} 

function carregar_s(select_0,select_a,select_b,tp,titulo){
  Combo0 = $(select_0);
  Combo1 = $(select_a);
  Combo2 = $(select_b); 
  tit_combo = titulo;
  var url; 
 	url = 'remote.asp?id='+Combo1[Combo1.selectedIndex].value+'&id0='+Combo0[Combo0.selectedIndex].value+'&tp='+tp; 
  Combo2.options.length = 0; 
  addItem(Combo2,"Aguarde...","",false,Combo2.length) 
  myIframe.location = url; 
  Combo2.focus() 
} 

function carregar_para(select_0, titulo){
  Combo2 = $(select_0);
  tit_combo = titulo;
  var url; 
  url = 'remote.asp?tp=2'; 
  Combo2.options.length = 0; 
  addItem(Combo2,"Aguarde...","",false,Combo2.length) 
  myIframe.location = url; 
  Combo2.focus() 
} 

function addItem(obj,strText,strValue,blSel,intPos){  
     var newOpt,i,ArTemp,selIndex;  
     selIndex = (blSel)?intPos:obj.selectedIndex;  
     newOpt = new Option(strText,strValue);  
     Len = obj.options.length+1  
     if (intPos > Len) return  
     obj.options.length = Len  
     if (intPos != Len) {  
          ArTemp = new Array();  
          for(i=intPos;i<obj.options.length-1;i++)  
               ArTemp[i] = Array(obj.options[i].text,obj.options[i].value);  
          for(i=intPos+1;i<Len;i++)  
               obj.options[i] = new Option(ArTemp[i-1][0],ArTemp[i-1][1]);  
     }  
     obj.options[intPos] = newOpt;  
     if (selIndex > intPos)  
          obj.selectedIndex = selIndex+1;  
     else if (selIndex == intPos)   
          obj.selectedIndex = intPos;  
}  


function inicia(){ 
local1 = new Array(); 
var maximo1, i; 
local1 = myIframe.loc; 
maximo1 = local1.length; 
Combo2.options.length = 0; 
addItem(Combo2,tit_combo,'',false,Combo2.length); 
for (i=0;i<maximo1;i++){ 
addItem(Combo2,local1[i][1],local1[i][0],false,Combo2.length); 
} 
} 
