Fx.Morph = Fx.Styles.extend({
 
	start: function(className){
 
		var to = {};
 
		$each(document.styleSheets, function(style){
			var rules = style.rules || style.cssRules;
			$each(rules, function(rule){
				if (!rule.selectorText.test('\.' + className + '$')) return;
				Fx.CSS.Styles.each(function(style){
					if (!rule.style || !rule.style[style]) return;
					var ruleStyle = rule.style[style];
					to[style] = (style.test(/color/i) && ruleStyle.test(/^rgb/)) ? ruleStyle.rgbToHex() : ruleStyle;
				});
			});
		});
		return this.parent(to);
	}
 
});
 
Fx.CSS.Styles = ["backgroundColor", "height", "opacity", "overflow"];
  
var myMorph1 = new Fx.Morph('neurochemistry', {wait: false});
var myMorph2 = new Fx.Morph('mindfulness', {wait: false});
var myMorph3 = new Fx.Morph('disgust', {wait: false});
var myMorph4 = new Fx.Morph('expression', {wait: false});
var myMorph5 = new Fx.Morph('attention', {wait: false});
var myMorph6 = new Fx.Morph('learning', {wait: false});
var myMorph7 = new Fx.Morph('ptsd', {wait: false});

var imgs = ['img2','img3','img4','img7','img5', 'img1', 'img6'];
var catAdam = [1,1,1,1,1,0,0];
var catEve = [0,0,0,0,1,1,1];
var catAll = [1,1,1,1,1,1,1];

function setVisibility(vals) {
	for (var i_tem = 0; i_tem < imgs.length; i_tem++)
		if (vals[i_tem]==1) {
			document.getElementById(imgs[i_tem]).style.visibility='visible';
		} else {
			document.getElementById(imgs[i_tem]).style.visibility='hidden';
		}
} 


$('linkAdam').addEvent('click', function(e){
	new Event(e).stop();
	setVisibility(catAdam);
	 
	myMorph1.start('short');
	myMorph2.start('full');
	myMorph3.start('full');
	myMorph4.start('full');
	myMorph5.start('full');
	myMorph6.start('short');
	myMorph7.start('full');
	document.getElementById('linkAdam').className = 'here';		
	document.getElementById('linkEve').className = 'there';		
	document.getElementById('linkAll').className = 'there';		
});
 
$('linkEve').addEvent('click', function(e){
	new Event(e).stop();
	setVisibility(catEve);
	 
	myMorph1.start('full');
	myMorph2.start('short');
	myMorph3.start('short');
	myMorph4.start('short');
	myMorph5.start('full');
	myMorph6.start('full');
	myMorph7.start('short');
	document.getElementById('linkAdam').className = 'there';		
	document.getElementById('linkEve').className = 'here';		
	document.getElementById('linkAll').className = 'there';		
});

$('linkAll').addEvent('click', function(e){
	new Event(e).stop();
	setVisibility(catAll);
 
	myMorph1.start('full');
	myMorph2.start('full');
	myMorph3.start('full');
	myMorph4.start('full');
	myMorph5.start('full');
	myMorph6.start('full');
	myMorph7.start('full');
	document.getElementById('linkAdam').className = 'there';		
	document.getElementById('linkEve').className = 'there';		
	document.getElementById('linkAll').className = 'here';		

});
