
function photoAlbum(objName){
	this.objName = objName;
	this.pathThumbnail = '';
	this.pathImage = '';
	this.imageLoading = 'loading.gif';
	this.imageNames = new Array();
	this.fileloc = new Array();
	this.divIdImage = 'image';
	this.divIdPreview = 'preview';
	
	// Add photo
	this.addPhoto = function(fileNameImage, fileNameThumbnail, altTag){
		var fileNameThumbnail, fileNameImage, altTag;
		if(typeof(altTag) == "undefined" || altTag == ''){altTag = fileNameImage;}
		if(typeof(fileNameThumbnail) == "undefined" || fileNameThumbnail == ''){fileNameThumbnail = fileNameImage;}		
		this.imageNames[this.imageNames.length] = new Array(fileNameImage, fileNameThumbnail, altTag);	
	}
	
	// Create preview strip
	this.renderPreviwStrip = function(){
		var i, thumbnailStyle;
		var divLayer='';
		
		for(i=0; i<this.imageNames.length; i++) {
			
			// Detect Style
			if(i==this.imageNames.length){
				thumbnailStyle = '';
			} else {
				thumbnailStyle = '';
			}
			divLayer += '<div style="display:inline" onclick="javascript:' + this.objName + '.showImage(\'' + i + '\')"><img src="' + this.pathThumbnail + this.imageNames[i][1] + '" border="0" alt="' + this.imageNames[i][2] + '" style="white-space:nowrap;"/></div>';
		}
		
		document.getElementById(this.divIdPreview).innerHTML = '<div style="white-space:nowrap;">' + divLayer + '</div>';
		if(this.imageNames.length > 0){
			this.showImage(0);
		}
	}
	
	// Show Image
	this.showImage = function(i){
		
		var i;		
		var a = this.imageNames[i][2];
		var result = a.search(/pdf/i);		
		if ( result == -1)
		{
			
			document.getElementById(this.divIdImage).innerHTML = '<img id="' + this.objName + 'Image" src="' + this.pathImage + this.imageNames[i][0] + '" border="0" alt="' + this.imageNames[i][2] + '"/>'; 
			document.getElementById(this.objName + "Image").src = this.imageLoading;
			document.getElementById(this.objName + "Image").alt = "Loading...";
			document.getElementById(this.objName + "Image").src = this.pathImage + this.imageNames[i][0];
			document.getElementById(this.objName + "Image").alt = this.imageNames[i][2];
		}		
		else
		{			
			location.href = "docs/" + a;
		}
	}
}
