/* ****************************************
 * Image Array 
 * Format ...=["image path and filename", "image alternative text", "panel title", "link href", "link title"];
 **************************************** */

var arrImages = new Array();



arrImages[0]=["content/images/cust_include_list/fst_awards_09_winner.gif", "2009 FST Awards", "2009 FST Awards", "media/090326_FST_awards.pdf", "Read Press Release"];

arrImages[1]=["content/images/FST-Awards-shortlist-logo-2010.jpg","Financial Service Technology Awards 2010 Shortlisted", "2010 FST Awards"];





var c=0
var t
var arrLen = arrImages.length;						//Variable to store array length (number of items in array)
var arrSel = Math.floor(Math.random()*arrLen);		//Variable to store selected image - starts with Random Image


/* ****************************************
 * Updates image and title and calls fade effect functions
 **************************************** */
function fadePanel() {
	arrSel = arrSel + 1;
	if (arrSel == arrLen) {
		arrSel = 0;
	}

	document.getElementById('boxTitle').innerHTML = (arrImages[arrSel][2]);
	
	if (arrImages[arrSel][3] == "") {
		document.getElementById('fBoxItem').innerHTML = '<img id="boxImg">';
		document.getElementById('boxImg').src = (arrImages[arrSel][0]);
		document.getElementById('boxImg').alt = (arrImages[arrSel][1]);
	}
	else {
		document.getElementById('fBoxItem').innerHTML = '<a id="fBoxLink"><img id="boxImg"></a>';
		document.getElementById('boxImg').src = (arrImages[arrSel][0]);
		document.getElementById('boxImg').alt = (arrImages[arrSel][1]);
		document.getElementById('fBoxLink').href = (arrImages[arrSel][3]);
		document.getElementById('fBoxLink').title = (arrImages[arrSel][4]);
	}
	

	c=c+1;
	t=setTimeout("fadePanel()",4000);
	t=setTimeout("fadeIn()", 0);
	t=setTimeout("fadeOut()",2500);
}


/* ****************************************
 * Fade in panel
 **************************************** */
function fadeIn() {
	opacity('fBox', 0, 99, 1000);
}


/* ****************************************
 * Fade out panel
 **************************************** */
function fadeOut() {
	opacity('fBox', 99, 0, 1000);
}


/* ****************************************
 * Opacity function to change element opacity
 **************************************** */
function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
} 


/* ****************************************
 * change the opacity for different browsers
 **************************************** */
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
}

