//MooTools More, <http://mootools.net/more>. Copyright (c) 2006-2009 Aaron Newton <http://clientcide.com/>, Valerio Proietti <http://mad4milk.net> & the MooTools team <http://mootools.net/developers>, MIT Style License.

MooTools.More={version:"1.2.4.4",build:"6f6057dc645fdb7547689183b2311063bd653ddf"};(function(){var a=function(c,b){return(c)?($type(c)=="function"?c(b):b.get(c)):"";
};this.Tips=new Class({Implements:[Events,Options],options:{onShow:function(){this.tip.setStyle("display","block");},onHide:function(){this.tip.setStyle("display","none");
},title:"title",text:function(b){return b.get("rel")||b.get("href");},showDelay:100,hideDelay:100,className:"tip-wrap",offset:{x:16,y:16},windowPadding:{x:0,y:0},fixed:false},initialize:function(){var b=Array.link(arguments,{options:Object.type,elements:$defined});
this.setOptions(b.options);if(b.elements){this.attach(b.elements);}this.container=new Element("div",{"class":"tip"});},toElement:function(){if(this.tip){return this.tip;
}return this.tip=new Element("div",{"class":this.options.className,styles:{position:"absolute",top:0,left:0}}).adopt(new Element("div",{"class":"tip-top"}),this.container,new Element("div",{"class":"tip-bottom"})).inject(document.body);
},attach:function(b){$$(b).each(function(d){var f=a(this.options.title,d),e=a(this.options.text,d);d.erase("title").store("tip:native",f).retrieve("tip:title",f);
d.retrieve("tip:text",e);this.fireEvent("attach",[d]);var c=["enter","leave"];if(!this.options.fixed){c.push("move");}c.each(function(h){var g=d.retrieve("tip:"+h);
if(!g){g=this["element"+h.capitalize()].bindWithEvent(this,d);}d.store("tip:"+h,g).addEvent("mouse"+h,g);},this);},this);return this;},detach:function(b){$$(b).each(function(d){["enter","leave","move"].each(function(e){d.removeEvent("mouse"+e,d.retrieve("tip:"+e)).eliminate("tip:"+e);
});this.fireEvent("detach",[d]);if(this.options.title=="title"){var c=d.retrieve("tip:native");if(c){d.set("title",c);}}},this);return this;},elementEnter:function(c,b){this.container.empty();
["title","text"].each(function(e){var d=b.retrieve("tip:"+e);if(d){this.fill(new Element("div",{"class":"tip-"+e}).inject(this.container),d);}},this);$clear(this.timer);
this.timer=(function(){this.show(this,b);this.position((this.options.fixed)?{page:b.getPosition()}:c);}).delay(this.options.showDelay,this);},elementLeave:function(c,b){$clear(this.timer);
this.timer=this.hide.delay(this.options.hideDelay,this,b);this.fireForParent(c,b);},fireForParent:function(c,b){b=b.getParent();if(!b||b==document.body){return;
}if(b.retrieve("tip:enter")){b.fireEvent("mouseenter",c);}else{this.fireForParent(c,b);}},elementMove:function(c,b){this.position(c);},position:function(e){if(!this.tip){document.id(this);
}var c=window.getSize(),b=window.getScroll(),f={x:this.tip.offsetWidth,y:this.tip.offsetHeight},d={x:"left",y:"top"},g={};for(var h in d){g[d[h]]=e.page[h]+this.options.offset[h];
if((g[d[h]]+f[h]-b[h])>c[h]-this.options.windowPadding[h]){g[d[h]]=e.page[h]-this.options.offset[h]-f[h];}}this.tip.setStyles(g);},fill:function(b,c){if(typeof c=="string"){b.set("html",c);
}else{b.adopt(c);}},show:function(b){if(!this.tip){document.id(this);}this.fireEvent("show",[this.tip,b]);},hide:function(b){if(!this.tip){document.id(this);
}this.fireEvent("hide",[this.tip,b]);}});})();
/*
script: mootools.slideGallery.js

description: Multifunctional slide carousel for MooTools.

license: MIT-style license

authors:
- Sergii Kashcheiev

requires:
- core/1.2.4: Fx.Tween
- core/1.2.4: Fx.Transitions

provides: [slideGallery, fadeGallery]
*/
var slideGallery = new Class({
	Version: "1.2.1",
	Implements: [Options],
	options: {
		holder: ".holder",
		elementsParent: "ul",
		elements: "li",
		nextItem: ".next",
		prevItem: ".prev",
		stop: ".stop",
		start: ".start",
		speed: 600,
		duration: 4000,
		steps: 1,
		current: 0,
		transition: Fx.Transitions.linear,
		direction: "horizontal",
		mode: "callback",
		disableClass: "disable",
		currentClass: "current",
		paging: false,
		autoplay: false,
		onStart: function(current, visible, length) {},
		onPlay: function(current, visible, length) {}
	},
	initialize: function(gallery, options) {
		this.gallery = gallery;
		this.setOptions(options);
		this.holder = this.gallery.getElement(this.options.holder);
		this.itemsParent = this.holder.getElement(this.options.elementsParent);
		this.items = this.itemsParent.getElements(this.options.elements);
		this.next = this.gallery.getElement(this.options.nextItem);
		this.next.cl = this.next.className;
		this.prev = this.gallery.getElement(this.options.prevItem);
		this.prev.cl = this.prev.className;
		this.stop = this.gallery.getElement(this.options.stop);
		this.start = this.gallery.getElement(this.options.start);
		this.current = this.options.current;
		this.bound = { rotate: this.rotate.bind(this) }
		
		if(this.options.direction == "horizontal") {
			this.direction = "margin-left";
			this.size = this.items[0].getWidth();
			this.visible = Math.round(this.holder.getWidth()/this.size);
		}
		else {
			this.direction = "margin-top";
			this.size = this.items[0].getHeight();
			this.visible = Math.round(this.holder.getHeight()/this.size);
		}
		
		if(this.next == null) this.next = new Element("a").injectInside(this.gallery);
		if(this.prev == null) this.prev = new Element("a").injectInside(this.gallery);
		
		if(this.visible < this.items.length) {
			this.options.steps = this.options.steps > this.visible ? this.visible : this.options.steps;
			this.options.duration = this.options.duration < 1000 ? 1000 : this.options.duration;
			
			if(this.options.mode != "circle") {
				for(var i=0; i<this.items.length; i++) {
					if(this.items[i].hasClass(this.options.currentClass)) this.current = i;
				}
				if(this.visible+this.current >= this.items.length) {
					this.margin = (this.items.length-this.visible)*this.size;
					this.current = this.items.length-this.visible;
				}
				else this.margin = this.current*this.size;
				
				if(this.options.paging) {
					this.paging = new Element("ul").injectInside(this.gallery).addClass("paging");
					for(var i=0; i<Math.ceil((this.items.length-this.visible)/this.options.steps)+1; i++) {
						this.paging.innerHTML += '<li><a href="#">' + parseInt(i+1) + '</a></li>';
					}
					this.paging = this.paging.getElements("a");
					this.paging.each(function(el, i) {
						el.addEvent("click", function() {
							if(i*this.options.steps+this.visible >= this.items.length) {
								this.margin = (this.items.length-this.visible)*this.size;
								this.current = this.items.length-this.visible;
							}
							else this.current = i*this.options.steps;
							this.margin = this.current*this.size;
							
							this.play(this.options.speed);
							return false;
						}.bind(this));
					}.bind(this));
				}
				this.play(0);
			}
			else {
				for(; this.items.length < this.options.steps+this.visible;) {
					this.items.clone().inject(this.itemsParent, "bottom");
					this.items = this.itemsParent.getElements(this.options.elements);
				}
				this.current = 0;
				this.options.paging = false;
			}
			
			this.next.addEvent("click", function() {
				if(this.options.mode != "circle") {
					if(this.visible+this.current >= this.items.length) {
						if(this.options.mode == "callback") {
							this.margin = 0;
							this.current = 0;
						}
					}
					else if(this.visible+this.current+this.options.steps >= this.items.length) {
						this.margin = (this.items.length-this.visible)*this.size;
						this.current = this.items.length-this.visible;
					}
					else	{
						this.current = this.current+this.options.steps;
						this.margin = this.current*this.size;
					}
					this.play(this.options.speed);
				}
				else {
					var _this = this;
					this.margin = this.size*this.options.steps;
					this.itemsParent.set("tween", {
						duration: this.options.speed,
						transition: this.options.transition,
						property: this.direction,
						onComplete: function()	{
							for(var i=0; i<_this.options.steps; i++) {
								if(_this.current >= _this.items.length) _this.current = 0;
								_this.current++;
								_this.items[_this.current-1].inject(_this.itemsParent, "bottom");
							}
							this.set(0);
						},
						onCancel: function() {	this.onComplete(); }
					});
					this.itemsParent.tween(-this.margin);
				}
				return false;
			}.bind(this));
			
			this.prev.addEvent("click", function() {
				if(this.options.mode != "circle") {
					if(this.current <= 0) {
						if(this.options.mode == "callback") {
							this.margin = (this.items.length-this.visible)*this.size;
							this.current = this.items.length-this.visible;
						}
					}
					else if(this.current-this.options.steps <= 0) {
						this.margin = 0;
						this.current = 0;
					}
					else	{
						this.current = this.current-this.options.steps;
						this.margin = this.current*this.size;
					}
					this.play(this.options.speed);
				}
				else {
					for(var i=0; i<this.options.steps; i++) {							
						if(this.current-1 < 0) this.current = this.items.length;
						--this.current;
						this.items[this.current].inject(this.itemsParent, "top");
					}
					this.itemsParent.setStyle(this.direction, -this.size*this.options.steps + "px");
					this.margin = 0;
					this.play(this.options.speed);
				}
				return false;
			}.bind(this));

			if(this.options.autoplay || this.start || this.stop) {
				if(!this.options.autoplay) this.gallery.addClass("stopped");
				this.timer = this.bound.rotate.delay(this.options.duration);
				this.gallery.addEvent("mouseenter", function() {
					this.options.autoplay = false;
					$clear(this.timer);
				}.bind(this));
				this.gallery.addEvent("mouseleave", function() {
					if(!this.gallery.hasClass("stopped")) {
						$clear(this.timer);
						this.options.autoplay = true;
						this.timer = this.bound.rotate.delay(this.options.duration);
					}
				}.bind(this));
			}
			if(this.stop) {
				this.stop.addEvent("click", function() {
					this.gallery.addClass("stopped").fireEvent("mouseenter");
					return false;
				}.bind(this));
			}
			if(this.start) {
				this.start.addEvent("click", function() {
					this.gallery.removeClass("stopped").fireEvent("mouseenter");
					return false;
				}.bind(this));
			}
		}
		else {
			this.next.addClass(this.next.cl + "-" + this.options.disableClass);
			this.prev.addClass(this.prev.cl + "-" + this.options.disableClass);
			this.next.addEvent("click", function() {return false;}.bind(this));
			this.prev.addEvent("click", function() {return false;}.bind(this));
			if(this.stop) this.stop.addEvent("click", function() {return false;}.bind(this));
			if(this.start) this.start.addEvent("click", function() {return false;}.bind(this));
			this.gallery.addClass("stopped");
		}
		this.options.onStart(this.current, this.visible, this.items.length);
	},
	play: function(speed) {
		if(this.options.mode == "line") {
			this.next.removeClass(this.next.cl + "-" + this.options.disableClass);
			this.prev.removeClass(this.prev.cl + "-" + this.options.disableClass);
			if(this.visible+this.current >= this.items.length) this.next.addClass(this.next.cl + "-" + this.options.disableClass);
			else if(this.current==0) this.prev.addClass(this.prev.cl + "-" + this.options.disableClass);
		}
		this.itemsParent.set("tween", {
			duration: speed,
			transition: this.options.transition
		});
		this.itemsParent.tween(this.direction, -this.margin);
		if(this.options.paging) {
			this.paging.removeClass("active");
			this.paging[Math.ceil(this.current/this.options.steps)].addClass("active");
		}
		this.options.onPlay(this.current, this.visible, this.items.length);
	},
	rotate: function() {
		if(this.options.autoplay) {
			this.next.fireEvent("click");
			this.timer = this.bound.rotate.delay(this.options.duration);
		}
	}
});
var fadeGallery = new Class({
	Extends: slideGallery,
	initialize: function(gallery, options) {
		this.previous = null;
		this.parent(gallery, options);
		this.visible = 1;
		this.options.steps = 1;
	},
	play: function(speed) {
		if(this.previous == null) this.previous = this.items;
		this.previous.set("tween", {
			duration: speed,
			transition: this.options.transition
		});
		this.previous.tween("opacity", 0);
		this.items[this.current].set("tween", {
			duration: speed,
			transition: this.options.transition
		});
		this.items[this.current].tween("opacity", 1);
		if(this.options.paging) {
			this.paging.removeClass("active");
			this.paging[Math.ceil(this.current/this.options.steps)].addClass("active");
		}
		this.previous = this.items[this.current];
		this.options.onPlay(this.current, this.visible, this.items.length);
	}
});

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()
{
	
	$$('a[rel=external]').addEvent('click', function(e){
		e.stop();
		window.open(this.href);
	});
	
	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');
            }
        });
    });
	
	// Slide Gallery
	
	if($('slideGallery'))
	{
		new slideGallery($('slideGallery'), {
			steps: 1,
			autoplay: true,
			duration: 3000,
			mode: 'circle',
			speed: 250
		});
		if(!Browser.Engine.trident)
		{
			$$('.gallery .prev, .gallery .next').each(function(el){
				el.set('opacity', 0.5).addEvents({
					'mouseout': function(){
						el.fade(0.5);
					},
					'mouseover': function(){
						el.fade(1);
					}
				});
			});
		}
	}
	
	// Tabs product pages
	
	if($('Tabs'))
	{
		$$('#Tabs div.tab-content').each(function(div, i){
			if(i > 0)
			{
				div.setStyle('display', 'none');
			}
		});
		$$('#Tabs ul li').each(function(el, i){
			if(i == 0)
			{
				el. addClass('current');
			}
			el.addEvent('click', function(){
				var c = $$('#Tabs div.tab-content');
				c.setStyle('display', 'none');
				c[i].setStyle('display', 'block');
				
				$$('#Tabs li.current').removeClass('current');
				el. addClass('current');
			});
		});
	}
	
	
	// Voucher Form
	
	if($('form_voucher'))
	{
		var f = $('form_voucher');
		
		f.addEvent('submit', function(e){
			e.stop();
			
			var input_email = f.getElement('input[name=email]');
			var email = input_email.get('value');
			
			var regex_mail = /^[\w\-\.]+@[\w\-\.]+\.\w+$/;
			
			if(!regex_mail.test(email))
			{
				input_email.highlight('#f00');
				return;
			}
			
			var postData = 'email='+email;
			postData+= f.getElement('input[name=newsletter]').checked ? '&newsletter=1' : '';
			
			f.getElements('input').set('disabled', 'disabled');

			f.getElement('input[type=submit]').set('value', 'sending data...');
			
			new Request({
				onSuccess: function(response){

					if(response.toInt() == 0 && response != 'success' && response != 'default')
					{
						response = 'default';
					}

					new Fx.Morph(f).start({
						height: 0,
						opacity: 0
					}).chain(function(){
						var p = new Element('p', {
							html: '<strong>'+$('response_'+response).get('html')+'</strong>',
							styles: {
								fontSize: 14,
								opacity: 0
							}
						});
						p.replaces(f);
						p.fade(1);
						
					});
				},
				url: 'getvoucher.php'	
			}).send(postData);
		});
	}
	
	// staff sample books
	$$('.glow-book').each(function(el){
		var IE = Browser.Engine.trident;
		var img = el.getElement('img');
		
		if(IE)
		{
			
			img.setStyle('display', 'none');
		}
		else
		{
			el.store('fxInstance', new Fx.Tween(img));
		
			img.setStyle('opacity', 0);
		}

		el.setStyle('z-index', 5);

		el.addEvents({
			'mouseout': function(){
				if(IE)
				{
					img.setStyle('display', 'none');
				}
				else
				{
					var fx = el.retrieve('fxInstance');
					fx.pause();
					fx.start('opacity', 0);
				}
			},
			'mouseover': function(){
				if(IE)
				{
					img.setStyle('display', 'block');
				}
				else
				{
					var fx = el.retrieve('fxInstance');
					fx.pause();
					fx.start('opacity', 1);
				}
			}	
		});
	});
}
window.addEvent('domready', function () {
	init();
});