/* theweb.js */

/* Style switcher: Change the page style using a select menu. */
var switcher = {	// Switch the styles
 topline:false,		// the div#topline element
 bottomline:false,	// the div#bottomline element
 form:false,		// the form#switcher element
 controller:false,	// the controller form element
 init:function(){	// switcher.init()
  if(
   !document.getElementById || 
   !document.getElementsByTagName || 
   !document.getElementById('topline') ||
   !document.getElementById('bottomline')
  ) return;									// check for method availability
  switcher.topline    = document.getElementById('topline');			// Assign the topline
  switcher.bottomline = document.getElementById('bottomline');			// Assign the bottomline
  switcher.form       = document.getElementById('switcher');			// Assign the switcher
  switcher.controller = switcher.form.getElementsByTagName('select')[0];	// Assign select element to the controller
  switcher.addEvent(switcher.controller,'change',function(){
   switcher.topline.className    = this.value;
   switcher.bottomline.className = this.value;
  });	// Add an event to the controller triggered by the onchange event
  /* Don't need to have a submit button */
  //var input = switcher.form.getElementsByTagName('input')[0];			// get the submit button
  //input.parentNode.removeChild(input);						// and delete it on onchange
 },
 addEvent:function(obj,type,fn){
  if(obj.addEventListener){obj.addEventListener(type,fn,false);}
  else if(obj.attachEvent){
   obj["e"+type+fn] = fn;
   obj[type+fn] = function(){obj["e"+type+fn](window.event);};
   obj.attachEvent("on"+type,obj[type+fn]);
  };
 }
};

/* AJAX for the Power Bar */
var XMLHttpRequestObject = false;

if(window.XMLHttpRequest){XMLHttpRequestObject = new XMLHttpRequest();}

function getData(dataSrc,divID)
{
 if(XMLHttpRequestObject)
 {
  XMLHttpRequestObject.open("GET",dataSrc);
  XMLHttpRequestObject.onreadystatechange = function()
  {
   if(XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200)
   {
    displayText(divID,XMLHttpRequestObject.responseText);
   };
  };
  XMLHttpRequestObject.send(null);
 };
};

function displayText(divID,text)
{
 var obj = document.getElementById(divID);
 obj.innerHTML = text;
};

/* Using switcher.addEvent function, trigger switcher.init() on page load. */
switcher.addEvent(window,'load',switcher.init);

