function ListOption(codigo, nome){
    this.codigo = codigo;
    this.nome = nome;
}

var cityListCache = new Array(35);

var countryListCache;

function getCityList( estado, targetName, selectedValue ){
  if ( cityListCache && cityListCache[ estado*1 ] )
    return fillCityList( estado, targetName, selectedValue );
  else
    return parent.serverFrame.location ="cityLoader.asp?uf=" + estado + "&targetName="+targetName+"&selectedValue="+selectedValue;
}

function fillCityList( estado, targetName, selectedValue ){
	try{
    targetList = eval( "top.innerFrame.corpo." + targetName );
    strAttr = ""
    
    strAttr += " onChange='" + targetList.onChange +"' ";
    strAttr += " name='" + targetList.name + "' ";
    
    top.innerFrame.corpo.document.getElementById(targetList.name+'_Div').innerHTML = "<SELECT id='MUNICIPIO' " + strAttr + " >" + cityListCache[ estado*1 ] + "</SELECT>";

    targetList = eval( "top.innerFrame.corpo." + targetName );
    targetList.disabled = false;
    targetList.multiple = false;
    targetList.size = 1;
    setListValue( targetList, selectedValue );
    top.innerFrame.corpo.notifyMe();
    return true;
	}catch( ignore ){}
}

function getCountryList( targetName, selectedValue ){
  if ( countryListCache && countryListCache.length != 0 )
    return fillCountryList( targetName, selectedValue );
  else
    return parent.serverFrame.location ="countryLoader.asp?targetName="+targetName+"&selectedValue="+selectedValue;
}

function fillCountryList( targetName, selectedValue ){
    targetList = eval( "top.innerFrame.corpo." + targetName );

    strAttr = " onChange='" + targetList.onChange +"' ";
    strAttr += " name='" + targetList.name + "' ";
    
    top.innerFrame.corpo.document.getElementById(targetList.name+'_Div').innerHTML = "<SELECT ID='PAIS' " + strAttr + " >" + countryListCache + "</SELECT>";

    targetList = eval( "top.innerFrame.corpo." + targetName );
    targetList.disabled = false;
    targetList.multiple = false;
    targetList.size = 1;
    
    setListValue( targetList, selectedValue );
    top.innerFrame.corpo.notifyMe();
    return true;
}

function setListValue( list, selectedValue ){
  list.value=selectedValue;
  /*
  //alert( list.name );
  //alert( selectedValue );
  for (var i = 0 ; i < list.length ; i++){
    if ( list[i].value == selectedValue*1 ){
      //alert('work');
      list.selectedIndex = i;
      return;
    }
  }*/
}
