(function() {
	
	function rel_external (el) {
		el.observe("click", function(event) {
			event.preventDefault();
			window.open(this.href);
		});
	}
	
	function reset (field) {
		field.observe("focus", function() {
			if (this.value  == this.defaultValue) {
				this.value = '';
			}
		});
		
		field.observe("blur", function() {
			if (this.value == '') {
				this.value = this.defaultValue;
			}
		});
	}
	
	function rollo_load (el) {
		var img = new Image();
		img.src = el;
	}
	
	function rollo (el) {
		el.srcOver = el.src.replace(/(\.[^.]+)$/, '_r$1');
		el.srcOut = el.src;
		rollo_load(el.srcOver);
		el.observe("mouseover", function() {
			this.src = el.srcOver;
		});
		el.observe("mouseout", function() {
			this.src = el.srcOut;
		});
	}
	
	function archive_list (el) {
		var link_list = el.down(1);
		el.observe('mouseover', function() {
			link_list.show();
		});
		el.observe('mouseout', function() {
			link_list.hide();
		});
	}
	
	function photo_gallery (el, i) {
		if (i % 3 == 0) {
			el.addClassName('first');
		};
	}
	
	function init () {
		$$("ul#sidebar_events_list li:last-child").invoke("addClassName", "last-child");
		
		$$("a[rel~=external]").each(rel_external);
		
		$$("input.reset").each(reset);
		
		$$("div.about_thumbs img:nth-child(2)").invoke("addClassName", "mid_child");
		
		$$("a.rollo img:not([src$=_r.jpg])").each(rollo);
		
		$$('ul.archive_links').invoke('hide');
		
		$$('ul.archive_list').each(archive_list);
		
		$$('ul#main_events_list li:nth-child(odd)').invoke('addClassName', 'events_stripes');
		
		$$('div.checkout_details:nth-child(even)').invoke('addClassName', 'even');
		
		$$('ul#gallery_list li').each(photo_gallery);
	}
	
	document.observe("dom:loaded", init);
	
})();