var ftime = 300;

jQuery(document).ready(function(){
	// Choose image
	document.getElementById("bgDiv").style.backgroundImage = "url(\"images/alex" + parseInt(Math.random() * 9 + 1) + ".jpg\")";
	
	// Show contact info or image?
	if (location.hash.substring(1) == "contact") {
		$('#bgDiv div').css("opacity",1);
		$('#bgDiv').css({"width": 350,"height": 300,"top": 30});
		$('#bgDiv div').css("display","block");
	}
	else $('#bgDiv div').css("opacity",0); // Hide contact info
	
	// Obfuscate email address
	var addr = "AlexStoll";
	addr = addr + "@gmail.com";
	addr = "<a href=\"mailto:" + addr + "\">" + addr + "</a>";
	$("#addr").html(addr);
	
	$("img[title]").tipsy({gravity: 's'});
});

$(function() {
	$("#button").click(function() {
	  $('#bgDiv div').css("display","block");

	  $('#bgDiv div').animate({
		opacity: 1,
	  }, ftime);
	  
	  $('#bgDiv').animate({
		width: 350,
		height: 300,
		top: 30
	  }, ftime, function(){
		document.getElementById("bgDiv").style.backgroundImage = "url(\"images/alex" + parseInt(Math.random() * 9 + 1) + ".jpg\")";
	  });
	});
});

$(function() {
	$("#close").click(function() {	
	  $('#bgDiv div').animate({
		opacity: 0,
	  }, ftime);
	  
	  $('#bgDiv').animate({
		width: 980,
		height: 410,
		top: 0,
	  }, ftime);

	  window.setTimeout('$("#bgDiv div").css("display","none")', ftime);
	});
});
