function loadImage(){
	var preload = new Image();
	$(preload).attr("src","/img/site2.jpg");
	$(preload).bind("load", fadeImage);
	$("#message").bind("click",growText);
}
function fadeImage(){
	$("#logo").html('<img src="/img/site2.jpg" alt="" width="1156" height="579" id="theLogo" style="display:none;" />');
	$("#theLogo").fadeIn(5000, fadeText);
}

var timeout = null;

function fadeText(){
	var colors = Array(
		"#00AEEF", // cyan
		"#11A1E8",
		"#318ADA",
		"#5E69C8",
		"#8E45B3",
		"#B826A2",
		"#DB0D93",
		"#EC008C", // magenta
		"#ED0784",
		"#ED1576",
		"#EF2862",
		"#F03D4D",
		"#F14F3A",
		"#F25E2B",
		"#F36523", // orange
		"#EC6B25",
		"#DF7828",
		"#CB8A2D",
		"#B69E33",
		"#A4B038",
		"#94BE3C",
		"#8CC63E"  // lime
	);
	var c=0;
	var chars = $("#text").html().split("");
	var newString = "";
	for(var i=0; i < chars.length; i++){
		if(chars[i] != " " && chars[i] != "."){
			newString += "<span>"+chars[i]+"</span>";
		} else {
			newString += chars[i];
		}
	}
	$("#text").html(newString);
	$("#text span").each(function(e){
		$(this).hover(
			function(i){
				$(this).css("color",colors[c]);
				c++;
				if(c >= colors.length){ c=0; }
				if(!timeout){
					timeout = setTimeout(showMessage,10000);
				}
			},
			function(o){
				$(this).animate({
					color:"#FFF"
				},
				{duration:800});
			}
		);
	});
	$("#contact").fadeIn(3000);
}

var size = 11;
function showMessage(){
	if(size < 48){
		$("#message").show(1000);
		clearTimeout(timeout);
		timeout = null;
	}
}

function growText(){
	if(size == 24){
		newSize = "48px";
		size = 48;
	}
	if(size == 11){
		newSize = "24px";
		size = 24;
	}
	$("#text").animate({ fontSize:newSize }, {duration:500});
	$("#message").hide(1000);
}

$(document).ready(loadImage);