/* Copyright (c) 2010 Komrade Ltd. */

window.addEvent('domready',function() {
	
	var box = new multiBox('mb', {
		overlay: new overlay()
	});

	var advanced = new multiBox('advanced', {
		overlay: new overlay(),
		descClassName: 'advancedDesc'
	});

	new SmoothScroll({links:'.scroll-link'});
	
	$('portfolio').getElements('div.project').fade('hide');
	$('portfolio').getElement('div.active').fade('show');
	
	$$('#portfolio-links a').addEvent('click', function(e){
		e.stop();
		$$('#portfolio-links a').removeClass('active');
		this.addClass('active');
		index = this.get('text').toInt()-1;
		elToShow = $('portfolio').getElements('div.project')[index];
		if(elToShow.hasClass('active')){
			return;
		}
		elToHide = $('portfolio').getElement('div.active');
		fadeIn = new Fx.Tween(elToShow);
		fadeOut = new Fx.Tween(elToHide);
		fadeIn.start('opacity', 1).chain(function(){elToShow.addClass('active');});
		fadeOut.start('opacity', 0).chain(function(){elToHide.removeClass('active');});
	});
	
	$('contact-form-submit').addEvent('click', function(e){
		e.stop();
		$$("input[name=name]").removeClass('error');
		$$("input[name=email]").removeClass('error');
		$$("textarea[name=comment]").removeClass("error");
		$('contact-form-log').empty().addClass('loading');
		new Request.HTML({
			url:'includes/contact.php', 
			update: $('contact-form-log'), 
			noCache: true,
			evalScripts: true,
			onComplete: function(){
				$('contact-form-log').removeClass('loading');
			}
			}).post($('contact-form'));
	});
	
	window.fireEvent('theClouds','',2000);
	
});

window.addEvent('theClouds',function() {
	var fx = new Fx.Tween($('cloudsContainer'));
	fx.start('top', '0');
});

