// Codigo para aumentar e diminuir fonte
var tam = 11;

function mudaFonte(tipo,elemento){
	if (tipo=="mais") {
		if(tam<24) tam+=1;
		createCookie('fonte',tam,365);
	} else {
		if(tam>10) tam-=1;
		createCookie('fonte',tam,365);
	}
	var numero_destaques=11;
	var numero_linkmanchete=2;

	var numero_linkfeature = 0;

	document.getElementById('txt_home').style.fontSize = tam+'px';

}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	} else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

//********* Fim aumentar e diminuir fonte





















var ticker_layer = false ;
var step_time = 25 ;
var freeze_time = 3000 ;
var news_index = 0 ;
var title_index = 0 ;
var end_title = "_" ;
var title_max_size = 62 ; // 62
var pause = false ;
var freeze_timeout_id ;
var step_timeout_id ;
var step_char_length = 1 ;

var foo = false ;

function prepare(){
	var container_size = 475 ; // 475
	for ( var i = 0 ; i < news.length - 1 ; i++ ){
		var t = news[i][0] ;

		t = t.replace(/\&quot;/gi,'"') ;
		t = t.replace(/\&amp;/gi,'&') ;
		t = t.replace(/\&#039;/gi,'\'') ;

		var dummy = document.createTextNode( t ) ;
		document.getElementById('dummy').appendChild( dummy ) ;
		var size = document.getElementById('dummy').offsetWidth ;

		while( size > container_size ){
			t = t.substring( 0 , t.lastIndexOf( ' ' ) ) ;
			t += '...';
			clear_element( 'dummy' ) ;
			var dummy = document.createTextNode( t ) ;
			document.getElementById('dummy').appendChild( dummy ) ;
			size = document.getElementById('dummy').offsetWidth ;
		}
		clear_element( 'dummy' ) ;
		news[i][0] = t ;
	}
}

function clear_element( name ){
	/* esvaziar dummy */
	if ( document.getElementById( name ) ){
		while ( document.getElementById( name ).lastChild != null ){
			var child = document.getElementById( name ).lastChild ;
			document.getElementById( name ).removeChild( child ) ;
		}
	}
}

function begin_roll_ticker(){
	window.setTimeout( "roll_ticker()" , step_time ) ;
}

function move_next(){
	if ( title_index == 0 ){
		// índice de notícias já está na posição certa, apenas dar play
		freeze_timeout_id = window.setTimeout( "roll_ticker()" , news[title_index][0] ) ;
	}
	else{
		title_index = 0 ;
		next_line(0) ;
	}
}

function move_prev(){
	if ( title_index == 0 ){
		// índice de notícias já foi movido; corrigir
		news_index == 0 ? news_index = news.length - 2 : news_index-- ;
		prev_line(0) ;
	}
	else{
		title_index = 0 ;
		prev_line(0) ;
	}
}

function fill_line(){
	news_index-- ;
	if ( news_index < 0 ){
		news_index = news.length - 2 ;
	}

	step_char_length = news[news_index][0].length - title_index ;
	step_timeout_id = window.setTimeout( "roll_ticker()" , step_time ) ;
}

function t_next( obj ){
	pause = false ;
	freeze_timeout_id = window.clearTimeout( freeze_timeout_id ) ;
	step_timeout_id = window.clearTimeout( step_timeout_id ) ;
	step_timeout_id = window.setTimeout( 'move_next()' , step_time ) ;
}

function t_prev( obj ){
	pause = false ;
	freeze_timeout_id = window.clearTimeout( freeze_timeout_id ) ;
	step_timeout_id = window.clearTimeout( step_timeout_id ) ;
	step_timeout_id = window.setTimeout( 'move_prev()' , step_time ) ;
}

function t_pause( obj ){
	pause = !pause ;
	if ( pause ){
		// limpar timeout se uma notícia já estiver presente
		if ( title_index == 0 && freeze_timeout_id ){
			window.clearTimeout( freeze_timeout_id ) ;
		}
		else{
			news_index >= news.length - 2 ? news_index = 0 : news_index++ ;
			window.clearTimeout( step_timeout_id ) ;
			step_timeout_id = window.setTimeout( "fill_line()" , step_time ) ;
		}
	}
	else{
		if ( title_index == 0 ){
			next_line(0) ;
		}
	}
}

function roll_ticker(){
	prepare() ;

	var title ;
	if ( title_index == 0 ){
		while ( document.getElementById('ticker').lastChild != null ){
			var child = document.getElementById('ticker').lastChild ;
			document.getElementById('ticker').removeChild( child ) ;
		}
	}

	if( news[news_index][1].indexOf('/videocasts/') != -1 ) {
		document.getElementById('ticon').innerHTML = '<img border="0" src="http://f.i.uol.com.br/folha/multimidia/images/icn-videocast.gif" alt="Videocast" title="Videocast" style="margin-right:1px">' ;
	} else if( news[news_index][1].indexOf('/podcasts/') != -1 ) {
		document.getElementById('ticon').innerHTML = '<img border="0" src="http://f.i.uol.com.br/folha/multimidia/images/icn-podcast.gif" alt="Podcast" title="Podcast" style="margin-right:1px">' ;
	}  else {
		document.getElementById('ticon').innerHTML = '' ;
	}

	if ( news_index < news.length + 2 && news[news_index][0].length >= title_index ){
		title = news[ news_index ] ;

		document.getElementById('ticker_anchor').setAttribute( "href" , title[1] ) ;

		if ( news_index == 0 && typeof( ticker_ad ) != "undefined" ){
			document.getElementById('ticker_anchor').setAttribute( "target" , "_blank" ) ;
			document.getElementById('ticker_anchor').style.color = "#0033cc" ;
		}
		else{
			document.getElementById('ticker_anchor').setAttribute( "target" , "_parent" ) ;
			document.getElementById('ticker_anchor').style.color = "#cc3300" ;
		}

		var s_text = title[0].substring( title_index  , title_index + step_char_length ) ;
		title_index += step_char_length ;

		if ( step_char_length > 1 ){
			step_char_length = 1 ;
		}

		if ( document.getElementById('ticker').lastChild != null ){
			if ( document.getElementById('ticker').lastChild.nodeValue == "_" ){
				child = document.getElementById('ticker').lastChild ;
				document.getElementById('ticker').removeChild( child ) ;
			}
		}

		var txt = document.createTextNode( s_text ) ;
		document.getElementById('ticker').appendChild( txt ) ;

		if ( title[0].length > title_index ) {
			if ( title_index % 10 != 0 ){
				txt = document.createTextNode( "_" ) ;
				document.getElementById('ticker').appendChild( txt ) ;
			}
		}

		step_timeout_id = window.setTimeout( "roll_ticker()" , step_time ) ;
	}
	else{
		title_index = 0 ;

		if ( !pause ){
			next_line( freeze_time ) ;
		}
	}
}

function next_line( t ){
	news_index >= news.length - 2 ? news_index = 0 : news_index++ ;
	freeze_timeout_id = window.setTimeout( "roll_ticker()" , t ) ;
}

function prev_line( t ){
	news_index == 0 ? news_index = news.length - 2 : news_index-- ;
	freeze_timeout_id = window.setTimeout( "roll_ticker()" , t ) ;
}






































var iDelaySlide = 6000 ; // 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" );
	}

	if ( aJJBA && aJJBA.length > rotate_index ){
		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] && aJJBA.length > rotate_index && 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(){
	var 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];
			}
		}
	}
}