// JavaScript Document

var iconPos = new Array();
iconPos['news-headlines'] = "44px";
iconPos['press-release'] = "156px";

function firstLoad(type) {
	var bg = readCookie('bg');
	
	$("#bg > *").attr({ 
          src: "../wallpapers/"+bg
      });
	
	$("#unicorn").animate({
		left: iconPos[type]
	  }, 1500);
	
	h = $("#"+type).html();
	$("#art-headlines").html(h);
	
	$("a.sub-nav").bind("click", function() {
		  switchContent($(this).attr('name'));
	});
}



function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function switchContent(name) {
	$("#unicorn").stop();
	h = $("#"+name).html();
	$("#art-headlines").html(h);
	$("#unicorn").animate({
		left: iconPos[name]
	  }, 1500);
}
