// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

var MyUtils = {
	switchem: function(element, otherelement) {
		$(otherelement).toggle();
		element.toggle();
	}
}

Element.addMethods(MyUtils);

var lastLOR = null;
var leftOrRight = function() {
	if (lastLOR == "rc" || lastLOR == null) {
		return lastLOR = "lc";
	}
	else if (lastLOR == "lc") {
		return lastLOR = "rc";		
	}
}

function puffit(lOr) {
	$(lOr).hide();
	Effect.Appear(lOr);
}

var lastGC;
function getContent(obj, lOr) {
	closebox();
	page = obj.innerHTML + ".html";
	if (lastGC == page) return;
	lOr = leftOrRight();	
	new Ajax.Updater(lOr, page, {method: 'get', asyncronous:true, onSuccess:puffit(lOr)});
	lastGC = page;
}

var lastReveal = null;
function reveal(obj) {
	thisReveal = obj.id + '_info';
	thisReveal = $(thisReveal);
	if (lastReveal == thisReveal) return;
	if (lastReveal != null) $(lastReveal).hide();
	Effect.Appear(thisReveal, {duration:1, to:.6});
	lastReveal = thisReveal;
}

function openbox(obj) {
	var cp = $('center_popup');
	if (obj.id) {
		var objid = obj.id;
	}
	else {
 		var objid = obj;
	}
	cp.hide();
	$('overlay').show();
	page = "center/"+ objid + ".html";
	new Ajax.Updater(cp, page, {method: 'get', asyncronous:true, evalscripts:true, onSuccess:Effect.BlindDown(cp, {duration:1})});
	$('close_button').show();
}

function closebox() {
	$('overlay').hide();
	$('close_button').hide();
	$('center_popup').hide();
}