//msgbox
var msgbox = {};

msgbox.show = function(imagem, width) //tipo: alerta, confirmacao, carregando
{
	var height = 500;
	
	$("#msgbox .image").attr("src",imagem);
	$("#msgbox .image").css({width:width});
	$("#msgbox").css({width:(Number(width) + 20) + "px"});
	var top = ($(window).height() - height) / 2;
	
	var left = ($(window).width() - width) / 2;
	$("#msgbox").css({top:top,left:left});
	
	//alert("top:" + top + "  left:" + left); 
	
	//bug Firefox
	if($("#msgbox").css("display") != "block")
	{
		$("#msgbox").css({display:"block"});
		$("#msgbox").hide();
		$("#msgbox_background").css({display:"block"});
		$("#msgbox_background").hide();
		
		$("#msgbox").fadeIn("fast");
		$("#msgbox_background").fadeIn("fast");
	}
	
}

msgbox.hide = function()
{
	//alert("hide");
	$("#msgbox").fadeOut("fast");
	$("#msgbox_background").fadeOut("fast");
	$("#msgbox .image").attr("src"," ");
}

function setAparence(obj, texto){
    if(obj.value == texto)
        obj.value = '';
    
    obj.onblur = function(){
        if(obj.value == '')
            obj.value = texto
    }
}

function showBox(sMensagem, iWidth, objName){
    var _width = iWidth - 29;
    var elemento = '<table class="box vermelho" id="'+objName+'">'+
	               '    <tr class="header">'+
		           '        <td class="cantoEsquerdo" width="10">&nbsp;</td>'+
		           '         <td class="definicao" width="'+_width+'">&nbsp;</td>'+
		           '       <td class="cantoDireito" width="19"><a href="javascript:void hideBox(\''+objName+'\');"></a></td>'+
	               '    </tr>'+
	               '    <tr><td colspan="3" class="body">'+
	               '    '+ sMensagem +
	               '    </td></tr>'+
	               '    <tr class="footer">'+
		           '        <td class="cantoEsquerdo">&nbsp;</td>'+
		           '        <td class="definicao">&nbsp;</td>'+
		           '        <td class="cantoDireito">&nbsp;</td>'+
	               '    </tr>'+
                   '</table>';
    
    document.body.innerHTML += elemento; 
      
    $("#"+objName).fadeIn('slow');
    
    return false;
}

function hideBox(objName){
    $("#"+objName).fadeOut('slow');
}