window.addEvent('domready', function() {

	//Creamos el Accordion buena onda y moderno.
	var myAccordion = new Accordion($('accordion'), 'div.toggler', 'div.element', {
		fixedHeight: 490,
		opacity: false,
		onActive: function(toggler, element){
			toggler.setStyle('color', '#fff');
		},
		onBackground: function(toggler, element){
			toggler.setStyle('color', '#fff');
		}				
	});
	
	//Los Bichos que Cambian
		var images = ['url(http://faunadiseno.com/wp-content/themes/default/images/bi1.gif)' , 'url(http://faunadiseno.com/wp-content/themes/default/images/bi2.gif)' , 'url(http://faunadiseno.com/wp-content/themes/default/images/bi3.gif)' , 'url(http://faunadiseno.com/wp-content/themes/default/images/bi4.gif)' , 'url(http://faunadiseno.com/wp-content/themes/default/images/bi5.gif)']

	var imgsrc = images.getRandom();

	$('bicho').setStyle('background-image', imgsrc); 
	
	
	

});

// El menu moderno.
var Kwix = {

	start: function(){
		Kwix.parseKwicks();
	},

	parseKwicks: function(){

		var squeeze_to = 20;
		var max_width = 130;

		//get original widths
		var start_widths = new Array();
		var kwicks = $$('#kwick .cat-item');
		var fx = new Fx.Elements(kwicks, {wait: false, duration: 250, transition:Fx.Transitions.Cubic.easeOut});
		kwicks.each(function(kwick, i){

			start_widths[i] = kwick.getStyle('width').toInt();

			//mouse is in, squeeze and expand
			kwick.addEvent('mouseenter', function(e){

				var obj = {};
				obj[i] = {
					'width': [kwick.getStyle('width').toInt(), max_width]
				};

				var counter = 0;

				kwicks.each(function(other, j){
					if (other != kwick){
						var w = other.getStyle('width').toInt();
						if (w != squeeze_to) obj[j] = {'width': [w,squeeze_to] };
					}
				});
				fx.start(obj);
			}
			);
		});

		//mouse is out, squeeze back
		$('kwick').addEvent('mouseleave', function(e){
			var obj = {};
			kwicks.each(function(other, j){
				obj[j] = {'width': [other.getStyle('width').toInt(), start_widths[j]]};
			});
			fx.start(obj);
		});
	}
};

//lock and load!
window.addEvent('domready',Kwix.start);


