/* ads.js */

$(document).ready(function() {
	$("#fullad img").click(function () {
		$("#fullad").fadeOut("fast");
	});				
	$("#fullad td.closebutton").click(function () {
		$("#fullad").fadeOut("fast");
		return false;
	});	
	
	$(".ad.jja1").click(function () {
		
		setupFullAd({	src: 'ads/images/JJA-ad.jpg',
						alt: "Home Buyer's Package for GKSSA Members",
					caption: "Mention you saw this ad at gkssa.org and we&rsquo;ll donate $50 to the GKSSA upon your mortgage approval."
					});

		var elFullAd = positionFullAd();
		
		$(elFullAd).toggle("slow"); 
	});
});


/*
	set image src and alt and optional caption
*/
function setupFullAd(params)
{
	$("#fullad img"
			).attr('src', params.src
			).attr("alt", params.alt);
	// recall: title remains 'click to close'		

	$("#fullad td.caption").html(params.caption);
}


/*
	div#fullad uses absolute positioning; adjust for possible page scroll
*/
function positionFullAd()
{
	var elFullAd = $("#fullad");
	if (!$(elFullAd).is(":visible"))
	{
		var aWScroll = getWindowScrollXY();
		$(elFullAd).css("top", 30 + aWScroll[1] + 'px');
	}
	
	return elFullAd;
}