var NS4 = (document.layers);
var NS6 =  ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) == 5))
var IE4 = (document.all);
var MAC45 = (navigator.appVersion.indexOf("MSIE 4.5") != -1)
var MAC51 = (navigator.appVersion.indexOf("MSIE 5.1") != -1)
var ver4 = (NS4 || IE4);   
var isMac = (navigator.appVersion.indexOf("Mac") != -1);
var menuHeight=-22;
var menuOffset=258;
var overmenu = false;
var openmenu = 'quicklinks';
var overcheck = null;
var menulevel=0;

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];
    }
  } 
}

/* find an object by id */
function MM_findObj(n, d) { //v4.01
  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);
  if(!x && d.getElementById) x=d.getElementById(n); 
  return x;
}

/* Functions that swaps images. */
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];
    
    }
  }
}

/* Functions that swaps down images. */
function MM_nbGroup(event, grpName) { //v6.0
//alert(event + " " +grpName);

  var i,img,nbArr,args=MM_nbGroup.arguments;

//alert(args[0]);
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; 
    img.MM_up = args[3]; 
    img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) 
      if ((img = MM_findObj(args[i])) != null) {
        //alert(img.src);
        if (!img.MM_up) img.MM_up = img.src;
        img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])?args[i+1] : img.MM_up);
        nbArr[nbArr.length] = img;
      }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) { 
      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; 
    }
  } else if (event == "down") {
    nbArr = document[grpName];

    if (nbArr) for (i=0; i < nbArr.length; i++) { 
        img=nbArr[i]; 
//    alert(img.src);        
        img.src = img.MM_up; img.MM_dn = 0; 
    }
    document[grpName] = nbArr = new Array();

    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
   
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = (args[i+1]) ? args[i+1] : img.MM_up;
      nbArr[nbArr.length] = img;
  } }
}

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 disableOnMouseOut(target){
   
   var node = document;
   var tag = "a"  
   var allElements = node.getElementsByTagName(tag);
   var allElementsLength = allElements.length;
   var i;
   
   for (i = 0; i < allElementsLength; i++) {
      var thisElement = allElements[i];

      //alert("|"+thisElement.getAttribute("id")+"|");
      
      // this is a workaround or IE, Firefox returns null automatically if it doesn't exist
      idElement = thisElement.getAttribute("id")=='' ? null : thisElement.getAttribute("id");
      
      // only process rows that have an ID attribute      
      if (idElement!=null) {
         
        // if the img tag contains the specified target 
        if (idElement==target) {
          //alert(thisElement.onmouseout);
          thisElement.onmouseout=null;
          //alert(thisElement.onmouseout);
        };
      }
    }       

};

function setTopNavRowImageRoll(target){
   
   var node = document;
   var tag = "img"  
   var allElements = node.getElementsByTagName(tag);
   var allElementsLength = allElements.length;
   
   for (i = 0; i < allElementsLength; i++) {
      var thisElement = allElements[i];

      //alert("|"+thisElement.getAttribute("id")+"|");
      
      // this is a workaround or IE, Firefox returns null automatically if it doesn't exist
      idElement = thisElement.getAttribute("id")=='' ? null : thisElement.getAttribute("id");
      
      // only process rows that have an ID attribute      
      if (idElement!=null) {
         
        // if the img tag contains the specified target 
        if (idElement==target) {
            thisElement.src=eval(target+"_roll.src");
        };
      }
    }       

};

  function validDate(dateVal){
    var isValid=true;
    if(dateVal.length > 10){
       isValid = false;
    }
    else{
      for (i=0; i < dateVal.length; i++) {
         if(i==2 || i==5){
           if(dateVal.charAt(i) != "/"){
            i = dateVal.length;
            isValid = false;
           }
         }
         else if ((dateVal.charAt(i) < "0") || (dateVal.charAt(i) > "9") ){
            i = dateVal.length;
            isValid = false;           
         }
      }
    } 
    return isValid
  }


function setTopNavRowImageNorm(target){
   
   var node = document;
   var tag = "img"  
   var allElements = node.getElementsByTagName(tag);
   var allElementsLength = allElements.length;
   
   for (i = 0; i < allElementsLength; i++) {
      var thisElement = allElements[i];

      //alert("|"+thisElement.getAttribute("id")+"|");
      
      // this is a workaround or IE, Firefox returns null automatically if it doesn't exist
      idElement = thisElement.getAttribute("id")=='' ? null : thisElement.getAttribute("id");
      
      // only process rows that have an ID attribute      
      if (idElement!=null) {
         
        // if the img tag contains the specified target 
        if (idElement==target) {
            thisElement.src=eval(target+"_norm.src");
        };
      }
    }       

};

function setAllTopNavRowImages(target){
   
   var node = document;
   var tag = "img"  
   var allElements = node.getElementsByTagName(tag);
   var allElementsLength = allElements.length;
   
   for (i = 0; i < allElementsLength; i++) {
      var thisElement = allElements[i];

      //alert("|"+thisElement.getAttribute("id")+"|");
      
      // this is a workaround or IE, Firefox returns null automatically if it doesn't exist
      idElement = thisElement.getAttribute("id")=='' ? null : thisElement.getAttribute("id");
      
      // only process rows that have an ID attribute      
      if (idElement!=null) {
         
        // if the img tag contains the specified target 
        if (idElement!=target) {
          //alert("<> " + eval(idElement+"_norm.src"));
          thisElement.src=eval(idElement+"_norm.src");
        } else {
          //alert("= " + eval(target+"_roll.src"));
          thisElement.src=eval(target+"_roll.src");
        };
        
      }
    }       

};
function toggleNavRow(target){

   var node = document;
   var tag = "tr"  
   var allElements = node.getElementsByTagName(tag);
   var allElementsLength = allElements.length;
   var i;
   
   for (i = 0; i < allElementsLength; i++) {
      var thisElement = allElements[i];

      //alert("|"+thisElement.getAttribute("id")+"|");
      
      // this is a workaround or IE, Firefox returns null automatically if it doesn't exist
      idElement = thisElement.getAttribute("id")=='' ? null : thisElement.getAttribute("id");
      
      // only process rows that have an ID attribute      
      if (idElement!=null) {
      
        // if the TR line contains the specified target, hide it,
        // otherwise show it
        if (idElement!=target) {
          thisElement.style.display="none";
        } else {
          thisElement.style.display="";
        };
        
      }
    }       

};

function PopUp(newRef,dLeftPoint,dTopPoint,width,height) {
  var MyUrl=newRef;
  var MyWindowName = 'myWindow';
  var maxWidth = window.screen.availWidth;
  var maxHeight = window.screen.availHeight;
  
  var leftPoint = dLeftPoint;
  var topPoint = dTopPoint; 
  var windowWidth = width;
  var windowHeight = height;
    
  if (topPoint == "NA")
    topPoint = 20;
    
  if (leftPoint == "NA" && width == "NA")
    leftPoint = parseInt(maxWidth / 2);
  else if (leftPoint == "NA" && width != "NA")
    leftPoint = parseInt(maxWidth - width);
    
  if (windowWidth == "NA")
    windowWidth = parseInt(maxWidth / 2);
    
  if (windowHeight == "NA") 
    windowHeight = parseInt(maxHeight * 0.75);    
    
  var MyWindow = window.open(MyUrl,MyWindowName,"height=" +windowHeight+",width="+windowWidth+",scrollbars=yes,alwaysRaised=yes,resizable=yes,top="+topPoint+",left="+leftPoint);
  MyWindow.focus(); 
}

function PopUpWithTitle(title,newRef,dLeftPoint,dTopPoint,width,height) {
  var MyUrl=newRef;
  var MyWindowName = title;
  var maxWidth = window.screen.availWidth;
  var maxHeight = window.screen.availHeight;
  
  var leftPoint = dLeftPoint;
  var topPoint = dTopPoint; 
  var windowWidth = width;
  var windowHeight = height;
    
  if (topPoint == "NA")
    topPoint = 20;
    
  if (leftPoint == "NA" && width == "NA")
    leftPoint = parseInt(maxWidth / 2);
  else if (leftPoint == "NA" && width != "NA")
    leftPoint = parseInt(maxWidth - width);
    
  if (windowWidth == "NA")
    windowWidth = parseInt(maxWidth / 2);
    
  if (windowHeight == "NA") 
    windowHeight = parseInt(maxHeight * 0.75);    
    
  var MyWindow = window.open(MyUrl,MyWindowName,"height=" +windowHeight+",width="+windowWidth+",scrollbars=yes,alwaysRaised=yes,resizable=yes,top="+topPoint+",left="+leftPoint);
  MyWindow.focus(); 
}

function PopUpCheck(newRef,dLeftPoint,dTopPoint,width,height,popUp) {
if ((popUp == null || popUp != "Y") && (newRef != "")){
   PopUp(newRef,dLeftPoint,dTopPoint,width,height);
}
}
  
function newFullWindow(url) {
  var MyWindow = window.open(url,"myWindow","height=600,width=800,scrollbars=yes,alwaysRaised=yes,resizable=yes,location=yes,menubar=yes,toolbar=yes");
  MyWindow.focus(); 
}
function newSmallerWindow(url) {
  var MyWindow = window.open(url,"myWindow","height=500,width=700,scrollbars=yes,alwaysRaised=yes,resizable=yes,location=yes,menubar=yes,toolbar=yes");
  MyWindow.focus(); 
}
function flashWindow(url) {
  var MyWindow = window.open(url,"myWindow","height=500,width=700,scrollbars=yes,alwaysRaised=yes,resizable=yes,location=yes,menubar=yes,toolbar=yes");
  MyWindow.focus(); 
}
 
function signUpEmail(form) {
  var valid = validEmail(form.emailAddress.value)
    if (!valid) {
    alert("Please verify your email address.  It must be of the form name@domain.ext")
    form.emailAddress.focus();
  }
  else {
    var url = "mailListMessage.jsp?emailAddress="+form.emailAddress.value +
                                  "&mlname=" + form.mlname.value +
                                  "&mlnbr=" + form.mlnbr.value +
                                  "&message=" + form.message.value +
                                  "&emailTo=" + form.emailTo.value;
    window.open(url,"new_window","height=300,width=600,location=no");
  }
}

function openWindow2() {
  var valid = validEmail(window.document.eForm.emailAddress.value)
    if (!valid) {
    alert("Please verify your email address.  It must be of the form name@domain.ext")
    window.document.eForm.emailAddress.focus();
  }
  else {
    var type
    if (window.document.eForm.emailType[0].checked == true)
      type = "html"
    else
      type = "text"
    var url = "mailListMessage.jsp?emailAddress="+window.document.eForm.emailAddress.value+"&emailType="+type+"&tid=LD01&tc=2";
    window.open(url,"new_window","height=230,width=485,location=no");
  }
}
function openInSameWindow() {
  var valid = validEmail(window.document.eForm.emailAddress.value)
    if (!valid) {
    alert("Please verify your email address.  It must be of the form name@domain.ext")
    window.document.eForm.emailAddress.focus();
  }
  else {
      var type
      if (window.document.eForm.emailType[0].checked == true)
        type = "html"
      else
        type = "text"
    var url = "mailListMessage.jsp?emailAddress="+window.document.eForm.emailAddress.value+"&emailType="+type+"&tid=LD01&tc=2";
    window.location = url;
  }
}

function popUpSmaller(url,title,sizePct){
 var newHeight=0;
 var newWidth=0;
 if (navigator.appName == "Netscape") {  
  newHeight = window.innerHeight * (sizePct / 100)
  newWidth = window.innerWidth * (sizePct / 100)
 } else {
  newWidth = document.body.clientWidth * ((sizePct+2) / 100)
  newHeight = document.body.clientHeight * ((sizePct-3) / 100)
 }
// use the following line for testing - then you will be able to see what page you are on when errors occur
// var newWindow = window.open(url,title,"height="+newHeight+",width="+newWidth+",scrollbars=yes,alwaysRaised=yes,menubar=yes,toolbar=yes,location=yes,resizable=yes,status=yes");
 var newWindow = window.open(url,title,"height="+newHeight+",width="+newWidth+",scrollbars=yes,alwaysRaised=yes,resizable=yes,status=yes");
 newWindow.focus();
}

 function trim(sData) {
    var sTrimmed = String(sData);
    sTrimmed = sTrimmed.replace(/(^[ |\t]+)|([ |\t]+$)/g, '');
  return sTrimmed;
}

function validEmail(email) {
  var the_at = email.indexOf("@")
   var after_the_at = email.substring(the_at+1,email.length)
  var the_dot = after_the_at.indexOf(".")
  var the_space = email.indexOf(" ")
    
   if ((the_at == -1) ||
     (the_at == 0) ||
    (the_dot <= 0) ||
    (the_dot >= after_the_at.length-1) ||
    (the_space != -1)) {
    return false
  }
  else {
    return true
  }
}

//the code below is from TribalGeneration.com  It works most of the time
//-----------------------------------------------------------------------
function menuOver(){
  overmenu=1;
}

function menuOut(){
  overmenu=0;
  if (IE4 || NS6 || NS4){
    menulevel=menulevel+1;
    setTimeout("menuOutTimer()",100);
  }
}

// Check to see if menu is open but not used, if so it is closed
function checkmenu (){ //openmenu,check
  if (overmenu == 0){
    if (NS6){
         menu=document.getElementById(openmenu+"layer");
    }
    else if (NS4){
         menu=eval("document.layers."+openmenu+"layer");
    }
    else{
         menu=eval(openmenu+"layer");
    }

    if (NS4){
      menu.visibility = "hide";
    }
    else{
      menu.style.visibility = "hidden";
    } 
  //  unswap_img(openmenu);
  }
}

function menuOutTimer(){
  menulevel=menulevel-1;
  if(menulevel==0) checkmenu();
}

function tocItem (name) {
  if(document.images){
    var thisUrl = document.location.href
//alert(thisUrl);
    var position = thisUrl.indexOf("html/");
    var section = thisUrl.substring(position+5,position+9);
    if (section == ("nph/") || section == ("qol/")){
      section = thisUrl.substring(position+5,position+8);
    }
  }
  this.on = new Image();
  this.on.src = "/vimedia/"+section+"/quickLinks.jpg"
  this.off = new Image();
  this.off.src = "/vimedia/"+section+"/quickLinks.jpg"
}

function toc_new (name) {
  tocItem[name] = new tocItem(name);
}

// Swap out image for mouseover event
function swap_img (imgName, openmenu){
  if (document.images) {
    if ((openmenu == null) || (IE4) || (NS6))
        document[imgName].src = tocItem[imgName].on.src
    else{
      image= eval("document.layers."+openmenu+"layer.document.images['"+imgName+"']");
      image.src = tocItem[imgName].on.src;
    }
  }
}

// Return to original image
function unswap_img (imgName, openmenu){
  if (document.images) {
    if ((openmenu == null) || (IE4) || (NS6))
       document[imgName].src = tocItem[imgName].off.src
    else{
        image= eval("document.layers."+openmenu+"layer.document.images['"+imgName+"']");
        image.src = tocItem[imgName].off.src;
    }
  }
}

if (document.images != null) {
toc_new('quicklinks');
}

// Find Position of Image File
function FindLeftEdge(img) {
        xPos = img.offsetLeft;
        tempEl = img.offsetParent;
        while (tempEl != null) {
                xPos += tempEl.offsetLeft;
                tempEl = tempEl.offsetParent;
        }
        return xPos ;
}

// Find Position of Image File
function FindTopEdge(img) {
        yPos = img.offsetTop;
        tempEl = img.offsetParent;
        while (tempEl != null) {
                yPos += tempEl.offsetTop;
                tempEl = tempEl.offsetParent;
        }
        if (MAC45) yPos=menuOffset;
    if (MAC51) yPos=menuOffset;
        return yPos ;
        }

function findloc (imgname)
{// Find Position of Image File
var holdingImage = document.images[imgname];
//var canvasLeft = (NS4 && !NS6) ? holdingImage.x +150 : FindLeftEdge(holdingImage)+150;
//var canvasTop = (NS4 && !NS6) ? holdingImage.y -22 : FindTopEdge(holdingImage)-22;
var canvasLeft = (NS4 && !NS6) ? holdingImage.x  : FindLeftEdge(holdingImage);
var canvasTop = (NS4 && !NS6) ? holdingImage.y : FindTopEdge(holdingImage);
var canvasWidth = holdingImage.width;
var canvasHeight = holdingImage.height;
return ([canvasLeft,canvasTop]);
}       
// Show Menu Layer
function showMenu(imgname) {
        if (NS6) 
             menu=document.getElementById(imgname+"layer")
        else if (NS4)
             menu=eval("document.layers."+imgname+"layer")
        else menu=eval(imgname+"layer");
        if (NS4) menu.visibility = "show"
        else menu.style.visibility = "visible"
        openmenu=imgname;
}

// Hide Menu Layer
function hideMenu() {
   if (openmenu != null){
        if (NS6) 
             menu=document.getElementById(openmenu+"layer")
        else if (NS4)
             menu=eval("document.layers."+openmenu+"layer")
        else menu=eval(openmenu+"layer");
        if (NS4) menu.visibility = "hide"
        else menu.style.visibility = "hidden"
   //     unswap_img(openmenu)
  }
}

// Pop Up Menu for QuickLinks
function popupQL (imgname){
overmenu=1;

    showMenu(imgname);
}

// half second timeout after mouse moves away from image or subnav in IE 
function menutimeout (openmenu){
  if (IE4 || NS6 || NS4){
    setTimeout("checkmenu()",100);
  }
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}
function tmt_findObj(n){
        var x,t; if((n.indexOf("?"))>0&&parent.frames.length){t=n.split("?");
        x=eval("parent.frames['"+t[1]+"'].document.getElementById('"+t[0]+"')");
        }else{x=document.getElementById(n)}return x;
}
// end of quickLinks functions

function setBook(book) {
  for (i=0; i<window.document.scriptureSearch.b.length; i++) {
    if (window.document.scriptureSearch.b.options[i].value == book) {
      window.document.scriptureSearch.b.options[i].selected = true
    }
  }  
}  
//---------------------------------slideshow--------------------------------------
/*==================================================*
 $Id: slideshow.js,v 1.16 2003/10/14 12:39:00 pat Exp $
 Copyright 2000-2003 Patrick Fitzgerald
 http://slideshow.barelyfitz.com/
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or
 (at your option) any later version.
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *==================================================*/
// There are two objects defined in this file:
// "slide" - contains all the information for a single slide
// "slideshow" - consists of multiple slide objects and runs the slideshow
//==================================================
// slide object
//==================================================
function slide(src,link,text,target,attr,credit,slideNbr) {
  // This is the constructor function for the slide object. It is called automatically when you create a new slide object.
  // For example: s = new slide();
  
  this.src = src;// Image URL
  this.link = link;// Link URL
  this.credit = credit;// photocredit to display
  this.slideNbr = slideNbr;// slideNbr dsc to display
  this.text = text;// Text to display
  this.target = target;// Name of the target window ("_blank")

  // Attributes for the target window:
  // width=n,height=n,resizable=yes or no,scrollbars=yes or no,
  // toolbar=yes or no,location=yes or no,directories=yes or no,
  // status=yes or no,menubar=yes or no,copyhistory=yes or no
  // Example: "width=200,height=300"
  this.attr = attr;

  if (document.images) {
    this.image = new Image();// Create an image object for the slide
  }

  this.loaded = false;// Flag to tell when load() has already been called

  //--------------------------------------------------
  this.load = function() {
    // This method loads the image for the slide
    if (!document.images) { return; }
    if (!this.loaded) {
      this.image.src = this.src;
      this.loaded = true;
    }
  }
  //--------------------------------------------------
  this.hotlink = function() {
    // This method jumps to the slide's link. If a window was specified for the slide, then it opens a new window.
    var mywindow;
    if (!this.link) return;// If this slide does not have a link, do nothing
    if (this.target) { // Open the link in a separate window?
      // If window attributes are specified, use them to open the new window
      if (this.attr) {
        mywindow = window.open(this.link, this.target, this.attr);
      } else {
        // If window attributes are not specified, do not use them (this will copy the attributes from the originating window)
        mywindow = window.open(this.link, this.target);
      }     
      if (mywindow && mywindow.focus) mywindow.focus(); // Pop the window to the front
    } else {
       location.href = this.link; // Open the link in the current window
    }
  }
}

//==================================================
// slideshow object
//==================================================
function slideshow( slideshowname ) {
  // This is the constructor function for the slideshow object.
  // It is called automatically when you create a new object. For example: ss = new slideshow("ss");

  // Name of this object (required if you want your slideshow to auto-play) For example, "SLIDES1"
  this.name = slideshowname;

  // When we reach the last slide, should we loop around to start the slideshow again?
  this.repeat = true;

  // Number of images to pre-fetch.
  // -1 = preload all images.
  //  0 = load each image is it is used.
  //  n = pre-fetch n images ahead of the current image.
  // I recommend preloading all images unless you have large
  // images, or a large amount of images.
  this.prefetch = -1;

  // Milliseconds to pause between slides. Individual slides can override this.
  this.timeout = 3000;

  // Hook functions to be called before and after updating the slide
  // this.pre_update_hook = function() { }
  // this.post_update_hook = function() { }

  // These are private variables
  this.slides = new Array();
  this.current = 0;
  this.timeoutid = 0;

  //--------------------------------------------------
  // Public methods
  //--------------------------------------------------
  this.add_slide = function(slide) {
    // Add a slide to the slideshow.  For example: SLIDES1.add_slide(new slide("s1.jpg", "link.html"))
    var i = this.slides.length;
    if (this.prefetch == -1) { // Prefetch the slide image if necessary
      slide.load();
    }
    this.slides[i] = slide;
  }

  //--------------------------------------------------
  this.play = function(timeout) {
    // This method implements the automatically running slideshow.
    // If you specify the "timeout" argument, then a new default timeout will be set for the slideshow.
  
    // Make sure we're not already playing
    this.pause();
  
    // If the timeout argument was specified (optional) then make it the new default
    if (timeout) {
      this.timeout = timeout;
    }
  
    // If the current slide has a custom timeout, use it;  otherwise use the default timeout
    if (typeof this.slides[ this.current ].timeout != 'undefined') {
      timeout = this.slides[ this.current ].timeout;
    } else {
      timeout = this.timeout;
    }

    // After the timeout, call this.loop()
    this.timeoutid = setTimeout( this.name + ".loop()", timeout);
  }

  //--------------------------------------------------
  this.pause = function() {
    // This method stops the slideshow if it is automatically running.
  
    if (this.timeoutid != 0) {
      clearTimeout(this.timeoutid);
      this.timeoutid = 0;
    }
  }

  //--------------------------------------------------
  this.update = function() {
    // This method updates the slideshow image on the page

    // Make sure the slideshow has been initialized correctly
    if (! this.valid_image()) { return; }
  
    // Call the pre-update hook function if one was specified
    if (typeof this.pre_update_hook == 'function') {
      this.pre_update_hook();
    }

    // Convenience variable for the current slide
    var slide = this.slides[ this.current ];

    slide.load();// Load the slide image if necessary
  
    // Update the image.
    this.image.src = slide.image.src;

   // Update the text
   this.display_slideNbr();
   this.display_credit();
   this.display_text();
   
    // Call the post-update hook function if one was specified
    if (typeof this.post_update_hook == 'function') {
      this.post_update_hook();
    }

    // Do we need to pre-fetch images?
    if (this.prefetch > 0) {

      var next, prev, count;

      // Pre-fetch the next slide image(s)
      next = this.current;
      prev = this.current;
      count = 0;
      do {
        // Get the next and previous slide number Loop past the ends of the slideshow if necessary
        if (++next >= this.slides.length) next = 0;
        if (--prev < 0) prev = this.slides.length - 1;

        // Preload the slide image
        this.slides[next].load();
        this.slides[prev].load();

        // Keep going until we have fetched
        // the designated number of slides

      } while (++count < this.prefetch);
    }
  }

  //--------------------------------------------------
  this.goto_slide = function(n) {
    // This method jumpts to the slide number you specify. If you use slide number -1, then it jumps to the last slide.
    // You can use this to make links that go to a specific slide, or to go to the beginning or end of the slideshow.
    // Examples:
    // onClick="myslides.goto_slide(0)"
    // onClick="myslides.goto_slide(-1)"
    // onClick="myslides.goto_slide(5)"
  
    if (n == -1) {
      n = this.slides.length - 1;
    }
    if (n < this.slides.length && n >= 0) {
      this.current = n;
    }
  
    this.update();
  }

  //--------------------------------------------------
  this.goto_random_slide = function(include_current) {
    // Picks a random slide (other than the current slide) and displays it.
    // If the include_current parameter is true,then See also: shuffle()

    var i;
    if (this.slides.length > 1) {// Make sure there is more than one slide

      // Generate a random slide number,
      // but make sure it is not the current slide
      do {
        i = Math.floor(Math.random()*this.slides.length);
      } while (i == this.current);
 
      // Display the slide
      this.goto_slide(i);
    }
  }

  //--------------------------------------------------
  this.next = function() {
    // This method advances to the next slide.

    // Increment the image number
    if (this.current < this.slides.length - 1) {
      this.current++;
    } else if (this.repeat) {
      this.current = 0;
    }

    this.update();
  }

  //--------------------------------------------------
  this.previous = function() {
    // This method goes to the previous slide.
    // Decrement the image number
    if (this.current > 0) {
      this.current--;
    } else if (this.repeat) {
      this.current = this.slides.length - 1;
    }
  
    this.update();
  }


  //--------------------------------------------------
  this.shuffle = function() {
    // This method randomly shuffles the order of the slides.

    var i, i2, slides_copy, slides_randomized;

    // Create a copy of the array containing the slides
    // in sequential order
    slides_copy = new Array();
    for (i = 0; i < this.slides.length; i++) {
      slides_copy[i] = this.slides[i];
    }

    // Create a new array to contain the slides in random order
    slides_randomized = new Array();

    // To populate the new array of slides in random order, loop through the existing slides, picking a random
    // slide, removing it from the ordered list and adding it to the random list.
    do {
      // Pick a random slide from those that remain
      i = Math.floor(Math.random()*slides_copy.length);

      // Add the slide to the end of the randomized array
      slides_randomized[ slides_randomized.length ] = slides_copy[i];

      // Remove the slide from the sequential array,
      // so it cannot be chosen again
      for (i2 = i + 1; i2 < slides_copy.length; i2++) {
        slides_copy[i2 - 1] = slides_copy[i2];
      }
      slides_copy.length--;
      // Keep going until we have removed all the slides
    } while (slides_copy.length);

    // Now set the slides to the randomized array
    this.slides = slides_randomized;
  }

  //--------------------------------------------------
  this.get_text = function() {
    // This method returns the text of the current slide
    return(this.slides[ this.current ].text);
  }
  //--------------------------------------------------
  this.get_credit = function() {
    // This method returns the photocredit of the current slide
    return(this.slides[ this.current ].credit);
  }
  this.get_slideNbr = function() {
    // This method returns the slideNbr of the current slide
    return(this.slides[ this.current ].slideNbr);
  }

  //--------------------------------------------------
  this.display_text = function(text) {
    if (!text) {
      text = this.slides[ this.current ].text;
    }
  
    // If a textarea has been specified, then change the text displayed in it
    if (this.text && typeof this.text.value != 'undefined') {
      this.text.value = text;
    }

    // If a text id has been specified, then change the contents of the HTML element
    if (this.textid) {

 // alert("text- "+text);
    r = this.getElementById(this.textid);
      if (!r) { return false; }
      if (typeof r.innerHTML == 'undefined') { return false; }   
      r.innerHTML = text;// Update the text
    }
   // trying to clean up for validation.  "Anonymous function does not always return a value."
   return false;
  }

   //--------------------------------------------------
  this.display_credit = function(credit) {
    if (!credit) {
      credit = this.slides[ this.current ].credit;
    }
  
    // If a textarea has been specified, then change the photocredit displayed in it
    if (this.credit && typeof this.credit.value != 'undefined') {
      this.credit.value = credit;
    }

    // If a text id has been specified, then change the contents of the HTML element
    if (this.creditid) {
      r = this.getElementById(this.creditid);
      if (!r) { return false; }
      if (typeof r.innerHTML == 'undefined') { return false; }   
      r.innerHTML = credit;// Update the photocredit
    }
   // trying to clean up for validation.  "Anonymous function does not always return a value."
   return false;
  }
     //--------------------------------------------------
  this.display_slideNbr = function(slideNbr) {
    if (!slideNbr) {
      slideNbr = this.slides[ this.current ].slideNbr;
    }
  
    // If a textarea has been specified, then change the text displayed in it
    if (this.slideNbr && typeof this.slideNbr.value != 'undefined') {
      this.slideNbr.value = slideNbr;
    }

    // If a text id has been specified, then change the contents of the HTML element
    if (this.slideNbrid) {
      r = this.getElementById(this.slideNbrid);
      if (!r) { return false; }
      if (typeof r.innerHTML == 'undefined') { return false; }   
      r.innerHTML = slideNbr;// Update the text
    }
    // trying to clean up for validation.  "Anonymous function does not always return a value."
    return false;
  }
 //--------------------------------------------------
  this.hotlink = function() {
    // This method calls the hotlink() method for the current slide.
    this.slides[ this.current ].hotlink();
  }

  //--------------------------------------------------
  this.save_position = function(cookiename) {
    // Saves the position of the slideshow in a cookie, so when you return to this page, the position in the slideshow  won't be lost.
    if (!cookiename) {
      cookiename = this.name + '_slideshow';
    }
    document.cookie = cookiename + '=' + this.current;
  }

  //--------------------------------------------------
  this.restore_position = function(cookiename) {
  // If you previously called slideshow_save_position(), returns the slideshow to the previous state.
  
    //Get cookie code by Shelley Powers
   if (!cookiename) {
      cookiename = this.name + '_slideshow';
   }
  
   var search = cookiename + "=";
  
   if (document.cookie.length > 0) {
      offset = document.cookie.indexOf(search);
      // if cookie exists
      if (offset != -1) { 
        offset += search.length;
        // set index of beginning of value
        end = document.cookie.indexOf(";", offset);
        // set index of end of cookie value
        if (end == -1) end = document.cookie.length;
        this.current = parseInt(unescape(document.cookie.substring(offset, end)));
     }
   }
  }

  //--------------------------------------------------
  this.noscript = function() {
    // This method is not for use as part of your slideshow,
    // but you can call it to get a plain HTML version of the slideshow images and text.
    // You should copy the HTML and put it within a NOSCRIPT element, to
    // give non-javascript browsers access to your slideshow information.
    // This also ensures that your slideshow text and images are indexed by search engines.
    $html = "\n";
  
    // Loop through all the slides in the slideshow
    for (i=0; i < this.slides.length; i++) {
      slide = this.slides[i];
      $html += '<P>';
      if (slide.link) {
        $html += '<a href="' + slide.link + '">';
      }
      $html += '<img src="' + slide.src + '" ALT="slideshow image">';
      if (slide.link) {
        $html += "<\/a>";
      }
      if (slide.text) {
        $html += "<BR>\n" + slide.text;
      }
       if (slide.credit) {
        $html += "<BR>\n" + slide.credit;
      }
       if (slide.slideNbr) {
        $html += "<BR>\n" + slide.slideNbr;
      }
      $html += "<\/P>" + "\n\n";
    }
  
    // Make the HTML browser-safe
    $html = $html.replace(/\&/g, "&amp;" );
    $html = $html.replace(/</g, "&lt;" );
    $html = $html.replace(/>/g, "&gt;" );
  
    return('<pre>' + $html + '</pre>');
  }

  //==================================================
  // Private methods
  //==================================================
  this.loop = function() {
    // This method is for internal use only. This method gets called automatically by a JavaScript 
    // timeout. It advances to the next slide, then sets the next timeout.
    // If the next slide image has not completed loading yet, then do not advance to the next slide yet.

    // Make sure the next slide image has finished loading
    if (this.current < this.slides.length - 1) {
      next_slide = this.slides[this.current + 1];
      if (next_slide.image.complete == null || next_slide.image.complete) {
        this.next();
      }
    } else { // we're at the last slide
      this.next();
    }
    this.play( );// Keep playing the slideshow
  }
  //--------------------------------------------------
  this.valid_image = function() {// Returns 1 if a valid image has been set for the slideshow
    if (!this.image){
      return false;
    }
    else {
      return true;
    }
  }

  //--------------------------------------------------
  this.getElementById = function(element_id) {
    // This method returns the element corresponding to the id

    if (document.getElementById) {
     return document.getElementById(element_id);
    }
    else if (document.all) {
    return document.all[element_id];
    }
    else if (document.layers) {
     return document.layers[element_id];
    } else {
    return undefined;
    }
  }

}
//---------------------------------end slideshow--------------------------------------





//---------------------------------drop down--------------------------------------
 function toggleDropDownMenu(sublink) {
     
     if(document.getElementById(sublink).style.visibility == 'hidden' || 
        document.getElementById(sublink).style.visibility == '')
          document.getElementById(sublink).style.visibility = 'visible';
     else
          document.getElementById(sublink).style.visibility = 'hidden';
}

 function showDropDownMenu(sublink) {
    document.getElementById(sublink).style.visibility = 'visible';
}

function hideDropDownMenu(sublink) {
    document.getElementById(sublink).style.visibility = 'hidden';
}
//---------------------------------end drop down--------------------------------------


// Generates a pop-up window containing an embed statement.
// Embed is deprecated in HTML 4.01
// Call from a link: href="javascript:embedStream('url', width, height)"
function embedStream (url, width, height) 
{

   //  If null or 0 dimensions, provide defaults.
   if ((width == 0) || (width == null)) 
        width = 300;
   if ((height == 0) || (height == null))
        height = 300;
   
   // Determine the embed type to use. 
   // Use fixed dimensions for realaudio console.
   if ((url.lastIndexOf(".ra") != -1) || (url.lastIndexOf(".rm") != -1)){
     fileType = "audio/x-pn-realaudio-plugin";
   }
   else if (url.lastIndexOf(".wmv") != -1) {
     fileType = "video/x-ms-wmv";
   }
   else if (url.lastIndexOf(".mov") != -1) {
     fileType = "video/quicktime";
   }

   if (!(url.lastIndexOf(".rm") != -1)){
        var win = window.open("", "win", "width=" + width + ",height=" + height); // 
        win.document.open("text/html", "replace");
        win.document.write("<HTML><HEAD><TITLE>Media Viewer</TITLE></HEAD><BODY>");
        win.document.write("<embed src=\"" + url + "\" autostart=\"true\"");
        win.document.write(" type='" + fileType + "'");
        width = width - 20;
        height = height - 10;
        win.document.write(" width=" + width + " height=" + height + ">");
        win.document.write("</body></html>");
        win.document.close();
   } else {
        location.replace(url);
   }
}

function embedStreamB(url, fmtCd, typeCd, height, width) 
{
   var mediaTypeStr="";

   //  If null or 0 dimensions, provide defaults.
   if ((width == 0) || (width == null)) 
        width = 340;
   if ((height == 0) || (height == null))
        height = 340;

   if (fmtCd == "RM" || fmtCd == "RA" || fmtCd == "RV") {

       if (typeCd == "SND") {
         mediaTypeStr="audio/x-pn-realaudio-plugin"
       } else {
         mediaTypeStr="video/vnd.rn-realvideo"
       }
       
       var win = window.open("","little_stream_window","height=" + height +",width=" + width);

       win.document.open("text/html", "replace");

       win.document.writeln("<html><body>");
       win.document.writeln("<OBJECT ID=\"PlayerRMP\" type=\"" + mediaTypeStr + "\" CLASSID=\"clsid:cfcdaa03-8be4-11cf-b84b-0020afbbccfa\" width=" + width + " height=" + height + " >");
       win.document.writeln("<PARAM name=\"CONTROLS\" value=\"imagewindow,controlpanel\">");
       win.document.writeln("<PARAM name=\"SRC\" value=\"" + url + "\">");
       win.document.writeln("<PARAM name=\"AUTOSTART\" value=\"true\">");
       win.document.writeln("<EMBED name=\"playerRMP\" src=\"" + url + "\" type=\"" + mediaTypeStr + "\" width=" + width + " height=" + height + " nojava=\"true\"");
       win.document.writeln(" AUTOSTART=\"true\"");
       win.document.writeln(" CONTROLS=\"imagewindow,controlpanel\"");
       win.document.writeln(" CONSOLE=\"one\">");
       win.document.writeln("</object>");
       win.document.writeln("</body></html>"); 
       win.document.close(); 
     } else if (fmtCd=="WMV" || fmtCd=="WMA" || fmtCd=="AVI") {

            var win = window.open("","little_stream_window","height="+height+",width="+width+",resizeable=yes");
            win.document.open("text/html", "replace");
            win.document.writeln("<html><body>");
            win.document.writeln("<OBJECT ID=\"PlayerWM\" CLASSID=\"CLSID:22d6f312-b046-11d0-94ab-008c74c7e95\" TYPE=\"application/x-oleobject\" width=" + width + " height=" + height + " >");
            win.document.writeln("<PARAM NAME=\"filename\" VALUE=\"" + url + "\">");
            win.document.writeln("<PARAM NAME=\"AUTOSTART\" VALUE=\"true\">");
            win.document.write("<EMBED name=\"playerwm\" TYPE=\"application/x-mplayer2\" width=" + width + " height=" + height + " ");
            win.document.write(" SRC=\"" + url + "\"");
            win.document.write(" AUTOSTART=\"true\"></embed>");
            win.document.write(" </object>");
            win.document.writeln("</body></html>"); 
            win.document.close(); 
     }
     else if (fmtCd=="MOV" || fmtCd=="QT" || fmtCd=="MOO" || fmtCd=="MOOV") {
       if (typeCd == "SND") {
         mediaTypeStr="audio/quicktime"
         height=20
         width=400
       } else mediaTypeStr="video/quicktime"
            var win = window.open("","little_stream_window","height="+height+",width="+width);
            win.document.open("text/html", "replace");
            win.document.writeln("<html><body>");
            win.document.writeln("<OBJECT id=\"PlayerQT\" CLASSID=\"clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B\" width=" + width + " height=" + height + " >");
            win.document.writeln("<PARAM name=\"SRC\" VALUE=\"" + url + "\">");
            win.document.writeln("<PARAM name=\"AUTOPLAY\" VALUE=\"true\">");
            win.document.writeln("<PARAM name=\"CONTROLLER\" VALUE=\"true\">");
            win.document.writeln("<EMBED TYPE=\"" + mediaTypeStr + "\"");
            win.document.writeln(" SRC=\"" + url + "\" width=" + width + " height=" + height + " enablejavascript=\"true\"");
            win.document.writeln(" AUTOPLAY=\"true\"");
            win.document.writeln(" pluginspage=\"www.apple.com/quicktime/download\">");
            win.document.writeln("</object>");
            win.document.writeln("</body></html>"); 
            win.document.close(); 
      } 
      
}

function validateTellAFriendForm(form) {
    var is_valid = true
    if (form.toEmail.value == "") {
      alert("You must enter a recipients email address.")
      form.toEmail.focus()
      is_valid = false
    } 
    else if  (form.toName.value == "") {
      alert("You must enter the recipient's name.");
      form.toName.focus()
      is_valid = false
    } 
    else if (form.fromEmail.value == "") {
      alert("Please enter your email address.")
      form.fromEmail.focus()
      is_valid = false
    } 
    else if (form.fromName.value == "") {
      alert("You must enter your name.");
      form.fromName.focus()
      is_valid = false
    }
    else {    
      var the_at = form.fromEmail.value.indexOf("@")
      var after_the_at = form.fromEmail.value.substring(the_at+1,form.fromEmail.value.length)
      var the_dot = after_the_at.indexOf(".")
      var after_the_dot = form.fromEmail.value.substring(the_dot+1,after_the_at.length)
      var the_space = form.fromEmail.value.indexOf(" ")
        
      var the_at2 = form.toEmail.value.indexOf("@")
      var after_the_at2 = form.toEmail.value.substring(the_at2+1,form.toEmail.value.length)
      var the_dot2 = after_the_at2.indexOf(".")
      var after_the_dot2 = form.toEmail.value.substring(the_dot2+1,after_the_at2.length)
      var the_space2 = form.toEmail.value.indexOf(" ")
      if ((the_at == -1) ||
          (the_at == 0) ||
          (the_dot <= 0) ||
          (after_the_dot.length <=0) ||
          (the_space != -1)) {
        alert("Please verify your email address.  It must be of the form name@domain.ext")
        form.fromEmail.focus()
        is_valid = false
      }
      else if ((the_at2 == -1) ||
               (the_at2 == 0) ||
               (the_dot2 <= 0) ||
               (after_the_dot2.length <= 0) ||
               (the_space2 != -1)) {
        alert("Please verify the email address to which you are sending this.  It must be of the form name@domain.ext")
        form.toEmail.focus()
        is_valid = false
      }
    } 
    //return is_valid
    return is_valid
  }
  
  
  function checkMultipleEmails(email) {
    email.toEmail.value = trim(email.toEmail.value);
    var validForm = true;
        
    if (email.toEmail.value != null) {
      var new_line = 0
      var length_email = 0
      
      while(email.toEmail.value.indexOf("\n")>0) {
        new_line = 0
        length_email = 0  
        if (email.toEmail.value.indexOf("\n") > 0) 
          new_line = email.toEmail.value.indexOf("\n")
        if (email.toEmail.value.length > 0)
          length_email = email.toEmail.value.length
        email.toEmail.value = email.toEmail.value.substring(0,new_line)+" "+ email.toEmail.value.substring(new_line+1,length_email)
      }       
      while(email.toEmail.value.indexOf(",,")>0) {
        var commas = 0
        var leng = 0
        leng = email.toEmail.value.length
        commas = email.toEmail.value.indexOf(",,")
        email.toEmail.value = email.toEmail.value.substring(0,commas)+ email.toEmail.value.substring(commas+1,leng)
      }
      while(email.toEmail.value.indexOf(", ,")>0) {
        var commas = 0
        var leng = 0
        leng = email.toEmail.value.length
        commas = email.toEmail.value.indexOf(", ,")
        email.toEmail.value = email.toEmail.value.substring(0,commas)+ email.toEmail.value.substring(commas+2,leng)
      }     
      if (email.toEmail.value > " ") {
        var email_list = email.toEmail.value
        while(email_list > "") {
          var the_comma =  email_list.indexOf(",")
          if (the_comma <= 1) 
            email_addr = trim(email_list)
          else 
            email_addr = trim(email_list.substring(0,the_comma))
            
          var the_at = email_addr.indexOf("@")
          var after_the_at = email_addr.substring(the_at+1,email_addr.length)
          var the_dot = after_the_at.indexOf(".")
          var space = email_addr.indexOf(" ") 
          if (trim(email_addr)> " " &&
              ((the_at == -1) ||
              (the_at == 0) ||
              (the_dot <= 0) ||
              (the_dot >= email_addr.length-1) ||
              (space != -1)))
          {
            alert("Please verify the email address:"+email_addr+". \nIt must be of the form name@domain.ext with no spaces ")
            email.toEmail.focus()
            return false
          }
          if (the_comma <= 1) 
            email_list = ""
          else 
            email_list =  email_list.substring(the_comma+1,email_list.length)
        }     
      }  
    }   
    else if (email.toEmail.value == "") {
      alert("Please enter at least one e-mail address");
      email.toEmail.focus;
      validForm = false;
    }    
    return validForm
  }
  
  
     
  /*         
 function getInvNum(form) {
          var orderNumber = form.nbr.value;
          //alert(orderNumber);
          var invoiceNumber;
          
          //if there is an N, then it is a confirmation number
          //if it is only 7 digits long, then it is an order number
          
          if (orderNumber.length == 7) { 
              alert("case 2");
              invoiceNumber == orderNumber.concat("01")
          } else  {
              alert("case 3");
              invoiceNumber = orderNumber; 
          }
          
          form.nbr.value = invoiceNumber;
        //  return invoiceNumber;
}
  */
 
  
  function changeObjectDisplay(div_id, newDisplay) {
    var the_style;  
    the_style = document.getElementById(div_id);
    the_style.style.display = newDisplay;
  }
    
  function toggleObjectDisplay(div_id) {
    var the_style;  
    var newDisplay;
    the_style = document.getElementById(div_id);
    if (the_style.style.display == "")
      newDisplay = "none";
    else
      newDisplay = "";
      the_style.style.display = newDisplay;
  }
  
  function toggle(element) {
    var the_element;
    var the_style;
    the_element = document.getElementById(element);
    the_style = the_element.style.display;
    if (the_style == "")
      the_style = "none";
    else
      the_style = "";  
  }
    
  function increment (obj){
    obj.value++;
  }
  function decrement (obj){
    obj.value--;
  }
  
  function saveSectionFromMaint() {
    var myForm=document.forms.sectionForm;
    var section = new Section();
    section.catalog = myForm.catalog.value;
    section.id = myForm.id.value;
    section.parentId = myForm.parentId.value;
    section.desc = myForm.desc.value;
    section.status = myForm.status.value;
    section.ord = myForm.ord.value;
    saveSection(section, 'response');
    window.location = "sectionMaint.jsp";
  }
  
  function getSelectedId(tableId) {
    var table = dojo.widget.byId(tableId);
    var JSONrow = table.getSelectedData();
    var id = JSONrow.Id;
    return id;
  }
  
    function dojoRequest(file, divId){
        var docPane = dojo.widget.byId(divId);
  if (!file){
      docPane.setContent("Not Found.");
  }else{
      docPane.setUrl(file);
       }
    }  
  
  function foreach(array, fn) {
    var len = array.length;
    for (var n = 0; n < len; n++) 
      fn(array[n]);
  }
  
 
 /*
 
  Zebra-stripe a table and on hover for rows
  h/t http://www.mlwinter.pwp.blueyonder.co.uk/clj/easyrider/table.html
  
 */
 
 function getByTagName( o, tN ) {
      if( o ) {
        if( o.getElementsByTagName ) {
          return o.getElementsByTagName( tN );
        } else if( o.all && o.all.tags ) {
          return o.all.tags( tN );
        }
      }
      return null;
    }
 
  
  function stripeTable( tableId, stripeClass ) {
      var c = 0, t = document.getElementById( tableId ), tB = null;

      if( t ) {
        if( t.tBodies ) {
          tB = t.tBodies;
        } else {
          tB = getByTagName( t, 'TBODY' );
        }
      }
      if( tB ) {
        for( var b, r = null, i = 0, n = tB.length; i < n; ++i, r = null ) {
          if( b = tB[ i ]) {
            if( b.rows ) {
              r = b.rows;
            } else {
              r = getByTagName( b, 'TR' );
            }
          }
          if( r ) {
            for( var j = 0, m = r.length; j < m; ++j, ++c ) {
              if( !( c % 2 )) {
                r[ j ].className = stripeClass;
              }
            }
          }
        }
      }
    }

function setElementStyle( e, p, v ) {
      if( e ) {
        if( e.style ) {
          e.style[ p ] = v;
        } else {
          e[ p ] = v;
        }
      }
    }
    

    
 function initializeTableRowHover( tableId, foreCol, backCol ) {
      var t = document.getElementById( tableId ), tB = null;

      if( t ) {
        if( t.tBodies ) {
          tB = t.tBodies;
        } else {
          tB = getByTagName( t, 'TBODY' );
        }
      }
      if( tB ) {
        for( var b, r = null, i = 0, n = tB.length; i < n; ++i, r = null ) {
          if( b = tB[ i ]) {
            if( b.rows ) {
              r = b.rows;
            } else {
              r = getByTagName( b, 'TR' );
            }
          }
          if( r ) {
            for( var j = 0, m = r.length; j < m; ++j ) {
              r[ j ].onmouseover = showRowHover;
              r[ j ].onmouseout = hideRowHover;
            }
          }
        }
      }

      function hideRowHover() {
        setElementStyle( this, 'color', '' );
        setElementStyle( this, 'backgroundColor', '' );
      }
  
      function showRowHover() {
        setElementStyle( this, 'color', foreCol );
        setElementStyle( this, 'backgroundColor', backCol );
      }
    } 
 /*
 end Zebra-stripe a table and on hover for rows
 */
 
    /*
     Flash MP3 Player
     */
    
    function Mp3Player() {
        this.id;
        this.site;
    }
    
    var settings = new Mp3Player();
    settings.site = "nph";
    settings.id = "mp3player-flash-container";
    
    function updateStatus(elementId,valueStr) {
        if (elementId=='mp3player-pct') {
            var e=document.getElementById('mp3player-progress-bar');
            e.style.width=valueStr;
        } else {
            var e2=document.getElementById(elementId);
            if (valueStr=='disconnected') {
                valueStr='stopped';
            }
            e2.innerHTML = valueStr;
        }     
    }   

    function fl_play(id,mediaRef) {       
        var p = document.getElementById('mp3player-play-pause-img');
        var f = "javascript:fl_togglepause('" + id + "');";
        p.src = '/vimedia/' + settings.site + '/mp3player_pause.gif';
        document.getElementById('mp3player-play-pause-link').href=f;
        swfobject.getObjectById(id).js_play(mediaRef);
    }
            
    function fl_setPlay(id,mediaRef) {            
        var i = document.getElementById("mp3player-play-pause-img");
        i.src = "/vimedia/" + settings.site + "/mp3player_play.gif";
        var g = "javascript:fl_play('" + id + "','" + mediaRef + "');";
        document.getElementById("mp3player-play-pause-link").href = g;        
    }            

    function fl_stop(id) {
        var i = document.getElementById('mp3player-play-pause-img');
        i.src = '/vimedia/' + settings.site + '/mp3player_play_disabled.gif';
        swfobject.getObjectById(id).js_stop();
        document.getElementById('mp3player-play-pause-link').href='javascript:void(0);';            
    }

    function fl_togglepause(id) {      
        var h = "javascript:fl_togglepause('" + id + "');";
        var i = document.getElementById('mp3player-play-pause-link');
        i.href = h;
        var j = document.getElementById('mp3player-play-pause-img').src;
      
        if (j.indexOf('/vimedia/' + settings.site + '/mp3player_pause.gif') > 0) {
            j = '/vimedia/" + settings.site + "/mp3player_play.gif';
        } else {
            j = '/vimedia/" + settings.site + "/mp3player_pause.gif';
        }
        swfobject.getObjectById(id).js_togglepause();
    }
    
    function displayFormValues(formName)
    {
        var str = '';
        var elem = document.forms[formName].elements;
        for(var i = 0; i < elem.length; i++)
        {
            str += "Type:" + elem[i].type + "\n";
            str += "Name:" + elem[i].name + "\n";
            str += "Value:" + elem[i].value + "\n";
            str += "\n";
        } 
        alert(str);
    }
    
    var hFormSubmitted = 0;
    
    
    function submitHdrSearch()
    {
    	if (hFormSubmitted==0) {
    	document.getElementById("hdrQuery").value = document.getElementById("gcsQuery").value;
    	hFormSubmitted = 2;
    	document.forms.sForm.submit();
    	return false;
    	} else if (hFormSubmitted==1) {
        	document.getElementById("gcsRefine").value = document.getElementById("gcsQuery").value;
        	hFormSubmitted = 2;
        	document.forms.gcsSearch.submit();
        }
    	return false;
    }

    /*
     End Flash MP3 Player
     */
