window.addEvent('domready', function(){
var myFades = new Fader('.fadeMe');
									 
// SLIDES THE TRANSFORMATION PICTURES LEFT AND RIGHT
// Declaring increment vars
var totIncrement = 0;
var increment = 387;
var maxRightIncrement = increment*(-2);

// FX var
var fx = new Fx.Tween('sliderList', {
property: 'margin-left',
duration: 1000,
transition: Fx.Transitions.Back.easeInOut,
	onStart: function() {
		$("slide-left").removeEvents('click');
		$("slide-right").removeEvents('click');
	},
	onComplete: function() {
		appEvent();
	}
});

function appEvent() {
// Previous Button
$('slide-left').addEvents({
	'click' : function(event){
		if(totIncrement<0){
			event.stop();
			totIncrement = totIncrement + increment;
			fx.start(totIncrement);
		}
	}
	});

// Next Button
$('slide-right').addEvents({
	'click' : function(event){
			if(totIncrement>maxRightIncrement){
				event.stop();
				totIncrement = totIncrement - increment;
				fx.start(totIncrement);
			}
		}
	});
}

if($('slide-left') && $('slide-right') ){
	appEvent();
}

	
// FADES SOCIAL MEDIA BUTTONS
['twitlink', 'fblink', 'mslink'].each(function(item, index){

	 $(item).addEvents({  
	       'mouseenter': function() {
		  	   this.set('morph', {duration: 250, transition: Fx.Transitions.Sine.easeOut});
	           this.morph({'opacity': [1, 0.3]} );  
	       },  
	       'mouseout': function() {
			   this.set('morph', {duration: 250, transition: Fx.Transitions.Sine.easeOut});
	           this.morph({'opacity': [0.3, 1]});  
	       }  
	   })
}); // ends the iterator

//FADES AND RECREATES TESTIMONIALS:
new FadeInFadeOut();

//LOGIN DROP DOWN
if($("hiddenlogin")){
	$('hiddenlogin').setStyle('height','auto');
}
	var mySlide = new Fx.Slide('hiddenlogin').hide();
	
	//Show-Hide login panel when you click the link "Login" on top of the page
    $('hello').addEvent('click', function(e){ tog(e); });
	$('loginbutton').addEvent('click', function(e){ tog(e); });
	
	function tog(e){
		e = new Event(e);
		mySlide.toggle(); //show-hide login panel
		e.stop();
	}

});

