function preparaMenu(meuMenu) {
        if (!document.getElementsByTagName) return false;
        if (!document.getElementById) return false;
        if (!document.getElementById(meuMenu)) return false;
        var menumain = document.getElementById(meuMenu);
        var menuitems = menumain.getElementsByTagName("li");
        for ( var i=0; i < menuitems.length; i++) {
                menuitems[i].className=""
                var aUL = menuitems[i].getElementsByTagName("ul").item(0);
                if(aUL){
                        aUL.className += " temSub";
                        menuitems[i].getElementsByTagName("a").item(0).onclick = function() {
                                return showSub(this);
                        }
                }
        }
        return ""
}
function showSub(myURL){
    if (!document.getElementById) return true;
    aUL = myURL.parentNode.getElementsByTagName("ul").item(0);
    marca=(aUL.className.indexOf("temSub") != -1) ? "" : "temSub"
    preparaMenu("menuSuperior")
    aUL.className = marca
    aUL.parentNode.className=(marca=="temSub")?"":"marcado"
    myURL.blur()
    return false;
}

//cookies
function setCookie(name, value, expires, path, domain, secure) {
          var curCookie = name + "=" + escape(value) +
          ((expires) ? "; expires=" + expires.toGMTString() : "") +
          ((path) ? "; path=" + path : "") +
          ((domain) ? "; domain=" + domain : "") +
          ((secure) ? "; secure" : "");
         document.cookie = curCookie;
}
function getCookie(name) {
        var dc = document.cookie;
        var prefix = name + "=";
        var begin = dc.indexOf("; " + prefix);
        if (begin == -1) {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
        } else
        begin += 2;
        var end = document.cookie.indexOf(";", begin);
        if (end == -1)
        end = dc.length;
        return unescape(dc.substring(begin + prefix.length, end));
}
function deleteCookie(name, path, domain) {
	if (getCookie(name)) {
		   document.cookie = name + "=" +
		   ((path) ? "; path=" + path : "") +
		   ((domain) ? "; domain=" + domain : "") +
		   "; expires=Thu, 01-Jan-70 00:00:01 GMT";
		   history.go(0);
	}
}
function fixDate(date) {
	var base = new Date(0);
	var skew = base.getTime();
	if (skew > 0) date.setTime(date.getTime() - skew);
}


var now = new Date();
fixDate(now);
now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
var ZOOM = parseInt(getCookie("PP_ZOOM"));

//funções de aumento/diminuição da fonte
var DOM2=document.getElementById
var valorinicial;
var escala;
var ampliado;



function initzoom()
	{
	if (ZOOM)
		valorinicial = ZOOM;
	else
		valorinicial = 100;

	if (DOM2)
		{
		document.body.style.fontSize=valorinicial+"%";
		document.body.innerHTML;
		 }
	//valorinicial = valor;
	}

function zoom(Marcos)
	{
    if ((valorinicial<=120)&&(Marcos.indexOf('mais')==0))
		valorinicial+= 10;
	if ((valorinicial>80)&&(Marcos.indexOf('menos')==0)) 
		valorinicial-= 10;
	if ((valorinicial!=100)&&(Marcos.indexOf('padrao')==0)) 
		valorinicial=100;
	if (DOM2)
		{
		document.body.style.fontSize=valorinicial+"%";
		document.body.innerHTML;
		setCookie("PP_ZOOM", valorinicial, now);
		}
	}


//Validação do Formulário de Ouvidoria
function envia_ouvidoria() {
	if ( document.getElementById('assunto').value == '' || document.getElementById('assunto').value == 'assunto' ) {
		alert("O Assunto é campo obrigatório!");
		document.getElementById('assunto').focus();
		return false;
	}
	if ( document.getElementById('mensagem').value == '' ) {
		alert("A Mensagem é campo obrigatório!");
		document.getElementById('mensagem').focus();
		return false;
	}

	return true;
}	


//Validação do Formulário do Fale Conosco
function envia_fale_conosco() {
	if ( document.getElementById('assunto').value == '' || document.getElementById('assunto').value == 'assunto' ) {
		alert("O Assunto é campo obrigatório!");
		document.getElementById('assunto').focus();
		return false;
	}
	if ( document.getElementById('mensagem').value == '' ) {
		alert("A Mensagem é campo obrigatório!");
		document.getElementById('mensagem').focus();
		return false;
	}

	return true;
}

function apaga(valor)
	{
	if (valor == 1 && document.getElementById('encontra').value == "digite a palavra")
		document.getElementById('encontra').value = "";

	if (valor == 2 && document.getElementById('nome').value == "digite seu nome")
		document.getElementById('nome').value = "";

	if (valor == 3 && document.getElementById('email').value == "digite seu e-mail")
		document.getElementById('email').value = "";
	
	if (valor == 4 && document.getElementById('telefone').value == "Coloque aqui seu telefone")
		document.getElementById('telefone').value = "";
	
	if (valor == 5 && document.getElementById('assunto').value == "Coloque aqui o assunto")
		document.getElementById('assunto').value = "";
	
	}
	
function restaura(valor)
	{
	if (valor == 1 && document.getElementById('encontra').value == "")
		document.getElementById('encontra').value = "digite a palavra";

	if (valor == 2 && document.getElementById('nome').value == "")
		document.getElementById('nome').value = "digite seu nome";
	
	if (valor == 3 && document.getElementById('email').value == "")
		document.getElementById('email').value = "digite seu e-mail";

	if (valor == 4 && document.getElementById('telefone').value == "")
		document.getElementById('telefone').value = "Coloque aqui seu telefone";

	if (valor == 5 && document.getElementById('assunto').value == "")
		document.getElementById('assunto').value = "Coloque aqui o assunto";

	}
	
function cleanfield(text, id)
	{
		valor = document.getElementById(id).value;
		if(valor == text){
			document.getElementById(id).value = "";
			}
		if(valor == ""){
			document.getElementById(id).value = text
			}	
}
	
function verifica()
	{
	if (document.getElementById('municipios').value != "")
		{
		document.getElementById('prefeitos').value = "";
		document.getElementById('prefeitos').readOnly = 1;
		}
	else
		document.getElementById('prefeitos').readOnly = 0;
	}

function cadastra_news()
	{
	var mensagem = "";
	if (document.getElementById('nome').value == "Coloque aqui seu nome" || document.getElementById('nome').value == "")
		mensagem += "\n- Nome;";
	if (document.getElementById('email').value == "Coloque aqui seu e-mail" || document.getElementById('email').value == "")
		mensagem += "\n- E-mail;";

	if (mensagem != "")
		window.alert ("Preencha o(s) campo(s) obrigatório(s)." + mensagem);
	else
		document.getElementById('cadastra').submit();		
}
function testa_ler(){
	if(document.getElementById("deacordo").checked == false){
		document.getElementById("deacordo").focus();
		alert('Você deve estar de acordo com o programa e estatuto do partido para imprimir. Marque a ultima opção do formulário.');
	}else{
		document.getElementById("ficha_filiacao").submit();
		}
}