// vars
var imageDir;
var currentIndex = 0;
var imageCount = 5;
var interval = 3000;
var step = 0;
var fromImage;
var toImage;
var trans;
var transStepDur = 100;

function initTransitions(img1Id, img2Id, imgDir, imgCnt, intervalDuration, transStepDuration)
{

imageCount = imgCnt;

// get random start index
currentIndex = rand(imageCount);

imageDir = imgDir;
fromImage = document.getElementById(img1Id);
toImage = document.getElementById(img2Id);
fromImage.src = imageDir + getNextIndex() + '.jpg';
// assume previous load
//toImage.src = imageDir + currentIndex + '.jpg';
toImage.className = 'Fade10';
interval = intervalDuration * 1000;
transStepDur = transStepDuration * 1000;

// setup the first transition
window.setTimeout('doNextTransition()', interval);

}
function doTransition()
{

// set img
//toImage.src = imageDir + currentIndex + '.jpg';

// reset step
step = 0;

// do transition steps
trans = window.setInterval('doTransitionStep()', transStepDur);

}
function doTransitionStep()
{
// bump step
step++;

if(step <= 10)
{
fromImage.className = 'Fade' + (10 - step);
toImage.className = 'Fade' + step;
}
else
{

// clear this interval
window.clearInterval(trans);

// pre-load next image.
fromImage.src = imageDir + getNextIndex() + '.jpg';

// setup the next transition
window.setTimeout('doNextTransition()', interval);
}
}
function doNextTransition()
{
// swap
var temp = toImage;
toImage = fromImage;
fromImage = temp;

// update index
currentIndex = getNextIndex();

// do next transition
doTransition();
}
function getNextIndex()
{
if(currentIndex >= imageCount - 1)
{
return 0;
}
else
{
return currentIndex + 1;
}
}

rnd.today=new Date();
rnd.seed=rnd.today.getTime();

function rnd() {
rnd.seed = (rnd.seed*9301+49297) % 233280;
return rnd.seed/(233280.0);
};

function rand(number) {
return Math.ceil(rnd()*number);
};function showObjectById(id) {

var obj = null;

if (document.getElementById) {

obj = document.getElementById(id);
obj.style.visibility = 'visible';
}

return obj;

}

function showObject(obj) {

obj.style.visibility = 'visible';

return obj;

}

function showObject(obj) {

if (obj != null) {

obj.style.visibility = 'visible';

}

return obj;

}

function hideObjectById(id) {

var obj = null;

if (document.getElementById) {

obj = document.getElementById(id);
obj.style.visibility = 'hidden';

}

return obj;

}

function hideObject(obj) {

if (obj != null) {

obj.style.visibility = 'hidden';

}

return obj;

}

function getObjectById(id) {

var obj = null;

if (document.getElementById) {

obj = document.getElementById(id);

}

return obj;

}

function swapImageById(id, imageUrl)
{

var obj = document.getElementById(id);

if(obj != null && obj.src)
{

obj.src = imageUrl;

}

}

function openWindowOnChange(reset, ignoreIndex)
{

var list = event.srcElement;

if(list.selectedIndex != ignoreIndex && list.options.item(list.selectedIndex).value != "")
{

eval("window.open(" + list.options.item(list.selectedIndex).value + ")");

}

if(reset)
{

list.selectedIndex = 0;

}

}

function goToUrlOnChange(e)
{
var targ;
if (!e) var e = window.event;
if (e.target) targ = e.target;
else if (e.srcElement) targ = e.srcElement;
if (targ.nodeType == 3) // defeat Safari bug
	targ = targ.parentNode;
var list = targ;
window.location = list.options.item(list.selectedIndex).value;
}

