/* Author: James Dorondo

*/

$(document).ready(function() {
	$("#dorondo").css({ opacity: 0 });
	$("#menu_id").css({ opacity: 0 });
	$("#dorondo").animate({ opacity: 0.8, top: "50px" }, 1000);
	$("#menu_id").animate({ opacity: 0.6 }, 1800);
	
	// Firefly Animation
	$(".fireflyPos1").css({top: "-200px", left: "50px"});
	$(".fireflyPos2").css({top: "-400px", left: "250px"});
	$(".fireflyPos3").css({top: "-300px", left: "450px"});
	$(".fireflyPos4").css({top: "-100px", left: "550px"});
	$(".fireflyPos5").css({top: "-600px", left: "650px"});
	
	setInterval(function() {
		var lumens = Math.floor(Math.random()*80) + 10;
		lumens = lumens/100;
		$(".firefly").css({ opacity: lumens });
		}, 500);
	
	setInterval(function() {
		var posY = Math.floor(Math.random()*400) + 100;
		var posX = Math.floor(Math.random()*740) + 10;
		$(".fireflyPos1").animate({ top: "-"+posY+"px", left: posX+"px" }, 2000);
		}, 2000);
		
	setInterval(function() {
		var posY = Math.floor(Math.random()*400) + 100;
		var posX = Math.floor(Math.random()*740) + 10;
		$(".fireflyPos2").animate({ top: "-"+posY+"px", left: posX+"px" }, 1900);
		}, 1900);
		
	setInterval(function() {
		var posY = Math.floor(Math.random()*400) + 100;
		var posX = Math.floor(Math.random()*740) + 10;
		$(".fireflyPos3").animate({ top: "-"+posY+"px", left: posX+"px" }, 1500);
		}, 1500);
		
	setInterval(function() {
		var posY = Math.floor(Math.random()*400) + 1200;
		var posX = Math.floor(Math.random()*740) + 10;
		$(".fireflyPos4").animate({ top: "-"+posY+"px", left: posX+"px" }, 2200);
		}, 2200);
	
	setInterval(function() {
		var posY = Math.floor(Math.random()*400) + 100;
		var posX = Math.floor(Math.random()*740) + 10;
		$(".fireflyPos5").animate({ top: "-"+posY+"px", left: posX+"px" }, 1700);
		}, 1700);
		
	
	// Menu Animation
	$("#menu ul li").css({ opacity: 0 });
	$("#menu ul li:nth-child(1)").css({ left: "-100px" });
	$("#menu ul li:nth-child(2)").css({ left: "-50px" });
	$("#menu ul li:nth-child(3)").css({ left: "0px" });
	$("#menu ul li:nth-child(4)").css({ left: "50px" });
	$("#menu ul li:nth-child(5)").css({ left: "100px" });
	
	$("#menu ul li").animate({ opacity: 1.0, left: "0px" }, 1000);
	
	// Menu Rollovers
	$(".button").hover(function() {
		var pageName = $(this).slice(0,1).attr("pageName");
		//alert("Over: " + pageName);
		$(this).attr("src","img/site/button-"+pageName+"-ov.png").css({ opacity: 0.7 });
		$("#"+ pageName +"").animate({ top: "-2px" }, 100);
		
	}, function() {
		var pageName = $(this).slice(0,1).attr("pageName");
		//alert("Out: " + pageName);
		$(this).attr("src","img/site/button-"+pageName+".png").css({ opacity: 1.0 });
		$("#"+ pageName +"").animate({ top: "0px" }, 200);
	});
	
	
	//Menu Actions
	$(".button").click(function() {
		var pageName = $(this).slice(0,1).attr("pageName");
		$("#windowContent").css({opacity: 0});
		//alert(pageName);
		$("#display").animate({ opacity: 1.0, top: "-400px", left: "-50px", height: "500px", width: "800px" }, 500, function() {
		$(".windowClose").animate({ opacity: 1.0 }, 500);
		//$("#windowContent").css('backgroundColor','#ff0');
		$("#windowContent").css({ top: "25px", left: "30px", width: "740px", height: "450px" });
		$("#windowContent").animate({ opacity: 1.0 }, 1000).html('<div id="windowContent"><iframe src="' + pageName + '.php" width="740" marginwidth="0" height="450" marginheight="0" scrolling="Auto" frameborder="0"></iframe></div>');
		//$.get('resources/aotm/' + pagCon + '.php', function(data) { $('#' + id).html(data); });
		});
		
	});
	
	// Display
	$("#display").css({ opacity: 0.0, top: "0px", height: "1px", width: "1px" });
	
	$(".windowClose").click(function(evt) {
		$(".windowClose").animate({ opacity: 0.0 }, 0, function() {	
		$("#display").animate({ opacity: 0.0, top: "0px", left: "350", height: "0px", width: "0px" }, 500).html('<div id="windowContent"></div>')
		});
		});
	
});
