/**
* @author cuong.tran
* @email cuong.tran@enclaveit.com, cuongtranquoc@gmail.com
* @function Event photo album slide show
* @last update: 11 May 2010 
*/
var currentImageIndex = 0;
var ImageSlideDuration = 5000;
/*var thisBrowserIsIE = isIE();
function isIE(){
	var ua = navigator.userAgent.toLowerCase(); 
	return !((ua.indexOf("msie") != -1) && (ua.indexOf("opera") == -1) && (ua.indexOf("webtv") == -1)); 
};
*/
//change the opacity for different browsers
function site_changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    var m = opacity / 100;
    object.opacity = m; 
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
};
function fn_continueBlend(imageid, imagefile, millisec) {    
    var speed = Math.round(millisec / 100);
    var timer = 0;
    //make new image
    document.getElementById(imageid).src = imagefile;
    for (i = 0; i <= 100; i++) {
        setTimeout("site_changeOpac(" + i + ",'" + imageid + "')", (timer * speed));
        timer += 1;
    }
};
function site_blendimage(divid, imageid, imagefile, millisec) {    
    /*
	if (thisBrowserIsIE){
		//set the current image as background	
		document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")";
		//make image transparent
		site_changeOpac(0, imageid);
		window.setTimeout(function() {fn_continueBlend(imageid, imagefile, millisec);}, 100); // this fixes firefox flicker
	}else
	*/
	{	
		document.getElementById(imageid).src = imagefile;		
	}
};
function changePhotoImage() {
    currentImageIndex++;
    if (currentImageIndex > EventPhotoAlbum.EventImages.length - 1) {
        currentImageIndex = 0;
		prepareImageEnable = false;
    }      
    window.setTimeout(function() { changePhotoImage() }, ImageSlideDuration);
    preloadNext();
};
function preloadNext() {   
	site_blendimage(EventPhotoAlbum.containerID, EventPhotoAlbum.imageID, EventPhotoAlbum.EventImages[currentImageIndex], 1000);
};
/*--------------ONLOAD----------------*/
if (!window.firstCustImage) {
    window.firstCustImage = true;
    window.setTimeout(changePhotoImage, ImageSlideDuration);
}
preloadNext();
/*-----------------------------------*/    
