/*
 * Created for OrionTravel.co.uk
 * By b4k4 web design (http://b4k4.co.uk/)
 *
 * Requires the Mootools (v.2) JS framework
 */

window.addEvent('domready', function() {

	// Add the navigation menu effects
	$$('#nav li a').each(function(elem) {
		elem.fx = new Fx.Tween(elem, { "property" : "margin-left", "duration" : 150, "wait" : false });
		elem.addEvent('mouseover', function() { this.fx.start("0"); });
		elem.addEvent('mouseout', function() { this.fx.start("4"); });
	});
	
	// Add a colour-tween to heading links
	$$('h1 a').each(function(elem) {
							 elem.baseColor = elem.getStyle('color');
							 elem.fx = new Fx.Tween(elem, { "property" : "color", "duration" : 150, "wait" : false });
							 elem.addEvent('mouseover', function() { this.fx.start("#c00"); });
							 elem.addEvent('mouseout', function() { this.fx.start(elem.baseColor); });
	});
	
	// Add image gallery thumb hover titles
	$$('.image-thumbs img').each(function(thumb) {
		if (thumb.getProperty("alt")) {
			thumb.titleElem = new Element('div', {'class' : 'thumb-title', 'text' : thumb.getProperty("alt")}).inject(thumb.parentNode).fade('hide');
			thumb.fx = new Fx.Tween(thumb.titleElem, { "property" : "opacity", "duration" : 250, "wait" : false });
			thumb.addEvent('mouseover', function() { thumb.fx.start(.9); });
			thumb.addEvent('mouseout', function() { thumb.fx.start(0); });
		}
	});
	
	// link-box effects
	$$('.link-box a').each(function(elem) {
		elem.fx = new Fx.Tween(elem, { "property" : "padding-right", "duration" : 150, "wait" : false });
		elem.addEvent('mouseover', function() { this.fx.start("28 0"); });
		elem.addEvent('mouseout', function() { this.fx.start("20 0"); });
	});
	
	// add a "next" arrow to the main gallery image on hover
	var mainImage = $('nextlink');
	if (mainImage) {
		mainImage.fx = new Fx.Tween( 
							new Element('span', {'class' : "next-arrow" }).inject(mainImage).fade('hide'), 
							{ 'property' : "opacity", 'duration' : 250, "wait" : false }
						);
		mainImage.addEvent('mouseover', function() { this.fx.start(1); });
		mainImage.addEvent('mouseout', function() { this.fx.start(0); });
	}
	
});