/*
Script: kwicks.js / tab effects
License: MIT-style license.
About: zebra.js for mootools framework <http://www.mootools.net/> (c) 2007 Valerio Proietti, MIT-style license.
Version: 1.0
Note: XHTML doctype is required.
		
*/

/*
Class: Kwicks / Tabs effect

Example:
		(start code)
		var kwicks = new Kwicks();
		(end)
		
Note: Don't forget to insert "<script language="Javascript" type="text/javascript" src="js/mootools.js"></script>" into the head page before this js file. */

var Kwicks = new Class({

	initialize : function() {
		this.createBorder();
		this.parseKwicks();
	},
	
	// -----------------------------------------------------------------
	createBorder : function(){
		var element_right = new Element('div', {'class': 'right'});
		element_right.injectTop($('kwick'));
		
		var element_left = new Element('div', {'class': 'kleft'});
		element_left.injectTop($('kwick'));		
	},
	
	// -----------------------------------------------------------------
	parseKwicks : function() {
		var kwicks = $$('#kwick .kwick');
		
		var fx = new Fx.Elements(kwicks, {wait: true, duration: 400, transition: Fx.Transitions.quadOut});
		
		kwicks.each(function(kwick, i){
			
			kwick.addEvent('click', function(e){
				new Event(e).stop();
				window.location=$ES('.vertical', kwick).getProperty('href');
			});
			
			kwick.addEvent('mouseenter', function(e){
				var obj = {};
			
				obj[i] = {
				
					'width': [kwick.getStyle('width').toInt(), 508]
				};
				kwicks.each(function(other, j){
					if (other != kwick){
						var w = other.getStyle('width').toInt();
						if (w != 105) obj[j] = {'width': [w, 49]};
					}
				});
				fx.start(obj);
			});
			
			kwick.addEvent('mousemove', function(e){
				if(kwick.getStyle('width').toInt()==49){
					var obj = {};
				
					obj[i] = {'width': [kwick.getStyle('width').toInt(), 508]};
					
					kwicks.each(function(other, j){
						if (other != kwick){
							var w = other.getStyle('width').toInt();
							if (w != 105) obj[j] = {'width': [w, 49]};
						}
					});
					fx.start(obj);
				}
			});
			
		});
		

		
		$('kwick').addEvent('mouseleave', function(e){
			
			var obj = {};
			
			kwicks.each(function(other, j){
				if(other.getStyle('width').toInt()!=49){
					obj[j] = {'width': [other.getStyle('width').toInt(), 49]};
				};
			});		
			
			fx.start(obj);
		});

	}

});


window.addEvent('domready',function() {
	var kwicks = new Kwicks();
});

