var msgBox;

function msgbox_onLoad()
{
    msgBox = $("#msgbox");
    msgBox.realign = function()
    {
        var left = ($(window).width() - msgBox.width()) / 2;
        var top = ($(window).height() - msgBox.height()) / 2;
        msgBox.css({left:left, top:top});
		
		//alert("realign()");
		//alert("width: " + msgBox.width() + " - height: " + msgBox.height());
    }
    
    msgBox.show = function(title, text)
    {
       msgBox.find("div.header div.title").html(title);
       msgBox.find("div.content div.msg").html(text);
       msgBox.realign();
       msgBox.fadeIn("normal");
	   
	   sendBox.background.show();
    }

    msgBox.hide = function()
    {
       msgBox.fadeOut("normal");
	   
	   sendBox.background.hide();
    }
    
    msgBox.hideButton = function()
    {
        msgBox.find("img.button").fadeOut("fast");
    }
    msgBox.showButton = function()
    {
        msgBox.find("img.button").fadeIn("fast");
    }
    
    msgBox.find("img.button").click(function() {msgBox.hide();});
    
	setTimeout(timeOut, 200);
	msgBox.realign();
	
	
	
   // msgBox.show("Preencha dos os Campos", "Preencha todos os campos <br/> este e aquele.");
}

$(document).ready(msgbox_onLoad);
$(window).resize(function(){msgBox.realign()});


function timeOut()
{
	msgBox.realign();
	//alert("realign");
	setTimeout(timeOut, 200);
}