///---------------------------------------------------------------------------------
/// GetLayerStyle: return the layer's style object
/// Usage: 
///		- objectId		: the layer's ID
///---------------------------------------------------------------------------------
function GetLayerStyle(objectId) {
    // cross-browser function to get an object's style object given its id
    if(document.getElementById && document.getElementById(objectId)) {
	// W3C DOM
	return document.getElementById(objectId).style;
    } else if (document.all && document.all(objectId)) {
	// MSIE 4 DOM
	return document.all(objectId).style;
    } else if (document.layers && document.layers[objectId]) {
	// NN 4 DOM.. note: this won't find nested layers
	return document.layers[objectId];
    } else {
	return false;
    }
} // GetLayerStyle

///---------------------------------------------------------------------------------
/// ChangeObjectVisibility: change a specified object's visibility
/// Usage: 
///		- objectId		: the object's ID
///		- visible			: TRUE/FALSE
///---------------------------------------------------------------------------------
function ChangeObjectVisibility(objectId, visible) {
	// get a reference to the cross-browser style object and make sure the object exists
	var styleObject = GetLayerStyle(objectId);
	if(styleObject) {
		if (visible) styleObject.display = "block";
		else styleObject.display = "none";
		return true;
	} else {
		// we couldn't find the object, so we can't change its visibility
		return false;
	}
} // ChangeObjectVisibility

///---------------------------------------------------------------------------------
/// blendimage: fade in/out the image effect
///---------------------------------------------------------------------------------
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++; 
    } 
} 

///---------------------------------------------------------------------------------
/// initgallery: do all initial work 
///---------------------------------------------------------------------------------
var currImg = 0;
function initGallery(){
	if (photo_set.length==0) return;
	ChangeObjectVisibility('largeImg', true);
	ChangeObjectVisibility('img_desc_0', true);
	
	for (j = 0; j < photo_set.length; j++)
	{
		MM_preloadImages(photo_path+photo_set[j]);
	}
}

///---------------------------------------------------------------------------------
/// showImage: show an image specified by its index
///---------------------------------------------------------------------------------
function showImage(iPhoto){
	//-- hide the old image description and then show the new
	ChangeObjectVisibility('img_desc_'+currImg, false);
	ChangeObjectVisibility('img_desc_'+iPhoto, true);
	
	currImg = iPhoto;
	
	//-- fade the image
	if (document.all){
		var transVal = "blendTrans(Duration=1)";
		var transStr = "blendTrans";
		document.images.largeImg.style.filter=transVal;
		document.images.largeImg.filters.blendTrans.Apply();
	}
	document.images.largeImg.src = photo_path+photo_set[iPhoto];
	if (document.all) document.images.largeImg.filters.blendTrans.Play();
	if (window.photo_alt!=null){
		document.images.largeImg.alt = photo_alt[iPhoto];
		document.images.largeImg.title = photo_alt[iPhoto];
	}
}
