window.addEvent('domready', function() {
	$$('.trigger').each(function(trig) {
		var target = trig.getParent();
		trig.active = false;
		trig.bgcolorfx = new Fx.Tween(target, {duration: 'short', link: 'cancel'});
		trig.txtcolorfx = new Fx.Tween(target, {duration: 'short', link: 'cancel'});
		trig.widthfx = new Fx.Tween(target, {duration: 'short', link: 'cancel'});
	});
	$$('.trigger')[0].active = true;
	var myAccordion = new Fx.Accordion($$('.trigger'), $$('.element'), {
		alwaysHide: true,
		duration: 'short',
		opacity: true,
		initialDisplayFx: false,
		onActive: function(toggler, element) {
			toggler.active = true;
			toggler.bgcolorfx.start('background-color', '#FFFFFF');
			toggler.txtcolorfx.start('color', '#101111');
			toggler.widthfx.start('width', '820px');
			toggler.tween('padding', '30px');
			toggler.getParent().tween('margin-left', '0px');
			toggler.getParent().setStyle('background-image', 'none');
			toggler.getParent().getFirst().tween('margin', '30px');
			toggler.getParent().getFirst().set('html', '-');
		},
		onBackground: function(toggler, element) {
			toggler.active = false;
			toggler.bgcolorfx.start('background-color', '#14161c').chain(function() {
				toggler.getParent().setStyle('background', '#14161c url(t_fyord/imgs/bg_tab_grad.png) repeat-y top right');
			});
			toggler.txtcolorfx.start('color', '#FFFFFF');
			toggler.widthfx.start('width', '740px');
			toggler.tween('padding', '20px');
			toggler.getParent().tween('margin-left', '10px');
			toggler.getParent().getFirst().tween('margin', '20px');
			toggler.getParent().getFirst().set('html', '+');
		}
	});
	$$('.trigger').getParent().set('tween', {duration: 'short'});
	$$('.trigger').getParent().getFirst().set('tween', {duration: 'short'});
	$$('.trigger').set('tween', {duration: 'short'});
	$$('.trigger').addEvent('mouseover', function() {
		if (this.active != true) {
			this.bgcolorfx.start('background-color', '#72393a');
			this.getParent().tween('margin-left', '0px');
			this.getParent().getFirst().tween('margin', '30px');
			this.widthfx.start('width', '780px');
			this.tween('padding', '30px');
		}
	});
	$$('.trigger').addEvent('mouseout', function() {
		if (this.active != true) {
			var parentTab = this.getParent();
			this.bgcolorfx.start('background-color', '#14161c').chain(function() {
				parentTab.setStyle('background', '#14161c url(t_fyord//imgs/bg_tab_grad.png) repeat-y top right');
			});
			this.getParent().tween('margin-left', '10px');
			this.getParent().getFirst().tween('margin', '20px');
			this.widthfx.start('width', '740px');
			this.tween('padding', '20px');
		}
	});
	$$('.toggle').addEvents({
	    'mouseover': function() {
			this.getNext().fireEvent('mouseover');
	    },
	    'click': function() {
			myAccordion.display($$('.toggle').indexOf(this));
	    }
	});
	if (!Browser.Platform.ipod) {
		var myKeyboardEvents = new Keyboard({eventType: 'keydown'});
		myKeyboardEvents.addEvents({
		    'Down': function() {
				if (Shadowbox.isOpen() == true) {
					Shadowbox.close();
				}
			    myAccordion.display.delay(1, myAccordion, (myAccordion.previous + 1) % myAccordion.togglers.length);
		    },
		    'Up': function() {
				if (Shadowbox.isOpen() == true) {
					Shadowbox.close();
				}
		    	if (myAccordion.previous == 0) {
		    		myAccordion.display.delay(1, myAccordion, myAccordion.togglers.length - 1);
		    	} else {
			    	myAccordion.display.delay(1, myAccordion, (myAccordion.previous - 1) % myAccordion.togglers.length);
		    	}
			},
			'Right': function() {
				if (Shadowbox.isOpen() != true) {
					Shadowbox.open($$('.img')[myAccordion.previous].getFirst());
				}
			},
			'Enter': function() {
				if (Shadowbox.isOpen() == true) {
					Shadowbox.close();
				} else {
					Shadowbox.open($$('.img')[myAccordion.previous].getFirst());
				}
			}
		});
		myKeyboardEvents.activate();
		var toolTips = new Tips('.tooltip', {
			className: "tooltips"
		});
	}
	Shadowbox.init({
		players: ["img","html","iframe","qt","flv"],
		overlayColor: '#000',
		overlayOpacity: 0.8,
		enableKeys: true
	});
	$$('img').each(function(image) {
		image.set('height', image.offsetHeight);
	});
});


