// JavaScript Document
function Acredito(){
	window.open('http://www.fluminense.com.br/euacredito','janelaAcredito', 'status=no,scrollbars=no,width=800, height=600');
}

function carregaPagina(url, tipo)
{
	if (tipo==1)
		window.open(url);
	else
		location='http://www.fluminense.com.br/';
}


function abreCanal (){
	window.open ('/canalflu/canalfluMain.asp','Canal_Flu','width=780,height=635,scrollbars=1,resizable=1,marginleft=0,margintop=0');
}

function abreRadioFlu (){
	window.open ('/Fluscripts/audio.asp','Radio_Flu','width=770,height=650,scrollbars=1,marginleft=0,margintop=0');
}

var tablink_idname = new Array("tablink")
var tabcontent_idname = new Array("tabcontent")
var tabcount = new Array("10")
var loadtabs = new Array("1")  
var autochangemenu = 0;
var changespeed = 3;
var stoponhover = 0;

function trocaIMG(qtd, ini, fim, selecionado)
{
	var i=0; 
	var nome_imagem = '';
	i = ini
	for(;i<=fim; i++)
	{
		nome_imagem = document.getElementById('imagemSub'+i).src;
		if (i == selecionado)
		{
			if (nome_imagem.substr(nome_imagem.length -7, nome_imagem.length) == 'Off.gif')
			{
				parent.document.getElementById('imagemSub'+i).src = nome_imagem.substr(0, nome_imagem.length - 7)+'On.gif';
			}
		}
		else
		{
			if (nome_imagem.substr(nome_imagem.length -6, nome_imagem.length) == 'On.gif')
			{
				parent.document.getElementById('imagemSub'+i).src = nome_imagem.substr(0, nome_imagem.length - 6)+'Off.gif';
			}
		}
	}
}

function easytabs(menunr, active) 
{
	var nome_imagem = '';
	if (menunr == autochangemenu)
	{
		currenttab=active;
	}
	if ((menunr == autochangemenu)&&(stoponhover==1)) 
	{
		stop_autochange()
	} 
	else if ((menunr == autochangemenu)&&(stoponhover==0))  
	{
		counter=0;
	}
	menunr = menunr-1;
	for (i=1; i <= tabcount[menunr]; i++)
	{
		nome_imagem = document.getElementById('imagem'+i).src
		if (i == active)
		{
			if (nome_imagem.substr(nome_imagem.length -7, nome_imagem.length) == 'Off.gif')
			{
				parent.document.getElementById('imagem'+i).src = nome_imagem.substr(0, nome_imagem.length - 7)+'On.gif';
			}
		}
		else
		{
			if (nome_imagem.substr(nome_imagem.length -6, nome_imagem.length) == 'On.gif')
				parent.document.getElementById('imagem'+i).src = nome_imagem.substr(0, nome_imagem.length - 6)+'Off.gif';
		}
		document.getElementById(tabcontent_idname[menunr]+i).style.display = 'none';}
		document.getElementById(tablink_idname[menunr]+active).className='tab'+active+' tabactive';
		document.getElementById(tabcontent_idname[menunr]+active).style.display = 'block';
	}
	var timer; counter=0; 
	var totaltabs=tabcount[autochangemenu-1];
	var currenttab=loadtabs[autochangemenu-1];
	function start_autochange()
	{
		counter=counter+1;
		timer=setTimeout("start_autochange()",1000);
		if (counter == changespeed+1) 
		{
			currenttab++;
			if (currenttab>totaltabs) 
			{
				currenttab=1
			}
			easytabs(autochangemenu,currenttab);
			restart_autochange();
		}
	}
	function restart_autochange()
	{
		clearTimeout(timer);
		counter=0;
		start_autochange();
	}
	function stop_autochange()
	{
		clearTimeout(timer);
		counter=0;
	}
	window.onload=function()
	{
		var menucount=loadtabs.length; 
		var a = 0; 
		var b = 1; 
		do {
			easytabs(b, loadtabs[a]);
			a++; 
			b++;
		}while (b<=menucount);
		if (autochangemenu!=0)
		{
			start_autochange();
		}
		/*Marca o tab e as img selecionada*/
		if ((document.getElementById('tab').value !='') && 
			(document.getElementById('total').value !='') && 
			(document.getElementById('submenusel').value !='') && 
			(document.getElementById('submenuini').value !='') &&
			(document.getElementById('submenufim').value !=''))
		{
			easytabs(1, document.getElementById('tab').value);
			trocaIMG(document.getElementById('total').value,document.getElementById('submenuini').value,document.getElementById('submenufim').value,document.getElementById('submenusel').value)
		}
		/*Marca o tab e as img selecionada*/
	}

/**/
function vai(){
	strAddress = '../FluFcBusca.asp?strbusca=' + document.getElementById('txtbusca').value;
	//alert (strAddress);
	document.location.href = strAddress;	
}

function trocaImagem(Objeto, Img1, Img2)
{
	Objeto.src = '/FluFcImagens/'+ Img2
}

function escreveFlash(CaminhoSWF, Largura, Altura)
{
	var flash="";
	flash += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="'+ Largura +'" height="'+ Altura +'">'
	flash += '<param name="movie" value="'+ CaminhoSWF +'" />'
	flash += '<param name="quality" value="high" />'
	flash += '<param name="wmode" value="transparent">'
	flash += '<embed src="'+ CaminhoSWF +'" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="'+ Largura +'" height="'+ Altura +'"  wmode="transparent"></embed>'
	flash += '</object>'
	document.write(flash)
}

function EscondePopup(){
	document.getElementById('popupfloat').style.visibility="hidden";
}

function voto(e){
	marcado = -1
	for (i=0; i<document.enquete.resp.length; i++) {
		if (document.enquete.resp[i].checked) {
			marcado = i
			resposta = document.enquete.resp[i].value
		}
	}

	if (marcado == -1) {
		alert("Selecione uma resposta.");
		document.enquete.resp[0].focus();
	} else {
		window.open('FluFcEnqueteVoto.asp?e=' + e + '&id=' + resposta,'voto','width=348,height=200');
	} 
}

function resultado(e){
	//alert ('resultadoenquete.asp?e=' + e);
	window.open ('FluFcEnqueteResultado.asp?e=' + e,'resultado','width=365,height=290,scrollbars=1');
}
// painel rotativo //
function changeOpac(opacity)
{
	var obj = $('to-blend').style;
	obj.opacity=(opacity/101);
	obj.MozOpacity=(opacity/101);
	obj.KhtmlOpacity=(opacity/101);
} 

function blend(imagefile)
{
	var speed=7;
	var timer=0;
	for(i=100;i>0;i-=2) setTimeout('changeOpac('+i+')', timer++ * speed);
	setTimeout('changeContent()', timer * speed);
	for(i=0;i<=100;i+=2) setTimeout('changeOpac('+i+')', timer++ * speed);
} 

function changeImg(id)
{
	clearTimeout(timeoutId);
	atual+=parseInt(id);
	if(atual>Item.length-1) atual=0;
	if(atual<0) atual=Item.length-1;
	if(imgDsp[atual].complete==false)
	{
		atual--;
		timeoutId = setTimeout('changeImg('+id+')',500);
		return;
	} 
	if(d.all && navigator.userAgent.indexOf('Opera')==-1)
	{
		try 
		{
		oDiv = $('to-blend');
		oDiv.style.filter="blendTrans(duration=0.7)";
		oDiv.filters.blendTrans.apply();
		oDiv.filters.blendTrans.play();
		changeContent();
		} 
		catch(e) { changeContent(); }
	} 
	else 
	{ 
		blend(); 
	}
	if(!paused) timeoutId=setTimeout('changeImg(1)',6000);
} 

function loadImages()
{
	imgDsp = new Array();
	for(n=0;n<Item.length;n++)
	{
		imgDsp[n]=new Image();
		imgDsp[n].src=Item[n][1];
	}
	okToGo = true;
} 

function changeContent()
{
	d.img1.src=imgDsp[atual].src;
	d.img1.alt=d.img1.title=Item[atual][0];
	$('txt1').innerHTML=Item[atual][2];
	if(usaCredito!='') $('credito').innerHTML=Item[atual][0];
	$('icon-area').innerHTML=Item[atual][4];
}

function delItem(arr,item)
{
	for(;item<arr.length;item++) arr[item]=arr[item + 1];
	arr.length=arr.length-1;
} 

function goURL()
{
(Item[atual][3].indexOf('_blank')!=-1) ? window.open(Item[atual][3].substring(0,Item[atual][3].indexOf(' '))) : location.href=Item[atual][3];
} 

function startSlide()
{ 
	loadImages();
	if(!paused) timeoutId=setTimeout('changeImg(1)',6000);
} 

function initialize()
{
	timeoutId=0;
	textareaContent=d.form_cr.select_cr.value.split(/[\r\n]/i);
	Item = new Array();
	for(x=0,y=0;x<textareaContent.length;x++)
	{ 
		if(textareaContent[x].length>30) Item[y++]=textareaContent[x].split('|');
	}
	for(i=Item.length-1;i>=0;i--)
	{
		Item[i][0]=Item[i][0].replace(/([ \n\t\r])+/, " ");
		Item[i][4]=(Item[i][4].length<3) ? '' : '<img src="'+Item[i][4]+'" border="0" style="margin-left:4px;" />';
		if(Item[i][1].length<3||Item[i][3].length<3||Item[i][2].length<3||Item[i][0].length<2) delItem(Item,i);
	}
	if(Item.length==1) d.write('<style>#anterior,#proximo,#pause{visibility:hidden;}</style>');
		atual = Math.random().toString().substring(2,6) % Item.length;
} 
function startPanel(){
	usaCredito = '';
	initialize();
	if(arguments.length>0)
	{
		if(!isNaN(arguments[0])) atual = arguments[0];
	}
	if(paused) 
	{
		imgpause='on'; altpause='alt="Ligar" title="Ligar"';
	}
	else 
	{
		imgpause='off'; altpause='alt="Parar" title="Parar"';
	}
/*	d.write('<div id="prox-ant"><a href="javascript:void(0)" id="anterior" onclick="if(okToGo)changeImg(-1)"><IMG SRC="img/btnSetaAnt.gif" WIDTH="20" HEIGHT="20" BORDER="0" ALT="Notícia anterior" title="Notícia anterior"></a>');
	d.write('<a href="javascript:void(0)" id="proximo" onclick="if(okToGo)changeImg(1)"><IMG SRC="FluFcImagens/btnSetaProx.gif" WIDTH="20" HEIGHT="20" BORDER="0" ALT="Próxima notícia" title="Próxima notícia"></a></div>');
	d.write('<div id="to-blend">'+usaCredito+'<a href="javascript:goURL()"><img src="'+Item[atual][1]+'" id="imgslide" name="img1" border="0" title="'+Item[atual][0]+'" alt="'+Item[atual][0]+'"></a>');
	d.write('<h2><a href="javascript:goURL()" id="p-link"><span id="txt1">'+Item[atual][2]+'</span><span id="icon-area">'+Item[atual][4]+'</span></a></h2></div>');
*/
	d.write('<div id="prox-ant"><a href="javascript:void(0)" id="anterior" onclick="if(okToGo)changeImg(-1)"><IMG SRC="img/btnSetaAnt.gif" WIDTH="20" HEIGHT="20" BORDER="0" ALT="Notícia anterior" title="Notícia anterior"></a>');
	d.write('<a href="javascript:void(0)" id="proximo" onclick="if(okToGo)changeImg(1)"><IMG SRC="img/btnSetaProx.gif" WIDTH="20" HEIGHT="20" BORDER="0" ALT="Próxima notícia" title="Próxima notícia"></a></div>');
	d.write('<div id="to-blend">'+usaCredito+'<h2><a href="javascript:goURL()" id="p-link"><span id="txt1">'+Item[atual][2]+'</span><span id="icon-area">'+Item[atual][4]+'</span></a></h2>');
	d.write('<a href="javascript:goURL()"><img src="'+Item[atual][1]+'" id="imgslide" name="img1" border="0" title="'+Item[atual][0]+'" alt="'+Item[atual][0]+'"></a></div>');
	
	} 
	function pauseSlide()
	{
		if(paused)
		{
			$('pause').src='';
			$('pause').title='Parar'; $('pause').alt = 'Parar';
			paused=false;
			startSlide();
		}
		else
		{
			clearTimeout(timeoutId);
			$('pause').src='';
			$('pause').title='Ligar'; $('pause').alt = 'Ligar';
			paused = true;
		} 
	}
	


