
/************************************
	SET FONTS
************************************/
Cufon.replace('div#header, div#footer, body#interior h1, div#bubble div.interior h2, div#bubble div.close', { hover: true, fontFamily: 'TradeCondensed' });
Cufon.replace('div#bubble div.interior p', { hover: true, fontFamily: 'Trade' });

window.addEvent('domready', function() {

	/************************************
		NAVIGATION BUBBLE
	************************************/
	var prev_nav = null;
	var prev_content = null;
	var bubble_FX = new Fx.Morph('bubble', {
		duration: 300,
		transition:Fx.Transitions.Cubic.easeOut
	}).set({'opacity':0});
	$$('ul#navigation li a').each(function(a){
		a.addEvent('click', function(e){
			e.stop();
			var rel = a.getProperty('rel');

			if (prev_nav == a) {
				prev_nav = null;
				bubble_FX.start({
					'opacity': 0,
					'margin-top': 0
				});
			}
			else {
				if (prev_content != null) {
					$(prev_content).setStyle('display','none');
				}
				$(rel).setStyle('display','block');
				prev_content = $(rel);

				var mid = a.getLeft() + (a.getWidth()/2);
				var bubbletop = a.getTop() + a.getHeight();
				var bubbleleft = mid - ($('bubble').getWidth()/2);
				$('bubble').setStyles({
					'left': bubbleleft,
					'top': bubbletop
				});
				bubble_FX.set({
					'opacity': 0,
					'margin-top': 0
				}).start({
					'opacity': 1,
					'margin-top': -15
				});
				prev_nav = a;
			}
		});
	});
	$$('div#bubble div.close a').addEvent('click', function(close){
		prev_nav = null;
		bubble_FX.start({
			'opacity': 0,
			'margin-top': -30
		});
	});


	/************************************
		PHOTO FILTERING
	************************************/
	var Flipbook = {
		selectedtab : 'viewall',
		init : function()
		{
			$$('div#footer ul li a').each(function(tag){
				tag.addEvent('click', function(e){
					var e = new Event(e).stop();
					Flipbook.switcher(tag.getProperty('id'));
				});
			});
		},
		switcher : function(type)
		{
			if (type != Flipbook.selectedtab) {
				$(Flipbook.selectedtab).removeClass('selected');
				$(type).addClass('selected');
				Flipbook.selectedtab = type;
			}
			$$('div#flipbook ol li').each(function(li){
				var a = li.getFirst('a');
				if (type == 'viewall') {
					li.fade(1);
					li.removeClass('disabled');
					a.setProperty('rel', 'lightbox[photoset]');
				}
				else {
					if (!li.hasClass(type)) {
						li.fade(.2);
						li.addClass('disabled');
						a.setProperty('rel', 'lightbox[image]');
					}
					else if (li.hasClass(type)) {
						li.fade(1);
						li.removeClass('disabled');
						a.setProperty('rel', 'lightbox[photoset]');
					}
				}
			});
		}
	}
	Flipbook.init();
});