
function resizeFrame()
{
	if (document.getElementById("divAjaxBanner"))
	{
		var intWidth = parseInt(document.body.clientWidth, 10);
		if (navigator.userAgent.indexOf("Gecko") != -1)
			intWidth = parseInt(window.innerWidth, 10);

		document.getElementById("divAjaxBanner").style.width = intWidth - 330;
	}

	try { fixDownloadLinkTextPosition(); } catch(e) {}
}

function fixDownloadLinkTextPosition()
{
	var objLinkText = document.getElementById("projectDownloadLinkText");
	if (!objLinkText) return; //sanity check

	var linkHeight = objLinkText.offsetHeight;
	var topMargin = (65 - linkHeight) / 2; //60 = 70 height - 5 padding
	objLinkText.style.marginTop = topMargin;
}

// ========= news page functions ==============
function openNewsItem(recid)
{
	top.location = "http://www.lostluggagestudios.com/forums/viewtopic.php?t=" + recid;
}

// =============== Main page rotating banner ===================
var aryBannerList;
var currentBannerIndex = 0;
var useTinyBanner = false;

function startBannerRotation(bannerlist, tinyVersion)
{
	aryBannerList = bannerlist.split(',');
	useTinyBanner = tinyVersion;
	getBanner();
}

function getBanner()
{
	var bannerContainer =  useTinyBanner ? "#divAjaxTinyBanner" : "#divAjaxBanner";

	//I use animate to handle the fadeout because fadeOut collapses the element when it's transparent, which screws up the page layout
	$(bannerContainer).animate({opacity: 0}, 1000, function()
	{
		currentBannerIndex++;
		if (currentBannerIndex >= aryBannerList.length)
			currentBannerIndex = 1; //this skips the leading -1 entry

		$.ajax({
			url: "http://www.lostluggagestudios.com/getBanner.php?id="+ aryBannerList[currentBannerIndex] +"&tiny="+ (useTinyBanner ? 1 : 0),
			cache: false,
			success: function(responseData){
				$(bannerContainer).html(responseData).animate({opacity: 1}, 1000);
			}
		});

		//set up the next round!
		setTimeout("getBanner()", 10000);
	});
}

// =============== Misfortune Cookies ===================
function gimmeAnotherCookie()
{
	$("#cookieText").html("(retrieving...)");
	$.ajax({
		url: "http://www.lostluggagestudios.com/getMisfortuneCookie.php",
		cache: false,
		success: function(responseData){
			$("#cookieText").html(responseData);
		}
	});
	$(".misfortuneCookie A").blur();
}

//Mail protection, from http://www.labs.skengdon.com/mailProtect/
(function($){$.fn.mailProtect=function(options){var mail=options.user+'@'+options.domain;var href='mailto:'+mail;return this.each(function(){var text=($(this).text())?$(this).text():mail;$(this).empty();if(options.link){var a=document.createElement('a');$(this).append(a);$(a).attr('href',href);$(a).text(text);}else{$(this).text(mail);}});};}(jQuery));

