// JavaScript Document
window.addEvent('domready', function() {
	
	$$('.galleryButton').addEvents({
		'mouseenter': function(){
			this.set('tween', {
				duration: 500,
				transition: Fx.Transitions.Quad.easeOut
			}).tween('opacity', '1');
		},
		'mouseleave': function(){
			this.set('tween', {
				duration:500
			}).tween('opacity', '.5');
		}
	});
	
	$$('#galleryWrapper div div a').addEvents({
		'mouseenter': function(){
			this.set('tween', {
				duration: 500,
				transition: Fx.Transitions.Quad.easeOut
			}).tween('border-color', '#ffffff');
		},
		'mouseleave': function(){
			this.set('tween', {
				duration:500
			}).tween('border-color', '#4b4b4b');
		}
	});
	
	$$('#nav li a').addEvents({
		'mouseenter': function(){
			this.set('tween', {
				duration: 1500,
				transition: Fx.Transitions.Quad.easeOut
			}).tween('opacity', '0');
		},
		'mouseleave': function(){
			this.set('tween', {}).tween('opacity', '1');
		}
	});

	$$('#contactSend').addEvents({
		'mouseenter': function(){
			this.set('tween', {
				duration: 750,
				transition: Fx.Transitions.Quad.easeOut
			}).tween('opacity', '0');
		},
		'mouseleave': function(){
			this.set('tween', {}).tween('opacity', '1');
		}
	});
	
	$$('.formRow').addEvents({
		'mouseenter': function(){
			this.morph({'background-color': '#d0cece'});
		},
		'mouseleave': function(){
			this.morph({'background-color': '#e2e1e1'});
		}
	});
	
	
		
	// Gallery
		$$('.galleryButton').setStyle('opacity','.5');
		$$('.galleryGroup').setStyle("display","none");
		$('1').style.display = "block";
		
		len = $$('#galleryInner .galleryGroup').length;		
		
		var comingInItem;
		var currentItem = 1;
		$('prev').addEvent('click', function(){
			if(currentItem == 1){
				comingInItem = (len);
			}else{
				comingInItem = (currentItem - 1);
			}
		});
		$('next').addEvent('click', function(){
			if(currentItem == len){
				comingInItem = 1;
			}else{
				comingInItem = (currentItem + 1);
			}
		});
		
		
	//changing gallery items
	$$('.galleryButton').addEvent('click', function(e) {

			e.stop();
		var myEffect = new Fx.Morph('galleryWrapper', {
			duration: 1000, 
			transition: Fx.Transitions.Sine.easeIn,
			onComplete: function(){
				$(''+currentItem+'').style.display = "none";
				$(''+comingInItem+'').style.display = "block";
				fadeInGallery();
			}}); 
	myEffect.start({
    'opacity': 0 
	});
	});

function fadeInGallery(){
	var myEffect = new Fx.Morph('galleryWrapper', {
    duration: 750, 
	transition: Fx.Transitions.Sine.easeOut,
	onComplete: function (){
		currentItem = comingInItem;
	}});
	myEffect.start({
    'opacity': 1
		
	})
}


	




}); // end of mt domready
