// JavaScript Document

$(document).ready(function() {
	var popOut = "#popout"; // Name of the popout container.
	var adBox = "#adbox"; // Name of the animated bit of the ad.
	var adWidth = $(adBox).width() + $("#cap").width(); // Width of the ad container.
 
	function openAd() {
		$(popOut).height(adWidth+"px");
		$(adBox).animate({marginTop: "0"},1000);
	}
	
	function closeAd() {
		$(adBox).animate({marginTop: "-"+adWidth+"px"},1000,"linear",
			function(){ $(popOut).width($("#cap").width() + "px"); }
		);
	}
 
	$("#open").click(function() {
		openAd();
		return false; 
	});
	$("#close").click(function() {
		closeAd();
		return false;
	});
	$("#jump").click(function() {
		closeAd();
		window.location = '#';
		return false;
	});	
	
	$(popOut).animate({opacity: 1.0}, 1000, "linear", openAd);
	
});
