// DHTML menu functions
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

// SPI functions

function getElement(ID) {
  if(IE)
    if(SM) { // Netscape 6 hits here
      return document.getElementById(ID);
    }
    else { // IE 5 & 6 hit here
       return document.all[ID];
    }
//  if(NS) { // Netscape 4 hits here - but our callers don't use layers
//    var ItemA = document.layers[ID];
//  }
}

//sidebar popup window
function sidebarScreen(ID) {
  sidebarWindow = window.open("Sidebar.cfm?Article_ID=" + ID,"sidebarWindow",
  "width=465,height=500,menubar=no,resizable=yes,status=no,scrollbars=yes,left=0,top=0");
  sidebarWindow.focus();
}

//video popup window
function videoScreen(URL) {
  videoWindow = window.open(URL,"videoWindow",
  "width=752,height=418,menubar=no,resizable=no,status=no,scrollbars=no,left=0,top=0");
  videoWindow.focus();
}

//SPLOG popup window
function splogScreen(ID) {
  splogWindow = window.open("Sidebar.cfm?Article_ID=" + ID,"splogWindow",
  "width=750,height=600,menubar=no,resizable=yes,status=no,scrollbars=yes,left=20,top=400");
  splogWindow.focus();
}

//SPLOG popup window, unique name
function splogScreenKeep(ID) {
  splogWindow = window.open("Sidebar.cfm?Article_ID=" + ID,"splog"+ID,
  "width=750,height=600,menubar=no,resizable=yes,status=no,scrollbars=yes,left=20,top=400");
  splogWindow.focus();
}

//photo popup window
function photoScreen(Article, Seq) {
  photoWindow = window.open("Photo.cfm?Article=" + Article + "&Seq=" + Seq,"photoWindow",
  "width=465,height=500,menubar=no,resizable=yes,status=no,scrollbars=yes,left=0,top=0");
  photoWindow.focus();
}

//favorites popup window
function favoritesScreen(A_ID,L_ID,Action) {
  favoritesWindow = window.open("Favorites.cfm?A_ID=" + A_ID + "&Action=" + Action,"favoritesWindow",
  "width=200,height=150,menubar=no,resizable=no,status=no,scrollbars=no,left=0,top=0");
  favoritesWindow.focus();

  if(IE) {
    var ItemA = getElement(L_ID + 'A');
    var ItemD = getElement(L_ID + 'D');
//    if(SM) { // Netscape 6 hits here
//      var ItemA = document.getElementById(L_ID + 'A');
//      var ItemD = document.getElementById(L_ID + 'D');
//    }
//    else { // IE 5 & 6 hit here
//       var ItemA = document.all[L_ID + 'A'];
//       var ItemD = document.all[L_ID + 'D'];
//    }
  }
//  if(NS) { // Netscape 4 hits here - but FavoriteLink.cfm doesn't create layers
//    var ItemA = document.layers[L_ID + 'A'];
//    var ItemD = document.layers[L_ID + 'D'];
//  }

  if(!ItemA) { return false; }

  if (Action == 'A') {
    ItemA.style.display = 'none';
    ItemD.style.display = 'inline';
  }
  else if (Action == 'D') {
    ItemA.style.display = 'inline';
    ItemD.style.display = 'none';
  }
// else they're not registered, so don't change the link display
}

//logo animation
function GoggleLight(Show) {
  var ItemL = getElement('LogoImage');
  if(!ItemL) { return false; }
  if (Show) { ItemL.src = 'images/logo_eyes.gif'; }
  else      { ItemL.src = 'images/logo.gif'; }
}
function EarMuffLight(Show) {
  var ItemL = getElement('LogoImage');
  if(!ItemL) { return false; }
  if (Show) { ItemL.src = 'images/logo_ears.gif'; }
  else      { ItemL.src = 'images/logo.gif'; }
}

// Clear all <tagname> input objects on form, submit (or not)

function clearall(tagname, eletype, arg)
// Clears all radio buttons if clearall("input",  "radio", false);
// Clears all anchors named "result" if clearall("result", "", false);
{
  if (tagname == "input")
  {
    var inputs = document.getElementsByTagName(tagname);
    for(var iIndex in inputs)
    {
      if (inputs[iIndex].type == "result")
      {
        alert(inputs[iIndex].innerHTML);
      }
      if (inputs[iIndex].type == eletype)
      {
        inputs[iIndex].checked = false;
      }
    }
    return arg;
  } else {
    var inputs = document.getElementsByName(tagname);
    for(var iIndex in inputs)
    {
       if (inputs[iIndex].innerHTML != undefined)
       {
         inputs[iIndex].innerHTML = "";
       }
    }
    return arg;
  }
}

// Clear all Radio and Result

function clearall2()
{
  clearall("input",  "radio", false);
  clearall("result", "", false);
  return false;
}

var ofEmailValue;

function EnterEmail()
{
  var x=document.getElementById("ofEmail");
  ofEmailValue = x.value;
}

function LeaveEmail()
{
  var x=document.getElementById("ofEmail");
  if (x.value != ofEmailValue)
    alert("Please check your email address for accuracy. Registrations fail when an email address is typed in error. You entered '" + x.value + "'.");
}



// "Borrowed functions"

/***********************************************
* Show Hint script- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/

var horizontal_offset="9px" //horizontal offset of hint box from anchor link

/////No further editting needed

var vertical_offset="0" //horizontal offset of hint box from anchor link. No need to change.
var ie=document.all
var ns6=document.getElementById&&!document.all

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=(whichedge=="rightedge")? parseInt(horizontal_offset)*-1 : parseInt(vertical_offset)*-1
if (whichedge=="rightedge"){
var windowedge=ie && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-30 : window.pageXOffset+window.innerWidth-40
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure+obj.offsetWidth+parseInt(horizontal_offset)
}
else{
var windowedge=ie && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetHeight
}
return edgeoffset
}

function showhint(menucontents, obj, e, tipwidth){
if ((ie||ns6) && document.getElementById("hintbox")){
dropmenuobj=document.getElementById("hintbox")
dropmenuobj.innerHTML=menucontents
dropmenuobj.style.left=dropmenuobj.style.top=-500
if (tipwidth!=""){
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=tipwidth
}
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+obj.offsetWidth+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+"px"
dropmenuobj.style.visibility="visible"
obj.onmouseout=hidetip
}
}

function hidetip(e){
dropmenuobj.style.visibility="hidden"
dropmenuobj.style.left="-500px"
}

function createhintbox(){
var divblock=document.createElement("div")
divblock.setAttribute("id", "hintbox")
document.body.appendChild(divblock)
}

if (window.addEventListener)
window.addEventListener("load", createhintbox, false)
else if (window.attachEvent)
window.attachEvent("onload", createhintbox)
else if (document.getElementById)
window.onload=createhintbox
