// JavaScript Document

function findPage(target){
document.getElementById(target).className='selected';
	}


// DHTML SLIDESHOW SCRIPT
// Adriano Santi, 27 Sept. 2005




// This sets the dimensions of the slideshow - they must be the same as the dimensions you set for the slideshow div

var slidewidth = 456;
var slideheight = 192;

// This sets the speed of the fade-out - the higher the number, the slower it'll go

var fadespeed = 40;

// This defines for how many seconds an image displays before fading out.

var imagetime = 3;

// This defines the pre-loading text - use |loaded| to display the number of images loaded and |total| for the total number of images.

var preloadtext = '';




// DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU'RE DOING!

// Browser sniffing
var moz = (document.getElementById && !document.all) ? 1:0;
var safari = (navigator.userAgent.indexOf('AppleWebKit') >= 0) ? 1:0;
var ie = (document.getElementById && document.all) ? 1:0;

// Returns alpha value of a given object
function getAlpha(obj) {
if (moz) {
	currAlpha = document.getElementById(obj).style.opacity * 100;
	}
else if (safari) {
	currAlpha = document.getElementById(obj).style.opacity * 100;
	}
else if (ie) {
	currAlpha = document.getElementById(obj).filters.alpha.opacity;
	}
return currAlpha;
}

// Advances the slides
function switchImgs(index) {
slidecount = slides.length;
if (index == (slidecount -1)) {
	nextIndex = 0;
	}
else {
	nextIndex = index + 1;
	}
document.getElementById('slide').style.backgroundImage = 'url('+ slides[(index)] +')';
setTimeout("document.getElementById('slideshow').style.backgroundImage = 'url('+ slides[(nextIndex)] +')'",20);
setTimeout("fade('slide', nextIndex)",20);
setAlpha('slide',100);
}

// Sets the alpha of a given object
function setAlpha(obj, value) {
if (moz) {
	document.getElementById(obj).style.opacity = (value / 100);
	}
else if (safari) {
	document.getElementById(obj).style.opacity = (value / 100);
	}
else if (ie) {
	document.getElementById(obj).filters.alpha.opacity = value;
	}
}

imagetime = imagetime * 1000; // Converts user-set imagetime to miliseconds.
var fadeTimer = ''; // Assigned to the timeout for fading

// Fades slides 
function fade(obj, currIndex) {
theSlide = obj;
theIndex = currIndex
currAlpha = getAlpha('slide');
if (currAlpha > 0) {
	setAlpha('slide', (currAlpha - 5));
	fadeTimer = window.setTimeout("fade(theSlide, theIndex)",fadespeed);
	}
else {
	window.clearTimeout(fadeTimer);
	window.setTimeout("switchImgs(theIndex)",imagetime);
	}
}

function slideshow() {
	window.setTimeout("switchImgs(0)",imagetime);
	}


// Preloading block

var preload = new Array();
preload['loaded'] = new Array();
preload['loading'] = new Array();
var currCount = 0, slidetimer = '';

function initslideshow() {
	if (ie) {
		document.getElementById('slideshow').innerHTML = '<div id="slide" style="filter: alpha(Opacity: 100)"></div>';
		document.getElementById('slide').filters.alpha.opacity = 100;
		}
	else {
		document.getElementById('slideshow').innerHTML = '<div id="slide"></div>';
		document.getElementById('slide').style.opacity = 1;
		}
	document.getElementById('slide').style.width = document.getElementById('slideshow').offsetWidth +'px';
	document.getElementById('slide').style.height = document.getElementById('slideshow').offsetHeight +'px';
	document.getElementById('slideshow').style.background = 'url('+ slides[0] +')';
	for (i = 0; i < slides.length; i++) { 
		preload['loading'][i] = new Image();
		preload['loading'][i].src = slides[i];
		}
	for (i=0;i<preload['loading'].length;i++) {
		preload['loaded'][i] = false;
		}
	checkLoad();
	}

var loaderdiv = '<div id="loader" style="display: inline; width: 150px; font-family: Arial, Sans-serif; font-size: 11px; color: #683825; background: none; padding: 1px">|loadingtext|</div>';

function checkLoad() {
pt = preloadtext.replace('|loaded|', currCount);
pt = pt.replace('|total|', slides.length);
ld = loaderdiv.replace('|loadingtext|', pt);
document.getElementById('slide').innerHTML = ld;
if (currCount == preload['loading'].length) {
	document.getElementById('loader').style.display = 'none';
	slideshow();
	return
	}
for (i=0;i<preload['loading'].length;i++) {
	if (preload['loaded'][i] == false && preload['loading'][i].complete) {
		preload['loaded'][i] = true;
		currCount++;
		}
	}
slidetimer = setTimeout("checkLoad()",10);
}

//window.onload = function() {  }