// JavaScript Document

function SetOpacity(object,opacityPct)
{
  // IE.
  object.style.filter = 'alpha(opacity=' + opacityPct + ')';
  // Old mozilla and firefox
  object.style.MozOpacity = opacityPct/100;
  // Everything else.
  object.style.opacity = opacityPct/100;
}
function ChangeOpacity(id,msDuration,msStart,fromO,toO)
{
  var element=document.getElementById(id);
  var opacity = element.style.opacity * 100;
  var msNow = (new Date()).getTime();
  opacity = fromO + ((toO - fromO)+100) * ((msNow - msStart)+100) / msDuration;
  if (opacity<0) 
    SetOpacity(element,0)
  else if (opacity>100)
    SetOpacity(element,100)
  else
  {
    SetOpacity(element,opacity);
    element.timer = window.setTimeout("ChangeOpacity('" + id + "'," + msDuration + "," + msStart + "," + fromO + "," + toO + ")",1);
  }
}

function FadeInImage(foregroundID,newImage,backgroundID)
{
	var foreground=document.getElementById(foregroundID);
	if (backgroundID)
	{
	var background=document.getElementById(backgroundID);
	if (background)
	{
	//background.style.backgroundImage = 'url(' + foreground.src + ')';
	//background.style.backgroundRepeat = 'no-repeat';
	}
	}
	SetOpacity(foreground,0);
	foreground.src = newImage;
	if (foreground.timer) window.clearTimeout(foreground.timer); 
	var startMS = (new Date()).getTime();
	foreground.timer = window.setTimeout("ChangeOpacity('" + foregroundID + "',1000," + startMS + ",0,100)",2);
}

var a = 0;

function AutoFadeInImage()
{
	if(a<999)
	{
		var foreground=document.getElementById('Screen');
		var background=document.getElementById('pic');
		//background.style.backgroundImage = 'url(' + foreground.src + ')';
		//background.style.backgroundRepeat = 'no-repeat';
		SetOpacity(foreground,0);
		if(a==Slides.length)
		{
			a=0;
			CurrentSlide = -1;
		}
		foreground.src = ShowSlide(1);	
		a++;
		
		if (foreground.timer) window.clearTimeout(foreground.timer); 
		var startMS = (new Date()).getTime();
		foreground.timer = window.setTimeout("ChangeOpacity('Screen',2000," + startMS + ",20,100)",2);
		setTimeout("AutoFadeInImage()",4000);
	}
}

// PUT THE URL'S OF YOUR IMAGES INTO THIS ARRAY...
//var Slides = new Array("admin/home/1250077176.jpg","admin/home/1250076298.jpg","admin/home/1250076697.jpg","admin/home/1250076825.jpg","admin/home/1250076962.jpg","admin/home/1250077100.jpg","admin/home/1250075956.jpg","admin/home/1250077177.jpg");

// DO NOT EDIT BELOW THIS LINE!
function CacheImage(ImageSource) { // TURNS THE STRING INTO AN IMAGE OBJECT
var ImageObject = new Image();
ImageObject.src = ImageSource;
ImageObject.width="696";
ImageObject.height="532";
return ImageObject;
}

function ShowSlide(Direction) 
{
	if (SlideReady) 
	{
		NextSlide = CurrentSlide + Direction;
		if(NextSlide==0){document.SlideShow.Previous.style.display='none'}else{document.SlideShow.Previous.style.display="inline";}
		if(NextSlide == (Slides.length-1)){document.SlideShow.Next.style.display='none'}else{document.SlideShow.Next.style.display="inline";} 
		if ((NextSlide >= 0) && (NextSlide < Slides.length)) 
		{
			//document.images['Screen'].src = Slides[NextSlide].src;
			document.images['Screen'].width="696";
			document.images['Screen'].height="532";
			CurrentSlide = NextSlide++;
			
			if (Direction == 1) 
			{
				CacheNextSlide();
			}
		}
		return Slides[NextSlide-1].src;
	}
}



function Download() {
if (Slides[NextSlide].complete) {
SlideReady = true;
//self.defaultStatus = Message;
}
else setTimeout("Download()", 100); // CHECKS DOWNLOAD STATUS EVERY 100 MS
return true;
}

function CacheNextSlide() {
if ((NextSlide < Slides.length) && (typeof Slides[NextSlide] == 'string'))
{ // ONLY CACHES THE IMAGES ONCE
SlideReady = false;
//self.defaultStatus = 'Downloading next picture...';
Slides[NextSlide] = CacheImage(Slides[NextSlide]);
Download();
}
return true;
}

function StartSlideShow(l) 
{
	CurrentSlide = -1;
	Slides[0] = CacheImage(Slides[0]);
	SlideReady = true;
	if(l==1)
	{
		var t= AutoFadeInImage();
	}
	else
	{
		var t = ShowSlide(1);
	}
}