

ativo=true;
	
	
function submeterContato(){
	$('#bt_contatoForm').unbind('click').bind('click',function(){alert('VocÃª jÃ¡ clicou ! Aguarde atÃ© a mensagem de confirmaÃ§Ã£o.'); return false;});
    $("#contatoForm").ajaxSubmit({
        target: '',
        url: './gestor/modulos/contato/?acao=set2', 
        type: 'post', 
        success: function(resposta, statusText, xhr) {
			res = resposta.split('|');
			resformated = '';
			if(isArray(res)) {
				if(res.length<=1){ document.contatoForm.reset(); }
				for(i=0;i<res.length;i++){
					resformated += res[i]+'\n';
				}
			}else{
				resformated = resposta;
				document.contatoForm.reset();
			}
    		alert(resformated);
			$('#bt_contatoForm').unbind('click').bind('click',function(){return valida('contatoForm');});
        }
    		
    });
}
	
	
	
function submeterTwitter(){
	
	$('#bt_twitterForm').unbind('click').bind('click',function(){alert('Você já clicou ! Aguarde até a mensagem de confirmação.'); return false;});
    $("#twitterForm").ajaxSubmit({
 	   		
        target: '',
        url: 'includes/enviatwitter.php', 
        type: 'post', 
        success: function(resposta) {
			res = resposta.split('|');
			resformated = '';
			if(isArray(res)) {
				if(res.length<=1){ document.twitterForm.reset(); }
				for(i=0;i<res.length;i++){
					resformated += res[i]+'\n';
				}
			}else{
				resformated = resposta;
				document.twitterForm.reset();
			}
    		alert(resformated);
			$('#bt_twitterForm').unbind('click').bind('click',function(){return valida('twitterForm');});
        }
    		
    });
	
}




var opts =
  // horizontal Dock with images expanding downwards in the vertical axis...
{ align: 'botton'
  // set the maximum minor axis (vertical) image dimension to 48px
, size: 30
  // add labels..
, labels: true
  // swap the GIF extension for PNG extension for the larger image...
, source: function(i){ return this.src.replace(/gif$/,'png'); }
};

function isArray(o){
	return(typeof(o.length)=="undefined")?false:true;
}


	function replaceAll(str, de, para){
	    var pos = str.indexOf(de);
	    while (pos > -1){
			str = str.replace(de, para);
			pos = str.indexOf(de);
		}
	    return (str);
	}

function submeterBusca(formulario,url,content_form){
		   data = $('#'+formulario).serialize();
		   url= '?url='+url+'&'+ data+' #res';
		   $('#col_meio').html('<div id="buscaResults"><h2 id="tit_result" class="titulo">Resultados da pesquisa</h2><p align="center">Carregando ...</p></div>');
		   $('#buscaResults').fadeIn('slow');
		   $('#tit_result').fadeIn('slow');
		   $.get('buscar.php'+url, function(data) {
			 	    $('#buscaResults').html(data);	
					$('#buscaResults').html($('#buscaResults #res').html());
			});

		  // $(content_form).attr('src', url);
		   //$(content_form).show();
		   //$("#"+formulario).reset();
}



function submeterNewsletter(){
	if(document.formnews.nome.value == 'Nome' || document.formnews.email.value == 'E-mail'){
		alert('Digite um Nome e E-mail Validos');
	}else{
		$("#formnews").ajaxSubmit({
			target: '',
			url: './gestor/modulos/email_newsletter/?acao=set2', 
			type: 'post', 
			success: function(resposta) {
				res = resposta.split('|');
				resformated = '';
				if(isArray(res)) {
					if(res.length<=1){ document.formnews.reset(); }
					for(i=0;i<res.length;i++){
						resformated += res[i]+'\n';
					}
				}else{
					resformated = resposta;
					document.formnews.reset();
				}
				alert(resformated);
			}
				
		});
	}
	
}



	
	function idsDivs(classe){	
		arrayDivs=$("."+classe);
		stringArrays='';
		for(t=0;t<arrayDivs.length;t++){
			stringArrays=stringArrays+'_'+arrayDivs[t].id;
		}
		return stringArrays;
	}

	function submeter2(formulario,content,pasta,content_form,acao,conteudoSelecionado){

		
	       $("#"+formulario).ajaxSubmit({
	    	   		
	           target: '',
	           url: acao+'&respAjax=1', 
	           type: 'post', 
	           success: function(resposta) {

		   			resposta=replaceAll(resposta,"&amp;","&");
	   			
					resp=resposta.split(',,');
					destino=resp[2];
					
					if(destino){
						if(destino[destino.length-1]==1){
							$("#"+formulario+" input").removeClass("erro");
						}
					}

				   if(resp[1]=='respAjax'){
					    mostraResposta(resp[0]);
					    url=pasta+destino;
						carregarConteudo(content,content_form,url,conteudoSelecionado);
	               }else{
	            	   $(content_form).html(resposta).show();
			       }
	           }
	       
	       		
	       });
	      
	       return true;
		}
	    
	    
	function submeter(formulario,content,pasta,content_form,acao,conteudoSelecionado){

		   $("#"+formulario).ajaxForm(function() {

	       $("#"+formulario).ajaxSubmit({
	    	   		
	               target: '',
	               url: acao+'&respAjax=1', 
	               type: 'post', 
	               success: function(resposta) {
	    	
	    	   			resposta=replaceAll(resposta,"&amp;","&");
						resp=resposta.split(',,');
						destino=resp[2];
						
						if(destino){
							if(destino[destino.length-1]==1){
								$("#"+formulario+" input").removeClass("erro");
							}
						}

					   if(resp[1]=='respAjax'){
						    mostraResposta(resp[0]);
						    url=pasta+destino;
							carregarConteudo(content,content_form,url,conteudoSelecionado);
		               }else{
		            	   $(content_form).html(resposta).show();
				       }
	               }
	       });
	       
	       return false;
		   });
  
	       
	}
	
	
	function is_array(input){
		return typeof(input)=='object'&&(input instanceof Array);
	}


	function limparCampos(campos){
  		
  		var arrayCampos=campos.split(',');
  		
  		b=0; while(b < arrayCampos.length ){
  			document.getElementById(arrayCampos[b]).value='';
  			b++;
  		}
  	}



	function buscarSelecionados(Elemento){
	

  		var arrayIds = document.getElementById(Elemento).arrayIds; 

  		var cont = 0; 
		
		var arrayIDS = new Array();

		if(!(arrayIds.length)){
			if(arrayIds.checked){
				arrayIDS[0]=arrayIds;
				return arrayIDS;
			}
		}
		
		for (var x=0; x < arrayIds.length; x++) {
			if (arrayIds[x].checked) {
				arrayIDS[cont] = arrayIds[x];
				cont = cont + 1;
			}
  		}
		
		return arrayIDS;
	}
	
	
	function campoData(campo,time){

		$(function() {  
		    $(campo).datepicker({
				onSelect: function(dateText, inst) { 
					oData = ($(campo).datepicker("getDate")); 
					dia = oData.getDate();
					mes = oData.getMonth()+1;
					ano = oData.getFullYear()
					if (dia<10) dia = '0'+dia;
					if (mes<10) mes = '0'+mes;
					data = dia+"/"+mes+"/"+ano;
					document.location = "agenda.php?data="+data;
				},
		    	showButtonPanel: false,
				duration: '',
				dateFormat:'dd/mm/yy',  
				showTime: time,  
				constrainInput: false,  
				stepMinutes: 1,  
				stepHours: 1,  
				altTimeField: '',
				changeMonth: false,
				changeYear: false,
				dayNames: ['Domingo', 'Segunda', 'Terça', 'Quata', 'Quita', 'Sexta', 'S&aacute;bado'],
				dayNamesMin: ['Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'S&aacute;b'],
				dayNamesShort: ['Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'S&aacute;b'],
				monthNames: ['Janeiro','Fevereiro','Março','Abril','Maio','Junho','Julho','Agosto','Setembro','Outubro','Novembro','Dezembro'],
				monthNamesShort: ['Jan','Fev','Mar','Abr','Mai','Jun','Jul','Ago','Set','Out','Nov','Dez'],
		        time24h: true  
		     });

		});
		
	}
	
	
	
	function txtBoxFormat(strField, sMask, evtKeyPress) {
	     var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;
	
	     if(window.event) { // Internet Explorer
	       nTecla = evtKeyPress.keyCode; }
	     else if(evtKeyPress.which) { // Nestcape / firefox
	       nTecla = evtKeyPress.which;
	     }
	    //se for backspace não faz nada
		
	    if (nTecla != 8){
	     sValue = document.getElementById(strField).value;
	    // alert(sValue);
	
	     // Limpa todos os caracteres de formatação que
	     // já estiverem no campo.
	     sValue = sValue.toString().replace( "-", "" );
	     sValue = sValue.toString().replace( "-", "" );
	     sValue = sValue.toString().replace( ".", "" );
	     sValue = sValue.toString().replace( ".", "" );
	     sValue = sValue.toString().replace( "/", "" );
	     sValue = sValue.toString().replace( "/", "" );
	     sValue = sValue.toString().replace( "(", "" );
	     sValue = sValue.toString().replace( "(", "" );
	     sValue = sValue.toString().replace( ")", "" );
	     sValue = sValue.toString().replace( ")", "" );
	     sValue = sValue.toString().replace( " ", "" );
	     sValue = sValue.toString().replace( " ", "" );
	     fldLen = sValue.length;
	     mskLen = sMask.length;
	
	     i = 0;
	     nCount = 0;
	     sCod = "";
	     mskLen = fldLen;
	
	     while (i <= mskLen) {
	       bolMask = ((sMask.charAt(i) == "-") || (sMask.charAt(i) == ".") || (sMask.charAt(i) == "/"))
	       bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == " "))
	
	       if (bolMask) {
	         sCod += sMask.charAt(i);
	         mskLen++; }
	       else {
	         sCod += sValue.charAt(nCount);
	         nCount++;
	       }
	
	       i++;
	     }
	
	     document.getElementById(strField).value = sCod;
	
	     if (nTecla != 8) { // backspace
	       if (sMask.charAt(i-1) == "9") { // apenas números...
	         return ((nTecla > 47) && (nTecla < 58)); 
		   } // números de 0 a 9
	       else { // qualquer caracter...
	         return true;
	       }
		 }
	     else {
	       return true;
	     }
	    }//fim do if que verifica se é backspace
	    
		/***
		* Observação: As máscaras podem ser representadas como os exemplos abaixo:
		* CEP -> 99.999-999
		* CPF -> 999.999.999-99
		* CNPJ -> 99.999.999/9999-99
		* Data -> 99/99/9999
		* Tel Resid -> (99) 999-9999
		* Tel Cel -> (99) 9999-9999
		* Processo -> 99.999999999/999-99
		* C/C -> 999999-!
		* E por aí vai...
		***/
		//USO:  onkeypress="return txtBoxFormat('id_do_campo', '99999999', event);"
	    
	}



	function verificaEquivalencias(strField,strField2){
		if (document.getElementById(strField).value != getElementById(strField2).value)  // Aqui faz a comparação se a senha 1 confere com a senha2 
		{ 
			alert ("As senhas não Conferem"); //Dispara o alerta caso a condição não seja favorável 
			document.getElementById(strField).focus(); // Aqui manda o foco voltar para a senha1
			return false; 
		} 
		return true; 
	}//Fim da Verifica Equivalencias //USO: verificaEquivalencias(id1,id2)



	function MascaraMoeda(objTextBox, SeparadorMilesimo, SeparadorDecimal, e){
		
	    var sep = 0;
	    var key = '';
	    var i = j = 0;
	    var len = len2 = 0;
	    var strCheck = '0123456789';
	    var aux = aux2 = '';
	    var whichCode = null;
		
		
		if(window.event) { // Internet Explorer
	       whichCode = e.keyCode; }
	     else if(e.which) { // Nestcape / firefox
	       whichCode = e.which;
	     }
		
		
	    if ((whichCode == 0) || (whichCode == 8)) return true;
		key = String.fromCharCode(whichCode); // Valor para o código da Chave
		
	    if (strCheck.indexOf(key) == -1) return false; // Chave inválida
		
	    len = objTextBox.value.length;
	    for(i = 0; i < len; i++)
	        if ((objTextBox.value.charAt(i) != '0') && (objTextBox.value.charAt(i) != SeparadorDecimal)) break;
	    aux = '';
	    for(; i < len; i++)
	        if (strCheck.indexOf(objTextBox.value.charAt(i))!=-1) aux += objTextBox.value.charAt(i);
	    aux += key;
	    len = aux.length;
	    if (len == 0) objTextBox.value = '';
	    if (len == 1) objTextBox.value = '0'+ SeparadorDecimal + '0' + aux;
	    if (len == 2) objTextBox.value = '0'+ SeparadorDecimal + aux;
	    if (len > 2) {
	        aux2 = '';
	        for (j = 0, i = len - 3; i >= 0; i--) {
	            if (j == 3) {
	                aux2 += SeparadorMilesimo;
	                j = 0;
	            }
	            aux2 += aux.charAt(i);
	            j++;
	        }
	        objTextBox.value = '';
	        len2 = aux2.length;
	        for (i = len2 - 1; i >= 0; i--)
	        objTextBox.value += aux2.charAt(i);
	        objTextBox.value += SeparadorDecimal + aux.substr(len - 2, len);
	    }
	    return false;
	    
	    /*
	    <form>
	    Valor R$: <input type="text" name="valor"  onKeyPress="return(MascaraMoeda(this,'.',',',event))">
	    </form>
	    */
	
	}


	function MM_jumpMenu(targ,selObj,restore){ //v3.0
	  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
	  if (restore) selObj.selectedIndex=0;
	}
	
	
	
	function vinculoInativo(id){
		
		if (confirm("Tem certeza que deseja apagar o comunicado?")){
		
			$.get("./gestor/modulos/vinculo/?acao=inativo&vinculo="+id, function(data) {
			   if(data==1){
				   $('#listaComunicados').load('./?pagina=comunicados #comunicados');
			   }else{
				   alert("Erro ao tentar deletar comunicado, tente novamente mais tarde.")
			   }
			});
		
		}

	}



