function getpage(ahref, level) {
	return true;
}
var Accordion = new Class({
	options: $H({
		childSelector: 'div',
		duration: 750,
		transition: 'circ:out'
	}),
	initialize: function (container, options) {
		this.options.extend(options || {});
		this.container = $(container);
		this.wrapper = this.container.getElement('div.accordion_wrapper');
		this.count = this.container.getElements('ul li').length;
		this.availWidth = this.container.getWidth();
		this.busy = false;
		this.setWrapperWidth();
		this.apply();
	},
	setWrapperWidth: function () {
		var w = this.availWidth * (this.count + 1);
		this.wrapper.setStyle('width', w);
	},
	setActiveTab: function (num) {
		if (this.container.getElement('ul li.current')) {
			this.container.getElement('ul li.current').removeClass('current');
		}
		this.container.getElements('ul li')[num].addClass('current');
	},
	start: function (num) {
		if (!this.busy) {
			this.busy = true;
			var x = (this.availWidth * num) * -1;
			var fx = new Fx.Tween(this.wrapper, {
				duration: this.options.duration,
				transition: this.options.transition
			})
			fx.start('left', x).chain(function () {
				this.busy = false;
			}.bind(this));
			this.setActiveTab(num);
		}
	},
	apply: function () {
		this.container.getElement('ul').getElements('a').each(function (a, i) {
			a.addEvents({
				'click': function (e) {
					e.stop();
					if (!this.busy) {
						this.start(i);
					}
				}.bind(this)
			});
		},
		this);
	}
});
var NewsSlide = new Class({
	options: $H({
		activeLinkClass: 'current',
		contentSelector: '.teaser_content',
		fadeDuration: 2000,
		fadeTransition: 'sine:out',
		fxDelay: 250,
		fxDuration: 750,
		fxTransition: 'sine:out',
		hoverColor: ['#fff', '#f9c638'],
		infoOpacity: .7,
		infoSelector: '.info',
		interval: 3000,
		navigationEnabled: true,
		navigationSelector: '.topics',
		navigationOpacity: .7,
		navigationPosition: 'bottom',
		onChange: $empty,
		pauseOnMouseOver: false,
		stack: true
	}),
	initialize: function (container, options) {
		this.options.extend(options || {});
		this.busy = false;
		this.container = $(container);
		this.currentItem = 0;
		this.interval = false;
		this.itemCount = this.getContentItems().length;
		this.within = null;
		this.stackAr = [];
		this.initContents();
		this.initNavigation();
		this.apply();
	},
	getContentItems: function () {
		return this.container.getElements(this.options.contentSelector);
	},
	getCurrentItem: function () {
		return this.getContentItems()[this.currentItem];
	},
	getNavigation: function () {
		return this.container.getElement(this.options.navigationSelector);
	},
	initContents: function () {
		this.getContentItems().each(function (item, i) {
			item.setStyle('opacity', i > 0 ? 0 : 1);
			item.setStyle('z-index', 0);
		},
		this);
	},
	initNavigation: function () {
		var navi = this.getNavigation();
		if (!this.options.navigationEnabled) {
			navi.dispose();
			return;
		}
		this.setActiveLink();
		var property = this.options.navigationPosition;
		navi.setStyle(property, (navi.getHeight() * -1) + 'px').setStyle('opacity', 0);
		var es = this.setRGBa(navi, this.options.navigationOpacity);
		if (this.options.hoverColor) {
			navi.getElements('a').each(function (a) {
				var fx = new Fx.Tween(a, {
					duration: 500,
					wait: false
				});
				a.addEvents({
					'mouseover': function () {
						fx.start('color', this.options.hoverColor[1]);
					}.bind(this),
					'mouseout': function () {
						fx.start('color', this.options.hoverColor[0]);
					}.bind(this)
				});
			},
			this);
		} (function () {
			var tween = new Fx.Morph(es[1], {
				duration: this.options.fxDuration,
				transition: this.options.fxTransition
			});
			if (this.options.navigationPosition == 'top') {
				tween.start({
					opacity: this.options.navigationOpacity,
					top: 0
				});
			} else {
				tween.start({
					bottom: 0,
					opacity: this.options.navigationOpacity
				});
			}
			var tween = new Fx.Morph(es[0], {
				duration: this.options.fxDuration,
				transition: this.options.fxTransition
			});
			(function () {
				if (this.options.navigationPosition == 'top') {
					tween.start({
						opacity: 1,
						top: 0
					});
				} else {
					tween.start({
						bottom: 0,
						opacity: 1
					});
				}
			}.bind(this)).delay(this.options.fxDelay);
		}.bind(this)).delay(this.options.get('fxDelay'));
	},
	switchContent: function (num) {
		if (!this.busy) {
			this.busy = true;
			var prev = this.getCurrentItem();
			if ($defined(num)) {
				var next = num;
			} else {
				var next = this.currentItem + 1 < this.itemCount ? this.currentItem + 1 : 0;
			}
			this.currentItem = next;
			var nextItem = this.getCurrentItem();
			this.setToTop(nextItem);
			var fx = new Fx.Tween(nextItem, {
				duration: this.options.get('fadeDuration'),
				transition: this.options.get('fadeTransition')
			});
			fx.start('opacity', 1).chain(function () {
				prev.setStyles({
					opacity: 0,
					zIndex: 0
				});
				if (this.interval === false && this.mousewithin === false && this.options.interval != false) {
					this.setInterval();
				}
				this.busy = false;
				this.doStack.delay(250, this);
			}.bind(this));
			this.options.get('onChange')();
			this.setActiveLink();
		}
		else if (this.busy && this.options.get('stack')) {
			this.pushStack(num);
		}
	},
	setActiveLink: function () {
		if (!this.options.navigationEnabled) {
			return;
		}
		var as = this.getNavigation().getElements('a');
		as.each(function (a, i) {
			if (a.hasClass(this.options.get('activeLinkClass'))) {
				a.removeClass(this.options.get('activeLinkClass'));
			}
			if (i == this.currentItem) {
				a.addClass(this.options.get('activeLinkClass'))
			}
		},
		this);
	},
	setInterval: function () {
		if (this.options.interval != false) {
			this.interval = this.switchContent.periodical(this.options.interval, this);
		}
	},
	killInterval: function () {
		$clear(this.interval);
		this.interval = false;
	},
	apply: function () {
		if (this.options.navigationEnabled) {
			this.getNavigation().getElements('a').each(function (a, i) {
				a.addEvent('click', function (e) {
					e.stop();
					if (!a.hasClass('current')) {
						this.killInterval();
						this.switchContent(i);
					}
				}.bind(this));
			},
			this);
		}
		if (this.options.pauseOnMouseOver) {
			this.getContentItems().each(function (el) {
				el.addEvents({
					'mouseover': function () {
						this.mousewithin = true;
						this.killInterval();
					}.bind(this),
					'mouseout': function () {
						this.mousewithin = false;
						this.setInterval();
					}.bind(this)
				});
			}.bind(this));
		} (function () {
			this.setInterval();
		}.bind(this)).delay(this.options.fxDelay);
	},
	pushStack: function (num) {
		if (!this.stackAr.contains(num)) {
			this.stackAr.push(num);
		}
	},
	doStack: function () {
		if (this.stackAr.length > 0) {
			this.killInterval();
			this.switchContent(this.stackAr[0]);
			this.stackAr.erase(this.stackAr[0]);
		}
	},
	setToTop: function (el) {
		this.getContentItems().each(function (item) {
			item.setStyle('z-index', item == el ? 1 : 0);
		});
	},
	setRGBa: function (el, opacity) {
		el = $(el);
		var bgColor = el.getStyle('background-color');
		var coords = el.getCoordinates();
		var clone = el.clone(false);
		clone.inject(el, 'after').setStyles({
			opacity: opacity,
			zIndex: 3
		});
		el.setStyles({
			backgroundColor: 'transparent',
			zIndex: 4
		});
		return [el, clone];
	}
});
var SlideShow = new Class({
    options: $H({
        fadeOut: false,
        fxDuration: 500,
        fxTransition: 'quart:out',
        interval: 5000,        
        showTitle: true
    }),
    initialize: function(element, options)
    {
        this.element = $(element);

        this.options.extend(options || {});

        this.current = 0;
        this.images = this.getImages();
        this.initImages();
        if(this.options.showTitle)
        {
            this.title = new Element('p', {
                'class' : 'title'
            }).inject(this.element);
            this.setTitle();
        }
        this.slide.periodical(this.options.interval, this);
    },
    getImages: function()
    {
        return this.element.getElements('img');
    },
    initImages: function()
    {
        this.images.each(function(img, i){
            img.setStyles({
                opacity: i == 0 ? 1 : 0,
                zIndex: i == 0 ? 1 : 0
            });
        });
    },
    slide: function()
    {
        var currentImage = this.images[this.current];
        var next = this.current + 1 < this.images.length ? this.current + 1 : 0;
        
        this.images[next].setStyles({
            opacity: 0,
            zIndex: 2
        });
        if(this.options.fadeOut)
        {
            new Fx.Tween(currentImage, {
                duration: this.options.fxDuration,
                transition: this.options.fxTransition
            }).start('opacity', 0);
        }
        new Fx.Tween(this.images[next], {
            duration: this.options.fxDuration,
            transition: this.options.fxTransition
        }).start('opacity', 1).chain(function(){
            currentImage.setStyles({
                opacity: 0,
                zIndex: 0
            });
            this.images[next].setStyle('z-index', 1);
            this.current = next;
            this.setTitle();
        }.bind(this));
    },
    setTitle: function()
    {
        if(!this.options.showTitle)
        {
            return;
        }
        this.title.set('html', this.images[this.current].get('title'));
    } 
});

var init = function () {
	if ($('news')) {
		new NewsSlide($('news'), {
			fadeDuration: 1500,
			fxDelay: 750,
			fxDuration: 1000,
			fxTransition: 'expo:out',
			hoverColor: false,
			interval: $('news').hasClass('_noautoplay') ? false : 5000,
			navigationEnabled: !$('news').hasClass('_nonavi'),
			navigationOpacity: .7,
			pauseOnMouseOver: $('news').hasClass('_pause')
		});
	}
	if ($('sample_fade')) {
		new NewsSlide($('sample_fade'), {
			fadeDuration: 1500,
			fxDelay: 750,
			fxDuration: 1000,
			fxTransition: 'expo:out',
			hoverColor: false,
			interval: 5000,
			navigationEnabled: false
		});
	}
	if($('accordion')){
		new Accordion($('accordion'));
	}
	$$('.alpha5').each(function (el) {
		el.fade(.5);
	});
	var myTips = new Tips('.tooltip');
	myTips.addEvent('show', function (tip, el) {
		tip.fade('in');
	}).addEvent('hide', function (tip, el) {
		tip.fade('out');
	});
	/*if($$('.overlay')[0]){
		var overlay = $$('.overlay')[0];
		var close = $$('.overlay')[0];
		close.addEvent('click', function () {
			new Fx.Tween(overlay, {
				duration: 250
			}).start('opacity', 0).chain(function () {
				overlay.dispose();
			});
		});
	}*/
    if ($$('.slideshow')[0]) {
        new SlideShow($$('.slideshow')[0], {
            fxDuration: 1250,
            fxTransiition: 'sine:in',
            interval: 5500,
            setTitle: true
        });
    }
    if ($$('.content-slideshow')[0]) {
        new SlideShow($$('.content-slideshow')[0], {
            fadeOut: true,
            fxDuration: 750,
            fxTransiition: 'sine:in',
            interval: 5000,
            setTitle: false
        });
    }
    $$('table.zebra').each(function(table){
        table.getElements('tr').each(function(tr, i){
            if(i > 0)
            {
                tr.addClass(i % 2 == 0 ? 'even' : 'odd');
            }
        });
    });
}
window.addEvent('domready', function () {
	init();
});