// Setando as variáveis de aumento de fonte

function MM_jumpMenu2(targ,selObj,restore){ //v3.0
	open(selObj.options[selObj.selectedIndex].value, targ);
}

var defaultFontSize = 100;
var maximumFontSize = 300;
var currentFontSize = defaultFontSize;

function resetFontSize() {
	resetSize = defaultFontSize - currentFontSize;
	changeFontSize(resetSize);
}

function changeFontSize(sizeDifference) {
	currentFontSize = currentFontSize + sizeDifference;

	if(currentFontSize > maximumFontSize) { alert('Você já chegou ao tamanho máximo!'); currentFontSize = 300;  }
	else if(currentFontSize < 60) { alert('Você já chegou ao tamanho mínimo!'); currentFontSize = 60;  }

	setFontSize(currentFontSize);
}

function setFontSize(fontSize){ document.getElementById('areaTexto').style.fontSize = fontSize + '%'; }


function centro(x) {
	if (x == "A") { changeFontSize(10); }
	else if (x == "D") { changeFontSize(-10); }
	else { resetFontSize(); }
}
	



function changeImg() {
images = new Array(5);
images[0] = '/imagens/img01.jpg';
images[1] = '/imagens/img02.jpg';
images[2] = '/imagens/img03.jpg';
images[3] = '/imagens/img04.jpg';
images[4] = '/imagens/img05.jpg';

index = Math.floor(Math.random()*images.length);

document.write('<img src="' + images[index] + '" alt="" />');
}
	

function changeFlash() {
images = new Array(2);
images[0] = '/banner_evolucao.swf';
images[1] = '/bnn_ceicoc03.swf';

index = Math.floor(Math.random()*images.length);

addFlash(images[index],"770","183","7,0,19,0");
}
	

//Função para adicionar arquivos em Flash às páginas

function addFlash(_src,_w,_h,_version){
	var novoHtml = '';
 	novoHtml += '  <object height="'+_h+'" width="'+_w+'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
	novoHtml += '  codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+_version+'" ';
	novoHtml += '  align="">';
	novoHtml += '    <param name="movie"   value="'+_src+'" />';
	novoHtml += '    <param name="quality" value="high" />';
	novoHtml += '    <param name="wmode"   value="transparent" />';
	novoHtml += '    <param name="bgcolor" value="#FFFFFF" />';
	novoHtml += '    <embed wmode="transparent" src="'+_src+'" pluginspage="http://www.macromedia.com/go/getflashplayer" height="'+_h+'" width="'+_w+'"></embed>';
	novoHtml += '  </object>';
  document.write(novoHtml);
}

function addFlash2(_src,_w,_h){
	var novoHtml = '';
 	novoHtml += '  <OBJECT height="'+_h+'" width="'+_w+'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
	novoHtml += '  codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ';
	novoHtml += '  wmode="transparent" ALIGN="">';
	novoHtml += '    <PARAM NAME="movie"   VALUE="'+_src+'">';
	novoHtml += '    <PARAM NAME="quality" VALUE="high">';
	novoHtml += '    <PARAM NAME="wmode"   VALUE="transparent">';
	novoHtml += '    <PARAM NAME="bgcolor" VALUE="#FFFFFF">';
	novoHtml += '    <EMBED wmode="transparent" src="'+_src+'" pluginspage="http://www.macromedia.com/go/getflashplayer" height="'+_h+'" width="'+_w+'"></EMBED>';
	novoHtml += '  </OBJECT>';
  return novoHtml;
}

var atual = 1; //esta var guarda o valor que tá sendo exibido agora.
var timeloop; //guardará o setInterval

function muda(qual){
    	
	//divs que estão dentro do destaques colocadas num array
    var divs = document.getElementById("destaquesRotativos").getElementsByTagName("div");
	var lis = document.getElementById("changeDest").getElementsByTagName("li");
    
	//formatando o qual
    var qual_num = Number(qual);
    if (qual_num < 1){ qual_num = divs.length; }
    else if (qual_num > divs.length) { qual_num = 1; }

    //colocando o zero antes se for necessário
    if (qual_num<10) {qual = "0" + qual_num} else { qual = qual_num };

    //voltando a classe de todas para o padrão que é vazio (resetando)
    for (var i = 0;i < divs.length;i++){ divs[i].className = ""; }
	for (var i = 0;i < lis.length;i++){ lis[i].className = ""; }

    //aplicando a classe exibe na que for pra exibir
    document.getElementById("dest_"+qual).className = "exibe";
	document.getElementById("item_"+qual).className = "on";
	
    //setando o atual
    atual = qual_num;
	
}

function iniciaAutomatico(){
	if (document.getElementById("destaquesRotativos")) {
		var divs = document.getElementById("destaquesRotativos").getElementsByTagName("div");
		var lis = document.getElementById("changeDest").getElementsByTagName("li");

		for (var i = 0;i < divs.length;i++){
			z = i + 1;
			divs[i].setAttribute('id','dest_0'+z);
			divs[i].className = "";
		}
		for (var i = 0;i < lis.length;i++){ lis[i].className = ""; }
		
		timeloop = setInterval("muda(Number(atual)+1)",4000);
		document.getElementById("dest_01").className = "exibe";
		document.getElementById("item_01").className = "on";
	}
}

window.onload = iniciaAutomatico;

function getfileextension(inputId) { 
	var fileinput = inputId; 
	if (!fileinput ) { return ""; }
	else {
		if (fileinput.length == 0) { return ""; }
		else {
			var dot = fileinput.lastIndexOf("."); 
			if (dot == -1 ) { return ""; }
			else {
				var extension = fileinput.substr(dot,fileinput.length); 
				return extension; 
			}
		}
	}
}

function renderPicture(input, linka, classe, w, h) {
	if (getfileextension(input) == '.swf') { document.write('<div class="'+classe+'">'+addFlash2(input, w, h)+'</div>'); } 
	else { document.write('<a href="'+linka+'" class="'+classe+'"><img src="'+input+'" alt="" width="'+w+'" height="'+h+'" /></a>'); }
}