/**
 * Fading script for G-R-O-W.co.uk
 * 
 * @author Huy Dinh < huy dinh at hot mail dot co dot uk >
 * @copyright Online48 2007
 * 
 */


/*
 * You can change this as desired!
 */

var GROW = {
	"/": {
		fgColor: "#ffffff",
		bgColor: "#9DD2FC"
	},
	"/theprogramme/": {
		fgColor: "#ffffff",
		bgColor: "#9DD2FC"
	},
	"/lifecoaching/": {
		fgColor: "#ffffff",
		bgColor: "#BDD676"
	},
	"/theaim/": {
		fgColor: "#ffffff",
		bgColor: "#B0B0B0"
	},
	"/principles/": {
		fgColor: "#ffffff",
		bgColor: "#BDD676"
	},
	"/contact/": {
		fgColor: "#ffffff",
		bgColor: "#B0B0B0"
	}
}

/*
 * Do not change the script below!
 */
YAHOO.util.Event.onContentReady("menu", registerEvents);
YAHOO.util.Event.onContentReady("maincontent", fadeIn);

function fadeIn(e) {
	var fadeAnim = new YAHOO.util.ColorAnim("maincontent", { color: { from:document.bgColor, to:GROW[location.pathname].fgColor } } );
	fadeAnim.duration = 1;
	fadeAnim.animate();
}

function registerEvents() {
	var links = document.getElementById("menu").getElementsByTagName("a");
	for (i=0;i<links.length;i++) {
		YAHOO.util.Event.addListener(links[i], "click", fireAnimation);
	}
}

function fireAnimation(e) {
	YAHOO.util.Event.preventDefault(e);
	var pathname = ("/"==this.pathname.charAt(0))?this.pathname:"/"+this.pathname;
	if (GROW[pathname]) {
		var fadeAnim = new YAHOO.util.ColorAnim(document.body, { backgroundColor: { to: GROW[pathname].bgColor } });
		fadeAnim.onComplete.subscribe(openURL, this.href);
		fadeAnim.animate();
	}
}

function openURL(msg, stat, href) {
	window.location = href;
}

document.writeln('<style type="text/css">#maincontent { color:' + GROW[location.pathname].bgColor + '; }<'+'/s'+'tyle>');