//###############################FUNCAO DA MASCARA DE VALORES###############################
/*Combo Box Image Selector:
By JavaScript Kit (www.javascriptkit.com)
Over 200+ free JavaScript here!
*/

    /***
    * Descrição.: formata um campo do formulário de
    * acordo com a máscara informada...
    * Parâmetros: - objForm (o Objeto Form)
    * - strField (string contendo o nome
    * do textbox)
    * - sMask (mascara que define o
    * formato que o dado será apresentado,
    * usando o algarismo "9" para
    * definir números e o símbolo "!" para
    * qualquer caracter...
    * - evtKeyPress (evento)
    *
    * Uso.......: <input type="textbox"
    * name="xxx".....
    * onkeyup="return txtBoxFormat(document.rcfDownload, 'str_cep', '99999-999', event);">
    * Observação: As máscaras podem ser representadas
    * como os exemplos abaixo:
    * CEP -> 99999-999
    * CPF -> 999.999.999-99
    * CNPJ -> 99.999.999/9999-99
    * C/C -> 999999-!
    * Tel -> (99) 9999-9999
    ***/
//-->
//funcao de mascara para formulario
function txtBoxFormat(objForm, strField, sMask, evtKeyPress)
	{
		var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;

		if(document.all)
			{ 
				nTecla = evtKeyPress.keyCode; // Internet Explorer
			}
		else if(document.layers)
			{ 
				nTecla = evtKeyPress.which; // Nestcape
			}

		sValue = objForm[strField].value;

		// 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++;
			}
				
		objForm[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
					{ 
						return true; // qualquer caracter...
					}
			}
		else
			{
				return true;
			}
	}
//###############################FUNCAO DA MASCARA DE VALORES###############################
















//###############################FUNCAO EQUIVALENTE AO SUBSTR_COUNT DO PHP###############################
function substr_count( haystack, needle, offset, length ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // *     example 1: substr_count('Kevin van Zonneveld', 'e');
    // *     returns 1: 3
    // *     example 2: substr_count('Kevin van Zonneveld', 'K', 1);
    // *     returns 2: 0
    // *     example 3: substr_count('Kevin van Zonneveld', 'Z', 0, 10);
    // *     returns 3: false
 
    var pos = 0, cnt = 0;
 
    if(isNaN(offset)) offset = 0;
    if(isNaN(length)) length = 0;
    offset--;
 
    while( (offset = haystack.indexOf(needle, offset+1)) != -1 ){
        if(length > 0 && (offset+needle.length) > length){
            return false;
        } else{
            cnt++;
        }
    }
 
    return cnt;
}
//###############################FUNCAO EQUIVALENTE AO SUBSTR_COUNT DO PHP###############################
















//###############################FUNCOES EQUIVALENTES AO BASE64_ENCODE E BASE64_DECODE DO PHP###############################
function urlencode( str ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Philip Peterson
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: AJ
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Brett Zamir (http://brett-zamir.me)
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: travc
    // +      input by: Brett Zamir (http://brett-zamir.me)
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Lars Fischer
    // %          note 1: info on what encoding functions to use from: http://xkr.us/articles/javascript/encode-compare/
    // *     example 1: urlencode('Kevin van Zonneveld!');
    // *     returns 1: 'Kevin+van+Zonneveld%21'
    // *     example 2: urlencode('http://kevin.vanzonneveld.net/');
    // *     returns 2: 'http%3A%2F%2Fkevin.vanzonneveld.net%2F'
    // *     example 3: urlencode('http://www.google.nl/search?q=php.js&ie=utf-8&oe=utf-8&aq=t&rls=com.ubuntu:en-US:unofficial&client=firefox-a');
    // *     returns 3: 'http%3A%2F%2Fwww.google.nl%2Fsearch%3Fq%3Dphp.js%26ie%3Dutf-8%26oe%3Dutf-8%26aq%3Dt%26rls%3Dcom.ubuntu%3Aen-US%3Aunofficial%26client%3Dfirefox-a'
                             
    var histogram = {}, unicodeStr='', hexEscStr='';
    var ret = (str+'').toString();
    
    var replacer = function(search, replace, str) {
        var tmp_arr = [];
        tmp_arr = str.split(search);
        return tmp_arr.join(replace);
    };
    
    // The histogram is identical to the one in urldecode.
    histogram["'"]   = '%27';
    histogram['(']   = '%28';
    histogram[')']   = '%29';
    histogram['*']   = '%2A';
    histogram['~']   = '%7E';
    histogram['!']   = '%21';
    histogram['%20'] = '+';
    histogram['\u00DC'] = '%DC';
    histogram['\u00FC'] = '%FC';
    histogram['\u00C4'] = '%D4';
    histogram['\u00E4'] = '%E4';
    histogram['\u00D6'] = '%D6';
    histogram['\u00F6'] = '%F6';
    histogram['\u00DF'] = '%DF';
    histogram['\u20AC'] = '%80';
    histogram['\u0081'] = '%81';
    histogram['\u201A'] = '%82';
    histogram['\u0192'] = '%83';
    histogram['\u201E'] = '%84';
    histogram['\u2026'] = '%85';
    histogram['\u2020'] = '%86';
    histogram['\u2021'] = '%87';
    histogram['\u02C6'] = '%88';
    histogram['\u2030'] = '%89';
    histogram['\u0160'] = '%8A';
    histogram['\u2039'] = '%8B';
    histogram['\u0152'] = '%8C';
    histogram['\u008D'] = '%8D';
    histogram['\u017D'] = '%8E';
    histogram['\u008F'] = '%8F';
    histogram['\u0090'] = '%90';
    histogram['\u2018'] = '%91';
    histogram['\u2019'] = '%92';
    histogram['\u201C'] = '%93';
    histogram['\u201D'] = '%94';
    histogram['\u2022'] = '%95';
    histogram['\u2013'] = '%96';
    histogram['\u2014'] = '%97';
    histogram['\u02DC'] = '%98';
    histogram['\u2122'] = '%99';
    histogram['\u0161'] = '%9A';
    histogram['\u203A'] = '%9B';
    histogram['\u0153'] = '%9C';
    histogram['\u009D'] = '%9D';
    histogram['\u017E'] = '%9E';
    histogram['\u0178'] = '%9F';
    
    // Begin with encodeURIComponent, which most resembles PHP's encoding functions
    ret = encodeURIComponent(ret);
 
    for (unicodeStr in histogram) {
        hexEscStr = histogram[unicodeStr];
        ret = replacer(unicodeStr, hexEscStr, ret); // Custom replace. No regexing
    }
    
    // Uppercase for full PHP compatibility
    return ret.replace(/(\%([a-z0-9]{2}))/g, function(full, m1, m2) {
        return "%"+m2.toUpperCase();
    });
}









function urldecode( str ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Philip Peterson
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: AJ
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Brett Zamir (http://brett-zamir.me)
    // +      input by: travc
    // +      input by: Brett Zamir (http://brett-zamir.me)
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Lars Fischer
    // %          note 1: info on what encoding functions to use from: http://xkr.us/articles/javascript/encode-compare/
    // *     example 1: urldecode('Kevin+van+Zonneveld%21');
    // *     returns 1: 'Kevin van Zonneveld!'
    // *     example 2: urldecode('http%3A%2F%2Fkevin.vanzonneveld.net%2F');
    // *     returns 2: 'http://kevin.vanzonneveld.net/'
    // *     example 3: urldecode('http%3A%2F%2Fwww.google.nl%2Fsearch%3Fq%3Dphp.js%26ie%3Dutf-8%26oe%3Dutf-8%26aq%3Dt%26rls%3Dcom.ubuntu%3Aen-US%3Aunofficial%26client%3Dfirefox-a');
    // *     returns 3: 'http://www.google.nl/search?q=php.js&ie=utf-8&oe=utf-8&aq=t&rls=com.ubuntu:en-US:unofficial&client=firefox-a'
    
    var histogram = {}, ret = str.toString(), unicodeStr='', hexEscStr='';
    
    var replacer = function(search, replace, str) {
        var tmp_arr = [];
        tmp_arr = str.split(search);
        return tmp_arr.join(replace);
    };
    
    // The histogram is identical to the one in urlencode.
    histogram["'"]   = '%27';
    histogram['(']   = '%28';
    histogram[')']   = '%29';
    histogram['*']   = '%2A';
    histogram['~']   = '%7E';
    histogram['!']   = '%21';
    histogram['%20'] = '+';
    histogram['\u00DC'] = '%DC';
    histogram['\u00FC'] = '%FC';
    histogram['\u00C4'] = '%D4';
    histogram['\u00E4'] = '%E4';
    histogram['\u00D6'] = '%D6';
    histogram['\u00F6'] = '%F6';
    histogram['\u00DF'] = '%DF'; 
    histogram['\u20AC'] = '%80';
    histogram['\u0081'] = '%81';
    histogram['\u201A'] = '%82';
    histogram['\u0192'] = '%83';
    histogram['\u201E'] = '%84';
    histogram['\u2026'] = '%85';
    histogram['\u2020'] = '%86';
    histogram['\u2021'] = '%87';
    histogram['\u02C6'] = '%88';
    histogram['\u2030'] = '%89';
    histogram['\u0160'] = '%8A';
    histogram['\u2039'] = '%8B';
    histogram['\u0152'] = '%8C';
    histogram['\u008D'] = '%8D';
    histogram['\u017D'] = '%8E';
    histogram['\u008F'] = '%8F';
    histogram['\u0090'] = '%90';
    histogram['\u2018'] = '%91';
    histogram['\u2019'] = '%92';
    histogram['\u201C'] = '%93';
    histogram['\u201D'] = '%94';
    histogram['\u2022'] = '%95';
    histogram['\u2013'] = '%96';
    histogram['\u2014'] = '%97';
    histogram['\u02DC'] = '%98';
    histogram['\u2122'] = '%99';
    histogram['\u0161'] = '%9A';
    histogram['\u203A'] = '%9B';
    histogram['\u0153'] = '%9C';
    histogram['\u009D'] = '%9D';
    histogram['\u017E'] = '%9E';
    histogram['\u0178'] = '%9F';
 
    for (unicodeStr in histogram) {
        hexEscStr = histogram[unicodeStr]; // Switch order when decoding
        ret = replacer(hexEscStr, unicodeStr, ret); // Custom replace. No regexing
    }
    
    // End with decodeURIComponent, which most resembles PHP's encoding functions
    ret = decodeURIComponent(ret);
 
    return ret;
}//###############################FUNCAO EQUIVALENTE AO SUBSTR_COUNT DO PHP###############################















//###############################FUNCAO DA MASCARA DE MOEDA###############################
	function FormataReais(fld, milSep, decSep, e)
		{
			var sep = 0;
			var key = '';
			var i = j = 0;
			var len = len2 = 0;
			var strCheck = '0123456789';
			var aux = aux2 = '';
			var whichCode = (window.Event) ? e.which : e.keyCode;
			//alert("whichCode: "+whichCode);
			if (whichCode == 13) return true;
			key = String.fromCharCode(whichCode);  // Valor para o código da Chave
			//alert("key: "+key);
			if (strCheck.indexOf(key) == -1) return false;  // Chave inválida
			len = fld.value.length;
			for(i = 0; i < len; i++)
			if ((fld.value.charAt(i) != '0') && (fld.value.charAt(i) != decSep)) break;
			aux = '';
			for(; i < len; i++)
			if (strCheck.indexOf(fld.value.charAt(i))!=-1) aux += fld.value.charAt(i);
			aux += key;
			len = aux.length;
			if (len == 0) fld.value = '';
			if (len == 1) fld.value = '0'+ decSep + '0' + aux;
			if (len == 2) fld.value = '0'+ decSep + aux;
			if (len > 2)
				{
					aux2 = '';
					for (j = 0, i = len - 3; i >= 0; i--)
						{
							//alert("aux2: "+aux2);
							if (j == 3)
								{
									aux2 += milSep;
									j = 0;
								}
							aux2 += aux.charAt(i);
							j++;
						}
					fld.value = '';
					len2 = aux2.length;
					for (i = len2 - 1; i >= 0; i--)
					fld.value += aux2.charAt(i);
					//alert("aux conta: "+fld.value+decSep+aux.substr(len - 3, len));
					fld.value += decSep + aux.substr(len - 2, len);
				}
			return false;
			
			
		}
//###############################FUNCAO DA MASCARA DE MOEDA###############################























//###############################FUNCOES DO DREAMWEAVER###############################
//funcao que abre uma janela pop-up - v2.0
function MM_openBrWindow(theURL,winName,features)
	{
		window.open(theURL,winName,features);
	}

//funcao do jump-menu - v3.0
function MM_jumpMenu(targ,selObj,restore)
	{
		eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
		if (restore) selObj.selectedIndex=0;
	}


//funcao que chama comando de javascript - v2.0
function MM_callJS(jsStr)
	{
		return eval(jsStr)	
	}


//funcao que busca o nome do objeto do formulario - v4.01
function MM_findObj(n, d)
	{
  		var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length)
			{
				d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
			}
		if(!(x=d[n])&&d.all) x=d.all[n];
		for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
		for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  		if(!x && d.getElementById) x=d.getElementById(n); return x;
	}

//funcao que verifica e valida os campos no fomrularo - v4.0
function MM_validateForm()
	{
		var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
 	 	for (i=0; i<(args.length-2); i+=3) 
			{ 
				test=args[i+2]; val=MM_findObj(args[i]);
				if (val)
					{
						nm=val.name;
						if ((val=val.value)!="")
							{
								if (test.indexOf('isEmail')!=-1) 
									{
										p=val.indexOf('@');
										if (p<1 || p==(val.length-1)) errors+='- '+nm+' deve conter um endereço de e-mail válido.\n';
									}
								else if (test!='R')
									{
										num = parseFloat(val);
										if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
										if (test.indexOf('inRange') != -1) 
											{
												p=test.indexOf(':');
												min=test.substring(8,p); 
												max=test.substring(p+1);
												if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
											}
									}
							}
						else if (test.charAt(0) == 'R') errors += '- É obrigatório o preenchimento do campo '+nm+'\n'; 
					}
  			} 
		if (errors) alert('Erro(s):\n'+errors);
  		document.MM_returnValue = (errors == '');
	}

//define qual navegador estou usando
if((navigator.appName == "Netscape")&&(parseInt(navigator.appVersion)>=4))
	{
		document.captureEvents( Event.KEYDOWN )
		document.onkeyup = countChars;
	}	

//funcao que pre-carrega as imagens - v3.0
function MM_preloadImages()	
	{
  		var d=document; if(d.images)
			{ 
				if(!d.MM_p) d.MM_p=new Array();
    			var i,j=d.MM_p.length,a=MM_preloadImages.arguments; 
				for(i=0; i<a.length; i++)
   				if (a[i].indexOf("#")!=0)
					{ 
						d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];
					}
			}
	}

//funcao que mostra/esconde layers
function MM_showHideLayers() 
	{ //v6.0
  		var i,p,v,obj,args=MM_showHideLayers.arguments;
  		for (i=0; i<(args.length-2); i+=3) 
		if ((obj=MM_findObj(args[i]))!=null) 
			{ 
				v=args[i+2];
    			if (obj.style) 
					{ 
						obj=obj.style; 
						v=(v=='show')?'visible':(v=='hide')?'hidden':v; 				
					}
    			obj.visibility=v; 
			}
	}
//-->

//funcao que volta a imagem original nas rollover images - v3.0
function MM_swapImgRestore() 
	{
  		var i,x,a=document.MM_sr; 
		for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
	}

//funcao que troca a imagem nas rollover images - v3.0
function MM_swapImage() 
	{
  		var i,j=0,x,a=MM_swapImage.arguments; 
		document.MM_sr=new Array; 
		for(i=0;i<(a.length-2);i+=3)
   		if ((x=MM_findObj(a[i]))!=null)
			{
				document.MM_sr[j++]=x; 
				if(!x.oSrc) x.oSrc=x.src; 
				x.src=a[i+2];
			}
}

//###############################FUNCOES DO DREAMWEAVER###############################













//funcao que conta caracteres restantes de um campo para digitar
function ContaCaracteres_PP(form,campo,limite)
	{
		//alert("campo: "+campo);
		tamanho_campo = eval("document."+form+"."+campo+".value.length");
		intCaracteres = limite - tamanho_campo;
		//alert("intCaracteres: "+intCaracteres);
		if (intCaracteres > 0)
			{
				eval("document."+form+".num_caracteres_"+campo+".value='"+intCaracteres+"'");
				return true;
			}
		else
			{
				eval("document."+form+".num_caracteres_"+campo+".value='0'");
				valor_limite = eval("document."+form+"."+campo+".value.substr(0,"+limite+")");
				eval("document."+form+"."+campo+".value='"+valor_limite+"'");
				return false;
			}
	}

//funcao que subemete o formulario
function envia_form(valor,formulario)
	{
		//alert("valor: "+valor);
		//alert("formulario: "+formulario);
		eval("document."+formulario+".acao.value=''");
		eval("document."+formulario+".acao.value='"+valor+"'");
		eval("document."+formulario+".submit()");
	}

//funcao que subemete o formulario exigindo o preenchimento de usuario e senha
function envia_form_senha(valor,formulario,texto_usuario,campo_usuario,campo_senha,lembrar_senha)
	{
		//alert("valor: "+valor);
		//alert("formulario: "+formulario);
		var usuario = eval("document."+formulario+"."+campo_usuario+".value");
		var senha = eval("document."+formulario+"."+campo_senha+".value");
		if(lembrar_senha!="sim")
			{
				if((usuario!="")&&(senha!=""))
					{
						envia_form(valor,formulario);
					}
				else
					{
						alert("Para prosseguir, digite seu "+texto_usuario+" e sua senha");
					}
			}
		else if(lembrar_senha=="sim")
			{
				if(usuario!="")
					{
						envia_form_action_target('inscreva_se','lembrar_senha.php','_self')
					}
				else
					{
						alert("Para prosseguir, digite seu "+texto_usuario);
					}
			}
		if((usuario=="")&&(senha=="")) eval("document."+formulario+"."+campo_usuario+".focus()");
		else if(usuario=="") eval("document."+formulario+"."+campo_usuario+".focus()");
		else if(senha=="") eval("document."+formulario+"."+campo_senha+".focus()");
	}

//funcao que subemete o formulario exigindo o preenchimento do campo CASA - RELATORIO DE SOLICITACOES SICME - INDUSTRIA EM ACAO
function envia_form_relatorio_sicme()
	{
		var casa = document.seleciona.casa_projeto[document.seleciona.casa_projeto.selectedIndex].value;
		if(casa!="")
			{
				envia_form('ver','seleciona');
			}
		else
			{
				alert("É necessário escolher a CASA");
			}
	}


//funcao que submete o formulario do lembrar senha
function envia_form_lembrar_senha()
	{
	
		var usuario = document.senha.usuario.value;
		var email = document.senha.email.value;

		if((usuario=="")&&(email==""))
			{
				alert('Digite o seu usuário e/ou senha');
			}
			
		else if((usuario!="")||(email!=""))
			{
				envia_form('lembrar_senha','senha');
			}
	}



//funcao que avisa quando foi dado dois cliques no botao de enviar
function desativa_dbClick()
	{
		alert("Para processar sua solicitação, clique apenas 1 vez no botão de enviar");
	}

//funcao que subemete o formulario de troca de senha
function envia_form_senha_alterar(valor,formulario)
	{
		var senha = eval("document."+formulario+".usuario_senha.value");
		var senha_repete = eval("document."+formulario+".usuario_senha_repete.value");
		if(senha == senha_repete)
			{
				eval("document."+formulario+".acao.value=''");
				eval("document."+formulario+".acao.value='"+valor+"'");
				//var valor_botao2 = eval("document."+formulario+".botao2.value");
				//alert("botao2: "+valor_botao2);
				eval("document."+formulario+".submit()");
			}
		else
			{
				alert("Senha digita nao confere. Favor digitar novamente");
			}
	}

//funcao que arredonda valores com casas decimais
function arredonda_valor(valor,casas)
	{
		var valor = Math.round( valor * Math.pow( 10 , casas ) ) / Math.pow( 10 , casas );
  	 	//document.write( novo );
		return(valor);
	}

//funcao que marca todos os checkbox no cadastro de usuarios
function permissao_marcar_tudo()
	{
   		var permitir_senha = document.admin.usuario_permitir_senha.checked;
   		var casa_fiemt = document.admin.casa_fiemt.checked;
   		var casa_sesi = document.admin.casa_sesi.checked;
   		var casa_senai = document.admin.casa_senai.checked;
   		var casa_iel = document.admin.casa_iel.checked;
   		var casa_gestao = document.admin.casa_gestao.checked;
		//alert("permitir_senha: "+permitir_senha)
		for (i=0;i<document.admin.elements.length;i++)
      	if(document.admin.elements[i].type == "checkbox")
       	document.admin.elements[i].checked=1
		if(permitir_senha==false) document.admin.usuario_permitir_senha.checked=false
		if(casa_fiemt==false) document.admin.casa_fiemt.checked=false
		if(casa_sesi==false) document.admin.casa_sesi.checked=false
		if(casa_senai==false) document.admin.casa_senai.checked=false
		if(casa_iel==false) document.admin.casa_iel.checked=false
		if(casa_gestao==false) document.admin.casa_gestao.checked=false
		document.admin.marcar_todos.checked=true
	}

//funcao que desmarca todos os checkbox no cadastro de usuarios
function permissao_desmarcar_tudo()
	{
   		var permitir_senha = document.admin.usuario_permitir_senha.checked;
   		var casa_fiemt = document.admin.casa_fiemt.checked;
   		var casa_sesi = document.admin.casa_sesi.checked;
   		var casa_senai = document.admin.casa_senai.checked;
   		var casa_iel = document.admin.casa_iel.checked;
   		var casa_gestao = document.admin.casa_gestao.checked;
		//alert("permitir_senha: "+permitir_senha)
   		for (i=0;i<document.admin.elements.length;i++)
      	if(document.admin.elements[i].type == "checkbox")
        document.admin.elements[i].checked=0
		if(permitir_senha==true) document.admin.usuario_permitir_senha.checked=true
		if(casa_fiemt==true) document.admin.casa_fiemt.checked=true
		if(casa_sesi==true) document.admin.casa_sesi.checked=true
		if(casa_senai==true) document.admin.casa_senai.checked=true
		if(casa_iel==true) document.admin.casa_iel.checked=true
		if(casa_gestao==true) document.admin.casa_gestao.checked=true
		document.admin.marcar_todos.checked=false
	} 
	
//funcao que limpa os valores do campo e retorna o foco nele
function limpa_valor(form,campo)
	{
		eval("document."+form+"."+campo+".value=''");
		eval("document."+form+"."+campo+".focus()");
	}

//funcao que desabilita o botao de inserir/alterar no form
function desabilita_botao()
	{
		var controle = document.admin.desabilita.value;
		if(controle=='desabilita') document.admin.botao.disabled = true;
	}


//funcao que passa para o proximo campo quando digitar o limite de caracteres
function pula_campo(campo_atual, limite, proximo_campo, form)
	{
		tamanho_campo = eval("document."+form+"."+campo_atual+".value.length");
		//alert("tamanho_campo: "+tamanho_campo);
		//alert("limite: "+limite);
		if(tamanho_campo == limite)
			{
				eval("document."+form+"."+proximo_campo+".focus()");
			}
	}

//funcao que verifica se foi digitado link e se tem http no texto
function verifica_http(campo)
	{
		var conteudo_link = campo.value;
		if(conteudo_link!="") 
			{
				tem_http = conteudo_link.indexOf("http://");
				if(tem_http < 0) 
					{
						alert("É necessário incluir 'http://' no início do endereço");
						campo.focus();
					}
			}
	}
	
	
//funcao que limpa o nome do link ao escolher um arquivo
function limpa_link(form,campo)
	{
		var conteudo_link = eval("document."+form+"."+campo+".value");
		if(conteudo_link!="") 
			{
				if(confirm("Ao escolher um arquivo para enviar, o conteúdo do LINK será apagado, deseja continuar?"))
					{
						eval("document."+form+"."+campo+".value=''");
					}
			}
	}
	
//funcao que muda o action e posta o form
function envia_form_action_target(formulario,action,target)
	{
		eval("document."+formulario+".target = '"+target+"'");
		eval("document."+formulario+".action = '"+action+"'");
		eval("document."+formulario+".submit()");
	}


//funcao que posta o formulario atribuindo um valor para o ACAO e mudando o action
function envia_form_action(formulario,action,valor_acao)
	{
		eval("document."+formulario+".acao.value = '"+valor_acao+"'");
		eval("document."+formulario+".action = '"+action+"'");
		eval("document."+formulario+".submit()");
	}


//funcao que posta o formulario atribuindo um valor para o ACAO e mudando o action
function envia_form_action_target_acao(formulario,action,target,valor_acao)
	{
		eval("document."+formulario+".acao.value = '"+valor_acao+"'");
		eval("document."+formulario+".target = '"+target+"'");
		eval("document."+formulario+".action = '"+action+"'");
		eval("document."+formulario+".submit()");
	}


/*********************MASCARA DO FIEMT INFORMA*********************/
//ativacao da mascara
function mascara(o,f)
	{
    	v_obj=o
    	v_fun=f
    	setTimeout("execmascara()",1)
	}
function execmascara()
	{
    	v_obj.value=v_fun(v_obj.value)
	}	

//funcao que so deixa digitar numeros
function soNumeros(v){
    return v.replace(/\D/g,"")
}
/*********************MASCARA DO FIEMT INFORMA*********************/



//funcao que marca todos os checkbox na secao de backup
function permissao_marcar_tudo_backup()
	{
		for (i=0;i<document.backup.elements.length;i++)
			{
				if(document.backup.elements[i].type == "checkbox");
				document.backup.elements[i].checked=1;
				document.backup.marcar_todos.checked=true;
			}
	}

//funcao que desmarca todos os checkbox na secao de backup
function permissao_desmarcar_tudo_backup()
	{
		for (i=0;i<document.backup.elements.length;i++)
			{
				if(document.backup.elements[i].type == "checkbox");
				document.backup.elements[i].checked=0;
				document.backup.marcar_todos.checked=false;
			}
	} 

//funcao substr_count do PHP transformada em Javascript
function substr_count( haystack, needle, offset, length ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // *     example 1: substr_count('Kevin van Zonneveld', 'e');
    // *     returns 1: 3
    // *     example 2: substr_count('Kevin van Zonneveld', 'K', 1);
    // *     returns 2: 0
    // *     example 3: substr_count('Kevin van Zonneveld', 'Z', 0, 10);
    // *     returns 3: false
 
    var pos = 0, cnt = 0;
 
    if(isNaN(offset)) offset = 0;
    if(isNaN(length)) length = 0;
    offset--;
 
    while( (offset = haystack.indexOf(needle, offset+1)) != -1 ){
        if(length > 0 && (offset+needle.length) > length){
            return false;
        } else{
            cnt++;
        }
    }
 
    return cnt;
}

/*********************FUNCOES AC FLASH DO DREAMWEAVER*********************/
//v1.0
//Copyright 2006 Adobe Systems, Inc. All rights reserved.
function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '<object ';
  for (var i in objAttrs)
    str += i + '="' + objAttrs[i] + '" ';
  str += '>';
  for (var i in params)
    str += '<param name="' + i + '" value="' + params[i] + '" /> ';
  str += '<embed ';
  for (var i in embedAttrs)
    str += i + '="' + embedAttrs[i] + '" ';
  str += ' ></embed></object>';

  document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "id":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}
/*********************FUNCOES AC FLASH DO DREAMWEAVER*********************/


//funcao que define o destaque como sem noticia
function semnoticia()
	{
		if(document.admin.noticia_nome) document.admin.noticia_nome.value = '';
		document.getElementById('noticia_nome').innerHTML = "Not&iacute;cia n&atilde;o escolhida.";
		document.admin.destaque_noticia.value = '';
	}


//funcao que retira os . e / do cpnj no post da contribuicao sindical
function retira_caracteres(form,campo)
	{
		var valor = eval("document."+form+"."+campo+".value");
		valor = valor.toString().replace( ".", "" );
		valor = valor.toString().replace( ".", "" );
		valor = valor.toString().replace( ".", "" );
		valor = valor.toString().replace( "/", "" );
		valor = valor.toString().replace( "-", "" );

		eval("document."+form+"."+campo+".value='"+valor+"'");
	}


/*********************FUNCOES DA CAIXA DE FOTOS*********************/
//funcao que retorna o nome do item selecionado na caixa de fotos
function nome_lista_de_fotos()
	{
    	var opcao = "";
	    for (i = 0 ; i < document.seleciona.id.length ; i++)
			{
				if (document.seleciona.id.options[i].selected)
			   		{
						opcao += (document.seleciona.id.options[i].text);
					}
       		}
		return opcao;
     	//alert ("A opcao escolhida foi: "+opcao)
	}

//funcao que adiciona a foto no form de cadastro
function adiciona_foto(check,origem)
	{
		var foto = document.seleciona.id.value;
		var foto_nome = nome_lista_de_fotos();
		
		if(origem=="fiemt_informa")
			{
				eval("self.opener.window.document.fiemt_informa.fiemt_informa_foto_destaque.value = foto");
				alert("A foto '"+foto_nome+"' foi selecionada!");
			}
		else if(origem=="foto_rodape")
			{
				var numero_foto = document.seleciona.foto_rodape_numero.value;
				
				eval("self.opener.window.document.admin.foto_rodape_nome_"+numero_foto+".value = foto_nome");
				eval("self.opener.window.document.admin.foto_rodape_caminho_"+numero_foto+".value = foto");
				eval("self.opener.window.document.images.foto_rodape_"+numero_foto+".src=foto");
			}
		else
			{
				var campo_mostra_foto = document.seleciona.mostra_foto.value;
				//alert("foto: "+foto+"\nfoto_nome: "+foto_nome+"\ncampo_mostra_foto: "+campo_mostra_foto)
				
				eval("self.opener.window.document.admin.foto_nome.value = foto_nome");
				eval("self.opener.window.document.admin.foto_caminho.value = foto");
				if(check=='sim') eval("self.opener.window.document.admin."+campo_mostra_foto+".checked = true");
				eval("self.opener.window.document.images.foto.src=foto");
			}

		window.close();
	}

//funcao que adiciona a foto no form de cadastro
function adiciona_foto_inserir(check,origem)
	{
		var foto = document.mostra_foto.foto_caminho.value;
		var foto_nome = document.mostra_foto.foto_nome.value;

		if(origem=="fiemt_informa")
			{
				eval("self.opener.window.document.fiemt_informa.fiemt_informa_foto_destaque.value = foto");
				alert("A foto '"+foto_nome+"' foi selecionada!");
			}
		else if(origem=="foto_rodape")
			{
				var numero_foto = document.mostra_foto.foto_rodape_numero.value;
				
				eval("self.opener.window.document.admin.foto_rodape_nome_"+numero_foto+".value = foto_nome");
				eval("self.opener.window.document.admin.foto_rodape_caminho_"+numero_foto+".value = foto");
				eval("self.opener.window.document.images.foto_rodape_"+numero_foto+".src=foto");
			}
		else
			{
				var campo_mostra_foto = document.mostra_foto.mostra_foto.value;
				//alert("foto: "+foto+"\nfoto_nome: "+foto_nome+"\ncampo_mostra_foto: "+campo_mostra_foto)
				
				eval("self.opener.window.document.admin.foto_nome.value = foto_nome");
				eval("self.opener.window.document.admin.foto_caminho.value = foto");
				if(check=='sim') eval("self.opener.window.document.admin."+campo_mostra_foto+".checked = true");
				eval("self.opener.window.document.images.foto.src=foto");
			}

		window.close();
	}
/*********************FUNCOES DA CAIXA DE FOTOS*********************/


//converte o numero em moeda
function float2moeda(num) 
	{
		x = 0;
		if(num<0) 
			{
				num = Math.abs(num);
				x = 1;
			}  
		if(isNaN(num)) num = "0";
      	cents = Math.floor((num*100+0.5)%100);
		num = Math.floor((num*100+0.5)/100).toString();
		
		if(cents < 10) cents = "0" + cents;
      	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
        num = num.substring(0,num.length-(4*i+3))+'.'
		+num.substring(num.length-(4*i+3));   
		ret = num + ',' + cents;   if (x == 1) ret = ' - ' + ret;return ret;
	}
	
	

//funcao que mostra ou esconde as opcoes de escolaridade no cadastro de curriculum
function mostra_cadastro_escolaridade(escolaridade)
	{
		if(escolaridade=='pos_graduacao')
			{
				document.getElementById("pos_graduacao").style.display = ''
				document.getElementById("ensino_superior").style.display = ''
				document.getElementById("ensino_medio").style.display = 'none'
				document.getElementById("ensino_tecnico").style.display = 'none'
				document.getElementById("ensino_fundamental").style.display = 'none'
			}
		if((escolaridade=='superior_completo')||(escolaridade=='superior_incompleto'))
			{
				document.getElementById("pos_graduacao").style.display = 'none'
				document.getElementById("ensino_superior").style.display = ''
				document.getElementById("ensino_medio").style.display = 'none'
				document.getElementById("ensino_tecnico").style.display = 'none'
				document.getElementById("ensino_fundamental").style.display = 'none'
			}
		if((escolaridade=='ensino_medio_completo')||(escolaridade=='ensino_medio_incompleto'))
			{
				document.getElementById("pos_graduacao").style.display = 'none'
				document.getElementById("ensino_superior").style.display = 'none'
				document.getElementById("ensino_medio").style.display = ''
				document.getElementById("ensino_tecnico").style.display = 'none'
				document.getElementById("ensino_fundamental").style.display = 'none'
			}
		if((escolaridade=='curso_tecnico')||(escolaridade=='curso_tecnico_incompleto'))
			{
				document.getElementById("pos_graduacao").style.display = 'none'
				document.getElementById("ensino_superior").style.display = 'none'
				document.getElementById("ensino_medio").style.display = 'none'
				document.getElementById("ensino_tecnico").style.display = ''
				document.getElementById("ensino_fundamental").style.display = 'none'
			}
		if((escolaridade=='ensino_fundamental_completo')||(escolaridade=='ensino_fundamental_incompleto'))
			{
				document.getElementById("pos_graduacao").style.display = 'none'
				document.getElementById("ensino_superior").style.display = 'none'
				document.getElementById("ensino_medio").style.display = 'none'
				document.getElementById("ensino_tecnico").style.display = 'none'
				document.getElementById("ensino_fundamental").style.display = ''
			}
	}


//funcao que mostra/esconde um item usando o display
function mostra_esconde(nome,acao)
	{
		eval("document.getElementById('"+nome+"').style.display = '"+acao+"'");
	}


//funcao que valida o formlario de contato - SITE FIEMT
function envia_form_contato()
	{
		var destino_mensagem = document.contato.destino_mensagem[document.contato.destino_mensagem.selectedIndex].value;
		var nome = document.contato.nome.value;
		var telefone = document.contato.telefone.value;
		var email = document.contato.email.value;
		var mensagem = document.contato.mensagem.value;
		
		var mensagem_alert = '';
		
		if(destino_mensagem=="") mensagem_alert += "\n- Selecione o destino da mensagem.";
		if(nome=="") mensagem_alert += "\n- Digite seu nome.";
		if((telefone=="")&&(email=="")) mensagem_alert += "\n- Digite um telefone ou e-mail para contato.";
		if(mensagem=="") mensagem_alert += "\n- Digite o texto da mensagem.";
		
		if(mensagem_alert=="")
			{
				document.contato.submit();
			}
		else
			{
				alert('Os seguintes erros foram encontrados: '+mensagem_alert);
			}
	}
	


/*####################FUNCAO QUE AUMENTA/DIMINUI A FONTE####################*/
var tam = 13;

function mudaFonte(tipo,elemento){
	if (tipo=="mais") {
		if(tam<18) tam+=1;
		createCookie('fonte',tam,365);
	} else {
		if(tam>10) tam-=1;
		createCookie('fonte',tam,365);
	}
	document.getElementById('texto_materia').style.fontSize = tam+'px';
	// document.getElementById('mudaFoto').style.fontSize = tam+'px';
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	} else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
/*####################FUNCAO QUE AUMENTA/DIMINUI A FONTE####################*/

//funcao que esconde a layer do banner flutuante
function Esconde(div){
//alert("div: "+div);
document.getElementById('pop_up_'+div).style.visibility="hidden";
}

//funcao que recarrega uma imagem
function recarrega_imagem(caminho,nome_img) {
	//alert(caminho+"\n"+nome_img);
	var now = new Date();
	if (document.images) {
		eval("document.images."+nome_img+".src = '"+caminho+"?"+now.getTime()+"'");
	}
}


//funcao que mostra/esconde as opcoes de tipo de cabecalho/rodape
function mostra_campo_cabecalho_rodape(tipo,operacao)
	{
		if(tipo=='cabecalho')
			{
				var valor = document.admin.newsletter_template_cabecalho_tipo.value;
				if(valor=='img')
					{
						document.getElementById('linha_cabecalho_imagem').style.display = '';
						document.getElementById('linha_cabecalho_texto').style.display = 'none';
						if(operacao=='alterar') document.getElementById('linha_cabecalho_imagem_trocar').style.display = '';
					}
				if(valor=='txt')
					{
						if(operacao=='alterar') document.getElementById('linha_cabecalho_imagem_trocar').style.display = 'none';
						document.getElementById('linha_cabecalho_imagem').style.display = 'none';
						document.getElementById('linha_cabecalho_texto').style.display = '';
					}
				if((valor=='')||(valor=='sem'))
					{
						if(operacao=='alterar') document.getElementById('linha_cabecalho_imagem_trocar').style.display = 'none';
						document.getElementById('linha_cabecalho_imagem').style.display = 'none';
						document.getElementById('linha_cabecalho_texto').style.display = 'none';
					}
			}

		if(tipo=='rodape')
			{
				var valor = document.admin.newsletter_template_rodape_tipo.value;
				if(valor=='img')
					{
						if(operacao=='alterar') document.getElementById('linha_rodape_imagem_trocar').style.display = '';
						document.getElementById('linha_rodape_imagem').style.display = '';
						document.getElementById('linha_rodape_texto').style.display = 'none';
					}
				if(valor=='txt')
					{
						if(operacao=='alterar') document.getElementById('linha_rodape_imagem_trocar').style.display = 'none';
						document.getElementById('linha_rodape_imagem').style.display = 'none';
						document.getElementById('linha_rodape_texto').style.display = '';
					}
				if((valor=='')||(valor=='sem'))
					{
						if(operacao=='alterar') document.getElementById('linha_rodape_imagem_trocar').style.display = 'none';
						document.getElementById('linha_rodape_imagem').style.display = 'none';
						document.getElementById('linha_rodape_texto').style.display = 'none';
					}
			}
	}
	
	
//funcao que mostra ou esconde a opcao de separador interno - secao importar e-mail em newsletters
function mostra_esconde_separador_interno()
	{
		
		for (i=0;i<document.admin.info_arquivo.length;i++)
			{
					if (document.admin.info_arquivo[i].checked == true)
						{
							var valor_escolhido = document.admin.info_arquivo[i].value;
						}
			}
			
		if((valor_escolhido=="nome_email")||(valor_escolhido=="email_nome"))
			{
				document.getElementById("linha_separador_interno").style.display = '';
			}
		else
			{
				document.getElementById("linha_separador_interno").style.display = 'none';			}
	}
	

//funcao que marca/desmarca todos os checkbox da tela de gerenciar e-mails
function marca_desmarca_lista_emails(opcao)
	{
		for (i=0;i<document.seleciona.elements.length;i++)
			{
				if(document.seleciona.elements[i].type == "checkbox")
					{
						document.seleciona.elements[i].checked = opcao;
					}
			}
	}
	

//funcao que efetua operacoes gerais com e-mails duplicados
function operacoes_gerais_importar(acao,nome_campo,formulario)
	{
		for (i=0;i<formulario.elements.length;i++)
			{
				if(formulario.elements[i].type == "select-one")
					{
						if(nome_campo=="operacoes_gerais_registros") var palavra_campos = "acao_registro[";
						else if(nome_campo=="operacoes_gerais_grupos") var palavra_campos = "acao_grupo[";
						
						if(substr_count(formulario.elements[i].name, palavra_campos) > 0) formulario.elements[i].value = acao;
					}
			}
	}


//funcao que submete o formulario de gerenciar e-mails com as acoes dos selecionados
function acoes_duplicados(formulario)
	{
		var acao_escolhida = formulario.com_selecionados.options[formulario.com_selecionados.selectedIndex].value;
		
		if(acao_escolhida!="")
			{
				if(acao_escolhida=="excluir")
					{
						if(confirm("Os e-mails selecionados serão permanentemente excluídos, deseja continuar?")) envia_form('excluir_selecionados',formulario.name);	
					}
				if(acao_escolhida=="inativar") envia_form('inativar_selecionados',formulario.name);	
				if(acao_escolhida=="ativar") envia_form('ativar_selecionados',formulario.name);	
				else if(substr_count(acao_escolhida, "definir_grupo_") > 0) 
					{
						if(confirm("A ação a seguir irá definir todos os e-mails selecionados como sendo somente de um mesmo grupo, deseja continuar?"))
							{
								formulario.nome_grupo_escolhido.value = formulario.com_selecionados.options[formulario.com_selecionados.selectedIndex].text;
								envia_form('define_grupo',formulario.name);
							}
					}
				else if(substr_count(acao_escolhida, "participar_grupo_") > 0) 
					{
						formulario.nome_grupo_escolhido.value = formulario.com_selecionados.options[formulario.com_selecionados.selectedIndex].text;
						envia_form('participar_grupo',formulario.name);
					}
			}
	}
	
	
	
//funcao que troca a cor do fundo da tabela, de acordo com o ID / numero colunas
function trocar_cor_fundo_tabela(cor,prefixo_coluna,num_colunas,id_linha)
	{
		var teste_colunas = "";
		
		for(x=1;x<=num_colunas;x++)
			{
				var nome_coluna = prefixo_coluna + x + "_" + id_linha;
				document.getElementById(nome_coluna).style.backgroundColor = "#" + cor;
			}
	}
	
//funcao que passa as informacoes de um list para outro	
function adicionaItem(campoOrig,campoDest) 
{
	x = campoOrig.value;
	
	if (x == "")
		{
			alert('Selecione um item!');
		}
	
	ListaDisponiveis = campoOrig; 
	ListaAcordo = campoDest;
	
	var len = ListaAcordo.length;
	
	for(var i = 0; i < ListaDisponiveis.length; i++) 
		{
			if ((ListaDisponiveis.options[i] != null) && 
				  (ListaDisponiveis.options[i].selected)) 
			{
				
				ListaAcordo.options[len] = new Option(ListaDisponiveis.options[i].text, ListaDisponiveis.options[i].value); 
				len++;
				ListaDisponiveis.options[i] = null;  
				i--;
			}
		}
}



//funcao que envia o formulario de inserir newsletter
function envia_form_inserir_newsletter(formulario)
	{
		var assunto = eval("document."+formulario+".newsletter_assunto.value");
		
		if(assunto=="") 
			{
				alert("Preencha o assunto da Newsletter.");
				eval("document."+formulario+".newsletter_assunto.focus();");	  
			}
		else envia_form('inserir','newsletter');
	}
	
	

//funcao que exibe o e-mail do remetente escolhido na secao Enviar Newsletter
function exibe_email_remetente(campo)
	{

		var email_remetente = campo.options[campo.selectedIndex].value;
		//alert(email_remetente+"\n"+email_remetente);
		
		if(email_remetente!="") 
			{
				email_remetente = email_remetente.toString().replace("_at_","@");
				email_remetente = email_remetente.toString().replace("_dot_",".");
				email_remetente = email_remetente.toString().replace("_dot_",".");
				email_remetente = email_remetente.toString().replace("_dot_",".");
				email_remetente = email_remetente.toString().replace("_dot_",".");
				document.getElementById("email_remetente").innerHTML = ' &lt;'+email_remetente+'&gt;';
			}
		else 
			{
				document.getElementById("email_remetente").innerHTML = '';
			}
	}


function ind_acao_limpa_area_dados_inserir_solicitacao(area_unidade,area_itens)
	{
		if(area_unidade==0) document.getElementById("unidades_da_acao").innerHTML = '&nbsp;';
		if(area_itens==0) document.getElementById("acoes_da_unidade").innerHTML = '&nbsp;';
	}
	
	
function muda_cor_fundo_input(campo,limite, cor_original, cor_mudar)
	{
		if(campo.value.length==limite) campo.style.backgroundColor = cor_mudar;
		else campo.style.backgroundColor = cor_original;
	}
	
	
function mostra_agendamento(valor_escolhido)
	{
		if(valor_escolhido=="unico")
			{
				document.getElementById('agendamento_unico').style.display = '';
				document.getElementById('agendamento_intervalo').style.display = 'none';
				document.getElementById('agendamento_frequencia').style.display = 'none';
			}
		else if(valor_escolhido=="semanal")
			{
				document.getElementById('agendamento_unico').style.display = 'none';
				document.getElementById('agendamento_intervalo').style.display = '';
				document.getElementById('agendamento_frequencia').style.display = '';
			}
		else if((valor_escolhido=="fila")||(valor_escolhido=="imediato"))
			{
				document.getElementById('agendamento_unico').style.display = 'none';
				document.getElementById('agendamento_intervalo').style.display = 'none';
				document.getElementById('agendamento_frequencia').style.display = 'none';
			}
				
	}
	
	
function mostra_nome_email_remetente(formulario)
	{
		var nome_remetente = formulario.email_remetente_mensagem.options[formulario.email_remetente_mensagem.selectedIndex].text;
		var email_remetente = formulario.email_remetente_mensagem.options[formulario.email_remetente_mensagem.selectedIndex].value;
		if(email_remetente!="") 
			{
				formulario.nome_remetente_mensagem.value = nome_remetente;
				document.getElementById('mostra_email_nome_remetente').innerHTML = "&lt;"+email_remetente+"&gt; "+nome_remetente;
			}
	}
