/* Script : Image Menu - Version : 2.2 - Authors : Samuel Birch - Licence : Open Source MIT Licence */
var ImageMenu = new Class({
	getOptions: function(){
		return {
			onOpen: false,
			onClose: Class.empty,
			openWidth: 200,
			openOthers: 75,
			transition: Fx.Transitions.Circ.easeInOut,
			duration: 900,
			open: 'active',
			border: 0
		};
	},
	initialize: function(elements, options){
		this.setOptions(this.getOptions(), options);
		this.elements = $$(elements);
		this.widths = {};
		this.widths.closed = this.elements[0].getStyle('width').toInt();
		this.widths.openSelected = this.options.openWidth;
		this.widths.openOthers = this.options.openOthers;
		this.fx = new Fx.Elements(this.elements, {wait: false, duration: this.options.duration, transition: this.options.transition});
		this.elements.each(function(el,i){
			el.addEvent('mouseenter', function(e){
				new Event(e).stop();
				this.reset(i);
			}.bind(this));
			var obj = this;
			el.addEvent('click', function(e){
				if(obj.options.onOpen){
					new Event(e).stop();
					if(obj.options.open == i){
						obj.options.open = null;
						obj.options.onClose(this.href, i);
					}else{
						obj.options.open = i;
						obj.options.onOpen(this.href, i);
					}
				}
			})
		}.bind(this));
		if(this.options.open){
			if($type(this.options.open) == 'number'){
				this.reset(this.options.open);
			}else{
				this.elements.each(function(el,i){
					if(el.id == this.options.open){
						this.reset(i);
					}
				},this);
			}
		}
	},
	reset: function(num){
		if($type(num) == 'number'){
			var width = this.widths.openOthers;
		}else{
			var width = this.widths.closed;
		}
		var obj = {};
		this.elements.each(function(el,i){
			var w = width;
			obj[i] = {'width': w};
		}.bind(this));
		if($type(num) == 'number'){
			obj[num] = {'width': this.widths.openSelected};
		}
		this.fx.start(obj);
	}
});
ImageMenu.implement(new Options);
ImageMenu.implement(new Events);


/* Script: dropMenu.js Drop menu going Nth levels License: MIT-style license. Author: Copyright (c) 2008 Chris Esler, <http://www.chrisesler.com/mootools> */
// Also known as IE fix
var TridentFix = new Class({
	tridentFix: function(item){
		item.addEvents({
			'mouseover':function(){
				this.addClass('iehover');
			},
			'mouseout':function(){
				this.removeClass('iehover');
			}
		});
	}
});
var DropMenu = new Class({
	Implements: [Options,TridentFix],
	options: {
		mode: 'horizontal'
	},
	menu: null,
	initialize: function(menu,options){
		if(options) this.setOptions(options);
		this.menu = $(menu);
		var children = this.menu.getChildren();
		children.each(function(item,index){
			var fChild, list;
			fChild = item.getFirst();
			list = fChild.getNext('ul');
			if(Browser.Engine.trident) this.tridentFix(item);
			if(list){
				item.mel = list;
				list.pel = item;
				new SubMenu(list);
			}
		},this);
	}	
});
var SubMenu = new Class({
	Implements: [Options,TridentFix],
	options: {
		mode: 'vertical'
	},
	menu: null,
	depth: 0,
	initialize: function(el,depth,options){
		if(options) this.setOptions(options);
		if(depth) this.depth = depth;
		this.menu = el;
		if(this.depth == 0)	this.menu.addClass('submenu');
		if(this.depth >= 1)	this.menu.addClass('sub_submenu');
		this.menu.fade('hide');
		this.menu.pel.addEvents(this.parentEvents); 
		var children = this.menu.getChildren();
		children.each(function(item,index){
			var fChild, list;
			fChild = item.getFirst();
			list = fChild.getNext('ul');
			if(Browser.Engine.trident) this.tridentFix(item);
			if(list){
				var count = new Element('span').set('html','\&raquo;').addClass('counter');
				item.adopt(count);
				count.fade('hide');
				item.mel = list;
				item.count = count;
				list.pel = item;
				new SubMenu(list,this.depth+1);
			}
		},this);
	},
	parentEvents: {
		'mouseover': function(){
			if(this.count) this.count.fade('in');
			this.mel.fade('in');		
		},
		'mouseout': function(){
			if(this.count) this.count.fade('out');
			this.mel.fade('out');
		}
	}
});
/*********************************************************/

window.addEvent('domready', function(){
	if($('imageMenu')) var myMenu = new ImageMenu($$('#imageMenu a'),{openWidth:728, open:'active'});
	var menu = new DropMenu('navmenu-h');
	if($('newsItemScroller')) new MooScroller('newsItemScroller', 'newsItemKnob');
	if($('newsTextScroller')) new MooScroller('newsTextScroller', 'newsTextKnob');
	
	if ($('myForm')){ new FormValidator('myForm');}

});