﻿$(document).ready(function(){

	//Objeto responsável por carrega a fonte selecionado pelo usuário.
	window.fonte = new Fonte();
	window.fonte.controlarTamanhoFonte();

	//Atualiza a fonte deacordo com a seleção feita pelo usuário.
    $('#menuTop li a.acessibilidade').click(function(){

        var title = $(this).attr('title');
        var i, a;

		if(title.indexOf('padrão')!=-1){

			window.fonte.controlarTamanhoFonte("Fonte padrão");

		}else{

	        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.getAttribute("title").indexOf('Contraste') == -1) {

					    a.disabled = false;
						window.fonte.setTamanho(a.getAttribute("title"));
						window.fonte.criarCookie();

	                }else if(a.getAttribute("title") == title && a.getAttribute("title").indexOf('Contraste') != -1){

						if(window.fonte.ALTO_CONTRASTE){
							window.fonte.ALTO_CONTRASTE = false;
							window.fonte.setTamanho("Fonte padrão");
							window.fonte.criarCookie();
						}else{
		                    a.disabled = false;
							window.fonte.ALTO_CONTRASTE = true;
							window.fonte.setTamanho(a.getAttribute("title"));
							window.fonte.criarCookie();
						}

					}
	            }

			}

		}

    });

});
