// Global variables
var ss_numslides=0;
var ss_currentslide=0,ss_oldslide=4;
var ss_x = 0;
var ss_slides = new Array();

var ss_ie_TransparentTextDiv=null;		//IE Only: Used for transparent text div in IE
var ss_bIsIE = navigator.appName == "Microsoft Internet Explorer";

function ssMakeSlideShow() 
{
   // find all images with the class "slide"
   imgDivs=document.getElementsByTagName("div");
   for (i=0; i<imgDivs.length; i++) 
   {
      if (imgDivs[i].className != "slide") continue;
      ss_slides[ss_numslides]=imgDivs[i];
      // stack images with first slide on top
      if (ss_numslides==0) 
      {
         imgDivs[i].style.display='block';
      } 
      else 
      {
         //imgDivs[i].style.zIndex=0;
         imgDivs[i].style.display='none';
         
      }
     // imgDivs[i].onclick=ssNextSlide;
      
      ss_numslides++;
   } // end for loop
   
   //IE Only: We must keep track of the current slide's transparent text div
   ssIE_SetCurrentTextDiv();
   
} // end ssMakeSlideShow()

function ssNextSlide() 
{
   if(ss_bIsIE)
   {
   	//IE Only: Ensure that the old slide's transparent text is hidden before we switch it out
	ssIE_ShowCurrentTextDiv(false);
   }
  
   ss_oldslide = ss_currentslide;
   ss_currentslide++;
   if (ss_currentslide >= ss_numslides) ss_currentslide = 0;
   
   if(ss_bIsIE)
   {
   	//IE Only: Ensure that the new slide's transparent text is hidden when we switch it in.
   	//The text div will be displayed once the slide is fully visible
  	 ssIE_SetCurrentTextDiv();
  	 ssIE_ShowCurrentTextDiv(false);
   } 
   
   
   ssSetOpacity(10);
   ss_slides[ss_oldslide].style.display='none';
   ss_slides[ss_currentslide].style.display='block';
   ssfadeIn(20);
}
function ssfadeIn(opacity) 
{
  if (opacity <= 100) 
  {
       ssSetOpacity(opacity);
       opacity += 10;
       window.setTimeout("ssfadeIn(" +opacity+ ")", 100);
  }
  else
  {
  	//IE Only: Once slide is visible, ensure the text div is on and transparent
  	ssIE_ShowCurrentTextDiv(true);
  }
  
  
}

function ssSetOpacity(opacity) 
{

  opacity = (opacity == 100)?99.999:opacity;
  
  // IE/Win
  ss_slides[ss_currentslide].style.filter = "alpha(opacity:"+opacity+")";
  
  // Safari<1.2, Konqueror
  //obj.style.KHTMLOpacity = opacity/100;
  
  // Older Mozilla and Firefox
  //obj.style.MozOpacity = opacity/100;
  
  // Safari 1.2, newer Firefox and Mozilla, CSS3
  ss_slides[ss_currentslide].style.opacity = opacity/100;
}


function ssIE_SetCurrentTextDiv()
{
  //IE Only: Use current slide's text div as the current transparent text div
  if(!ss_bIsIE) return;
  var childDivs = ss_slides[ss_currentslide].getElementsByTagName("div");
  ss_ie_TransparentTextDiv=null;
   for (i=0; i<childDivs.length; i++) 
   {
      if (childDivs[i].className == "slideshowtext") 
      {
     	 ss_ie_TransparentTextDiv =childDivs[i];
     	 break;
      }
   }
   
   
}

function ssIE_ShowCurrentTextDiv(bShow)
{
	//IE Only:
	//IE is a pain. It does not handle opacity in nested divs when the parent also has its opacity set. 
	//To get it to work, we must disable the current slide's opacity filter while the text is displayed.
	//That hack is carried out here
	
	if(!ss_bIsIE || !ss_ie_TransparentTextDiv) return;
	if(bShow)
	{
		//disable current slides div's opacity and display transparent text
		ss_slides[ss_currentslide].filters[0].Enabled=false;
		ss_ie_TransparentTextDiv.style.display='block'; 
	}
	else
	{
		//Hide transparent text
		ss_ie_TransparentTextDiv.style.display='none'; 
	}
}


