// Photorow
// (C) PC Help 2006

// Requires: Prototype, Scriptaculous
// Last update: 24/10/2006

// Photorow setup

// General scope variables setup

var Photorow = Class.create();
var myPhotorow;
var allPhotorows;
Photorow.prototype = {
	initialize: function(container,id) {
		this.preloader = new Image();
		this.preloader.onload=function(){
			var a = document.createElement('a');
			a.setAttribute('href', this.photorow.prefix_large + this.photorow.num + ".jpg");
			a.setAttribute('title',this.photorow.title);
			a.setAttribute('alt',this.photorow.title);
			a.setAttribute('rel','lightbox[photorow-' + this.photorow.id + ']');
			a.onclick = function () { myLightbox.start(this); return false; };
//a.onclick = function () {return false;}
			this.photorow.container.appendChild(a);
			var img = document.createElement('img');
			img.src = this.photorow.prefix + this.photorow.num + '.jpg';
			Element.hide(img);
			a.appendChild(img);
			Effect.Appear (img);
//			new Draggable(img,{ghosting: true});
//			Sortable.create(this.container,{tag:'img'});
			//this.photorow.newphoto();
			setTimeout('allPhotorows[' + this.photorow.id + '].photorow.newphoto();',10);
		};
		this.preloader.photorow=this;
		this.num=0;
		this.id = id;
		this.container = container;
		container.photorow=this;
		this.numphotos = this.container.getAttribute('numphotos');
		this.title = this.container.getAttribute('title');
		this.prefix = this.container.getAttribute('prefix');
		this.prefix_large = this.container.getAttribute('prefix_large');
		this.newphoto();
	},
	complete: function() {
//		Sortable.create(this.container,{tag:'div'});
	},
	newphoto: function() {
		if (this.num < this.numphotos) {
			this.num++;
			this.preloader.src = this.prefix + this.num + ".jpg";
		} else {this.complete();};
	}
}
function initPhotorow() {
	allPhotorows = document.getElementsByClassName("photorow");
	for(i = 0; i < allPhotorows.length; i++) {
		new Photorow(allPhotorows[i],i);
	}
}
// new domFunction(initPhotorow);
Event.observe(window, 'load', initPhotorow, false);
