window.addEvent('domready', function(){
	//var szNormal = 200, szSmall  = 180, szFull   = 260;
		var szNormal = 100, szSmall  = 80, szFull   = 200;

	var pestanyes = $$("#pestanyes .pestanya");
	var fx = new Fx.Elements(pestanyes, {wait: false, duration: 300, transition: Fx.Transitions.Back.easeOut});
	pestanyes.each(function(pestanya, i) {
		pestanya.addEvent("mouseenter", function(event) {
			var o = {};
			o[i] = {width: [pestanya.getStyle("width").toInt(), szFull]}
			pestanyes.each(function(other, j) {
				if(i != j) {
					var w = other.getStyle("width").toInt();
					if(w != szSmall) o[j] = {width: [w, szSmall]};
				}
			});
			fx.start(o);
		});
	});

	$("pestanyes").addEvent("mouseleave", function(event) {
		var o = {};
		pestanyes.each(function(pestanya, i) {
			o[i] = {width: [pestanya.getStyle("width").toInt(), szNormal]}
		});
		fx.start(o);
	})


	var scroll = new Fx.Scroll('demo-wrapper', {
			wait: false,
			duration: 1500,
			transition: Fx.Transitions.Quad.easeInOut
	});

	$('pestanya_1').addEvent('click', function(event) {
		event = new Event(event).stop();
		scroll.toElement('contingut_1');
	});

	$('pestanya_3').addEvent('click', function(event) {
		event = new Event(event).stop();
		scroll.toElement('contingut_3');
	});

	$('pestanya_2').addEvent('click', function(event) {
		event = new Event(event).stop();
		scroll.toElement('contingut_2');
	});

	$('pestanya_4').addEvent('click', function(event) {
		event = new Event(event).stop();
		scroll.toElement('contingut_4');
	});
	
	$('pestanya_5').addEvent('click', function(event) {
		event = new Event(event).stop();
		scroll.toElement('contingut_5');
	});

	$('pestanya_6').addEvent('click', function(event) {
		event = new Event(event).stop();
		scroll.toElement('contingut_6');
	});

	//$('pestanya_7').addEvent('click', function(event) {
//		event = new Event(event).stop();
//		scroll.toElement('contingut_7');
//	});

	var kwords = $$("#kwords .kword");
	kwords.each(function(kw, i) {
		//var newsize = Math.floor(Math.random()*20)+15;
		var newsize = 25;
		kw.effect('font-size').set(newsize);
	});
		
});