// JavaScript Document
/*********************************************
Begin universal funcs
*********************************************/
var d=document;
if(!d.getElementById && d.all){
	d.Id=function(x){return this.all[x]}
}else{
	d.Id=function(x){return this.getElementById(x)}
}
var undefined='undefined';
function getContent(URL){
	parent.nav_frame.document.location.href=URL;
}
function select_innerHTML(objeto,innerHTML){
/******
* select_innerHTML - corrige o bug do InnerHTML em selects no IE
* Veja o problema em: http://support.microsoft.com/default.aspx?scid=kb;en-us;276228
* Versão: 2.1 - 04/09/2007
* Autor: Micox - Náiron José C. Guimarães - micoxjcg@yahoo.com.br
* @objeto(tipo HTMLobject): o select a ser alterado
* @innerHTML(tipo string): o novo valor do innerHTML
*******/
    objeto.innerHTML = ""
    var selTemp = document.createElement("micoxselect")
    var opt;
    selTemp.id="micoxselect1"
    document.body.appendChild(selTemp)
    selTemp = document.getElementById("micoxselect1")
    selTemp.style.display="none"
    if(innerHTML.indexOf("<option")<0){//se não é option eu converto
        innerHTML = "<option>" + innerHTML + "</option>"
    }
    innerHTML = innerHTML.replace(/<option/g,"<span").replace(/<\/option/g,"</span")
    selTemp.innerHTML = innerHTML
      
    
    for(var i=0;i<selTemp.childNodes.length;i++){
  var spantemp = selTemp.childNodes[i];
  
        if(spantemp.tagName){     
            opt = document.createElement("OPTION")
    
   if(document.all){ //IE
    objeto.add(opt)
   }else{
    objeto.appendChild(opt)
   }       
    
   //getting attributes
   for(var j=0; j<spantemp.attributes.length ; j++){
    var attrName = spantemp.attributes[j].nodeName;
    var attrVal = spantemp.attributes[j].nodeValue;
    if(attrVal){
     try{
      opt.setAttribute(attrName,attrVal);
      opt.setAttributeNode(spantemp.attributes[j].cloneNode(true));
     }catch(e){}
    }
   }
   //getting styles
   if(spantemp.style){
    for(var y in spantemp.style){
     try{opt.style[y] = spantemp.style[y];}catch(e){}
    }
   }
   //value and text
   opt.value = spantemp.getAttribute("value")
   opt.text = spantemp.innerHTML
   //IE
   opt.selected = spantemp.getAttribute('selected');
   opt.className = spantemp.className;
  } 
 }    
 document.body.removeChild(selTemp)
 selTemp = null
}
var geoNavSelectedCountry = '';
var geoNavSelectedState = '';
var geoNavSelectedCity = '';
function updateGeoNav(type){
	geoNavSelectedCountry = d.geo_nav_form.select_country.options[d.geo_nav_form.select_country.selectedIndex].value;
	geoNavSelectedState = d.geo_nav_form.select_state.options[d.geo_nav_form.select_state.selectedIndex].value;
	geoNavSelectedCity = d.geo_nav_form.select_city.options[d.geo_nav_form.select_city.selectedIndex].value;
	if(type == 'country' && geoNavSelectedCountry != ''){
		getContent('/_ijax/nav.php?listtype=states&country='+geoNavSelectedCountry+'');
		d.Id('select_nav_link').href = 'http://www.thecollectionfirm.com/collectionservices/'+geoNavSelectedCountry+'/';
	}else if(type == 'state' && geoNavSelectedState == ''){
		select_innerHTML(d.Id('nav_select_city'),'<option value=\"\">- CITY -</option>');
		d.Id('select_nav_link').href = 'http://www.thecollectionfirm.com/collectionservices/'+geoNavSelectedCountry+'/';
	}else if(type == 'state' && geoNavSelectedState != ''){
		getContent('/_ijax/nav.php?listtype=cities&country='+geoNavSelectedCountry+'&state='+geoNavSelectedState+'');
		d.Id('select_nav_link').href = 'http://www.thecollectionfirm.com/collectionservices/'+geoNavSelectedCountry+'-'+geoNavSelectedState+'/';
	}else if(type == 'city' && geoNavSelectedCity == ''){
		d.Id('select_nav_link').href = 'http://www.thecollectionfirm.com/collectionservices/'+geoNavSelectedCountry+'-'+geoNavSelectedState+'/';
	}else if(type == 'city' && geoNavSelectedCity != ''){
		d.Id('select_nav_link').href = 'http://www.thecollectionfirm.com/collectionservices/'+geoNavSelectedCountry+'-'+geoNavSelectedState+'/'+geoNavSelectedCity+'.php';
	}else{
		getContent('/_ijax/nav.php?listtype=countries');
		d.Id('select_nav_link').href = 'http://www.thecollectionfirm.com/countrieslist/';
	}
}
