window.addEvent('domready', function(){
	
	$$('#nav li a').each(function(elt, i){
		elt.set('morph', {duration: 'short', transition: 'quint:out'});
		elt.addEvents({
			
			'mouseenter': 
			function(e)
			{
				this.morph({
					'padding-top': 0,
					'padding-bottom': 10					
				});
			},
			
			'mouseleave': 
			function(e)
			{
				this.morph({
					'padding-top': 5,
					'padding-bottom': 5

				});
			}
		});		
	});
	
	$$('ul.linklist a').each(function(elt,i){
		elt.set('morph',{'duration': 200, 'transition': 'quart:in:out'});
		elt.addEvents({
			'mouseenter': 
			function(e)
			{
				this.morph({
					'color' : '#ffffff',
					'background-color' : '#820807',
					'text-indent' : 20
				});
			},
			'mouseleave': 
			function(e)
			{
				this.morph({
					'color' : '#820807',
					'background-color' : '#ffffff',
					'text-indent' : 0
				});
			}
		});
	});
	
	if ($('banner')) 
	{
		$('banner').set('tween', {duration:300, transition: 'quad:in:out'});
		$('banner').addEvents({
			'mouseenter': 
			function(e)
			{
				this.tween('opacity', 0);
			},
			'mouseleave': 
			function(e)
			{
				this.tween('opacity', 1);
			}
		});		
	}
	
	if ($('workaccordion'))
	{
		var acc = new Accordion('#workaccordion h4',
								'#workimages .section',
								{
									opacity: true,
								  	duration: 350,
								  	transition: 'cubic:in:out',
								  	display: false
								});
								
		acc.addEvent('active', function(tog, elt){
			tog.morph({
				'color' : '#ffffff',
				'background-color' : '#820807',
				'font-size': 6
			});		
		});
		
		acc.addEvent('background', function(tog, elt){
			tog.morph({
				'color' : '#820807',
				'background-color' : '#ffffff',
				'font-size': 12
			});		
		});
		
		$$('#workaccordion h4').each(function(elt,i)
		{
			elt.set('morph',{'duration': 200, 'transition': 'quad:in:out', 'link': 'chain'});
			elt.addEvents({
				'mouseenter': 
				function(e)
				{
					this.morph({'text-indent' : 5});

				},
				'mouseleave': 
				function(e) {
					this.morph({'text-indent' : 0});

				}
			});
		});		
		
		
		var images = $$('.imageContainer img');
		$$('.images').each(function(elt, i){
			elt.set('tween', {duration: 500, transition: 'quint:out','link':'chain'})
		});
		$$('#workimages a').each(function(elt,i){
			elt.store('index', i);
			elt.addEvent('click', function(e){
				e.stop();
				images[i].getParent('.images').tween('margin-left', -images[i].getPosition(images[i].getParent('.images')).x);
				elt.getParent('ul').getChildren('li').each(function(link, idx){
					link.removeClass('activepic');
				});				
				elt.getParent('li').addClass('activepic');

			});
			
			
		});
		

		acc.display((Cookie.read('worktype')) ? Cookie.read('worktype') : 0);
		
	}
	
	
	
});