/**
 * AO INICIALIZAR
 */
$(document).ready(function() {
	/**
	 * BLOCK UI (LOADING)
	 */
	$.blockUI.defaults = {
			// message displayed when blocking (use null for no message)
			message:  'null',
			title: null,		// title string; only used when theme == true
			draggable: true,	// only used when theme == true (requires jquery-ui.js to be loaded)
			theme: false, // set to true to use with jQuery UI themes
			// styles for the message when blocking; if you wish to disable
			// these and use an external stylesheet then do this in your code:
			// $.blockUI.defaults.css = {};
			css: {
				padding:	0,
				margin:		0,
				width:		'auto',
				top:		'45%',
				left:		'45%',	
				textAlign:	'center',
				color:		'transparent',
				border:		'none',
				backgroundColor: 'transparent',
				cursor:		'wait',
				zIndex:'1000000000005'
			},
			// minimal style set used when themes are used
			themedCSS: {
				backgroundColor: 'transparent',
				border:		'none',
				color:		'transparent',
				cursor:		'wait',
				left:	'45%',
				top:	'45%',
				width:	'auto'
			},
			// styles for the overlay
			overlayCSS:  {
				backgroundColor:	'#000',
				opacity:			0.6,
				cursor:				'wait'
			},
			// style to replace wait cursor before unblocking to correct issue
			// of lingering wait cursor
			cursorReset: 'default',
			// styles applied when using $.growlUI
			growlCSS: {
				width:		'350px',
				top:		'10px',
				left:		'',
				right:		'10px',
				border:		'none',
				padding:	'5px',
				opacity:	0.6,
				cursor:		'default',
				color:		'transparent',
				backgroundColor: 'transparent',
				'-webkit-border-radius':'0px',
				'-moz-border-radius':	'0px',
				'border-radius':		'0px'
			},
			// IE issues: 'about:blank' fails on HTTPS and javascript:false is s-l-o-w
			// (hat tip to Jorge H. N. de Vasconcelos)
			/*jshint scripturl:true */
			iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank',
					// force usage of iframe in non-IE browsers (handy for blocking applets)
					forceIframe: false,
					// z-index for the blocking overlay
					baseZ: 2000,
					// set these to true to have the message automatically centered
					centerX: true, // <-- only effects element blocking (page block controlled via css above)
					centerY: true,
					// allow body element to be stetched in ie6; this makes blocking look better
					// on "short" pages.  disable if you wish to prevent changes to the body height
					allowBodyStretch: true,
					// enable if you want key and mouse events to be disabled for content that is blocked
					bindEvents: true,
					// be default blockUI will supress tab navigation from leaving blocking content
					// (if bindEvents is true)
					constrainTabKey: true,
					// fadeIn time in millis; set to 0 to disable fadeIn on block
					fadeIn:  100,
					// fadeOut time in millis; set to 0 to disable fadeOut on unblock
					fadeOut:  400,
					// time in millis to wait before auto-unblocking; set to 0 to disable auto-unblock
					timeout: 0,
					// disable if you don't want to show the overlay
					showOverlay: true,
					// if true, focus will be placed in the first available input field when
					// page blocking
					focusInput: true,
					// elements that can receive focus
					focusableElements: ':input:enabled:visible',
					// suppresses the use of overlay styles on FF/Linux (due to performance issues with opacity)
					// no longer needed in 2012
					// applyPlatformOpacityRules: true,
					// callback method invoked when fadeIn has completed and blocking message is visible
					onBlock: null,
					// callback method invoked when unblocking has completed; the callback is
					// passed the element that has been unblocked (which is the window object for page
					// blocks) and the options that were passed to the unblock call:
					//	onUnblock(element, options)
					onUnblock: null,
					// callback method invoked when the overlay area is clicked.
					// setting this will turn the cursor to a pointer, otherwise cursor defined in overlayCss will be used.
					onOverlayClick: null,
					// don't ask; if you really must know: http://groups.google.com/group/jquery-en/browse_thread/thread/36640a8730503595/2f6a79a77a78e493#2f6a79a77a78e493
					quirksmodeOffsetHack: 4,
					// class name of the message block
					blockMsgClass: 'blockMsg',
					// if it is already blocked, then ignore it (don't unblock and reblock)
					ignoreIfBlocked: false
	};		
	/**
	 * br.gov.dataprev.jquery.maskedinput.patterns.js
	 */
	jQuery(
			function($) {
				/* NIT */
				$('input[class*=nitFormat]').mask( "?999.99999.99-9" );
				/* NIT (Consulta CI) */
				$('input[class*=nitConsultaCIFormat]').mask( "?9.999.999.999-9" );
				/* PIS */
				$('input[class*=pisFormat]').mask( "?999.99999.99-9" );
				/* PASEP */
				$('input[class*=pasepFormat]').mask( "?999.99999.99-9" );
				/* CNPJ */
				$('input[class*=cnpjFormat]').mask( "?99.999.999/9999-99" );
				/* CNPJ RAIZ */
				$('input[class*=cnpjRaizFormat]').mask("?99.999.999");
				/* CPF */
				$('input[class*=cpfFormat]').mask( "?999.999.999-99" );
				/* CEI */
				$('input[class*=ceiFormat]').mask( "?99.999.99999/99" );
				/* CGC8 */
				$('input[class*=cgc8Format]').mask( "?99.999.999" );
				/* COMPROT */
				$('input[class*=comprotFormat]').mask( "?99999.999999/9999-99" );
				/* Ag�ncia */
				$('input[class*=agenciaFormat]').mask("?9999-9");
				/* Compet�ncia */
				$('input[class*=competenciaFormat]').mask("?99/9999");
				/* Compet�ncia (Consultas CI) */
				$('input[class*=competenciaConsultaFormat]').mask("99/9?999");
				/* C�digo de Endere�amento Postal (CEP) */
				$('input[class*=cepFormat]').mask( "?99999-999" );
				/* Cadastro Brasileiro de Ocupa��es (CBO) */
				$('input[class*=cboFormat]').mask( "?99999-9" );
				/* APS */
				$('input[class*=apsFormat]').mask( "?99.999.999" );
				/* N�mero do Benef�cio */
				$('input[class*=nbFormat]').mask( "?999.999.999-9" ); 	
				/* Ano */
				$('input[class*=anoFormat]').mask( "?9999" );
				/* DDD */
				$('input[class*=dddFormat]').mask( "?99" );
				/* N�mero telef�nico */
				$('input[class*=telefoneFormat]').mask( "?9999-9999" );
				/* N�mero telef�nico com ddd*/
				$('input[class*=telefoneCompletoFormat]').mask( "?(99) 9999-9999" );
				/* Ramal */
				$('input[class*=ramalFormat]').mask( "?9999" );
				/* DDD seguido do n�mero telef�nico */
				$('input[class*=dddFormat][class*=telefoneFormat]').unmask().mask( "?(99) 9999-9999" );
				/* Data */
				$('input[class*=dataFormat]').mask( "?99/99/9999" );
				/* Hora */
				$('input[class*=horaFormat]').mask( "?99:99:99" );
				/* Data seguido da hora */
				$('input[class*=dataFormat][class*=horaFormat]').unmask().mask( "?99/99/9999 99:99" );
				/* Placa de autom�vel */
				$('input[class*=placaFormat]').mask( "?aaa-9999" );
				/* Conv�nio do Termo de Ades�o */
				$('input[class*=convenioFormat]').mask( "?99999.999999/9999-99" );
				/* Valores em real */
				$('input[class*=realFormat]').maskMoney({symbol:"R$",decimal:",",thousands:"."});
				/* Valores em moeda */
				$('input[class*=moedaFormat]').maskMoney({symbol:"",decimal:",",thousands:"."});
				/* Valores decimais */
				$('input[class*=decimal3Format]').maskMoney({symbol:"",decimal:",",thousands:".",precision:3});
				$('input[class*=decimal4Format]').maskMoney({symbol:"",decimal:",",thousands:".",precision:4});
				/* C�digo de pagamento */
				$('input[class*=codPagFormat]').mask( "?9999" );
				/* Protocolo de requerimento */
				$('input[class*=protocoloFormat]').mask( "?99999.999999/9999-99" );
				/* Protocolo de ctc */
				$('input[class*=protocoloCTCFormat]').mask( "?99999999.9.99999/99-9" );
				// br.gov.dataprev.jquery.maskedinput.patternsDEPRECATED.js AINDA esta sendo usado!!!
				/* NIT */
				$('input[id*=nitFormat]').mask( "?9.999.999.999-9" );
				/* PIS */
				$('input[id*=pisFormat]').mask( "?999.99999.99-9" );
				/* PASEP */
				$('input[id*=pasepFormat]').mask( "?999.99999.99-9" );
				/* CNPJ */
				$('input[id*=cnpjFormat]').mask( "?99.999.999/9999-99" );
				/* CNPJ RAIZ */
				$('input[id*=cnpjRaizFormat]').mask("?99.999.999");
				/* CPF */
				$('input[id*=cpfFormat]').mask( "?999.999.999-99" );
				/* CEI */
				$('input[id*=ceiFormat]').mask( "?99.999.99999/99" );
				/* CEI */
				$('input[id*=cgc8Format]').mask( "?99.999.999" );
				/* Compet�ncia */
				$('input[id*=competenciaFormat]').mask("?99/9999");
				/* C�digo de Endere�amento Postal (CEP) */
				$('input[id*=cepFormat]').mask( "?99999-999" );
				/* DDD */
				$('input[id~=dddFormat]').mask( "?99?9" );
				/* N�mero telef�nico */
				$('input[id~=telefoneFormat]').mask( "?9999-9999" );
				/* Data */
				$('input[id*=dataFormat]').mask( "?99/99/9999" );
				/* Hora */
				$('input[id*=horaFormat]').mask( "?99:99?:99" );
				/* Valores em real */
				$('input[id*=realFormat]').maskMoney({symbol:"R$",decimal:",",thousands:"."});
				/* Valores em moeda */
				$('input[id*=moedaFormat]').maskMoney({symbol:"",decimal:",",thousands:"."});
			}
	);
});
/**
 * Bloqueia a tela ao clicar num bot�o com ajax="false" e com a mesma janela alvo.
 */
$(document).on("submit", "form[target != '_blank']", function () {
	PF('bloquearTelaWidget').block();
});
