/*					flippyMOO v1.1                        
			  An unobtrusive DIV flipper 	              
				 by Tim Novinger                         
	http://www.timnovinger.com | tim.novinger [at] gmail.com    
	
	MIT style license:                                             
	http://en.wikipedia.org/wiki/MIT_License      	
	
	Special Thanks To:
	 - Developers at http://www.redant.com.au/about/ for the great idea and base to work from
	 - Digitarald
	 - Kamicane
						
	Changelog:													  
	Version 1.0 (August 2nd, 2007)								  
	   - Initial build											  
																  
	Supported browsers at time of last update:					  
	  - Firefox 2.0.0.6							
	  - Safari 3.03 [win]
	  - Internet Explorer 7										  
	  - Internet Explorer 6 w/SP2								  
																  
	Planned Improvments			 	
	  - Full Safari 3 support [win & pc]
	  - Support for Opera 9.22
	  - Formal Script Options      									  
		(effect duration, timeout, ect.)	 	
*/
// ==========================================================================================
var Flippy = {					 
	initialize: function() {
		if(!$$('.flippy')) {return;} //check for existance of scroller

		//CONFIG OPTIONS
		this.flipEventShow = "mouseenter";
		this.flipEventHide = "mouseleave";
		this.timeout = 2000; //how long the flip is paused in milliseconds
		this.duration = 150; //duration of the movement effect in milliseconds
		
		//SET VARIABLES
		var flippyArray = $$(".flippies .flippy");
		var TEMP = flippyArray.getStyle('left'); //find existing width (essentially lets css control script behavior)
			TEMP.each(function(i){Flippy.Default = i.toInt();});
 
 		//DECLARE EFFECT
		this.fx = new Fx.Elements(flippyArray, {duration: this.duration, wait:true});
		
		//ADD EVENTS TO EACH FLIPPY DIV
		flippyArray.each(function(flippy, i) {
			flippy.addEvent(Flippy.flipEventShow, Flippy.show.pass([i, flippy], Flippy));
			flippy.addEvent(Flippy.flipEventHide, Flippy.hide.pass([i, flippy], Flippy));
	    });
	},
	
	show: function(i, flippy){
		var o = {};
		o[i] = {left: [flippy.getStyle("left").toInt(), 0]}
		this.fx.start(o);
	},
	
	hide: function(i, flippy){
		function restore(){
			var o = {};
			o[i] = {left: [flippy.getStyle("left").toInt(), this.Default]}
			this.fx.start(o);
		    }
		restore.bind(this).delay(this.timeout);
	}
};
// ==========================================================================================
window.addEvent('domready', Flippy.initialize.bind(Flippy)); //start script on DOM ready
