// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
function setupEditLinks() {
	edit_links = $$('.main .edit-link');
	for (i = 0; i < edit_links.length; i++) {
		new Tip(edit_links[i], $(edit_links[i].rel), {showOn: 'click', hideOn: 'click', effect: 'appear', fixed: true} );
		edit_links[i].onclick = function() { return false; }
	}
	
	edit_links = $$('.small .edit-link');
	for (i = 0; i < edit_links.length; i++) {
		new Tip(edit_links[i], $(edit_links[i].rel), {showOn: 'click', hideOn: 'click', effect: 'appear', fixed: true} );
		edit_links[i].onclick = function() { return false; }
	}
}

function matchColumnHeights() {
	var columns = $$('.column');
	max_height = 0;
	for (var i=0; i < columns.length; i++) {
		columns[i].setStyle({height: 'auto'});
		if (Element.getHeight(columns[i]) > max_height) {
				max_height = Element.getHeight(columns[i]);
		}
	};
	
	for (var i=0; i < columns.length; i++) {
		columns[i].setStyle({height: max_height + 'px'});
	};
	
	/*set the main column to the same height as the nav column
	maincolumn = $$('.column.main')[0];
	if (maincolumn) {
		navheight = Element.getHeight($('navcolumn')) - 184;
		if (Element.getHeight(maincolumn) < navheight) {
			maincolumn.setStyle({height: navheight + "px"});
		}
	}*/
}

function setupUnfill() {
	unfills = $$('.unfill');
	for (var i=0; i < unfills.length; i++) {
		Event.observe(unfills[i], 'focus', unfill);
	};
}

function unfill() {
	if (this.hasClassName('unfill')) {
		this.value = '';
		this.removeClassName('unfill');
	}
}

function init() {
	setupZoom();
	setupEditLinks();
	setupUnfill();
	matchColumnHeights();
	
	if ($('photo-nav')) {
		var Slider = new ContentSlider('photo-nav', 'photo-frame', {forwardButton: 'forward-button', backButton: 'back-button', unitWidth: 640, buttonsSelector: '#photo-buttons a'});
	}
}

Event.observe(window, 'load', init);