
window.addEvent('domready', function()
{
	Watchdog.initialize(document);
});

var Watchdog = {

	initialize: function() {
		this.update(document);
	},

	update: function(el) {

		Lightbox.init({container: el});

		$ES('.myReflect', el).addReflection({opacity:.3});
		$ES('.myReflect_head', el).addReflection({height:.5, opacity:.5});
		$ES('.myReflect_head2', el).addReflection({height:.5, opacity:.5});
		$ES('.myReflect_gross', el).addReflection({height:.2, opacity:.25});

		$ES('a[rel*="ajax-content"]').each(function(el){

			if (el.getProperty('onclick') ) el.setProperty('onclick', '');

			el.addEvent('click', function(evt){
				evt.stop();
				if (this.ajax) return;
				var content = $('ajax-content');
				content.addClass('ajax-loading').setStyle('height', content.scrollHeight + 'px').setHTML('');
				this.ajax = new Ajax (this.href, {
					method: 'get',
					onComplete: function(resp) {
						this.ajax = null;
						content.removeClass('ajax-loading').setStyles({'visibility': 'hidden', 'height': ''});
						content.setHTML(resp);
						Watchdog.update(content);
						content.effect('opacity', {duration: 1000}).start(0, 1);
					}.bind(el)
				}).request();

			}.bindWithEvent(el));
		});
	}
};