var msgBox;

function msgbox_onLoad()
{
    msgBox = $("#msgbox");
	msgBox.background = $("#msgBox_background");
    msgBox.realign = function()
    {
        var left = ($(window).width() - msgBox.width()) / 2;
        var top = ($(window).height() - msgBox.height()) / 2;
        msgBox.css({left:left, top:top});
		
		msgBox.background.realign();
    }
	
	msgBox.background.realign = function()
	{
		/*var left = ($(window).width() - sendBox.width()) / 2;
        var top = ($(window).height() - sendBox.height()) / 2;*/
		var width = $(document).width();
		var height = $(document).height();
		
        msgBox.background.css({left:0, top:0, width:width, height:height});
	}
	
	msgBox.background.show = function()
	{
		msgBox.background.fadeIn("normal");
		
		msgBox.background.realign();
	}
	
	msgBox.background.hide = function()
	{
		msgBox.background.fadeOut("normal");
	}
    
    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");
	   
	   msgBox.background.show();
    }

    msgBox.hide = function()
    {
       msgBox.fadeOut("normal");
	   
	   msgBox.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();});
    
   // msgBox.show("Preencha dos os Campos", "Preencha todos os campos <br/> este e aquele.");
}

$(document).ready(msgbox_onLoad);
$(window).resize(function() {msgBox.realign()});