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 + ")";
}

function shiftOpacity(id, millisec) {
	//if an element is invisible, make it visible, else make it ivisible
	if(document.getElementById(id).style.opacity == 0) {
		opacity(id, 0, 100, millisec);
	} else {
		opacity(id, 100, 0, millisec);
	}
}

function blendimage(divid, imageid, imagefile, millisec) {
	var speed = Math.round(millisec / 100);
	var timer = 0;
	
	//set the current image as background
	document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")";
	
	//make image transparent
	changeOpac(0, imageid);
	
	//make new image
	document.getElementById(imageid).src = imagefile;

	//fade in image
	for(i = 0; i <= 100; i++) {
		setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed));
		timer++;
	}
}

function currentOpac(id, opacEnd, millisec) {
	//standard opacity is 100
	var currentOpac = 100;
	
	//if the element has an opacity set, get it
	if(document.getElementById(id).style.opacity < 100) {
		currentOpac = document.getElementById(id).style.opacity * 100;
	}

	//call for the function that changes the opacity
	opacity(id, currentOpac, opacEnd, millisec)
}

function restartTimer () {

	timerID = setInterval('changePicture ()', 10000);

}

function stopTimer () {

	clearInterval (timerID);
	
}

function changePicture () {

	var tmp;
	
	currentPicID++;
	if (currentPicID + 1 > FrontPageAlbum.length)
		currentPicID = 0;
	pageno = 0;
	if (FrontPageAlbum.length < 4) {
		for (i = 0; i < 4 - FrontPageAlbum.length; i++) {
			pageno++
			document.getElementById("PageNo" + pageno).innerHTML = '<img src="images/spacer.gif" width="18" height="18" />'
		}
	}
	for (i = 0; i < FrontPageAlbum.length; i++) {
		pageno++
		if (i == currentPicID) {
			document.getElementById("PageNo" + pageno).innerHTML = '<a href="#" onclick="navigatePage (' + (i + 1) + '); return false;" onmouseover="navigatePage (' + (i + 1) + ', 1); return false;" onmouseout="restartTimer(); return false;"><img src="images/en/StoryAlbum/btn_photoShow_front_0' + (i + 1) + 'mo.gif" width="18" height="18" border="0" style="margin: 1px;" /></a>'
		}
		else {
			document.getElementById("PageNo" + pageno).innerHTML = '<a href="#" onclick="navigatePage (' + (i + 1) + '); return false;" onmouseover="navigatePage (' + (i + 1) + ', 1); return false;" onmouseout="restartTimer(); return false;"><img src="images/en/StoryAlbum/btn_photoShow_front_0' + (i + 1) + '.gif" width="18" height="18" border="0" style="margin: 1px;" /></a>'
		}
	}
	if (currentPicID > 0)
		document.getElementById("HeadlineBackward").innerHTML = '<a href="#" onclick="navigatePage(' + currentPicID + '); return false;"><img src="images/en/btn_main-back.png" width="12" height="50" border="0" /></a>'
	else
		document.getElementById("HeadlineBackward").innerHTML = '<img src="images/en/btn_main-backEnd.png" border="0" />';
	if (currentPicID + 1 != FrontPageAlbum.length)
		document.getElementById("HeadlineForward").innerHTML = '<a href="#" onclick="navigatePage(' + (currentPicID + 2) + '); return false;"><img src="images/en/btn_main-next.png" width="12" height="50" border="0" /></a>'
	else
		document.getElementById("HeadlineForward").innerHTML = '<img src="images/en/btn_main-nextEnd.png" border="0" />';
	nextPicID = currentPicID + 1;
	if (nextPicID + 1 > FrontPageAlbum.length)
		nextPicID = 0;
	tmp = '<div id="HeadlineImage" style="filter: alpha(opacity=0); -moz-opacity: 0; opacity: 0; width: 458px;">';
	if (FrontPageAlbum[currentPicID][2] != '') {
		tmp = tmp + '<a href="' + FrontPageAlbum[currentPicID][2] + '" onmouseover="stopTimer (); return false;" onmouseout="restartTimer (); return false;"' + FrontPageAlbum[currentPicID][5] + '>' + FrontPageAlbum[currentPicID][0] + '</a>';
	}
	else {
		tmp = tmp + FrontPageAlbum[currentPicID][0];
	}
	if (FrontPageAlbum[nextPicID][4] != '')
		tmp = tmp + FrontPageAlbum[nextPicID][4];
	tmp = tmp + '</div>';
	document.getElementById("ImagePanel").innerHTML = tmp;
	document.getElementById("HeadlineSubject").innerHTML = '<a href="' + FrontPageAlbum[currentPicID][2] + '" onmouseover="stopTimer (); return false;" onmouseout="restartTimer (); return false;"' + FrontPageAlbum[currentPicID][5] + '>' + FrontPageAlbum[currentPicID][1] + '</a></div>';
	document.getElementById("HeadlineContent").innerHTML = FrontPageAlbum[currentPicID][3]
	currentOpac('HeadlineImage', 100, 1000);
	
}

function navigatePage (pageNum, stopFlag) {

	var tmp
	
	if (1 == 1) {
	if (currentPicID != pageNum - 1) {
		currentPicID = pageNum - 1;
		pageno = 0;
		if (FrontPageAlbum.length < 4) {
			for (i = 0; i < 4 - FrontPageAlbum.length; i++) {
				pageno++
				document.getElementById("PageNo" + pageno).innerHTML = '<img src="images/spacer.gif" width="18" height="18" />'
			}
		}
		for (i = 0; i < FrontPageAlbum.length; i++) {
			pageno++
			if (i == currentPicID) {
				document.getElementById("PageNo" + pageno).innerHTML = '<a href="#" onclick="navigatePage (' + (i + 1) + '); return false;" onmouseover="navigatePage (' + (i + 1) + ', 1); return false;" onmouseout="restartTimer(); return false;"><img src="images/en/StoryAlbum/btn_photoShow_front_0' + (i + 1) + 'mo.gif" width="18" height="18" border="0" style="margin: 1px;" /></a>'
			}
			else {
				document.getElementById("PageNo" + pageno).innerHTML = '<a href="#" onclick="navigatePage (' + (i + 1) + '); return false;" onmouseover="navigatePage (' + (i + 1) + ', 1); return false;" onmouseout="restartTimer(); return false;"><img src="images/en/StoryAlbum/btn_photoShow_front_0' + (i + 1) + '.gif" width="18" height="18" border="0" style="margin: 1px;" /></a>'
			}
		}
		if (currentPicID > 0) {
			document.getElementById("HeadlineBackward").innerHTML = '<a href="#" onclick="navigatePage(' + currentPicID + '); return false;"><img src="images/en/btn_main-back.png" width="12" height="50" border="0" /></a>'
		}
		else {
			document.getElementById("HeadlineBackward").innerHTML = '<img src="images/en/btn_main-backEnd.png" border="0" />';
		}
		if (currentPicID + 1 != FrontPageAlbum.length)
			document.getElementById("HeadlineForward").innerHTML = '<a href="#" onclick="navigatePage(' + (currentPicID + 2) + '); return false;"><img src="images/en/btn_main-next.png" width="12" height="50" border="0" /></a>'
		else
			document.getElementById("HeadlineForward").innerHTML = '<img src="images/en/btn_main-nextEnd.png" border="0" />';
		nextPicID = currentPicID + 1;
		if (nextPicID + 1 > FrontPageAlbum.length)
			nextPicID = 0;
		if (timerID != 0)
			stopTimer ();
//		document.getElementById("ImagePanel").innerHTML = '<div id="HeadlineImage" style="filter: alpha(opacity=0); -moz-opacity: 0; opacity: 0; width: 486px;"><a href="' + FrontPageAlbum[currentPicID][2] + '" onmouseover="stopTimer (); return false;" onmouseout="restartTimer (); return false;"><img src="' + FrontPageAlbum[currentPicID][0] + '" border="0" /></a><img src="' + FrontPageAlbum[nextPicID][0] + '" style="display:none;" /></div>';
		tmp = '<div id="HeadlineImage" style="filter: alpha(opacity=0); -moz-opacity: 0; opacity: 0; width: 458px;">';
		if (FrontPageAlbum[currentPicID][2] != '') {
			tmp = tmp + '<a href="' + FrontPageAlbum[currentPicID][2] + '" onmouseover="stopTimer (); return false;" onmouseout="restartTimer (); return false;"' + FrontPageAlbum[currentPicID][5] + '>' + FrontPageAlbum[currentPicID][0] + '</a>';
		}
		else {
			tmp = tmp + FrontPageAlbum[currentPicID][0];
		}
		if (FrontPageAlbum[nextPicID][4] != '')
			tmp = tmp + FrontPageAlbum[nextPicID][4];
		tmp = tmp + '</div>';
		document.getElementById("ImagePanel").innerHTML = tmp;
		document.getElementById("HeadlineSubject").innerHTML = '<a href="' + FrontPageAlbum[currentPicID][2] + '" onmouseover="stopTimer (); return false;" onmouseout="restartTimer (); return false;"' + FrontPageAlbum[currentPicID][5] + '>' + FrontPageAlbum[currentPicID][1] + '</a></div>';
		document.getElementById("HeadlineContent").innerHTML = FrontPageAlbum[currentPicID][3]
		currentOpac('HeadlineImage', 100, 1000);
		if (stopFlag == null)
			restartTimer ();
	}
	else {
		stopTimer ();
	}
	}

	if (1 == 0) {
	tmp = '<div id="HeadlineImage" style="filter: alpha(opacity=0); -moz-opacity: 0; opacity: 0; width: 458px;">';
//	if (FrontPageAlbum[currentPicID][2] != '') {
//		tmp = tmp + '<a href="' + FrontPageAlbum[currentPicID][2] + '" onmouseover="stopTimer (); return false;" onmouseout="restartTimer (); return false;"' + FrontPageAlbum[currentPicID][5] + '>' + FrontPageAlbum[currentPicID][0] + '</a>';
//	}
//	else {
		tmp = tmp + '<img src="/images/en/img_aaf_news_01_04232010.jpg" border="0" />';
//	}
//	if (FrontPageAlbum[nextPicID][4] != '')
//		tmp = tmp + FrontPageAlbum[nextPicID][4];
	tmp = tmp + '</div>';
	document.getElementById("ImagePanel").innerHTML = tmp;
	}
	
}

