window.addEvent('domready',function(){
	fancy('#breadcrumb a.fancy','a.bchover');
	fancy('a.fancy','a.fancy:hover');
	fancy('input.fancy','input.fancyhover');
	nav();
	externallinks();
});

var externallinks = function(){
	document.getElements('a').addEvent('click',function(){
		if (this.get('href').toString().substr(0,7) == 'http://' && (this.get('href').toString().match(/^http:\/\/[(www.)]*do1\.uk\.com/) == null)){
			window.open(this.get('href'));
			return false;
		}
		return true;
	});
}

var nav = function(){
	var _el = document.getElements('#nav li');
	_el.addEvents({
		'mouseenter':function(){
			this.getElement('div').setStyles({'width':this.getSize().x,'cursor':'pointer'}).set('morph',{duration:100}).morph({'opacity':[0,0.08]});
		},
		'mouseleave':function(){
			this.getElement('div').set('morph',{duration:600}).morph({'opacity':[0.08,0]});
		}
	}).each(function(e){e.setStyle('width',e.getSize().x)});
	document.getElements('#nav li div').setStyles({'opacity':0,'background-color':'#eeeded'});
	document.getElements('#nav li a').setStyles({'position':'absolute'});
}

var fancy = function(elements,hover){
	var _el = document.getElements(elements);
	var col,bb; 
	_el.removeClass('fancy').addClass('fancyjs').set('morph',{duration:400}).addEvents({
		'mouseenter':function(){
			col = this.getStyle('color');
			bb = this.getStyle('border-bottom-color');
			this.set('morph',{duration:400}).morph(hover);
		},
		'mouseleave':function(){
			this.set('morph',{duration:400}).morph({'color':col,'border-bottom-color':bb});
		}
	});
	
}