﻿
//////////////////////////////////////
//// show and hide submenus //////////
//////////////////////////////////////  


// define menu array
var menuArray = new Array('services', 'links')

function ShowHideMenu(menuNum)
{
    if (document.getElementById)
    {
      // loop through elements in array
      for (var counter = 0; counter < menuArray.length; counter++)
      {
          // get current menu
          var currMenu = document.getElementById(menuArray[counter])
          
          // currMenu is null
          if (currMenu == null)
          {
              return
          }
          
          
          ////////////////////////////////////////
          
         
          // hide menu(s) not clicked  - need to add 1 because counter starts at 1
          if(menuNum != counter + 1)
          {
              currMenu.style.display = 'none'
          }
          
          
          ////////////////////////////////////////
       
       
           // clicked menu
           else
           {
                // hide menu currently displayed
                if (currMenu.style.display == 'block')
                {
                    currMenu.style.display = 'none'
                }
                
                // show clicked menu
                else
                {
                    currMenu.style.display = 'block'
                }
           }
      }
    }
}
   
   
//////////////////////////////////////
/////////// cycle images /////////////
//////////////////////////////////////  
   

// create array of images
var CyclingImages = new Array("content/images/firstcyclingimage.jpg", "content/images/secondcyclingimage.jpg", "content/images/thirdcyclingimage.jpg", "content/images/fourthcyclingimage.jpg")

// current image
var CurrImage = 0

// image count
ImageCount = CyclingImages.length


// cycle through images
function CycleImages()
{
    if (document.images)
    {
       // cycle image
       CurrImage++
       
       // if no more images, go back to first image
       if (CurrImage == ImageCount)
       {
          CurrImage = 0
       }
       
       // get image
       document.cyclingimage.src = CyclingImages[CurrImage]
       
       // set cycling frequency
       setTimeout("CycleImages()", 3 * 1000)
    }
} 



//////////////////////////////////////
/////// fade and cycle images ////////
//////////////////////////////////////


// slide show speed
var SlideShowSpeed = 6000 //var SlideShowSpeed = 5000

// fade duration
var FadeDuration = 3 

// create array of images
var CyclingImages = new Array("header/images/firstcyclingimage.jpg",
                              "header/images/secondcyclingimage.jpg", 
                              "header/images/thirdcyclingimage.jpg",
                              "header/images/fourthcyclingimage.jpg",
                              "header/images/fifthcyclingimage.jpg",
                              "header/images/sixthcyclingimage.jpg",
                              "header/images/seventhcyclingimage.jpg",
                              "header/images/eighthcyclingimage.jpg"
                              )

// timeout
var timeout

// increment image
var IncrementImage = 0

// image count
var ImageCount = CyclingImages.length

// preload images
var PreLoad = new Array() 

for (i = 0; i < ImageCount; i++) 
{
    PreLoad[i] = new Image()
    PreLoad[i].src = CyclingImages[i]
}


////////////////////////////////////////////


function FadeAndCycleImages() 
{
    if (document.all) 
    {
        // apply filter
        document.images.cyclingimage.style.filter = "blendTrans(duration=2)"
        document.images.cyclingimage.style.filter = "blendTrans(duration=FadeDuration)"
        document.images.cyclingimage.filters.blendTrans.Apply()
    }

    // get image
    document.images.cyclingimage.src = PreLoad[IncrementImage].src
    
    // filter image
    if (document.all) 
    {
        document.images.cyclingimage.filters.blendTrans.Play()
    }

    // increment image 
    IncrementImage = IncrementImage + 1
    
    // check image count
    if (IncrementImage > (ImageCount - 1)) 
    {
        // back to first image
        IncrementImage = 0
    }
    
    // timeout
    timeout = setTimeout('FadeAndCycleImages()', SlideShowSpeed)
}



//////////////////////////////////////////////////////
///// opem new window for viewing external links /////
//////////////////////////////////////////////////////


var newWindow
var posX  // posX and posY used to locate the window 
var posY

function OpenExternalLinksWindow(document) 
{
    newWindow = window.open(document, "", "width=600,height=400,scrollbars,resizable") // No spaces between width and height
}


//////////////////////////////////////////////////////
///// opem new window for viewing pdf file ///////////
//////////////////////////////////////////////////////


var newWindow
var posX  // posX and posY used to locate the window 
var posY

function OpenPDFWindow(PDFfile) 
{
    newWindow = window.open(PDFfile, "", "width=750,height=400,scrollbars,toolbar,resizable") // No spaces between width and height
}