var album = null;
var albumlink = new Array();
var adNum = 0;
var theTimer;
var loadCheckTimer = setTimeout("checkLoad()", 1000);

function initPhoto(){
	var valueDom = document.getElementById("activePhotoValue");
	var valueList = getLabelValue(valueDom);
	album = valueList.split(/,/gi);
}

function checkLoad() {
	var valueDom = document.getElementById("PhotoShow");
	if ( valueDom != null )
	{
		nextPhoto();
		clearTimeout(loadCheckTimer);
	}else{
		clearTimeout(loadCheckTimer);
		loadCheckTimer = setTimeout("checkLoad()", 1000);
	}
}

function getLabelValue( labelNode ){
	if (navigator.appName.indexOf("Netscape") != -1)
		return labelNode.textContent;
	else
		return labelNode.innerText;
}

function setTransition() {
    if (document.all) {
        albumrotator.filters.revealTrans.Transition = Math.floor(Math.random() * 23);
        albumrotator.filters.revealTrans.apply();
    }
}
function playTransition() {
    if (document.all) {
        albumrotator.filters.revealTrans.play();
    }
}
function nextPhoto() {
	if ( album == null )
		initPhoto();
			
    if (adNum < album.length - 1) {
        adNum++;
    } else {
        adNum = 0;
    }
    setTransition();
    document.images.albumrotator.src = album[adNum];
    playTransition();
   	clearTimeout(theTimer);
    theTimer = setTimeout("nextPhoto()", 6000);
}

function jump2url() {
    jumpUrl = albumlink[adNum];
    jumpTarget = "_blank";
    if (jumpUrl != "") {
        if (jumpTarget != "") {
            window.open(jumpUrl, jumpTarget);
        } else {
            location.href = jumpUrl;
        }
    }
}
function displayStatusMsg() {
    status = albumlink[adNum];
    document.returnValue = true;
}
function pausePlay() {
    clearTimeout(theTimer);
}

function stopPlay() {
    if (album.length > 0) {
        adNum = album.length - 1;
    }
    clearTimeout(theTimer);
}
function gotoPrevious() {
    adNum = adNum - 2;
    if ( adNum < 0 ){
    	adNum = album.length + adNum;
    }
    nextPhoto();
}
function gotoLast() {
    if (album.length - 1 > 0) {
        adNum = album.length - 2;
    }
    nextPhoto();
}


