// JavaScript Document
//é utf-8

jQuery.msgbox = {
	alert: function(header, msg, callback) {
		var box = "<p id=\"msgBoxP\">"+msg+"</p><input id=\"msgBoxOK\" type=\"button\" value=\"OK\" />";
		jQuery.msgbox.show(header, box);
		jQuery("#msgBoxOK").click(function() {
			jQuery.msgbox.close(callback);
		});
	},
	
	confirm: function(header, msg, callback) {
		var box = "<p id=\"msgBoxP\">"+msg+"</p><input id=\"msgBoxOK\" type=\"button\" value=\"OK\" /><input id=\"msgBoxCancel\" type=\"button\" value=\"Cancelar\" />";
		jQuery.msgbox.show(header, box);
		jQuery("#msgBoxOK").click(function() {
			jQuery.msgbox.close(callback);
		});
		jQuery("#msgBoxCancel").click(function() {
			jQuery.msgbox.close();
		});
	},
	
	show: function(header, msg, width) {
		if (width == undefined) {
			width = 300;
		}
		jQuery('body').append('<div class="msgbox-fundo"></div>');
		jQuery('.msgbox-fundo').css({
						 'display':'none',
						 'position':'absolute',
						 'top':'0',
						 'left':'0',
						 'width':'100%',
						 'height': jQuery(document).height(),
						 'background':'#fff',
						 'opacity':'0.3',
						 'filter':'alpha(opacity=30)'});
		
		if (jQuery.browser.mozilla || jQuery.browser.safari) {
			var top = (self.pageYOffset + 100);
		}
		else if (jQuery.browser.msie) {
			var top = document.documentElement.scrollTop + 100;
		}
		var left = (document.body.clientWidth / 2) - (width/2);
		
		jQuery('body').append('<div class="msgbox"><div class="msgboxHead"><h2></h2></div><div class="msgboxBody"></div></div>');
		if (jQuery.browser.msie && jQuery.browser.version < 7.0) {
			jQuery('.msgbox').css({
							 'width': width,
							 'display':'none',
							 'position':'absolute',
							 'top': top,
							 'left': left,
							 'text-align':'center',
							 'background':'#fff',
							 'border':'solid 1px #000'
							 });
			jQuery('.msgboxHead h2').css({
									  	'font-weight':'bold', 
										'font-size':'12px', 
										'margin':'0 0 0 -14px'
									 });
		}
		else {
			jQuery('.msgbox').css({
							 'width': width,
							 'display':'none',
							 'position':'absolute',
							 'top': top,
							 'left': left,
							 'background':'url(../imagens/box/box_04.png) no-repeat bottom right',
							 'text-align':'center'
							 });
			jQuery('.msgboxHead').css({
									 'height':'35px',
									 'background':'url(../imagens/box/box_02.png) no-repeat top right',
									 'margin':'-35px 0 0 0',
									 'padding':'0',
									 'text-align':'center'
									 });
			jQuery('.msgboxHead h2').css({
									 	'height':'35px',
										'background':'url(../imagens/box/box_01.png) no-repeat top left',
										'margin':'0 0 0 -14px',
										'padding':'14px 0 0 0',
										'color':'white', 
										'font-weight':'bold', 
										'font-size':'12px', 
										'text-shadow':'rgba(0,0,0,.4) 0px 2px 5px' /* Safari-only, but cool */
										 });
			jQuery('.msgboxBody').css({
										'background':'url(../imagens/box/box_03.png) no-repeat bottom left',
										'margin':'0 0 0 -14px',
										'padding':'10px 0 25px 0'
									  });
		}
			   
		jQuery('.msgboxHead h2').html(header);
		jQuery('.msgboxBody').html(msg);
			
		
		jQuery('.msgbox-fundo').fadeIn('fast', function() {
												   jQuery('.msgbox').fadeIn('fast');
												   });
	},
	
	close: function(callback) {
		jQuery('.msgbox').fadeOut('fast', function() {
			jQuery('.msgbox-fundo').fadeOut('fast', function() {
				jQuery('.msgbox-fundo').remove();
				jQuery('.msgbox').remove();
				if (callback !== undefined) {
					callback.call(this);
				}
			});
		});
	}
};
