//PIC scripts to handle setup & management of photobar 
//Created by John Logan - - - 11.17.2000 - - - www.continuity.nu

//Define the Photolist class to hold characteristics the Photolist
function Photolist_addPhoto( argPhotoName, argPhotoCaption ) {

	p = this.size++;
	this[p] = new Photo( this, argPhotoName, argPhotoCaption );
	
}

function Photolist_getIndex( argPhotoName ) {

	var rtnPhoto;
	
	for ( i = 0 ; i <= this.size ; i++ ) {
		if ( this[i] && this[i].name == argPhotoName ) {
			rtnPhoto = i;
			break;
		}
	}
	return rtnPhoto;	
}

function Photolist() {

	this.size = 0;
	this.linkURL = "photo.html?picname=";
	this.photoPath = "photos/";
	this.thumbEnd = "sm.jpg";
	this.photoEnd = ".jpg";
	this.width = 100;
	this.height = 75;

	this.addPhoto = Photolist_addPhoto;
	this.getIndex = Photolist_getIndex;
	
	return this;	
}

//Define the Photo class to hold characteristics of a Photo in the Photolist
function Photo_writeLink( ) {

	list = this.parent;

	if ( this.name ) {
		rtnLink = '<a href=\"' + this.photoPageURL + '\"><img src=\"' + 
						this.thumbURL + '\" width=\"' + list.width + 
						'\" height=\"' + list.height + '\" border=\"0\" alt=\"' +
						this.alttext + '\"></a>'
	}

	return rtnLink;
} 

function Photo_writeIMG( ) {

	list = this.parent;

	if ( this.name ) {
		rtnLink = '<img src=\"' + this.photoURL 
		
		if ( this.width ) rtnLink = rtnLink + '\" width=\"' + this.width 
		if ( this.height ) rtnLink = rtnLink + '\" height=\"' + this.height 
		
		rtnLink = rtnLink + '\" border=\"0\" alt=\"' + this.alttext + '\">'
	}

	return rtnLink;
} 

function Photo( list, argPhotoName, argPhotoCaption, argWidth, argHeight ) {
	
	this.parent = list;
	this.name = argPhotoName;
	this.caption = argPhotoCaption;
	this.alttext = argPhotoCaption;
	if ( argWidth ) this.width = argWidth;
	if ( argHeight ) this.height = argHeight;
	this.photoPageURL = list.linkURL + argPhotoName ;
	this.photoURL = list.photoPath + argPhotoName + list.photoEnd ;
	this.thumbURL = list.photoPath + argPhotoName + list.thumbEnd ;
	
	this.writeLink = Photo_writeLink;
	this.writeIMG = Photo_writeIMG;
	
	return this;
}
