var Flickr= Class.create();

Flickr.prototype = {
	photo : null, 
	notes : null, 
	regNoteBox : null, 

	initialize : function () {
		this.photo = $$('div.flickr.photo div.photo')[0];
		this.notes = $$('div.flickr.photo div.photo div.innernote');
		Flickr.regNoteBox = /^innernotebox-([0-9]+)$/i;

		this.registerNoteEvents();
		this.hideNotes();

		if (this.photo) {
			Event.observe(this.photo, 'mouseover', function (event) {
				flickr.showNotes();
			});

			Event.observe(this.photo, 'mouseout', function (event) {
				flickr.hideNotes();
			});
		}
	}, 

	registerNoteEvents : function () {

		for (var i=0;i<this.notes.length;i++) {
			window.status = this.notes[i].id;
			Event.observe(this.notes[i], 'mouseover', function (event) {
				var el = Event.element(event);
				if (el.id.match(Flickr.regNoteBox)) {
					var id = Flickr.regNoteBox.exec(el.id)[1];
					$('outernotebox-' + id).addClassName('highlighted');
					$('notetext-' + id).show();
				}
			});

			Event.observe(this.notes[i], 'mouseout', function (event) {
				var el = Event.element(event);
				if (el.id.match(Flickr.regNoteBox)) {
					var id = Flickr.regNoteBox.exec(el.id)[1];
					$('outernotebox-' + id).removeClassName('highlighted');
					$('notetext-' + id).hide();
				}
			});
		}
	},

	hideNotes : function () {
		for (var i=0;i<this.notes.length;i++) {
			var id = Flickr.regNoteBox.exec(this.notes[i].id)[1];
			$('notebox-' + id).hide();
			$('innernotebox-' + id).hide();
			$('notetext-' + id).hide();
		}
	}, 

	showNotes : function () {
		for (var i=0;i<this.notes.length;i++) {
			var id = Flickr.regNoteBox.exec(this.notes[i].id)[1];
			$('notebox-' + id).show();
			$('innernotebox-' + id).show();
		}
	}

}

var flickr = new Flickr();


