	var noticias = new Array(

	[ "Publicado o Informativo TSE n° 15 em versões PDF e RTF" , "midia/informativo.htm" , "" ] ,
	[ "Confira a nova composição da corte do TSE" , "institucional/ministros.htm" , "" ] ,
	[ "Prestação de Contas - Instruções sobre o extrato eletrônico de campanha" , "eleicoes/2010/prestacaoDeContas.html" , "" ] ,
	[ "Disponíveis novos resumos digitais para eleições suplementares" , "eleicoes/resumos_digitais.htm" , "" ] ,
	[ "Confira o calendário de eleições suplementares 2010" , "eleicoes/suplementares_2010.htm" , "" ] ,
	[ "Relatório das Eleições 2008" , "eleicoes/relatorio_2008.htm" , "" ] ,
	[ "Instruções e Resoluções das Eleições 2010" , "eleicoes/normas_2010/inst_resol.htm" , "" ] ,
	[ "Clipping TSE disponibiliza vídeos veiculados na televisão" , "midia/clipping.htm" , "blank" ] ,
	[ "Confira o novo formato do Calendário Eleitoral do TSE" , "eleicoes/2010/calendario.html" , "" ] ,
	[ "TSE publica nova lista de municípios que participarão do recadastramento biométrico" , "institucional/recadastramento/municipios.html" , "blank" ] ,
	[ "Leia o Relatório de Gestão Fiscal de 2009" , "contas_publicas/rel2009.htm" , "" ] ,
	[ "Principais destaques da página inicial do TSE podem ser acompanhados no twitter" , "http://twitter.com/TSEjusbr" , "blank" ] ,
	[ ]
	);
	
	var camada = false ;
	var passo = 40 ;
	var freeze_time = 5000 ;
	var noticias_index = 0 ;
	var title_index = 0 ;
	var end_title = "_" ;
	var title_max_size = 62 ; // 62
	var pause = false ;
	var freeze_timeout_id ;
	var passoout_id ;
	var step_char_length = 1 ;
	
	var foo = false ;
	
	function prepare(){
		var container_size = 475 ; // 475
		for ( var i = 0 ; i < noticias.length - 1 ; i++ ){
			var t = noticias[i][0] ;
	
			t = t.replace(/\&quot;/gi,'"') ;
			t = t.replace(/\&amp;/gi,'&') ;
			t = t.replace(/\&#039;/gi,'\'') ;
	
			var modelo = document.createTextNode( t ) ;
			document.getElementById('modelo').appendChild( modelo ) ;
			var size = document.getElementById('modelo').offsetWidth ;
	
			while( size > container_size ){
				t = t.substring( 0 , t.lastIndexOf( ' ' ) ) ;
				t += '...';
				clear_element( 'modelo' ) ;
				var modelo = document.createTextNode( t ) ;
				document.getElementById('modelo').appendChild( modelo ) ;
				size = document.getElementById('modelo').offsetWidth ;
			}
			clear_element( 'modelo' ) ;
			noticias[i][0] = t ;
		}
	}
	
	function clear_element( name ){
		/* esvaziar modelo */
		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(){
		$("img#botaoPlay").hide();
		window.setTimeout( "roll_ticker()" , passo ) ;
	}
	
	function move_next(){
		if ( title_index == 0 ){
			freeze_timeout_id = window.setTimeout( "roll_ticker()" , noticias[title_index][0] ) ;
		}
		else{
			title_index = 0 ;
			next_line(0) ;
		}
	}
	
	function move_prev(){
		if ( title_index == 0 ){
			noticias_index == 0 ? noticias_index = noticias.length - 2 : noticias_index-- ;
			prev_line(0) ;
		}
		else{
			title_index = 0 ;
			prev_line(0) ;
		}
	}
	
	function fill_line(){
		noticias_index-- ;
		if ( noticias_index < 0 ){
			noticias_index = noticias.length - 2 ;
		}
	
		step_char_length = noticias[noticias_index][0].length - title_index ;
		passoout_id = window.setTimeout( "roll_ticker()" , passo ) ;
	}
	
	function PlayPause(valor)
	{
		if (valor==2)
		{
			$("img#botaoPlay").hide();
			$("img#botaoPause").show();
		}
		else {
			$("img#botaoPlay").show();
			$("img#botaoPause").hide();
		}
	};

	function t_next( obj ){
		pause = false ;
		freeze_timeout_id = window.clearTimeout( freeze_timeout_id ) ;
		passoout_id = window.clearTimeout( passoout_id ) ;
		passoout_id = window.setTimeout( 'move_next()' , passo ) ;
		PlayPause(2);
	}
	
	function t_prev( obj ){
		pause = false ;
		freeze_timeout_id = window.clearTimeout( freeze_timeout_id ) ;
		passoout_id = window.clearTimeout( passoout_id ) ;
		passoout_id = window.setTimeout( 'move_prev()' , passo ) ;
		PlayPause(2);
	}
	
	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{
				noticias_index >= noticias.length - 2 ? noticias_index = 0 : noticias_index++ ;
				window.clearTimeout( passoout_id ) ;
				passoout_id = window.setTimeout( "fill_line()" , passo ) ;
			}
		}
		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 ( noticias_index < noticias.length + 2 && noticias[noticias_index][0].length >= title_index )
        {
			title = noticias[ noticias_index ] ;
	
			document.getElementById('ticker_anchor').setAttribute( "href" , title[1] ) ;
	
			if ( title[2] == "blank" ){
				document.getElementById('ticker_anchor').setAttribute( "target" , "_blank" ) ;
				document.getElementById('ticker_anchor').style.color = "#fff" ;
			}
			else{
				document.getElementById('ticker_anchor').setAttribute( "target" , "_parent" ) ;
				document.getElementById('ticker_anchor').style.color = "#fff" ;
			}
	
			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 ) ;
				}
			}
	
			passoout_id = window.setTimeout( "roll_ticker()" , passo ) ;
		}
		else{
			title_index = 0 ;
	
			if ( !pause ){
				next_line( freeze_time ) ;
			}
		}
	}
	
	function next_line( t ){
		noticias_index >= noticias.length - 2 ? noticias_index = 0 : noticias_index++ ;
		freeze_timeout_id = window.setTimeout( "roll_ticker()" , t ) ;
	}
	
	function prev_line( t ){
		noticias_index == 0 ? noticias_index = noticias.length - 2 : noticias_index-- ;
		freeze_timeout_id = window.setTimeout( "roll_ticker()" , t ) ;
	}
	

		

