// Insere flash sem borda
function swf(url, w, h, bg, vars, id) {

	if(bg) {
		ie_bg = '<param name="bgcolor" value="'+ bg +'" />';
		ff_bg = 'bgcolor="'+ bg +'"';
	}else {
		ie_bg = '<param name="wmode" value="transparent" />';
		ff_bg = 'wmode="transparent"';
	}

	if(vars) {
		ie_vars = '<param name="flashvars" value="'+ vars +'" />';
		ff_vars = 'flashvars="'+ vars +'"';
	}else {
		ie_vars =
		ff_vars = '';
	}

	cd_flash  = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
	cd_flash += 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" ';
	cd_flash += 'width="' + w + '" ';
	cd_flash += 'height="'+ h + '" ';
	cd_flash += 'id="'+ id +'" ';
	cd_flash += 'name="'+ id +'">';
	cd_flash += '<param name="movie" value="' + url + '" />';
	cd_flash += '<param name="menu" value="false" />';
	cd_flash += '<param name="quality" value="high" />';
	cd_flash += '<param name="salign" value="tl" />';
	cd_flash += '<param name="scale" value="noscale" />';
	cd_flash += ie_bg;
	cd_flash += ie_vars;
	cd_flash += '<embed src="' + url + '" type="application/x-shockwave-flash" ';
	cd_flash += 'pluginspage="http://www.macromedia.com/go/getflashplayer" ';
	cd_flash += 'menu="false" quality="high" salign="tl" scale="noscale" ';
	cd_flash += 'width="' + w + '" ';
	cd_flash += 'height="'+ h + '" ';
	cd_flash += 'id="'+ id +'" ';
	cd_flash += ff_bg;
	cd_flash += ff_vars;
	cd_flash += '></embed>';
	cd_flash += '</object>';

	document.write(cd_flash);

}

gE = function(alvo) {
	var e;
	e = document.getElementById(alvo);
	return e;
}
gEs = function(alvo) {
	var e;
	e = document.getElementsByTagName(alvo);
	return e;
}

// Chama func quando o HTML já foi todo carregado
function DOMReady(func){
	if(!(document.body==null)){
		func();
	}else{
		var func_rep = func;
		setTimeout(function(){ DOMReady(func_rep) }, 100);
	}
}

pE = function(tag,atributo,valor) {
	tdsAvs = document.getElementsByTagName(tag);
	var vlrs = new Array();

	for(i=0; i<tdsAvs.length; i++) {
		switch(atributo) {
			case "class" :
				if(tdsAvs[i].className) {
					attAtual = tdsAvs[i].className;
				}else {
					attAtual = "";
				}
			break;

			default :
				if(tdsAvs[i].getAttribute(atributo)) {
					attAtual = tdsAvs[i].getAttribute(atributo);
				}else {
					attAtual = "";
				}
			break;
		}

		attAtual = attAtual.toLowerCase();
		valor = valor.toLowerCase();

		if(attAtual == valor) {
			vlrs.push(tdsAvs[i]);
		}
	}

	if(vlrs.length > 0) {
		return vlrs;
	}else {
		return false;
	}
}

ajustaTags = function() {
	tags = pE('a', 'rel', 'tag');

	for(i=0; i<tags.length; i++) {
		tagAv = tags[i];
		classe = tagAv.className;
		prop = classe.slice(1,2);
		tagAv.style.fontSize = (prop*25)+'%';
	}
}
intervalo = false;
ajustaMenu = function(acao) {
	if(intervalo) clearInterval(fechaInt);
	if(acao == 'fecha') {
		gE('menu_futuante').style.height = '34px';
	}else if(acao == 'abre') {
		gE('menu_futuante').style.height = '150px';
	}
}

/******************************************************************************************************************/
/******************************************************************************************************************/
/******************************************************************************************************************/

aplicaFuncoes = function() {
	ajustaTags();

	gE('menu_futuante')['onmouseover'] = gE('fl_menuFutuante')['onmouseover'] = function() {
		ajustaMenu('abre');
	}
	gE('menu_futuante')['onmouseout'] = function() {
		intervalo = true;
		fechaInt = setInterval(function() { ajustaMenu('fecha'); }, 2000);
	}
	ajustaMenu('fecha');
}

DOMReady(aplicaFuncoes);

/******************************************************************************************************************/
/******************************************************************************************************************/
/******************************************************************************************************************/

function sleep(milliseconds) {
  var start = new Date().getTime();
  for (var i = 0; i < 1e7; i++) {
    if ((new Date().getTime() - start) > milliseconds){
      break;
    }
  }
}

function zIndexOn () {
  sleep(1000);
  document.getElementById('menu').style.zIndex = 0;
}


function zIndexOff () {
  document.getElementById('menu').style.zIndex = 1;
}

function xStrTranslate(Source)
{
	var ComAcento="ÁÉÍÓÚÀÈÌÒÙÂÊÎÔÛÄËÏÖÜÃÕÑÇáéíóúàèìòùâêîôûäëïöüãõñç";
	var SemAcento="AEIOUAEIOUAEIOUAEIOUAONCaeiouaeiouaeiouaeiouaonc";
	var I;		//CONTADOR DE USO GERAL
	var Car;	//CADA CARACTERE DO TEXTO
	var Saida="";	//TEXTO DE SAIDA
	var Pos;	//POSICAO DO ACENTO

	for(I=0;I<Source.length;I++)
	{//VERIFICA CADA LETRA
		Car=Source.charAt(I);
		if((Pos=ComAcento.indexOf(Car))!=-1)
		{//E' UM ACENTO
			Car=SemAcento.charAt(Pos);
		}
		Saida=Saida + Car;
	}
	return(Saida);
}

function mailpage()
{
mail_str = "mailto:?subject=Ola! Estou indicando esse link: " + xStrTranslate(document.title);
mail_str += "&body=Acredito que essa pagina possa ser de seu intresse: " + xStrTranslate(document.title);
mail_str += ". Voce podera ve-la em, " + location.href;
location.href = mail_str;
}

function ordena_tam_fonte(mais_menos)
{
	mudaTamanho('div', mais_menos);
}

function ordena_res_fonte()
{
//	restaura_fonte('div', +1);
	restaura_fonte('div', -10);
}

// Início do código de Aumentar/ Diminuir a letra
// Para usar coloque o comando: "java script:mudaTamanho('tag_ou_id_alvo', -1);" para diminuir
// e o comando "java script:mudaTamanho('tag_ou_id_alvo', +1);" para aumentar
var tagAlvo = new Array('p','li','h1','h2','h3','h4','h5','a','strong','ol','ul','dt','dd','resumo-dest'); //pega todas as tags p//
// Especificando os possíveis tamanhos de fontes, poderia ser: x-small, small...
//var tamanhos = new Array( '9px','10px','11px','12px','13px','14px','15px','20px' );
var tamanhos = new Array( '10px','11px','12px','13px','14px','15px','16px','20px' );
var tamanhoInicial = 3;
function mudaTamanho( idAlvo,acao ){
  if (!document.getElementById) return
  var selecionados = null,tamanho = tamanhoInicial,i,j,tagsAlvo;
  tamanho += acao;
  if (acao == -10) tamanho = 3;
  if ( tamanho < 0 ) tamanho = 0;
  if ( tamanho > 7 ) tamanho = 7;
  tamanhoInicial = tamanho;
  if ( !( selecionados = document.getElementById( idAlvo ) ) ) selecionados = document.getElementsByTagName( idAlvo )[ 0 ];

  selecionados.style.fontSize = tamanhos[ tamanho ];

  for ( i = 0; i < tagAlvo.length; i++ ){
    tagsAlvo = selecionados.getElementsByTagName( tagAlvo[ i ] );
    for ( j = 0; j < tagsAlvo.length; j++ ) tagsAlvo[ j ].style.fontSize = tamanhos[ tamanho ];
  }
}
// Fim do código de Aumentar/ Diminuir a letra

function restaura_fonte( idAlvo,acao )
{
	if (!document.getElementById) return
  var selecionados = null,tamanho = tamanhoInicial,i,j,tagsAlvo;
  tamanho += acao;
  if (acao == -10) tamanho = 3;
  if ( tamanho < 0 ) tamanho = 0;
  if ( tamanho > 7 ) tamanho = 7;
  tamanhoInicial = tamanho;
  if ( !( selecionados = document.getElementById( idAlvo ) ) ) selecionados = document.getElementsByTagName( idAlvo )[ 0 ];

  selecionados.style.fontSize = tamanhos[ 3 ];

  for ( i = 0; i < tagAlvo.length; i++ ){
    tagsAlvo = selecionados.getElementsByTagName( tagAlvo[ i ] );
    for ( j = 0; j < tagsAlvo.length; j++ ) tagsAlvo[ j ].style.fontSize = tamanhos[ 3 ];
  }
}
function valida_mail() {
		if (document.getElementById("dominio").selectedIndex == 2){
			window.open("https://webmail.proderj.rj.gov.br/src/redirect.php?login_username=" + document.getElementById("nome_usuario").value.replace(/^\s+|\s+$/g,"") + "@educacao.rj.gov.br" + "&secretkey=" + document.getElementById("senha_acesso").value.replace(/^\s+|\s+$/g,""),"WebMail");
	}
	if (document.getElementById("dominio").selectedIndex == 0){
			DoMyLookup("teste")
	}
}

// Webservice connection
function initWebservices()
{
     document.all.body.useService("LoginWS.asmx?WSDL","CallMyWebService");
}
function DoMyLookup(value) {
     document.all.body.CallMyWebService.callService(wsResult, "ValidaUsuario", "teste", "teste");
}

function wsResult(result) {
// Insert the result into the div (this method uses IE only for now
	window.alert("teste")
}

