    function change_percent( string_percent , float_factor ){
        return new String( Math.floor( Number( string_percent.replace( "%" , "" ) ) * float_factor ) + "%" ) ;
    }
       
    function set_fontsize( key ){
      // Changing the fontsize of titles ( <h1>, <h2>, and so on).
      var title_tags = new Array( "h1", "h2", "h3", "h4" ) ;
      var title_factor = 1.5 ; 	// Titles' size must increase or decrease more than the text content. In this case, 150%.
      for ( i = 0 ; i < title_tags.length ; i++ ){
        var elements = document.getElementsByTagName( title_tags[i] ) ;
        for ( j = 0 ; j < elements.length ; j++ ){
           elements[j].style.fontSize = change_percent( key, title_factor ) ;
           elements[j].style.lineHeight = change_percent( key, title_factor ) ;  
        }
      }
      // Changing the fontsize of text content
      var text_tags = new Array( "p", "li", "label", "legend", "input" ) ;
      for ( i = 0 ; i < text_tags.length ; i++ ){
        var elements = document.getElementsByTagName( text_tags[i] ) ;
        for ( j = 0 ; j < elements.length ; j++ ){
           elements[j].style.fontSize = key ;
           elements[j].style.lineHeight = change_percent( key , 1.5 ) ;  
        }
      }      
      document.getElementById( "increment_fontsize" ).setAttribute( "href" , "javascript:set_fontsize('" + change_percent( key, 1.2 ) + "' );" ) ;
      document.getElementById( "decrement_fontsize" ).setAttribute( "href" , "javascript:set_fontsize('" + change_percent( key, 0.8 ) + "' );" ) ;
    }

    function show_hide_topic( element_id ){
      if ( !document.getElementById ){
        return ;	
      }	
      if ( document.getElementById( element_id ) && document.getElementById( element_id + "-image" ) ){
        var topic_content = document.getElementById( element_id ).getElementsByTagName("div")[0] ;
        var topic_image = document.getElementById( element_id + "-image" ) ;
        if ( topic_content.style.display == "none" ){
            topic_content.style.display = "block" ;
            topic_image.setAttribute( "src" , "http://www.tst.jus.br/files/minus.png" ) ;
            topic_image.setAttribute( "alt" , "Fechar t&oacute;pico" ) ;
        }
        else{
            topic_content.style.display = "none" ;
            topic_image.setAttribute( "src" , "http://www.tst.jus.br/files/plus.png" ) ; 
            topic_image.setAttribute( "alt" , "Abrir t&oacute;pico" ) ;       }
      } 	
    }    

    function show_hide( to_show_id , to_hide_id ){
      if ( !document.getElementById ){
        return ;	
      }	
      if ( document.getElementById( to_show_id ) ){
        document.getElementById( to_show_id ).style.display = "block" ;
      }
      if ( document.getElementById( to_hide_id ) ){
        document.getElementById( to_hide_id ).style.display = "none" ;
      }      
    }

    function close_all_topics(){
      if ( !document.getElementById ){
        return ;
      }
      var divs = document.getElementsByTagName("div") ;
      var i_limit = divs.length ;
      for( i = 0; i < i_limit; i++ ){
	if( divs[i].getAttribute("id") ){
	  if( divs[i].getAttribute("id").match( new RegExp("t\\d+") ) ){
            show_hide_topic( divs[i].getAttribute("id") ) ;
	  }
	}
      }
    }

	function mudarCSS(titleCss){

if(document.getElementById("corPagina")!=null){
	document.getElementById("corPagina").value = titleCss
}


for(i=0;(a=window.document.getElementsByTagName("link")[i]);i++){
	if(a.getAttribute("title")==''){
		acao = ''
	}else{
		acao = 1	
	}
}

	if(acao!=''){
		
		if(titleCss=='branco'){
			
			
			setActiveStyleSheet(titleCss)	
/*			if(window.parent.frames[1].window.document.getElementById('imagem')!=null){			
				var Url = window.parent.frames[1].window.document.getElementById('imagem').src
				Url = Url.replace('preto.png','cabec2.gif')
				window.parent.frames[1].window.document.getElementById('imagem').src = Url
			}
*/			
		}else
		if(titleCss=='preto'){
			
			setActiveStyleSheet(titleCss)	
/*			if(window.parent.frames[1].window.document.getElementById('imagem')!=null){
				var Url = window.parent.frames[1].window.document.getElementById('imagem').src
				Url = Url.replace('cabec2.gif','preto.png')
				window.parent.frames[1].window.document.getElementById('imagem').src = Url
			}
*/			
		}else 
		if(titleCss=='padrao'){
			
			setActiveStyleSheet(titleCss)	
/*			if(window.parent.frames[1].window.document.getElementById('imagem')!=null){			
				var Url = window.parent.frames[1].window.document.getElementById('imagem').src
				Url = Url.replace('preto.png','cabec2.gif')
				window.parent.frames[1].window.document.getElementById('imagem').src = Url
			}
*/		}
	}
	
}


function setActiveStyleSheet(title) { 
  var i, a, main; 
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) { 
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) { 
      a.disabled = true; 
      if(a.getAttribute("title") == title) a.disabled = false; 
    } 
  } 
} 
 
function getActiveStyleSheet() { 
  var i, a; 
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) { 
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title"); 
  } 
  return null; 
} 
 
function getPreferredStyleSheet() { 
  var i, a; 
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) { 
    if(a.getAttribute("rel").indexOf("style") != -1 
      && a.getAttribute("rel").indexOf("alt") == -1 
      && a.getAttribute("title") 
      ) return a.getAttribute("title"); 
  } 
  return null; 
} 


 function alteraTamanho(multiplicador) {  
		   if (document.body.style.fontSize == "") {  
				document.body.style.fontSize = "12.0px";  
			}  
	   document.body.style.fontSize = parseFloat(document.body.style.fontSize) + (multiplicador * 0.2) + "px";  

 } 

 function tamanhoPadrao(){
		document.body.style.fontSize = "12.0px";
 }

 function limpaCampos(nf,campo, n){
		for(i=0;i<n;i++){
			 document.forms[nf].elements[i].value = document.forms[nf].elements[i].value.replace(/(^\s+)|(\s+$)/g, '');
		}
}

function autoTAB(nomeCampo, tamanhoCampo){ //Realiza autoSkip de campos de formulário
      var i=0; //variável utilizada para determinar o INDICE DO ELEMENTO dentro do FORM
      
      //Se o tamanho do conteudo do campo for igual ao tamanho passado como parametro para dar o AUTOTAB
      if (eval("document.forms[0]."+nomeCampo+".value.length")==tamanhoCampo){          
          
          //Descobrindo o INDEX do elemento atual para poder passar o FOCO para o próximo elemento       
          for (i=0; i<document.forms[0].elements.length; i++){
              
              //Se o elemento DESTE INDICE, acessado pelo LAÇO(FOR) atualmente, tiver o mesmo nome que foi passado como parametro
              //então esta é a posição atual do elemento do FORM
              if (nomeCampo == document.forms[0].elements[i].name){
                  
                  //Mudando o foco para o próximo elemento
                  document.forms[0].elements[i+1].focus();
                  break;                  
              }
          }   
      }
  }

function getCookie(name) {
       var dc = document.cookie;
       var prefix = name + "=";
       var begin = dc.indexOf("; " + prefix);
       if (begin == -1) {
       begin = dc.indexOf(prefix);
       if (begin != 0) return null;
       } else
       begin += 2;
       var end = document.cookie.indexOf(";", begin);
       if (end == -1)
       end = dc.length;
       return unescape(dc.substring(begin + prefix.length, end));
}

function setCookie(name, value, expires, path, domain, secure) {
        var curCookie = name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
        document.cookie = curCookie;
}

function deleteCookie(name, path, domain) {
       if (getCookie(name)) {
              document.cookie = name + "=" + 
              ((path) ? "; path=" + path : "") +
              ((domain) ? "; domain=" + domain : "") +
              "; expires=Thu, 01-Jan-70 00:00:01 GMT";
              history.go(0);
       }
}

