window.onload = init;

// Initialize
function init() {
  var temp = "";
  writeFlash(6, temp+"/common/swf/mastheads", 733, 211, "576421", "header", "jpg", "Bugsmart.ca", "_link_", "_target_");
  //randomHeader();
  selectOnChange();
  if (document.getElementsByTagName('body')[0].id &&
    document.getElementsByTagName('body')[0].id != 'search')
    googleSearchHighlight();
}

// Get element
function getElem(id) {
  var obj = (typeof id == 'string') ? document.getElementById(id) : id;
  return obj;
}

// Set event attribute
function setAttr(obj, handler, theFunction) {
  if (document.all) {
    obj[handler] = new Function(theFunction);
  } else {
    obj.setAttribute(handler, theFunction);
  }
}

// Events onchange
function selectOnChange() {
  var oSelect;

  if (document.getElementById("redirect")) {
    oSelect = document.getElementById("redirect");
  }
  if (oSelect) {
    setAttr(oSelect, 'onchange', "goPage(this)");
  }
}

// Redirect
function goPage(obj) {
	oValue = obj[obj.selectedIndex].value;
	if (oValue) location.href = oValue;
}

// Radomize header image
function randomHeader() {
  var r = Math.floor(Math.random() * 3 + 1);
  getElem('header').className = 'header' + r;
}
