////////////////////////////////////////
// Image Rollover functions
////////////////////////////////////////
// all images must be named [imageName] + [Off, Over, Down].[extension]
// all <img> tags must be named imageName.
var imagesA = new Array();

function loadImages(imageName, imagesPath, extension, x, y) 
{
   imagesA[imageName + "Off"] = new Image(x, y);
   imagesA[imageName + "Over"] = new Image(x, y);
   imagesA[imageName + "Off"].src = imagesPath + imageName + "Off" + "." + extension;
   imagesA[imageName + "Over"].src = imagesPath + imageName + "Over" + "." + extension;
}

function imageOver(imageName)
{
   if(document.images) {
      document.images[imageName].src = imagesA[imageName + "Over"].src;
   }
}

function imageOff(imageName)
{
   if(document.images) {
      document.images[imageName].src = imagesA[imageName + "Off"].src;
   }
}

////////////////////////////////////////
// slide show functions
////////////////////////////////////////
// the <img> tag where the slides are to be shown must be 
// the same as slideShowName.
var slides = new Array();
var slideIndex = 0;
var numberOfSlides = 0;

var autoSlideShow = true;
var slideShowName;
var slideShowInterval = 4000;

function addSlide(slidePath, slideFile) {
	slides[numberOfSlides] = slidePath + slideFile;
	numberOfSlides ++;
}

function addSlideInto(index, slidePath, slideFile) {
	if(index > numberOfSlides) {
		index = numberOfSlides;
	}
	slides[index] = slidePath + slideFile;
}

function initSlideShow(ssn) {
	slideIndex = 0;
	slideShowName = ssn;
	document.images[slideShowName].src = slides[0];
	adjustSlideFrame(slideShowName);
}

function nextSlide(slideShowName) {
	slideIndex++;
	if(slideIndex >= numberOfSlides) {
		slideIndex = 0;
	}
	document.images[slideShowName].src = slides[slideIndex];
	adjustSlideFrame(slideShowName);
}

function prevSlide(slideShowName) {
	slideIndex--;
	if(slideIndex < 0) {
		slideIndex = numberOfSlides - 1;
	}
	document.images[slideShowName].src = slides[slideIndex];
	adjustSlideFrame(slideShowName);
}

function loadSlide(slideShowName, index) {
	if((slideIndex >= 0) || (slideIndex < numberOfSlides)) {
		slideIndex = index;
		document.images[slideShowName].src = slides[slideIndex];
		adjustSlideFrame(slideShowName);
	}
}

function setAutoSlideShow() {
	if(autoSlideShow == false) {
		autoSlideShow = true;
		slideIndex++;
		runAutoSlideShow();
	} else {
		autoSlideShow = false;
	}
}

function runAutoSlideShow() {
	if(autoSlideShow) {
		if(slideIndex >= numberOfSlides) {
			slideIndex = 0;
		}
	document.images[slideShowName].filters["revealTrans"].apply();
		document.images[slideShowName].src = slides[slideIndex];
	document.images[slideShowName].filters["revealTrans"].play();
		adjustSlideFrame(slideShowName);
		window.setTimeout(runAutoSlideShow, slideShowInterval);
		slideIndex++;
	}
}

function adjustSlideFrame(slideShowName) {
	var width = document.images[slideShowName].width;
	var height = document.images[slideShowName].height;
	document.images[slideShowName + "Top"].width = width;
	document.images[slideShowName + "Top"].height = document.images[slideShowName + "TopLeft"].height;
	document.images[slideShowName + "Bottom"].width = width;
	document.images[slideShowName + "Bottom"].height = document.images[slideShowName + "BottomLeft"].height;
	document.images[slideShowName + "Left"].height = height;
	document.images[slideShowName + "Left"].width = document.images[slideShowName + "TopLeft"].width;
	document.images[slideShowName + "Right"].height = height;
	document.images[slideShowName + "Right"].width = document.images[slideShowName + "TopRight"].width;
	// resize and position transparent image
	document.images[slideShowName + "Image"].width = width;
	document.images[slideShowName + "Image"].height = height;
	//window.alert(document.slideImage.offsetTop + ":" + document.slideImage.offsetLeft);
}

///////////////////////////////////////////
// misc. page functions
///////////////////////////////////////////

// Automatic page forward
function pageForward(url) {
   location.assign(url);
}

// Page history functions
function historyBack(amount) 
{
   history.go(-(amount));
}

function historyForward(amount) 
{
   history.go(amount);
}


// Frame Killer functions
function frameKiller()
{
   if(top != self)
   {
      top.location = location;
   }
}


// Cursor set function
function setCursor(formName, fieldIndex)
{
   document.forms[formName].elements[fieldIndex].focus();
}


// Text Highlight function
function highlightText(formName, fieldIndex)
{
   document.forms[formName].elements[fieldIndex].focus();
   document.forms[formName].elements[fieldIndex].select();
}

// Internet Explorer / Netscape redirect
function explorerOrNetscape(iePage, netscapePage) {
	if(navigator.appName.indexOf("Microsoft") == 0) {
		location.assign(iePage);
	} else {
		location.assign(netscapePage);
	}
	//document.write(navigator.appName);
}

function loadPage(frame, path, page)
{
	window.document.main.location.href = path + page + ".html";
}
