iotServerRequest.customMessageHandler = function(msg, type)
{
	if(!type)
		type = "Notice";
	
	var msgWindow = $("#messageWindow");
	
	msgWindow.find(".messageType").text(type);
	msgWindow.find(".messageBody").html(msg);
	var screenWidth;
	if (document.documentElement)
	{
		screenWidth = document.documentElement.offsetWidth;
	}
	else
	{
		screenWidth = window.innerWidth;
	}
	
	var windowWidth = msgWindow.width();
	
	if(windowWidth < 200)
	{
		windowWidth = 200;
		msgWindow.width(windowWidth);
	}
	else if(windowWidth > 400)
	{
		windowWidth = 400;
		msgWindow.width(windowWidth);
	}
	
	left = Math.ceil((screenWidth - windowWidth) / 2);
	
	msgWindow.css("left", left + "px");
	msgWindow.css("top", ($(document).scrollTop() + 120) + "px");
	
	msgWindow.fadeIn("normal");
}

function setCurrentPage(page)
{
	$("#currentPage").get(0).value = page;
	
}

function adjustPageLinks()
{
	$(".iotPagination a").click(
		function(e)
		{
			setCurrentPage($(this).text());
			$("#queryForm").submit();
			e.preventDefault();
		}
	);
}

function playAndLoad(path)
{
	var playerName = "niftyPlayer";
	if(!niftyplayer(playerName))
	{
		$("#niftyPlayer").html("<a href=\"" + path + "\">Download File</a>");
		//alert("Error finding flash player");
		return;
	}
	niftyplayer(playerName).loadAndPlay(path);
}



var vgmq = {};
vgmq.messageClose = function()
{
	$("#messageWindow").fadeOut("normal");
}

readjustPage = function()
{
	dheight = $(document).height();
	cheight = $("#whitePage").height();
	
	if(dheight > cheight)
	{
		padding = $("#mainContainer").css("padding-bottom");
		padding = parseInt(padding.substr(0, padding.length - 2));
		$("#whitePage").height(dheight + padding);
	}
}

$(readjustPage);
