// Regions.js
//
// JavaScript functions for 'Regions' SQL database.
// Works in conjunction with data setup by Regions.asp.
// Warren Blatt & Michael Tobias, April 2005.



function setRegions(database)
{
  
   // Special case for the JOWBR database:
   if (database == "JOWBR") { database = "DEFAULT"; }
   
   // Get the Regions pulldown:
   var regionChooser = document.getElementById("GeoRegion");

   // Clear previous settings of the Regions pulldown:
   regionChooser.options.length = 0;
   
   // Populate options in the Regions pulldown:
   var index = 0;
   var label = "";
   for (var i = 0; i < reg_data.length; i++)
     {
	 if ( database == reg_data[i].sys )
         {
            label = reg_data[i].lab;
            if (reg_data[i].ind == "2")
              { label = " - - - " + label; }
            else if (reg_data[i].ind == "3")
              { label = " - - - - - - " + label; }
            else if (reg_data[i].ind == "4")
              { label = " - - - - - - - - - " + label; }
            else if (reg_data[i].ind == "5")
              { label = " - - - - - - - - - - - - " + label; }
              
            var y = document.createElement('span');
            y.innerHTML = label;

	    regionChooser.options[index++] = new Option (y.innerHTML, reg_data[i].val);
         }
     }
   
   // Provide a default option if this system has no regions:
   if ( ! index )
     { regionChooser.options[0] = new Option ("All Regions", "ALL", true, false); }
  
   // Set the sensitivity of the Regions pulldown:
   regionChooser.disabled = ( ! index );
}



function setButtonText(ButtonID, Text)
{
  var button = document.getElementById(ButtonID);
  button.value = Text;
}


function setSpanText(SpanID, Text)
{
  var span = document.getElementById(SpanID);
  span.innerHTML = Text;
}