function hide_states(){
  obj = document.getElementById("state");
  maxnodes=obj.childNodes.length;
  for (x=(maxnodes-1); x>=0; x--){ 
    if (obj.childNodes[x].nodeName == "OPTGROUP") {obj.removeChild(obj.childNodes[x]);}
    }
  }

function show_states(obj){
  document.getElementById("state").appendChild(obj);
  }

function set_state_row(){
  if (arguments[0]=="hide"){document.getElementById("staterow").style.display="none";}
  else if (arguments[0]=="show"){
    if ((navigator.userAgent.indexOf("Gecko")!=-1) || (navigator.userAgent.indexOf("Opera")!=-1)){document.getElementById("staterow").style.display="table-row";}
    else {document.getElementById("staterow").style.display="block";}  //IE browsers don't recognize "table-row"
    }
  }

function set_state_list (o_usa,o_india,o_canada){
  // do not let IE 5 browsers execute this (they get confused about OPTGROUP and crash)
  if ((document.getElementById("country")) && (navigator.userAgent.indexOf("MSIE 5")== -1)){
    if (document.getElementById("country").value=="CA"){
      set_state_row("show");
      hide_states();
      show_states(o_canada);
      }
    else if (document.getElementById("country").value=="US"){
      set_state_row("show");
      hide_states();
      show_states(o_usa);
      }
    else if (document.getElementById("country").value=="IN"){
      set_state_row("show");
      hide_states();
      show_states(o_india);
      }
    else {
      set_state_row("hide");
      hide_states();
      }
    }
  }
