function setEvent(o,v,i) //event registration
{
  if (i!=null && o!=null && v=="mouseover")
  {
    if (isIE) o.attachEvent("onmouseover",function () {tags[i].mouseover();});
    else o.addEventListener("mouseover",tags[i].mouseover,false);
  }
  else if (i!=null && o!=null && v=="mouseout")
  {
    if (isIE) o.attachEvent("onmouseout",function () {tags[i].mouseout();});
    else o.addEventListener("mouseout",tags[i].mouseout,false);
  }
  else if (i!=null && o!=null && v=="click")
  {
    if (isIE) o.attachEvent("onclick",function () {tags[i].click();});
    else o.addEventListener("click",tags[i].click,false);
  }
  else if (i!=null && o!=null && v=="focus")
  {
    if (isIE) o.attachEvent("onfocus",function () {tags[i].click();});
    else o.addEventListener("focus",tags[i].click,false);
  }
  else if (i!=null && o!=null && v=="submit")
  {
    if (isIE) o.attachEvent("onsubmit",function () {tags[i].submit();});
    else o.addEventListener("submit",tags[i].submit,false);
  }
  return null;
} //setEvent

var myMenu = {
  index: null,
  items: new Array(),
  cursor: null,
  timer: null
};//end myMenu

function setMenu()
{
  myMenu.index=idIndex("menu")+1;
  if (myMenu.index!=null)
  {
    for (n=0; n<tags[myMenu.index].childNodes.length; n++) //for every list item
    {
      myMenu.items[n] = objIndex(tags[myMenu.index].childNodes[n]);
      tags[myMenu.items[n]].index=n;
      tags[myMenu.items[n]].mouseover=showMenu;
      setEvent(tags[myMenu.index].childNodes[n],"mouseover",myMenu.items[n]);
      tags[myMenu.items[n]].mouseout=softShut;
      setEvent(tags[myMenu.index].childNodes[n],"mouseout",myMenu.items[n]);
    } //for
  } //if
} //setMenu

function showMenu()
{
  if (myMenu.cursor!=null && myMenu.cursor!=this.index)
  {
    shutMenu(myMenu.items[myMenu.cursor]);
  }
  if (myMenu.timer!=null)
  {
    clearTimeout(myMenu.timer);
    myMenu.timer=null;
  }
  if (myMenu.cursor!=this.index)
  {
    myMenu.cursor=this.index;
    if (tags[myMenu.items[myMenu.cursor]].className)
    {
      tags[myMenu.items[myMenu.cursor]].oldClass = tags[myMenu.items[myMenu.cursor]].className;
      tags[myMenu.items[myMenu.cursor]].className = tags[myMenu.items[myMenu.cursor]].className + " show";
    }
    else tags[myMenu.items[myMenu.cursor]].className = "show";
  }
  return null;
}

function shutMenu(ind)
{
  if (tags[ind].className)
  {
    if (tags[ind].className!="show") tags[ind].className=tags[ind].oldClass;
    else tags[ind].className = "";
  }
  myMenu.cursor=null;
  return null;
} //shutMenu

function softShut() { myMenu.timer=setTimeout("shutMenu(myMenu.items[myMenu.cursor])",1600); return null; }//softShut

var isIE = false;
var app = { init: function () { this.browser = this.searchString(this.b) || "An unknown browser"; this.version = this.searchVersion(navigator.userAgent) || this.searchVersion(navigator.appVersion)	|| "an unknown version";}, searchString: function (data) { for (var i=0;i<data.length;i++)	{ var dS = data[i].s; var dP = data[i].p; this.verSS = data[i].ver || data[i].id; if (dS) { if (dS.indexOf(data[i].ss) != -1)	return data[i].id; } else if (dP) return data[i].id;	}}, searchVersion: function (dS) { var index = dS.indexOf(this.verSS); if (index == -1) return; return parseFloat(dS.substring(index+this.verSS.length+1));}, b: [{s: navigator.userAgent,ss: "Chrome",id: "Chrome"},{s: navigator.userAgent,ss: "OmniWeb",ver: "OmniWeb/",id: "OmniWeb"},{s: navigator.vendor,ss: "Apple",id: "Safari"},{p: window.opera,id: "Opera"},{s: navigator.vendor,ss: "iCab",id: "iCab"},{s: navigator.vendor,ss: "KDE",id: "Konqueror"},{s: navigator.userAgent,ss: "Firefox",id: "Firefox"},{s: navigator.vendor,ss: "Camino",id: "Camino"},{/* for newer Netscapes (6+) */s: navigator.userAgent,ss: "Netscape",id: "Netscape"},{s: navigator.userAgent,ss: "MSIE",id: "Explorer",ver: "MSIE"},{s: navigator.userAgent,ss: "Gecko",id: "Mozilla",ver: "rv"},{/* for older Netscapes (4-) */s: navigator.userAgent,ss: "Mozilla",id: "Netscape",ver: "Mozilla"}]}; //Browser Detect -Quirksmode.org
app.init();
var tags = new Array();
function loadTags() { if (document.all && isIE) tags=document.all; else tags=document.getElementsByTagName('*'); return; } //loadTags
function objIndex(o) { for (t=0; t<tags.length; t++) { if (tags[t]==o) return t; } return null; } //objIndex
function idIndex(i) { for (t=0; t<tags.length; t++) { if (tags[t].id==i) return t; } return null; } //idIndex

var appWindow = null;

function formPopUp()
{
  if (appWindow==null)
  {
    appWindow=window.open("about:blank","Shorcast_APP","resizable=1,status=1,menubar=0,location=0,toolbar=0,width=810,height=562,left=0,top=0");
    this.target="Shorcast_APP";
    this.submit2();
  }
  else if (!appWindow.closed)
  {
    alert("Only one Shorcast Window can be open at once.\rPlease exit this window to open another Shorcast Service.");
    appWindow.focus();
  }
  else
  {
    appWindow=null;
    this.submit();
  }
  return;
}  //end formPopUp

function Timer()
{
  this.target = 0;
  this.list = new Array();
  this.purge = function (){
    tags[this.target].href = this.list[0];
    var trash = this.list.shift();
  } //end purge
}

var keepLink = new Timer();

function formNullify()
{
  document.forms["postLoginID"].elements["targetLink"].value = "";
  document.forms["postLoginID"].elements["targetDB"].value = "";
}

function linkInterrupt()
{

  keepLink.target = objIndex(this);
  var tempNum = keepLink.list.length;
  keepLink.list[tempNum] = this.href;
  this.href="javascript:void(0)";
  document.forms["postLoginID"].elements["targetLink"].value = keepLink.list[tempNum];
  document.forms["postLoginID"].elements["targetDB"].value = this.title;
  document.forms["postLoginID"].submit();
  setTimeout("keepLink.purge()",15);
  setTimeout("formNullify()",20);
//  window.open(keepLink.list[tempNum],"Shorcast","resizable=1,status=1,menubar=0,location=0,toolbar=0,width=810,height=562,left=0,top=0");
} //end testest


function idIndexMatch(textstring)
{
  var matchList = new Array();
  var pos=0;
  for (t=0; t<tags.length; t++)
  {
    if (tags[t].id.indexOf(textstring)==0)
    {
      matchList[pos]=t;
      pos++;
    } //end if
  } //end for
  return matchList;
} //idIndexMatch

function setLinkInterrupt()
{
  var popUpArray = idIndexMatch("popup");
  if (popUpArray.length>0)
  {
    for (n=0; n<popUpArray.length; n++) //for every list item
    {
      tags[popUpArray[n]].click=linkInterrupt;
      setEvent(tags[popUpArray[n]],"click",popUpArray[n]);
    } //for
  } //if
  var targetForm=idIndex("postLoginID");
  if (tags[targetForm].submit)
    tags[targetForm].submit2=tags[targetForm].submit;
  if (targetForm!=null)
  {
    setEvent(tags[targetForm],"submit",targetForm);
    tags[targetForm].submit=formPopUp;
  }
  return;
} //setMenu


function doFocus()
{
  var temp = idIndex("shorcastLogin");
  if (temp!=null)
  {
    var ele = 0;
    while (ele<tags[temp].elements.length)
    {

      if (tags[temp].elements[ele].tabIndex==100)
        tags[temp].elements[ele].focus();
      ele++;
    }
  }
  return;
}
function pageLoad()
{
  app.init();
  if (app.browser=="Explorer") isIE=!isIE;
  loadTags();
  var check = idIndex("calculatorForm");
  if (check!=null) setCalculator();
  setMenu();
  if (document.forms["postLoginID"]) setLinkInterrupt();
  doFocus();
} //pageLoad

window.onload = pageLoad;