/* 
   MARS STOUT JavaScript Document 
   Edited by: William Martin
   Date:      2:33 PM 1/6/2005 - Changed function popUp(URL) and added function pleasewait() 
   Date:      4:26 PM 1/19/2005 - added show() and hide() 
*/

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}

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) { //v4.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);
  if(!x && document.getElementById) x=document.getElementById(n); 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];}
}

function popUp(URL) {
   day = new Date();
   id = day.getTime();
   eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=300,height=10,left=362,top=234');");
}

function pleasewait() {
   alert("Loading Data, Please Wait...")
   alert.setTimeout("self.close()", 250);
}

function popUpHelp(URL) {
   day = new Date();
   id = day.getTime();
   eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=1,resizable=1,width=700,height=550,left=0,top=0');");
}


//"Accept terms" form submission- By Dynamic Drive
//For full source code and more DHTML scripts, visit http://www.dynamicdrive.com
//This credit MUST stay intact for use

var checkobj

function agreesubmit(el){
   checkobj=el
   if (document.all||document.getElementById){
      for (i=0;i<checkobj.form.length;i++){  //hunt down submit button
         var tempobj=checkobj.form.elements[i]
         if(tempobj.type.toLowerCase()=="submit")
         tempobj.disabled=!checkobj.checked
      }
   }
}

function defaultagree(el){
   if (!document.all&&!document.getElementById){
      if (window.checkobj&&checkobj.checked)
         return true
         else{
      alert("Please read/accept terms to submit form")
         return false
      }
   }
}
/*  
Made by Martial Boissonneault © 2002-2003 http://getElementById.com/
May be used and changed freely as long as this msg is intact
Visit http://getElementById.com/ for more free scripts and tutorials.
*/
var ns4 = (document.layers);
var ie4 = (document.all && !document.getElementById);
var ie5 = (document.all && document.getElementById);
var ns6 = (!document.all && document.getElementById);

function show(id){
 // Netscape 4
 if(ns4){
  document.layers[id].visibility = "show";
  document.layers['showit'].visibility = "hide";
 }
 // Explorer 4
 else if(ie4){
  document.all[id].style.visibility = "visible";
  document.all['showit'].style.visibility = "hidden";
 }
 // W3C - Explorer 5+ and Netscape 6+
 else if(ie5 || ns6){
  document.getElementById(id).style.visibility = "visible";
  document.getElementById('showit').style.visibility = "hidden";
 }
}

function hide(id){
 // Netscape 4
 if(ns4){
  document.layers[id].visibility = "hide";
  document.layers['showit'].visibility = "show";
 }
 // Explorer 4
 else if(ie4){
  document.all[id].style.visibility = "hidden";
  document.all['showit'].style.visibility = "visible";
 }
 // W3C - Explorer 5+ and Netscape 6+
 else if(ie5 || ns6){
  document.getElementById(id).style.visibility = "hidden";
  document.getElementById('showit').style.visibility = "visible";
 }
}

/*
    YADM - Yet another dynamic menu
    written by Chris Heilmann (http://icant.co.uk)
    Please refer to the yadm homepage for updates: http://www.onlinetools.org/tools/yadm/
    Free for non-commercial use. Changes welcome, but no distribution without 
    the consent of the author.
*/
function yadm()
{

// Variables, change these in case you need to set other class names (mmhide_ for 
// contribute users for example)
    var parentClass='isParent';             //gets applied when the LI has a nested UL
    var activeParentClass='isActive';       //gets applied when the nested UL is visible
    var preventHoverClass='nohover';        //denotes a navigation that should not get any hover effects
    var indicateJSClass='dhtml';            //gets applied to the main navigation when Javascript is available
    var toHideClass='hiddenChild';          //gets applied to hide the nested UL
    var toShowClass='shownChild';           //gets applied to show the nested UL
    var currentClass='current';             //denotes the current active sub element and prevents collapsing
    var d=document.getElementById('nav');   //denotes the navigation element 

// if DOM is not available stop right here.
    if(!document.getElementById && !document.createTextNode){return;}

// if the navigation element is available, apply the class denoting DHTML capabilities
    if(d)
    {
        d.className+=d.className==''?indicateJSClass:' '+indicateJSClass;
        var lis,i,firstUL,j,apply;

// loop through all LIs and check which ones have a nested UL
        lis=d.getElementsByTagName('li');
        for(i=0;i<lis.length;i++)
        {
            firstUL=lis[i].getElementsByTagName('ul')[0]
// if there is a nested UL, deactivate the first nested link and apply the class to show 
// there is a nested list
            if(firstUL)
            {
                lis[i].childNodes[0].onclick=function(){return false;}
                lis[i].className+=lis[i].className==''?parentClass:' '+parentClass;
// check if there is a "current" element 
                apply=true;
                if(new RegExp('\\b'+currentClass+'\\b').test(lis[i].className)){apply=false;}
                if(apply)
                {
                    for(j=0;j<firstUL.getElementsByTagName('li').length;j++)
                    {
                        if(new RegExp('\\b'+currentClass+'\\b').test(firstUL.getElementsByTagName('li')[j].className)){apply=false;break}
                    }
                }
// if there is no current element, apply the class to hide the nested list
                if(apply)
                {
                    firstUL.className+=firstUL.className==''?toHideClass:' '+toHideClass;
// check if there is a class to prevent hover effects and only apply the function
// onclick if that is the case, otherwise apply it onclick and onhover
                    if(new RegExp('\\b'+preventHoverClass+'\\b').test(d.className))
                    {
                        lis[i].onclick=function(){doyadm(this);}
                    } else {
                        lis[i].onclick=function(){doyadm(this);}
                        lis[i].onmouseover=function(){doyadm(this);}
                        lis[i].onmouseout=function(){doyadm(null);}
                    }
// if there is a current element, define the list as being kept open and apply the 
// classes to show the nested list and define the parent LI as an active one
                } else {
                    lis[i].keepopen=1;
                    firstUL.className+=firstUL.className==''?toShowClass:' '+toShowClass;
                    lis[i].className=lis[i].className.replace(parentClass,activeParentClass);
                }
            }
        }
    }
// function to show and hide the nested lists and add the classes to the parent LIs
    function doyadm(o)
    {
        var childUL,isobj,swap;

// loop through all LIs of the navigation       
        lis=d.getElementsByTagName('li');
        for(i=0;i<lis.length;i++)
        {
            isobj=lis[i]==o;
// function to exchange class names in an object
            swap=function(tmpobj,tmporg,tmprep)
            {
                tmpobj.className=tmpobj.className.replace(tmporg,tmprep)        
            }
// if the current LI does not have an indicator to be kept visible
            if(!lis[i].keepopen)
            {
                childUL=lis[i].getElementsByTagName('ul')[0];
// check if there is a nested UL and if the current LI is not the one clicked on
// and exchange the classes accordingly (ie. hide all other nested lists and 
// make the LIs parent rather than active.
                if(childUL) 
                {   
                    if(new RegExp('\\b'+preventHoverClass+'\\b').test(d.className))
                    {
                        if(new RegExp('\\b'+activeParentClass+'\\b').test(lis[i].className))
                        {
                            swap(childUL,isobj?toShowClass:toHideClass,isobj?toHideClass:toShowClass);      
                            swap(lis[i],isobj?activeParentClass:parentClass,isobj?parentClass:activeParentClass);       
                        } else {
    
                            swap(childUL,isobj?toHideClass:toShowClass,isobj?toShowClass:toHideClass);      
                            swap(lis[i],isobj?parentClass:activeParentClass,isobj?activeParentClass:parentClass);       
                        }
                    } else {
                            swap(childUL,isobj?toHideClass:toShowClass,isobj?toShowClass:toHideClass);      
                            swap(lis[i],isobj?parentClass:activeParentClass,isobj?activeParentClass:parentClass);       
                    }
                } 
            }
        }
    }
}
window.onload=function()
{
    yadm();
    // add other functions to be called onload below
}
