window.alert = function(text, wnd)
{
	if (typeof wnd == "undefined")
		wnd = window;
		
	var doc = wnd.document ? wnd.document : wnd.contentDocument;
	
	var messageDiv = doc.createElement("div");
	messageDiv.style.width = getTotalWidth()-12 + "px";
	messageDiv.className = "alert";
	messageDiv.appendChild(doc.createTextNode(text));
	messageDiv.style.zIndex = "1001";
	var body = doc.getElementsByTagName("body")[0];
	if (body.firstChild.className == "alert")
	{
		// hide any previous message div's 
		body.firstChild.style.display = "none";
	}
	setOpacity(messageDiv, 0);
	body.insertBefore(messageDiv, body.firstChild);
	
	var height = messageDiv.offsetHeight;
	messageDiv.style.top = -height + "px";
	setOpacity(messageDiv, 100);
	var y = -height;
	
	var move = function(step, onDone)
	{
		var handler = window.setInterval(function()
		{
			var dim = getScreenDimensions(wnd);

			y += step;
			if (y >= 0 && step > 0)
			{
				window.clearInterval(handler);
				y = 0;
				if (onDone)
					onDone();
			}
			else if (y < -height && step < 0)
			{
				window.clearInterval(handler);
				body.removeChild(messageDiv);
				if (onDone)
					onDone();
			}
			
			messageDiv.style.top = dim.scrollTop + y + "px";
		}, 40);		
	}
	
	var hide = function()
	{
		move(-5);
	}
	
	move(5, function()
	{
		window.setTimeout(hide, 3000);
	});
}
