// Função Popup: <a href="arquivo.ext" onclick="popup(this.href,'360','535','1'); return false;"></a>
function popup(url,w,h,s) {
	var oW=window.open(url,'popup','width='+w+',height='+h+',directories=0,location=0,menubar=0,resizable=0,scrollbars='+s+',status=0,toolbar=0,marginleft=0,margintop=0,left='+(((screen.availWidth-w)/2)+-10)+',top='+(((screen.height-h)/2)+-10));
}

//Função para impressão
function imprimir(){
	popimpressao = window.open('', '_blank', 'width=751,height=450,left=0,top=0,scrollbars=yes,resizable=no,menubar=no,toolbar=no');

	with (popimpressao.document) {
		write('<html><head><title></title></head>');
		write('<link rel="stylesheet" href="../../css/default.css" type="text/css">');
		write('<link rel="stylesheet" href="../../css/print.css" type="text/css">');
		write('<body>');
		write(document.getElementById("impressao").innerHTML);
		write('</body></html>');
		close();
		}
        popimpressao.print();
}


//Função de mostrar o submenu
function submenu(submenu) {
	if (document.getElementById("submenu_"+submenu).style.display == "block") {
		document.getElementById("menu_"+submenu).className = submenu;
		document.getElementById("submenu_"+submenu).style.display = "none";
	} else {
		document.getElementById("menu_"+submenu).className = submenu+"over";
		document.getElementById("submenu_"+submenu).style.display = "block";
	}
}

//Função de mostrar as combos das noticias anteriores
function combonoticia(combo) {
	if (document.getElementById("combodrop_"+combo).style.display == "block") {
		document.getElementById("combo_"+combo).className = combo;
		document.getElementById("combodrop_"+combo).style.display = "none";
	} else {
		document.getElementById("combo_"+combo).className = combo+"over";
		document.getElementById("combodrop_"+combo).style.display = "block";
	}
}

//
function trocames(mes,mm) {
	document.getElementById("mes").innerHTML = mes;
	document.noticiasAnteriores.hmes.value = mm;
}
function trocaano(ano) {
	document.getElementById("ano").innerHTML = ano;
	if (ano != 'Todos')
	{
		document.noticiasAnteriores.hano.value = ano;
	}
	
}

String.prototype.trim = function(){
   return this.replace(/(^\s*)|(\s*$)/g, "");
}

	function soNumeros(e){

		 var key;
		 var keychar;

		 if (window.event) {
			key = window.event.keyCode;
		 } else if (e) {
			key = e.which;
		 } else {
			return true;
		 }

		 keychar = String.fromCharCode(key);

		 // teclas de controle
		 if ((key==null) || (key==0) || (key==8) ||
			  (key==9) || (key==13) || (key==27) ) {
			return true;
		 } else if ((("0123456789").indexOf(keychar) > -1)) {
			return true;     
		 } else {
			return false;
		 }
}

function limitatext(campo,maxtamanho){
	if (campo.value.length>=maxtamanho && event.keyCode !=8 && event.keyCode !=46) { 
		event.keyCode = 0;
	}

	if (campo.value.length >= maxtamanho) {
		campo.value = campo.value.substring(0,maxtamanho);
	}

}

function popup(url,w,h,s) {
    var oW=window.open(url,'popup','width='+w+',height='+h+',directories=0,location=0,menubar=0,resizable=0,scrollbars='+s+',status=0,toolbar=0,marginleft=0,margintop=0,left='+(((screen.availWidth-w)/2)+-10)+',top='+(((screen.height-h)/2)+-10));
}