function getElement(psID) { 
  if(document.all) {return document.all[psID];}
  else{return document.getElementById(psID);}
} 

function setFields() {
  getElement('selLocation').value=getElement('Location').value;
}

function buildLocation() {
  var objCountry=getElement('Country');
  var objLocation=getElement('Location');
  var objselLocation=getElement('selLocation');
  var arrList=new Array();

  var vLocationValue=objselLocation.value;

  var vLocationFound=false;
  objLocation.options.length=0;
  var j=0;
  if (objCountry.value==0) {objLocation.options[j]=new Option('(all locations)', 0);}
  else {objLocation.options[j]=new Option('(all locations in ' + objCountry[objCountry.selectedIndex].innerHTML +  ')', 0);}
  j++;
  for (var i=0; i<arrOptions.length; i++) {
    var opt=arrOptions[i].split(';');
    
    if(objCountry.value==0){
			if(vLocationValue+''==opt[1]+''){vLocationFound=true;}
			arrList[j]=opt[1];
			j++;
    }
    else {
			if(opt[0]==objCountry.value){
				if(vLocationValue+''==opt[1]+''){vLocationFound=true;}
				arrList[j]=opt[1];
				j++;
			}
    }
  }

  //now get the values from the appropriate list
  var k=0;
  for (i=0;i<arrLocations.length;i++) {
    var opt=arrLocations[i].split(';');
    var found=false;
    j=0;
    while (j<arrList.length && found==false) {
      if(arrList[j]==opt[0]){found=true;objLocation.options[k+1]=new Option(opt[1], opt[0]);k++;}
      j++;
    }
  }
  if(vLocationFound){objLocation.value=vLocationValue;}
  else{objLocation.value=0;}
  setFields();
}  