window.addEvent('domready', function() {

/*****************************************************
|	Adds hook for Opera & Safari CSS
*****************************************************/

	if(window.opera) {
		document.body.addClass("opera");	
	}

/*****************************************************
|	Main Navigation
*****************************************************/

	var navItems = $$('#navGlobal ul li a');
	var activeItem = $E('.selected', '#navGlobal');
	
	navItems.each(function(item) {
		item.$tmp.fx = new Fx.Styles(item, {wait: false, duration: 500, transition: Fx.Transitions.Circ.easeInOut});
		if (activeItem) {activeItem.$tmp.fx2 = new Fx.Styles(activeItem, {wait: false, duration: 500, transition: Fx.Transitions.Circ.easeInOut});};
			
		if(item.hasClass("selected")){
			if(window.gecko || window.opera){
				item.$tmp.fx.start({'background-position': '0px 0px', 'color':'#fff'});
			} else {
				item.$tmp.fx.start({'background-position-y': 0, 'color':'#fff'});
			}
		} else {
			if(window.gecko || window.opera){
				item.$tmp.fx.start({'background-position': '0px 38px', 'color':'#fff'});
			} else {	
				item.$tmp.fx.start({'background-position-y': 38, 'color':'#fff'});
			}
			//	Show bg on mouse over	
			item.addEvent('mouseenter', function(event) {
				event = new Event(event).stop();
				this.$tmp.fx.stop();
				if (activeItem) {activeItem.$tmp.fx2.stop();};
				if(window.gecko || window.opera){
					this.$tmp.fx.start({'background-position': '0px 0px', 'color':'#fff'});
					if (activeItem) {activeItem.$tmp.fx2.start({'background-position': '0px 38px', 'color':'#fff'});};
				} else {
					this.$tmp.fx.start({'background-position-y': 0, 'color':'#fff' });
					if (activeItem) {activeItem.$tmp.fx2.start({'background-position-y': 38, 'color':'#fff'});};
				}
			});
			//	Hide bg on mouse leave	
			item.addEvent('mouseleave', function(event) {
				event = new Event(event).stop();
				this.$tmp.fx.stop();
				if(window.gecko || window.opera){
					this.$tmp.fx.start({'background-position': '0px 38px', 'color':'#fff'});
					if (activeItem) {activeItem.$tmp.fx2.start({'background-position': '0px 0px', 'color':'#fff'});};
				} else {			  
					this.$tmp.fx.start({'background-position-y': 38, 'color':'#fff'});
					if (activeItem) {activeItem.$tmp.fx2.start({'background-position-y': 0, 'color':'#fff'});};
				}	
			});
		}
	});

	//	Return to current open section when you leave the menu
	$('navGlobal').addEvent('mouseleave', function(event) {
		event = new Event(event).stop();
		if(window.gecko || window.opera){
			if (activeItem) {activeItem.$tmp.fx2.start({'background-position': '0px 0px'});};
		} else {			  
			if (activeItem) {activeItem.$tmp.fx2.start({'background-position-y': 0});};
		}
	});
	
/*****************************************************
|	Sub Navigation
*****************************************************/

	var navSubItems = $$('#navSub ul li a');
	var activeSubItem = $E('.current', '#navSub');
	
	if (navSubItems) {
		navSubItems.each(function(item2) {
			item2.$tmp.fx = new Fx.Styles(item2, {wait: false, duration: 400, transition: Fx.Transitions.Circ.easeInOut});
			if (activeSubItem) {activeSubItem.$tmp.fx2 = new Fx.Styles(activeSubItem, {wait: false, duration: 400, transition: Fx.Transitions.Circ.easeInOut});};
				
			if(item2.hasClass("current")){
				if(window.gecko || window.opera){
					item2.$tmp.fx.start({'background-position': '0px 0px'});
				} else {
					item2.$tmp.fx.start({'background-position-x': 0});
				}
			} else {
				if(window.gecko || window.opera){
					item2.$tmp.fx.start({'background-position': '-4px 0px'});
				} else {	
					item2.$tmp.fx.start({'background-position-x': -4});
				}
				//	Show bg on mouse over	
				item2.addEvent('mouseenter', function(event) {
					event = new Event(event).stop();
					this.$tmp.fx.stop();
					if (activeSubItem) {activeSubItem.$tmp.fx2.stop();};
					if(window.gecko || window.opera){
						this.$tmp.fx.start({'background-position': '0px 0px'});
						if (activeSubItem) {activeSubItem.$tmp.fx2.start({'background-position': '-4px 0px'});};
					} else {
						this.$tmp.fx.start({'background-position-x': 0});
						if (activeSubItem) {activeSubItem.$tmp.fx2.start({'background-position-x': -4});};
					}
				});
				//	Hide bg on mouse leave	
				item2.addEvent('mouseleave', function(event) {
					event = new Event(event).stop();
					this.$tmp.fx.stop();
					if(window.gecko || window.opera){
						this.$tmp.fx.start({'background-position': '-4px 0px'});
						if (activeSubItem) {activeSubItem.$tmp.fx2.start({'background-position': '0px 0px'});};
					} else {			  
						this.$tmp.fx.start({'background-position-x': -4});
						if (activeSubItem) {activeSubItem.$tmp.fx2.start({'background-position-x': 0});};
					}	
				});
			}
		});
	};
	
	var navSub = $('navSub')
	
	if (navSub) {
	//	Return to current open section when you leave the menu
		 navSub.addEvent('mouseleave', function(event) {
			event = new Event(event).stop();
			if(window.gecko || window.opera){
				if (activeSubItem) {activeSubItem.$tmp.fx2.start({'background-position': '0px 0px'});};
			} else {			  
				if (activeSubItem) {activeSubItem.$tmp.fx2.start({'background-position-x': 0});};
			}
		});
	};
	
/*****************************************************
|	More Links
*****************************************************/
var moreLink = $ES('.moreLink', '#contentMain');
	
	moreLink.each(function(item) {
	item.$tmp.fx = new Fx.Styles(item, {wait: false, duration: 200, transition: Fx.Transitions.Circ.easeInOut});
	
	if(window.gecko || window.opera){
		item.$tmp.fx.start({'background-position': '-18px, 0px'});
	} else {
		item.$tmp.fx.start({'background-position-x': -18});
	}
	item.addEvent('mouseenter', function(event) {
		event = new Event(event).stop();
			this.$tmp.fx.stop();
			if(window.gecko || window.opera){
				this.$tmp.fx.start({'background-position': '0px, 0px'});
			} else {			  
				this.$tmp.fx.start({'background-position-x': 0});
			}
	});
	item.addEvent('mouseleave', function(event) {
		event = new Event(event).stop();
			this.$tmp.fx.stop();
			if(window.gecko || window.opera){
				this.$tmp.fx.start({'background-position': '-18px, 0px'});
			} else {			  
				this.$tmp.fx.start({'background-position-x': -18});
			}
	});
});
	
var moreLink2 = $ES('.moreLink2', '#contentMain');
	
	moreLink2.each(function(item) {
	item.$tmp.fx = new Fx.Styles(item, {wait: false, duration: 200, transition: Fx.Transitions.Circ.easeInOut});
	
	if(window.gecko || window.opera){
		item.$tmp.fx.start({'background-position': '-18px, 0px'});
	} else {
		item.$tmp.fx.start({'background-position-x': -18});
	}
	item.addEvent('mouseenter', function(event) {
		event = new Event(event).stop();
			this.$tmp.fx.stop();
			if(window.gecko || window.opera){
				this.$tmp.fx.start({'background-position': '0px, 0px'});
			} else {			  
				this.$tmp.fx.start({'background-position-x': 0});
			}
	});
	item.addEvent('mouseleave', function(event) {
		event = new Event(event).stop();
			this.$tmp.fx.stop();
			if(window.gecko || window.opera){
				this.$tmp.fx.start({'background-position': '-18px, 0px'});
			} else {			  
				this.$tmp.fx.start({'background-position-x': -18});
			}
	});
});
	
var moreLink3 = $ES('.moreLink3', '#contentMain');
	
	moreLink3.each(function(item) {
	item.$tmp.fx = new Fx.Styles(item, {wait: false, duration: 200, transition: Fx.Transitions.Circ.easeInOut});
	
	if(window.gecko || window.opera){
		item.$tmp.fx.start({'background-position': '-18px, 0px'});
	} else {
		item.$tmp.fx.start({'background-position-x': -18});
	}
	item.addEvent('mouseenter', function(event) {
		event = new Event(event).stop();
			this.$tmp.fx.stop();
			if(window.gecko || window.opera){
				this.$tmp.fx.start({'background-position': '0px, 0px'});
			} else {			  
				this.$tmp.fx.start({'background-position-x': 0});
			}
	});
	item.addEvent('mouseleave', function(event) {
		event = new Event(event).stop();
			this.$tmp.fx.stop();
			if(window.gecko || window.opera){
				this.$tmp.fx.start({'background-position': '-18px, 0px'});
			} else {			  
				this.$tmp.fx.start({'background-position-x': -18});
			}
	});
});

/*****************************************************
|	Search Field
*****************************************************/
 
	var searchField = $('searchField');
	
	if (searchField) {
		searchField.addEvents({
			'focus': function(){ if (this.value == 'Enter your search' ) this.value = ''; }, 
			'blur': function(){ if (!this.value) this.value = 'Enter your search'; }
							  });
	}

/*****************************************************
|	External links
*****************************************************/

	$$('a.external').each(function(link){
		link.target = "_blank";
	});

//	End Mootools

});