window.onload = loadPage; 
var msgOpacity = 100; 
var theTimeout; 

var slides = new Array(); 


function loadPage() { 
     //build the array
     slides[0] = document.getElementById( 'slide_1' ); 
     slides[1] = document.getElementById( 'slide_2' ); 
     slides[2] = document.getElementById( 'slide_4' ); 
     slides[3] = document.getElementById( 'slide_3' ); 
     slides[4] = document.getElementById( 'slide_5' ); 
     slides[5] = document.getElementById( 'slide_6' ); 
     slides[6] = document.getElementById( 'slide_7' ); 
     slides[7] = document.getElementById( 'slide_8' ); 

     setTimeout( 'disolveSlide()', 2000 ); 

     // the mailing list functionality appears on all pages.
     attachJoinMailingList(); 

     //conditionally call the page specific attachHandlers function if it exists
     if ( typeof attachHandlers == 'function') {
          attachHandlers(); 
     } 
}

//-------------------------------------------------

function disolveSlide() {
     //this function is responsible for handl
     var theSlide = slides[0]; 
     

     if ( msgOpacity > -50 ) {
          var gbOpacity = ( msgOpacity - 5 ) /100; 

          theSlide.setAttribute( "style", " opacity: "+gbOpacity+";-ms-filter:\"progid:DXImageTransform.Microsoft.Alpha(Opacity="+msgOpacity+")\"; filter: progid:DXImageTransform.Microsoft.Alpha(Opacity="+msgOpacity+");"); 
 

          msgOpacity -=3; 

          if (msgOpacity < 10 ) {


               //reorder the deck
               slides.push(slides.shift());

               //reset the opacity on the last slide
               slides[7].setAttribute( "style", " opacity: 1;-ms-filter:\"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)\"; filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=100);"); 


               slides[0].style.zIndex = 8; 
               slides[1].style.zIndex = 7; 
               slides[2].style.zIndex = 6; 
               slides[3].style.zIndex = 5; 
               slides[4].style.zIndex = 4; 
               slides[5].style.zIndex = 3; 
               slides[6].style.zIndex = 2; 
               slides[7].style.zIndex = 1; 


               
               msgOpacity  = 100; 

               //dramatic pause between slides
               theTimeout = setTimeout("disolveSlide()", 4000 ); 
               return 1; 

          }  

     }
     theTimeout = setTimeout("disolveSlide()", 10 ); 
}

//-------------------------------------------------


function attachJoinMailingList() {

     // run the behavior to join the mailing list.
    
     
     var txtJoin = document.getElementById('txtJoinMailingList'); 
     txtJoin.setAttribute( 'dataType', 'ReqEmail'); 

 
     document.getElementById( 'btnJoinMailingList').onclick = function() {
          if ( validateForm( 'txtJoinMailingList') ) {


               var qString = 'email='+txtJoin.value; 

               var nextFunction = function () { }; 
               var aHandler = ajaxConfig("join_list", 'divJoinList',qString, nextFunction, true, true); 
               runQuery(aHandler);


          }
          



     }

     



}

