// <script language="javascript" type="text/javascript">
var folha_ads_chan = "" ;
var folha_ads_date = new Date();
var folha_ads_rand = Math.floor(folha_ads_date.getTime()*1000*Math.random()) ;
function folha_ads_show( site , size , expandable ) {
	var rand = Math.floor( 100000000 * Math.random() ) ;
	var position , width , height , conn_type ;
	folha_ads_chan = site ;
	if ( expandable != "1" ){ expandable = 0 ; }
	if ( size == "468x60" ){ position = "1" ; width = "468" ; height = "60" ; }
	if ( size == "120x30" ){ position = "1" ; width = "120" ; height = "30" ; }
	if ( size == "120x60" ){ position = "3" ; width = "120" ; height = "60" ; }
	if ( size == "120x600" ){ position = "6" ; width = "120" ; height = "600" ; }
	if ( size == "180x150" ){ position = "7" ; width = "180" ; height = "150" ; }
	if ( size == "300x250" ){ position = "0" ; width = "1" ; height = "1" ; }
	if ( size == "300x40" ){ position = "5" ; width = "300" ; height = "40" ; }
	if ( size == "120x600-2" ){ size = "120x600" ; position = "5" ; width = "120" ; height = "600" ; }
	if ( size == "1x1-2" ){ size = "1x1" ; position = "8" ; width = "1" ; height = "1" ; }
	if ( size == "300x250-2" ){ size = "300x250" ; position = "8" ; width = "1" ; height = "1" ; }
	if ( size == "1x1" ){ position = "11" ; width = "1" ; height = "1" ; }
	if ( size == "120x730" ){ position = "5" ; width = "120" ; height = "730" ; }
	if ( size == "90x45" ){ position = "4" ; width = "90" ; height = "45" ; }
	document.body.style.behavior = "url(#default#clientCaps)" ;
	if ( document.body.connectionType ){
		conn_type = ( document.body.connectionType == "lan" ) ? 1 : 0 ;
	}
	else{
		conn_type = 0 ;
	}
	document.write( "<scr" + "ipt language=\"javascript1.1\" type=\"text/javascript\" src=\"http://bn.uol.com.br/js.ng/site=folha&amp;chan=" + site + "&amp;size=" + size + "&amp;page=" + position + "&amp;expble=" + expandable + "&amp;conntype=" + conn_type + "&amp;tile=" + folha_ads_rand + "?\"><\/scr" + "ipt>" ) ;
}

// Chamada à função que escreve o código da publicidade com controle de exposição de uma vez por sessão
function folha_ads_show_once( site , size , expandable ) {
	window.onError = null ;
	var cookie_name = site.replace( "." , "_" ) + "-" + size ;
	var popup = document.cookie.indexOf( cookie_name ) ;
	if( popup == -1 ){
		folha_ads_show( site , size , expandable ) ;
		document.cookie = cookie_name + "=1" ;
	}
}

// Função de verificação do plugin flash
function flashPlugin( plugin_version ){
	var default_version = 5 ;
	var version ;
	if( plugin_version.length == "" ){
		version = new Number( default_version ) ;
	}
	else{
		version = new Number( plugin_version ) ;
	}
	var agent = navigator.userAgent.toLowerCase() ;
	var plugin = new String() ;
	var plugin_description = new String() ;
	if ( navigator.plugins && navigator.plugins.length ){
		for ( var i = 0 ; i < navigator.plugins.length ; i++ ){
			plugin = navigator.plugins[i] ;
			plugin_description = plugin.description.split( " " ) ;
			if ( plugin_description[0] == "Shockwave" && plugin_description[1] == "Flash" && plugin_description[2].split( "." )[0] >= version.valueOf() ){
	            return true ;
	        }
	        else{
		        for ( var j = 0 ; j < plugin.length ; j++ ){
		        	if ( plugin[j].type == "application/x-shockwave-flash"){
		        		return true ;
		        	}
		        }
		    }
		}
		return false ;
	}
	else if ( navigator.mimeTypes && navigator.mimeTypes.length ){
		var detectPlugin = navigator.mimeTypes[ "application/x-shockwave-flash" ] ;
		if( detectPlugin && detectPlugin.enabledPlugin ){
			return true ;
		}
		else{
			return false ;
		}
	}
	else if ( agent.indexOf( "msie" ) != -1 && parseInt( navigator.appVersion , 10 ) >= 4 ){
		document.write( "<scr" + "ipt language=\"VBScript\"> \n") ;
		document.write( "on error resume next \n" ) ;
		document.write( "dim plugin \n" ) ;
		document.write( "dim IEDetect \n" ) ;
		document.write( "set plugin = CreateObject(\"ShockwaveFlash.ShockwaveFlash." + version + "\") \n" ) ;
		document.write( "if IsObject( plugin ) then \n" ) ;
		document.write( "IEDetect = true \n" ) ;
		document.write( "else IEDetect = false \n" ) ;
		document.write( "end if" ) ;
		document.write( "<\/scr" + "ipt> \n") ;
		if( IEDetect ){
			return true ;
		}
	}
	return false ;
}

// Função para inserção local de peças em flash
function folha_flash_object( object_source , width , height , object_href , info , plugin_version ){
	if ( !flashPlugin( plugin_version ) ){ return ; }
	var html = "" ;
	html += "<p style=\"padding: 0; margin: 0 0 10px 0; width: " + width + "; height: " + height + "\">" ;
	if ( object_href.length > 0 ){
		 object_source += "?clicktag=" + object_href ;
	}
	if ( info.length > 0 ){
		html += "<span style=\"font: bold 10px arial;\">" + info + "<\/span><br>" ;
	}
	if ( navigator.appName.indexOf( "Internet Explorer" ) > -1 ){
		html += "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=" + plugin_version + ",0,0,0\" width=\"" + width + "\" height=\"" + height + "\">" ;
		html += "<param name=\"movie\" value=\"" + object_source + "\">" ;
		html += "<param name=\"quality\" value=\"high\">" ;
	}
	else{
		html += "<object type=\"application/x-shockwave-flash\" width=\"" + width + "\" height=\"" + height + "\" data=\"" + object_source + "\">" ;
	}
	html += "<\/object>" ;
	html += "<\/p>" ;
	document.write( html ) ;
}

// Função genérica para navegação que utilize tabs
function show_tab( obj_id ){
	if ( !document.getElementById ){
		return ;
	}
	var i , obj , parent_node ;
	if ( document.getElementById( obj_id ) ){
		obj = document.getElementById( obj_id ) ;
		obj_list = obj.parentNode.getElementsByTagName( obj.tagName ) ;
		for ( i = 0 ; i < obj_list.length ; i++ ){
			obj_list.item(i).style.display = "none" ;
		}
		obj.style.display = "block" ;
	}
}

function folhaonline_is_ie_mac(){
	return ( navigator.platform.toLowerCase().indexOf("mac") > -1 ) && ( navigator.appName.indexOf( "Internet Explorer" ) > -1 ) ;
}

/* O flash se atrapalha ao converter texto acentuado por problemas de charset.
O texto enviado ao flash então é enviado como códigos decimais de charset. */
function folhaonline_decompose( s ){
	var str = "" , val ;
	for( var i = 0; i < s.length; ++i ){
		val = s.charCodeAt(i).toString() ;
		while ( val.length < 3 ){
			val = "0" + val ;
		}
		str += val ;
	}
	return str ;
}

/* 16/8/2007 22:41 - fnemec
show and hide layers from most read */
function toggleMostNews( s ) {
	j(s,true) ;
	var h = 'http://f.i.uol.com.br/folha/furniture/4/images/trj-mais-' ;
	switch( s ) {
		case 'maisLidas' :
			document.getElementById('img_mais_lidas').src = h+'lidas108x20-1.gif' ;
			document.getElementById('img_mais_curiosas').src = h+'curiosas108x20-2.gif' ;
			document.getElementById('img_mais_enviadas').src = h+'enviadas108x20-2.gif' ;
			j('maisCuriosas',false);
			j('maisEnviadas',false);
			break ;
		case 'maisCuriosas' :
			document.getElementById('img_mais_lidas').src = h+'lidas108x20-2.gif' ;
			document.getElementById('img_mais_curiosas').src = h+'curiosas108x20-1.gif' ;
			document.getElementById('img_mais_enviadas').src = h+'enviadas108x20-2.gif' ;
			j('maisLidas',false);
			j('maisEnviadas',false);
			break ;
		case 'maisEnviadas' :
			document.getElementById('img_mais_lidas').src = h+'lidas108x20-2.gif' ;
			document.getElementById('img_mais_curiosas').src = h+'curiosas108x20-2.gif' ;
			document.getElementById('img_mais_enviadas').src = h+'enviadas108x20-1.gif' ;
			j('maisLidas',false);
			j('maisCuriosas',false);
			break ;
	}
}

function show_layer(fname,visible){
	if (document.layers) {
		if( visible ) { s = 'show' ; b = 'block' ; } else { s = 'hide' ; b = 'none' ; }
		document.layers[eval('"'+fname+'"')].visibility = s ;
	} else if (document.all) {
		if( visible ) { s = 'visible' ; b = 'block' ; } else { s = 'hidden' ; b = 'none' ; }
		document.all[eval('"'+fname+'"')].style.visibility = s ;
	} else if (document.getElementById) {
		if( visible ) { s = 'visible' ; b = 'block' ; } else { s = 'hidden' ; b = 'none' ; }
		document.getElementById(eval('"'+fname+'"')).style.visibility = s ;
	}
}
function set_display(fname,b){
	(b) ? s = 'block' : s = 'none' ;
	if (document.layers) {
		document.layers[eval('"'+fname+'"')].display = s ;
	} else if (document.all) {
		document.all[eval('"'+fname+'"')].style.display = s ;
	} else if (document.getElementById) {
		document.getElementById(eval('"'+fname+'"')).style.display = s ;
	}
}
/* handle_layer_display */
function j(fname,b){
	set_display(fname,b);
	show_layer(fname,b);
}

function draw_mini_player( url , text , width , height , path ){
	var tag = "" ;
	var flashvars = "url=" + escape( url ) + "&description=" + folhaonline_decompose( text ) ;
	if ( navigator.appName.indexOf( "Internet Explorer" ) > -1 ){
		tag += "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0\" width=\"" + width + "\" height=\"" + height + "\" id=\"player\" align=\"middle\">" ;
		tag += "<param name=\"movie\" value=\"" + path + "\">" ;
		tag += "<param name=\"allowScriptAccess\" value=\"always\">" ;
		tag += "<param name=\"quality\" value=\"high\">" ;
		tag += "<param name=\"flashvars\" value=\"" + flashvars + "\">" ;
		if ( folhaonline_is_ie_mac() ){
			tag += "<embed type=\"application/x-shockwave-flash\" width=\"" + width + "\" height=\"" + height + "\" id=\"player\" allowScriptAccess=\"always\"  src=\"" + path + "\" flashvars=\"" + flashvars + "\"><\/embed>" ;
		}
	}
	else{
		tag += "<object type=\"application/x-shockwave-flash\" width=\"" + width + "\" height=\"" + height + "\" data=\"" + path + "\" flashvars=\"" + flashvars + "\"  allowScriptAccess=\"always\" id=\"player\">" ;
	}
	tag += "<\/object>";
	document.write(tag);
}

function toggleMostNews(s,ne,sq){
	j(s,true) ;
	var host = 'http://f.i.uol.com.br/folha/furniture/4/images/trj-' ;
	switch( s ) {
		case 'maisLidas' :
			document.getElementById('img_mais_lidas').src = host+ne+'-mais-lidas-'+sq+'-1.gif' ;
			document.getElementById('img_mais_curiosas').src = host+ne+'-mais-curiosas-'+sq+'-2.gif' ;
			document.getElementById('img_mais_enviadas').src = host+ne+'-mais-enviadas-'+sq+'-2.gif' ;
			j('maisCuriosas',false);
			j('maisEnviadas',false);
			break ;
		case 'maisCuriosas' :
			document.getElementById('img_mais_lidas').src = host+ne+'-mais-lidas-'+sq+'-2.gif' ;
			document.getElementById('img_mais_curiosas').src = host+ne+'-mais-curiosas-'+sq+'-1.gif' ;
			document.getElementById('img_mais_enviadas').src = host+ne+'-mais-enviadas-'+sq+'-2.gif' ;
			j('maisLidas',false);
			j('maisEnviadas',false);
			break ;
		case 'maisEnviadas' :
			document.getElementById('img_mais_lidas').src = host+ne+'-mais-lidas-'+sq+'-2.gif' ;
			document.getElementById('img_mais_curiosas').src = host+ne+'-mais-curiosas-'+sq+'-2.gif' ;
			document.getElementById('img_mais_enviadas').src = host+ne+'-mais-enviadas-'+sq+'-1.gif' ;
			j('maisLidas',false);
			j('maisCuriosas',false);
			break ;
	}
}

var isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
function player_DoFSCommand(command, args) {
	var playerObj = isInternetExplorer ? document.all.player : document.player;
	//
	if(command == "start") start_refresh() ;
	if(command == "stop") stop_refresh() ;
	//
}
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
	document.write('<script language=\"VBScript\"\>\n');
	document.write('On Error Resume Next\n');
	document.write('Sub player_FSCommand(ByVal command, ByVal args)\n');
	document.write('	Call player_DoFSCommand(command, args)\n');
	document.write('End Sub\n');
	document.write('</script\>\n');
}
function start_refresh(){
	site_refresh = setInterval('top.location.reload()',300000);
}
function stop_refresh(){
	clearInterval(site_refresh);
}
start_refresh();


/* início do código para gerenciamento de colunistas no topo */
var folha_online_article_index = 0 ;

function folha_online_render_article(){
	if ( !article_content ){
		return ;
	}

	/* computar outros pesos */
	for ( var i = 0 , limit = folhaonline_article_data.length ; i < limit ; i++ ){
		for ( var j = 0 , jlimit = article_content.length ; j < jlimit ; j++ ){
			if ( folhaonline_article_data[i][0] == article_content[j][1] ){
				if ( folhaonline_article_data[i].length >= 3 && article_content[j].length >= 4 && article_content[j][2].length > 0 ){
					article_content[j][4] = Number(folhaonline_article_data[i][1]) + Number(article_content[j][4]) ;
					article_content[j][4] = Number(folhaonline_article_data[i][2]) + Number(article_content[j][4]) ;
				}
			}

		}
	}

	/* total */
	var t = 0 ;
	for ( var i = 0 , limit = article_content.length ; i < limit ; i++ ){
		if ( article_content[i].length >= 5 && article_content[i][2].length > 0 ){
			t += Number( article_content[i][4] ) ;
		}
	}

	var r = Math.floor( Math.random() * t ) ;
	var author ,path , title , target , kicker ;

	for ( var i = 0 , limit = article_content.length - 1 ; i < limit ; i++ ){
		if ( article_content[i].length >= 5 && article_content[i][2].length > 0 ){
			r -= article_content[i][4] ;

			if ( r <= 0 ){
				folha_online_article_index = i ;
				author = article_content[i][0] ;
				path = article_content[i][1] ;
				title = article_content[i][2];
				target = article_content[i][3];
				kicker = 'COLUNA' ;
				var blog = new RegExp( '\.folha\.blog\.uol\.com\.br' ) ;
				var podcast = new RegExp( 'podcast' ) ;
				var videocast = new RegExp ( 'videocast' ) ;
				if ( blog.test( target ) ){
					kicker = 'BLOG' ;
				}
				if ( podcast.test( target ) ){
					kicker = 'PODCAST' ;
				}
				if ( videocast.test( target ) ){
					kicker = 'VIDEOCAST' ;
				}
				break ;
			}
		}
	}

	if ( author ){
		var output = '';
		output += '<table class="tableArticleTeaser" cellspacing="0" cellpadding="0" border="0">' ;
		output += '<tr><td rowspan="4" width="70" height="70" valign="bottom" class="image" id="articleImage"><a id="photoLink" href="'+target+'"><img id="articlePhoto" src="http://f.i.uol.com.br/folha/colunas/images/foto-'+path+'-70x70.jpg" width="70" height="70" border="0" alt=""><\/a><\/td>' ;
		output += '<td id="articleKicker">'+kicker+'<\/td><\/tr>' ;
		output += '<tr><td id="articleTitle"><a href="'+target+'">'+title+'<\/a><\/td><\/tr>' ;
		output += '<tr><td id="articleAuthor"><a href="'+target+'">'+author+'<\/a><\/td><\/tr>' ;
		output += '<tr><td id="articleNavBar" align="right" valign="top">' ;
		output += '<table cellpadding="0" cellspacing="0" border="0" width="75%"><td style="padding: 0; margin: 0;" align="center"><a style="padding: 0; margin: 0;" href="javascript:void(0)" onclick="javascript:cp()"><img border="0" alt="Anterior" src="http://f.i.uol.com.br/folha/furniture/images/seta_esquerda.jpg"><\/a><\/td><td align="center"><a href="http://www1.folha.uol.com.br/folha/blogs/">BLOGS<\/a>, <a href="http://www1.folha.uol.com.br/folha/pensata/">COLUNAS<\/a> E <a href="http://www1.folha.uol.com.br/folha/podcasts/">PODCASTS<\/a><\/td><td align="center"><a href="javascript:void(0)" onclick="javascript:cn()"><img border="0" alt="Próximo" src="http://f.i.uol.com.br/folha/furniture/images/seta_direita.jpg"><\/a><\/td><\/tr><\/table><\/td><\/tr><\/table>' ;
		document.write( output ) ;
	}

}

function folha_online_fetch_article(){
	document.getElementById('articlePhoto').src = 'http://f.i.uol.com.br/folha/colunas/images/foto-'+article_content[folha_online_article_index][1]+'-70x70.jpg' ;

	var txt = document.createTextNode(article_content[folha_online_article_index][0]) ;
	obj = document.getElementById('articleAuthor') ;
	obj.replaceChild(txt , obj.childNodes[0] ) ;

	var target = article_content[folha_online_article_index][3] ;
	obj = document.getElementById('articleTitle') ;
	obj.innerHTML = '<a href="'+target+'">'+article_content[folha_online_article_index][2]+'<\/a>' ;
	document.getElementById('photoLink').href = target ; 
	
	var kicker = 'COLUNA' ;
	var blog = new RegExp( '\.folha\.blog\.uol\.com\.br' ) ;
	var podcast = new RegExp( '\podcast$' ) ;
	if ( blog.test( target ) ){
		kicker = 'BLOG' ;
	}
	if ( podcast.test( target ) ){
		kicker = 'PODCAST' ;
	}

	var txt = document.createTextNode(kicker) ;
	obj = document.getElementById('articleKicker') ;
	obj.replaceChild(txt , obj.childNodes[0] ) ;
}

function cp(){
	folha_online_article_index-- ;
	if ( folha_online_article_index < 0 ){
		folha_online_article_index = article_content.length - 2 ;
	}
	if ( article_content[folha_online_article_index][2].length == 0 ){
		cp() ;
	}
	else{
		folha_online_fetch_article() ;
	}
	return false ;
}

function cn(){
	folha_online_article_index++ ;
	if ( folha_online_article_index == article_content.length - 1 ){
		folha_online_article_index = 0 ;
	}
	if ( article_content[folha_online_article_index][2].length == 0 ){
		cn() ;
	}
	else{
		folha_online_fetch_article() ;
	}
	return false ;
}

/* controle da foto rotativa */
var iDelaySlide = 10000 ; // ms
var iDelayOpacity = 80 ; // ms
var rotate_index = 0 ; // int
var rotate_interval = null ;
var timer = null ;

function rreload(){
	if( !document.getElementById ){
		return ;
	}

	rotate_index += 1 ;
	if( rotate_index < 0 ) rotate_index = aJJBA.length - 1;
	if( rotate_index > aJJBA.length - 1) rotate_index =  0;

	if ( rotate_interval ){
		rpause() ;
	}
}

function rnav( iPos ){
	if( !document.getElementById ){
		return ;
	}

	rotate_index += iPos ;
	if( rotate_index < 0 ) rotate_index = aJJBA.length - 1;
	if( rotate_index > aJJBA.length - 1) rotate_index =  0;

	if ( rotate_interval ){
		rpause() ;
	}

	if ( timer ){
		jjba_opcty(100);
	}

	with( document ) {
		var el_crd = getElementById( "ju_crd" );
		var el_img = getElementById( "ju_img" );
		var el_ftr = getElementById( "ju_ftr" );
		var el_lnk1 =  getElementById( "ju_link1" );
		var el_lnk2 =  getElementById( "ju_link2" );
	}

	el_crd.innerHTML = aJJBA[ rotate_index ][0];
	el_img.src = aJJBA[ rotate_index ][1];
	el_lnk1.href = aJJBA[ rotate_index ][2];
	el_lnk2.href = aJJBA[ rotate_index ][2];
	el_ftr.innerHTML = aJJBA[ rotate_index ][3] ;
	el_img.alt = aJJBA[ rotate_index ][3];
	if( aJJBA[ rotate_index ][4] == 'PUBLICIDADE' ) { 
		el_lnk1.target = '_blank' ; 
		el_lnk2.target = '_blank' ; 
	}
	jjba_opcty(10);
	jjba_rotate();
}

function jjba_opcty( iOpacity ){
	var curLayer = document.getElementById('ju_img');
	iOpacity == null ? iOpacity = 0 : iOpacity += 10;
	curLayer.style.opacity = iOpacity / 100 ;
	curLayer.style.filter = 'alpha(opacity=' + iOpacity + ')';
	if( iOpacity < 100 ) {
		timer = setTimeout('jjba_opcty(' + iOpacity + ')', iDelayOpacity);
	} else {
		clearTimeout(timer);
		timer = null ;
		jjba_reset();
	}
}

function jjba_reset(){
	iOpacity = 99;
	var curLayer = document.getElementById('ju_img');
	curLayer.style.opacity = (iOpacity / 100);
	curLayer.style.filter = 'alpha(opacity=' + iOpacity + ')';
}

function jjba_rotate(){
	rotate_interval = window.setInterval('rnav(1)', iDelaySlide);
}

function rpause(){
	if ( rotate_interval ){
		clearInterval( rotate_interval );
		rotate_interval = null ;
	}
	else{
		rnav(1) ;
	}
}

function jjba_preload(a){
	var d = document;
	if(d.images) {
		if(!d.mm) d.mm = new Array();
		var i, j = d.mm.length ;
		for( i = 0; i < a.length; i++ ){
			if ( a[i][1].indexOf("#") != 0 ){
				d.mm[j] = new Image;
				d.mm[j++].src = a[i][1];
			}
		}
	}
}
//</script>
