
	var msg1 = 'Voc\u00EA deseja realmente excluir esse registro?';
	var msg2 = 'Voc\u00EA deseja salvar as informa\u00E7\u0151es antes de sair?';
	var msg3 = 'Aguarde, carregando informa\u00E7\u0151es...';
	
	function ShowHideElemAjax_Grid(obj, id, url, elem){
		var objElem = $(obj).parent().next();
		var objElemContainer = objElem.before().find('div.detalhes');
		
		if (objElem){
			if (objElem.css('display') == 'none'){
				objElem.css('display','');
				Ajax(url, objElemContainer, 'GET', true);
				$(obj).html('-');
				$(obj).find('td:first').find('input:checkbox').focus();
			}else{
				objElemContainer.html('');
				objElem.css('display','none');
				$(obj).html('+');
			}
		}
	}
	
	function Focus(obj){
		if (obj){
			obj.focus();
		}
	}
	
	function Ajax(link, obj, method, params, show_html, show_mensagem){
		obj = $(obj);
		if (show_html==undefined){
			show_html = true;
		}
		
		if (show_mensagem==undefined){
			show_mensagem = true;
		}

		if (obj){
			if (!show_html){
				if (show_mensagem){
					obj.html('<img src="jajFramework/_Images/ajax-loader.gif" /> Aguarde, salvando...');
				}
			}else{
				if (show_mensagem){
					obj.html('<img src="jajFramework/_Images/ajax-loader.gif" /> Aguarde, carregando...');
				}
			}
			if (obj.hasClass('hide')){
				obj.removeClass('hide');
				obj.addClass('show');
			}else{
				obj.show();
			}
		}
		
		$.ajax({
		  url: link,
		  cache: false,
		  data: params, 
		  type: method, 
		  success: function(html){
			if ((show_html) && (obj)){
				obj.html(html);
			}else{
				obj.hide(300);
			}
		  }
		});
	}

	function AjaxBefore(link,obj,method,params){
		$.ajax({
		  url: link,
		  cache: false,
		  data: params, 
		  type: method, 
		  success: function(html){
			if (obj){
				$(html).insertBefore($(obj));
			}
		  }
		});
	}
	
	function EsqueciSenha(email){
		alert('Sua senha foi enviada para o e-mail ' + email);
	}
	
	function ShowHideContainer(obj, pai, filho){
		$(obj).closest(pai).find(filho).toggle();
	}
	
	function HideMenu(obj){
		$(obj).closest('.menu').find('.container_menu').find('.sub').hide();
	}
	
	function Ativo(obj){
		obj = $(obj);
		obj.parent().parent().find('li').removeClass('ativo');
		obj.parent().addClass('ativo');
	}
	
	function MenuAtivo(obj, pai){
		obj = $(obj);
		obj.closest('.' + pai).find('li').find('a').removeClass('ativo');
		obj.addClass('ativo');
	}
	
	function Excluir(link, obj, metodo, params){
		if (confirm(msg1)){
			Ajax(link, obj, metodo, params, true);
		}
	}
	
	function toggleImg(obj, color){
		obj = $(obj);
		
		var imgini = obj.parent().parent().parent().find('li:first').find('img:first').attr('src');
		var imgobj = obj.find('img').attr('src');
		var titini = obj.parent().parent().parent().find('li:first').find('img:first').attr('title');
		var titobj = obj.find('img').attr('title');

		obj.parent().parent().parent().find('li:first').find('img:first').attr('src',imgobj);
		obj.find('img').attr('src',imgini);
		obj.parent().parent().parent().find('li:first').find('img:first').attr('title',titobj);
		obj.find('img').attr('title',titini);
		
		if (color!=''){
			obj.closest('tr').css('background',color);
		}
		
		obj.parent().hide(300);
	}
	
	function addMonthYearMEA(obj, name){
		obj = $(obj);

		var mes = obj.parent().find('select.js-' + name + '-mes option:selected').val();
		var ano = obj.parent().find('select.js-' + name + '-ano option:selected').val();
		
		obj.parent().find('input:hidden[name=' + name + ']').val(mes + '' + ano);
	}

	function KeyCode(event) {
		if (event.charCode) {
			return event.charCode;
		} else {
			return event.keyCode;
		}
	}
