var page_url = "home";
var page_col = "#333333";

var preview_swf = {};
preview_swf.fv = {};
preview_swf.p = {
	bgcolor:"#0C0C0C",
	scale:"noscale",
	quality:"high",
	menu:"false",
	swliveconnect:"true"
};
preview_swf.a = {
	id:"previewFlash",
	name:"previewFlash"
};
swfobject.embedSWF("home_preview.swf", "contentRibbon", "100%", "94", "8.0.0", "", preview_swf.fv, preview_swf.p, preview_swf.a);



var columnCol = {
	home:"#151515",
	flashearth:"#101112",
	planetarium:"#0E121A",
	games:"#4C0C32",
	imagination:"#480C0C",
	fractal:"#0C320C",
	television:"#252525",
	strobe:"#4C4C4C",
	anaglyph:"#151515",
	bounce:"#0C4C4C",
	light:"#32254C",
	dandelion:"#2C334C",
	webcam:"#4C4C0C",
	vote:"#491422",
	flickr:"#0C2543",
	twitter:"#183F4C",
	rss:"#4C250C",
	about:"#1D3248",
	mt:"#212121"
};

var SPEED = 300;
var section = "intro";

var ci_fx = null;
var cc_fx = null;
var fc_fx = null;
var fct_fx = null;

var introPauseID = 0;
var titlePauseID = 0;

function enterLinkHome() {
	if (!ready) return;
	
	var str = this.id.substr(0, this.id.length - 4);
	if (str.length < 1 || str == page_url) return;
	
	clearTimeout(introPauseID);
	showInfo(str);
	
	try {
		if (cc_fx != null) cc_fx.stop();
		cc_fx = new Fx.Style(cc, "background-color", {duration:SPEED});
		cc_fx.start(cc.getStyle("background-color"), columnCol[str]);
		
		if (fc_fx != null) fc_fx.stop();
		fc_fx = new Fx.Style(fc, "background-color", {duration:SPEED});
		fc_fx.start(fc.getStyle("background-color"), bgCol[str]);
		
		if (fct_fx != null) fct_fx.stop();		
		if (invertList[str]) {
			fct_fx = new Fx.Style(fct, "color", {duration:150});
			fct_fx.start(fct.getStyle("color"), "#000000");
		}
		else fct.setStyle("color", "#FFFFFF");
	}
	catch (e) { }
}

function leaveLinkHome() {
	if (!ready) return;
	
	clearTimeout(introPauseID);
	introPauseID = setTimeout(showIntroPause, 200);
}

function showIntroPause() {
	if (!ready) return;
	
	clearTimeout(introPauseID);
	showInfo("intro");
	
	try {
		if (cc_fx != null) cc_fx.stop();
		cc_fx = new Fx.Style(cc, "background-color", {duration:SPEED});
		cc_fx.start(cc.getStyle("background-color"), columnCol[page_url]);
		
		if (fc_fx != null) fc_fx.stop();
		fc_fx = new Fx.Style(fc, "background-color", {duration:SPEED});
		fc_fx.start(fc.getStyle("background-color"), bgCol[page_url]);
		
		if (fct_fx != null) {
			fct_fx.stop();
			fct_fx.set("#FFFFFF");
			fct_fx = null;
		}
		fct.setStyle("color", "#FFFFFF");
	}
	catch (e) { }
}

function showTitle() {
	clearTimeout(titlePauseID);
	try { document.getElementById("previewFlash").showTitle(section); }
	catch (e) { titlePauseID = setTimeout(showTitle, 100); }
}

function showInfo(str) {
	if (!ready) return;
	
	clearTimeout(introPauseID);
	
	var info = $(section + "Text");
	if (info) info.setStyle("display", "none");
	
	if (str == "" || str == "null" || str == undefined) {
		section = str = "intro";
		$("introText").setStyle("display", "block");
	}
	else {
		section = str;
		$("introText").setStyle("display", "none");
		var info = $(str + "Text");
		if (info) info.setStyle("display", "block");
	}
	
	showTitle();
}

window.addEvent("domready", function() {
	var links = $$("#linksColumns a");
	links.each(function(link, i) {
		link.addEvent("mouseenter", enterLinkHome);
		link.addEvent("mouseleave", leaveLinkHome);
	});
	
	links = $$("#footerLinks a");
	links.each(function(link, i) {
		link.addEvent("mouseenter", enterLinkHome);
		link.addEvent("mouseleave", leaveLinkHome);
	});
	
	cc = $("contentColumn");
	fc = $("footerCopy");
	fct = $("footerCopyText");
});