if (document.all)
	var tagDisplay = "block";
else
	var tagDisplay = "table-row";

function RedimensionaIframe(altura) {
	var IFR = document.getElementById('conteudo_fieg');	
	
	if (!altura)
		altura=10
	
	IFR.style.height = (document.all) ? IFR.contentWindow.document.body.scrollHeight+altura: (IFR.contentDocument.body.scrollHeight + altura) + 'px';
}

function fSubmit(frmCampo,teclapres) {
	var tecla = teclapres.keyCode;
	if (tecla == 13) {
		document.all.q.value += " site:sistemafieg.org.br";
	}
}

function mostraTabela(elementoID) {
	var menus 	 = document.frmCfgMenus.hddMenus.value;
	var vetMenus = menus.split(",");
	
	for (i=0; i < vetMenus.length; i++) {
		if (vetMenus[i] != elementoID) {
			document.getElementById(vetMenus[i]).style.display = 'none';
		} else {
			if (document.getElementById(elementoID).style.display == tagDisplay) {		
				document.getElementById(elementoID).style.display = 'none';
			} else if(document.getElementById(elementoID).style.display == 'none') {				
				document.getElementById(elementoID).style.display = tagDisplay;		
			}			
		}
	}
} 

function fecharSubs() {
	var menus 	 = document.frmCfgMenus.hddMenus.value;
	var vetMenus = menus.split(",");
	
	for (i=0; i < vetMenus.length; i++) {
		document.getElementById(vetMenus[i]).style.display = 'none';
	}
}

function MM_showHideLayers() { //v9.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
  with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

var tam=10;
function mudaFonte(tipo,r) {
	(r) ? tam=10 : void(0);

	if (tipo=="mais") {
		tam+=3;
	} else {
		tam-=3;
	}
	
	document.getElementById('mudaFonte').style.fontSize=tam;
	parent.RedimensionaIframe();
}


function printNoticia(id, modulo) {
	var url     = "noticias.php?action=print&codnoticia="+id+"&modulo="+modulo;
	var largura = 600;
	var altura  = 600;
	
	window.open(url, id, 'resizable=yes,scrollbars=yes,toolbar=yes,status=no, width=' + largura + ',height=' + altura + ',top=' + ((screen.availHeight/2) - (altura/2)) + ',left=' + ((screen.availWidth/2) - (largura/2)));
}

function validaTableSendNoticia() {
	if (document.frmDisparaMail.nome.value == "") {
		alert("Informe seu nome!");
		document.frmDisparaMail.nome.focus();
		return false;
	}

	if (document.frmDisparaMail.email.value == "") {
		alert("Informe seu e-mail!");
		document.frmDisparaMail.email.focus();
		return false;
	}
	if (document.frmDisparaMail.nome2.value == "") {
		alert("Informe o nome do destinatario!");
		document.frmDisparaMail.nome2.focus();
		return false;
	}
	if (document.frmDisparaMail.email2.value == "") {
		alert("Informe o e-mail do destinatario!");
		document.frmDisparaMail.email2.focus();
		return false;
	}
}

function montaFlash(destino, flavez, width, height, trans, scale){
	var myFlash = 
		'<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+width+'" height="'+height+'" id="'+flavez+'" align="middle">'+
		'<param name="allowScriptAccess" value="sameDomain" />'+
		'<param name="movie" value="'+flavez+'.swf?button=1" />'
	;
	if (trans == "yes"){
		myFlash += '<param name="wmode" value="transparent" />';
	}
	if (scale == "yes"){
		myFlash += '<param name="scale" value="noscale" />';
	}
	myFlash +=
		'<param name="quality" value="high" />'+
		'<param name="menu" value="false" />'+
		'<embed src="'+flavez+'.swf?button=1" quality="high" width="'+width+'" height="'+height+'"  align="middle" allowScriptAccess="sameDomain" wmode="transparent" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'+
		'</object>'
	;
	document.getElementById(destino).innerHTML = myFlash;
}

// ======================= <ATIVIDADES> ======================= //

function listaModalidade(valor, para_quem) {
	if (valor=="")
		valor = document.formBusca.tipo.value;
	
	http.open("GET", "/site/atividades_busca.php?action=carrega_modalidade&id=" + valor + "&para_quem=" + para_quem, true);
	http.onreadystatechange = handleHttpResponseListaModalidade;
	http.send(null);
}

function handleHttpResponseListaModalidade() {
	campo_select = document.formBusca.modalidade;	
	if (http.readyState == 4) {
		campo_select.options.length = 0;
		var temp = unescape(http.responseText);
		
		temp 	 = replaceCharacters(temp, "+", " ");
		results  = temp.split(",");
		for (i=0; i < results.length-1; i++ ) {
			string = results[i].split( "|" );
			campo_select.options[i] = new Option( string[0], string[1] );
		}
	}
}

function replaceCharacters(conversionString,inChar,outChar) {
  var convertedString = conversionString.split(inChar);
  convertedString = convertedString.join(outChar);
  return convertedString;
}

// ======================= </ATIVIDADES> ======================= //


function abrirAjuda(nome, id, width, height, top){
	document.getElementById('ajuda').style.width = width;
	document.getElementById('ajuda').style.height = height;
	document.getElementById('ajuda').style.top = top;
	//document.all.ajuda.style.left = left;
	document.getElementById('ajuda').style.display = "block";
	
	http.open("GET", "/site/atividades_busca.php?action=ajuda&nome="+nome+"&id="+id, true);
	http.onreadystatechange = handleHttpResponseAjuda;
	http.send(null);
}		

function handleHttpResponseAjuda() {
	if (http.readyState == 4) {
		//var img = "<img src='/site/lib/images/ajuda.gif' vspace='8' align='left' style='border-right:3px #FFFFE1 solid'>";
		var img = "";
		var temp = unescape(http.responseText);
		temp = replaceCharacters(temp, "+", " ");
		document.all.ajuda.innerHTML = img + temp;
	}
}

function fecharAjuda() {
	document.getElementById('ajuda').style.display = "none";
}


function validaPesquisa() {	
	if (document.formBusca.tipo.value=="") {
		alert("O tipo deve ser selecionado.");
		document.formBusca.tipo.focus();
		return false;
		
	} else if (document.formBusca.modalidade.value == '' || document.formBusca.modalidade.value == 0) {
		alert("A modalidade deve ser selecionado.");
		document.formBusca.modalidade.focus();
		return false;
		
	} else {
		formBusca.submit();
	}
}

function mostraTexto(id) {
	if (document.getElementById(id).style.display == "none") {
		document.getElementById(id).style.display = "block";
	} else {
		document.getElementById(id).style.display = "none";
	}
}

function open_popup(url, janela, largura, altura, barra) {
	window.open(url, janela, 'width=' + largura + ',height=' + altura + ', scrollbars=' + barra + ' ,top=' + ((screen.availHeight/2) - (altura/2)) + ',left=' + ((screen.availWidth/2) - (largura/2)));

	return ;
}

function fx(texto, id, tipo) {
	texto = decodeBase64(texto);
	
	if (tipo == "image")
		document.all[id].innerHTML = "<img src='"+texto+"' width='260' height='150'>";		
	else
		document.all[id].innerHTML = texto;
}