/* ----------------------- initialise ---------- modified 25 May 2010 ---------------------- */
//
// ----------- initialise only once ------------------------------------------------------
var currentTop=null, currentBotm=null, isIE=false, useFade=false, scrollT=null;
function initL()
 { // get image div object refs
   currentTop=document.getElementById("imgDiv_1");    // global ref to div
   currentBotm=document.getElementById("imgDiv_2");   // global ref to div
//
// check for user agent type. IE first
   if(typeof currentTop.style.opacity=="undefined" && navigator.userAgent.indexOf("MSIE")!= -1)      // check for IE  
     { // IE opacity value reqd is 0-100
      // set initial opacity for both divs
       currentTop.style.filter = 'alpha(opacity=100)';     // visible
       currentBotm.style.filter = 'alpha(opacity=20)';      // invisible
       isIE=true;                                       // flag IE as browser
       useFade=true;                                    // flag fade can be used
     }
    else if(typeof currentTop.style.opacity=="string" && navigator.userAgent.indexOf("MSIE")== -1)    // check for not IE
     { // not IE  opacity value reqd is 0.0-1.0
      // set initial opacity for both divs
       currentTop.style.opacity = 1;                 // visible
       currentBotm.style.opacity = 0.2;                 // invisible  
       isIE=false;                                   // flag IE is not browser
       useFade=true;                                 // flag fade can be used
     }
    else
      { // not recognised. don't use opacity changes
       isIE=false;                                    // flag IE is not browser
       useFade=false;                                 // flag fade cannot be used
       alert("error");
       return false;
      }
/* ------------- temporarily removed -------------
 // slow scroll to show slideshow if not already moved
 if(document.body.scrollTop==0)
  { scrollT=setTimeout("scrollDwn()",4000); }
// ------------------------------
*/
   return true;
 }
// ----------- end init ---------------------------------------------------------------------------
// scroll home page down slowly
var cntDwn=0, scrollStarted=false;
 function scrollDwn()
  { //check if page scrolled manually
     if(scrollStarted==false && document.body.scrollTop>0){ return; }
     // -------------
    scrollStarted=true;
    cntDwn+=1;
    scrollTo(0,cntDwn);
    if(cntDwn>90) 
      { cntDwn=null; return;  }
    else
      { scrollT=setTimeout("scrollDwn()",30);  }
  }
// -----------------------
//
//var allImages=["new2.jpg","new3.jpg","new1.jpg"];  // global images references are installed in page
// ------------------------------------
// stepF is opacity steps, dwell is wait between opacity step changes
 var stepF=2, dwell=60;            
 var imgPointer= -1, currentTopRef=null, currentBotmRef=null;  
 var fadeOutHi, fadeOutLow, fadeInHi, fadeInLow;  // global 
 var count=0;              
// ------------------------
var startTime=null, endTime=null;
 function main()
  {// load next bottom image
     imgPointer=(imgPointer<(allImages.length-1))?imgPointer+1: 0;    
     currentBotm.innerHTML='<img src="images/'+allImages[imgPointer]+'" onload="setTimeout(\'fadeInit()\',50)" width="300" height="450">\n';  
  }
// -------    
// fade top out, fade bottom in
 function fadeInit()
  {  fadeOutHi=100; fadeOutLow=16-stepF; fadeInHi=96+stepF; fadeInLow=0;
     count=0;
     fade();  
  }
// ---------
// -------- start fade ---------------------
// opacity value is 0-1 for non-IE and 0-100 for IE
 var count=null, fadeTO=null;
//
 function fade()
  {  ++count;
     if(count>(100/stepF))
      {// after fade processing 
        clearTimeout(fadeTO);
        afterFade(); 
        return;   }
    // ---------- 
    // change opacity of both images
     fadeOutHi=fadeOutHi-stepF;
     fadeOutHi=(fadeOutHi<=0)?0 : fadeOutHi;     
     setOpacity(1,currentTop,fadeOutHi);
    //
     fadeInLow=fadeInLow+stepF;
     fadeInLow=(fadeInLow>=100)?100 : fadeInLow;
     setOpacity(2,currentBotm,fadeInLow); 
    // call fade again 
     fadeTO=setTimeout("fade()",dwell);    
  }
// ---------
/* ============= set opacity here  ================ */
//
function setOpacity(numb,obj,value)
  { if(isIE==true) 
     { // IE opacity value reqd is 0-100
       obj.style.filter = 'alpha(opacity='+value+')';   
     }
    else 
     { // not IE  opacity value reqd is 0-1
       obj.style.opacity = value/100;
     }
  }
/* ============= end set opacity  ================ */
//
// when fade has finished
 function afterFade()
  { // move bottom to top after fade
     currentTop.style.zIndex=3;
     currentBotm.style.zIndex=5;
 // change obj refs   
     currentTopRef=(currentTop.id=="imgDiv_1")?"imgDiv_2":"imgDiv_1";
     currentTop=document.getElementById(currentTopRef);
     currentBotmRef=(currentTop.id=="imgDiv_1")?"imgDiv_2":"imgDiv_1";
     currentBotm=document.getElementById(currentBotmRef);
         
  // wait 5 secs between displayed pictures     
    setTimeout("main()",2000)
  }
// ------ end after Fade() ------ 


