/*function mantraShowHide(clicked) {
	var mantraDefns = new Array("you","do","what","you2","do2","well","let","everyone","know");
	for (var i in mantraDefns) {
		document.getElementById('mantra-' + mantraDefns[i] + '-defn').className="hide";
		var mantraLink = document.getElementById('mantra-' + mantraDefns[i])
		if (mantraLink.className=="mantra-selected") {
			mantraLink.className="";
		}
	}
	document.getElementById(clicked.id + '-defn').className="show";
	if (clicked.className!="mantra-active") {
		clicked.className="mantra-selected";
	}
}

function sidebarShow() {
	document.getElementById('sidebar-hidden').className="hide";
	document.getElementById('portfolio-thumb-area').className="two-col";
	document.getElementById('sidebar').className="show";
}

function sidebarHide() {
	document.getElementById('sidebar').className="hide";
	document.getElementById('sidebar-hidden').className="show";
	document.getElementById('portfolio-thumb-area').className="three-col";
}*/

function initLogoReel() {

	var reel = $$('#logo-reel img');
	var reelPos = 0;
	var reelLen = reel.length - 1;
	var reelFX = {};
	
	reel.each(function(el, i) {
		reelFX[i] = new Fx.Tween(el, {duration:1000});
	});
	
	var rotate = function() {
		if (reelPos < reelLen ) {
			reelFX[reelPos].start('opacity', '1', '0');
			reelPos++;
			reelFX[reelPos].start('opacity', '0', '1');
		} else {
			reelFX[reelPos].start('opacity', '1', '0');
			reelPos = 0;
			reelFX[reelPos].start('opacity', '0', '1');
		}
	};
	
	rotate.periodical(4000);

}

function initSidebar() {

	var sidebarWidth = '-308';
	var sidebar_hiddenWidth = '-69';

	var sidebar = new Fx.Tween('sidebar',{duration:1000});
	var sidebar_hidden = new Fx.Tween('sidebar-hidden',{duration:500});
	
	$('sidebar').setStyle('height', document.documentElement.clientHeight);
	sidebar_hidden.set('right', sidebar_hiddenWidth);
	
	$('hider').addEvent('click', function(e){
		e.stop();
		sidebar.start('right', '0', sidebarWidth).chain(function() {sidebar_hidden.start('right', sidebar_hiddenWidth, '0')});
		(function() {$('portfolio-thumb-area').set('class','three-col');}).delay(1000);
		e.preventDefault();
	});
	
	$('shower').addEvent('click', function(e){
		e.stop();
		sidebar_hidden.start('right', '0', sidebar_hiddenWidth).chain(function() {sidebar.start('right', sidebarWidth, '0')});
		$('portfolio-thumb-area').set('class','two-col');
		e.preventDefault();
	});
	
}

function initMantra() {

	var defns = $$('#mantra-list dd');
	var toggles = $$('#mantra-list dt a');
	
	var myDefns = {};
	
	defns.each(function(el, i) {
	
		myDefns[i] = new Fx.Slide(defns[i]);
		if(!toggles[i].hasClass('mantra-active')) {
			myDefns[i].hide();
		}
	
	});
	
	toggles.each(function(el, i) {
	
		toggles[i].addEvent('click', function(e) {
			
			if(!toggles[i].hasClass('mantra-active')) {
				toggles[i].addClass('mantra-selected');
			}
			
			defns.each(function(element, index) {
				if (myDefns[index].open && index != i) {
					myDefns[index].slideOut().chain(function(){myDefns[i].slideIn()});
					toggles[index].removeClass('mantra-selected');
				}
			});
			
			e.preventDefault();
			
		});
 
	});

}