// Reproduction of this code without prior concent is strictly prohibited
// Copyright 2004 Real Estate Technology Connection

function photo (src, thumb, desc, large) {
	
	this.src = src;
	this.thumb = thumb;
	this.desc = desc;
	this.large = large;
	
	if (document.images) {
		this.image = new Image();
	}
	
	this.load = function() {
	
		if (!document.images) {
			return;
		}
		if (this.image.src != this.src) {
			this.image.src = this.src;
		}
	}	
}
function photoview(photoviewname) {

	this.imageid;
	this.descid;
	this.thumbboxid;
	this.linkid;
	
	this.photos = new Array();
	
	this.add_photo = function (photo) {
		
		if (!document.images) {
			return;
		}
		
		var c = this.photos.length;
		
		this.photos[c] = photo;
	}
	
	this.load_photo = function (arraypos) {
		var photo = this.photos[arraypos];
		
		photo.load();
		
		if (this.imageid) {
			if (document.getElementById(this.imageid)) {
				document.getElementById(this.imageid).src = photo.src;
				document.getElementById(this.imageid).alt = photo.desc;
			}
		}
		if (this.descid) {
			if (document.getElementById(this.descid)) {
				document.getElementById(this.descid).innerHTML = photo.desc;
			}
		}
		if (this.linkid) {
			if (document.getElementById(this.linkid)) {
				document.getElementById(this.linkid).href = photo.large;
			}
		}
	}
	
	this.load_thumbnails = function () {
		if (document.getElementById(this.thumbboxid)) {
			var i = this.photos.length;
			var str = '';
			var image = new Array();
			for (var c = 0; c < i; c++) {
				var s = new String(str);
				str = s.concat('<img src="' + this.photos[c].thumb + '" alt="' + this.photos[c].desc + '" onclick="listing.load_photo(' + c + ')" />');
			}
			if (str.length > 0) {
				document.getElementById(this.thumbboxid).innerHTML = str;
			}
		} 
	}
}
