var head_swf = {};
head_swf.fv = {
	page:page_url,
	col:page_col
};
head_swf.p = {
	bgcolor:page_col,
	scale:"noscale",
	quality:"best",
	menu:"false",
	salign:"t",
	swliveconnect:"true"
};
head_swf.a = {
	id:"headerFlash",
	name:"headerFlash"
};
if (page_url != "home") swfobject.embedSWF("neave_preview.swf", "headerPreviewInner", "172", "100%", "8.0.0", "", head_swf.fv, head_swf.p, head_swf.a);

var page_help;

var page_invert;
if (page_invert != true) page_invert = false;

var colArrow = page_invert ? "_black.gif" : "_white.gif";
var upArrow = "/assets/images/arrow_up" + colArrow;
var downArrow = new Image();
downArrow.src = "/assets/images/arrow_down" + colArrow;

var collapsed = false;
var link_fx = null;
var text_fx = null;
var bgCol = {
	home:"#333333",
	extra:page_col,
	headerCollapse:page_col,
	flashearth:"#12171A",
	planetarium:"#0B1A39",
	games:"#FF0099",
	imagination:"#EE0000",
	fractal:"#009900",
	television:"#666666",
	strobe:"#FFFFFF",
	anaglyph:"#333333",
	bounce:"#00FFFF",
	light:"#9966FF",
	dandelion:"#7F9BFF",
	webcam:"#FFFF00",
	vote:"#F22259",
	flickr:"#0063DC",
	twitter:"#33CCFF",
	rss:"#FF6600",
	about:"#4499EE",
	mt:"#555555"
};
var invertList =  {
	home:false,
	extra:page_invert,
	headerCollapse:false,
	flashearth:false,
	planetarium:false,
	games:false,
	imagination:false,
	fractal:false,
	television:false,
	strobe:true,
	anaglyph:false,
	bounce:true,
	light:false,
	dandelion:false,
	webcam:true,
	vote:false,
	flickr:false,
	twitter:false,
	rss:false,
	about:false,
	mt:false
};

function enterLink() {
	if (!ready) return;
	
	try {
		var str = this.id.substr(0, this.id.length - 4);
		if (str.length < 1 || str == page_url || (str == "extra" && page_help)) return;
		
		if (invertList[str]) {
			if (text_fx != null) text_fx.stop();
			text_fx = new Fx.Style(this, "color", {duration:150});
			if (str == "extra" && !page_help) this.setStyle("background-image", "url('/assets/images/download_black.gif')");
			
			this.setStyle("color", "#FFFFFF");
			text_fx.start("#FFFFFF", "#000000");
		}
		
		var col = (bgCol[str] == "#000000") ? page_col : (page_url == "home" ? "#333333" : "#000000");
		this.setStyle("background-color", "#000000");
		if (link_fx != null) link_fx.stop();
		link_fx = new Fx.Style(this, "background-color", {duration:150});
		link_fx.start(col, bgCol[str]);
	}
	catch (e) { }
	
	try { document.getElementById("headerFlash").showLink(str); }
	catch (e) { }
}

function leaveLink() {
	if (!ready) return;
	
	var str = this.id.substr(0, this.id.length - 4);
	if (str.length < 1 || str == page_url || (str == "extra" && page_help)) return;
	
	resetLinks();
	try {
		this.setStyle("background-color", "");
		if (invertList[str] && str == "extra" && !page_help) this.setStyle("background-image", "url('/assets/images/download_white.gif')");
		this.setStyle("color", "");
	}
	catch (e) { }
}

function resetLinks() {
	try {
		if (link_fx != null) {
			link_fx.stop();
			link_fx.set("#000000");
			link_fx = null;
		}
		if (text_fx != null) {
			text_fx.stop();
			text_fx.set("#000000");
			text_fx = null;
		}
	}
	catch (e) { }
	
	try { document.getElementById("headerFlash").showLink(""); }
	catch (e) { }
}

function hideHeader() {
	if (!ready || collapsed) return;
	
	ready = false;
	collapsed = true;
	
	if (ha) ha.setStyle("background-image", "url('" + downArrow.src + "')");
	
	hl_fx.start(0);
	hp_fx.start(28);
	header_fx.start(28);
	content_fx.start(28);
	
	resetLinks();
}

function showHeader() {
	if (!ready || !collapsed) return;

	ready = false;
	collapsed = false;
	
	if (ha) ha.setStyle("background-image", "url('" + upArrow + "')");
	if (hc) hc.setStyle("display", "none");
	if (hl) hl.setStyle("display", "block");
	
	hl_fx.start(1);
	hp_fx.start(94);
	header_fx.start(94);
	content_fx.start(94);
	
	resetLinks();
}
	
function toggleHeader() {
	if (!ready) return;
	
	if (collapsed) showHeader();
	else hideHeader();
}

function initEmailLinks() {
	links = $$("#contentBody a");
	links.each(function(link, i) {
		if (link.href.indexOf("/email/") != -1) {
			link.addEvent("click", emailNeave);
			link.href = "#";
			link.removeAttribute("href");
		}
	});
}

function emailNeave() {
	var w = 370;
	var h = 230;
	if (screen.width) {
		x = (screen.width - w) / 2;
		y = (screen.height - h) / 2 - 30;
		posText = ",top=" + y + ",left=" + x;
	}
	else posText = "";

	window.open("/email/", "emailNeave", "resizable,width=" + w + ",height=" + h + posText);
}

var ready = false;
window.addEvent("domready", function() {
	if (navigator.vendor && navigator.vendor.indexOf("Apple") != -1) {
		var isSafari3 = false;
		if (window.devicePixelRatio && window.getMatchedCSSRules && !window.Opera) isSafari3 = !!window.getMatchedCSSRules(document.documentElement,'');
		if (!isSafari3) {
			try {
				$("content").removeChild(document.getElementById("contentFlash"));
				var ca = document.createElement("div");
				ca.setAttribute("id", "contentAlt");
				ca.innerHTML = '<h2>&nbsp;</h2><p>To view this page properly please upgrade your browser<br />to the <a href="http://www.apple.com/safari/download/" title="Get the free Apple Safari upgrade">latest version of Safari</a>.&nbsp; Thank you.</p>';
				$("content").appendChild(ca);
			}
			catch (e) { }
		}
	}
	
	hp = $("headerPreview");
	ha = $("headerArrow");
	hl = $("headerLinks");
	hc = $("headerCollapse");
	hcl = $("headerCollapseLink");
	
	if (ha) ha.addEvent("click", toggleHeader);
	if (hcl) {
		hcl.addEvent("click", toggleHeader);
		hcl.addEvent("mouseenter", enterLink);
		hcl.addEvent("mouseleave", leaveLink);
	}
	
	var links = $$("#linksColumns a");
	links.each(function(link, i) {
		link.addEvent("mouseenter", enterLink);
		link.addEvent("mouseleave", leaveLink);
	});
	
	links = $$("#footerLinks a");
	links.each(function(link, i) {
		link.addEvent("mouseenter", enterLink);
		link.addEvent("mouseleave", leaveLink);
	});
	
	fx_obj = {duration:200, transition:Fx.Transitions.Quad.easeInOut};
	hl_fx = new Fx.Style(hl, "opacity", {duration:100});
	hp_fx = new Fx.Style(hp, "height", fx_obj);
	content_fx = new Fx.Style($("content"), "top", fx_obj);
	header_fx = new Fx.Style($("header"), "height", fx_obj);
	header_fx.addEvent("onComplete", function() {
		try { cf = document.getElementById("contentFlash"); }
		catch (e) { }
		
		if (collapsed) {
			if (hp) hp.setStyle("height", "28px");
			if (hl) hl.setStyle("display", "none");
			if (hcl) hcl.setStyle("background-color", "");
			if (hc) hc.setStyle("display", "block");
			if (cf) cf.style.top = "28px";
		}
		else {
			if (hp) hp.setStyle("height", "94px");
			if (cf) cf.style.top = "94px";
		}
		
		ready = true;
	});
	
	ready = true;
});

try {
	var pageTracker = _gat._getTracker("UA-56095-3");
	pageTracker._initData();
	pageTracker._trackPageview();
}
catch (e) { }