addLoadEvent(textInit);

function textInit(){
	
	// TEXT SIZE	
	var t_small = document.getElementById('t_small');
	var t_medium = document.getElementById('t_medium');
	var t_large = document.getElementById('t_large');
	
	if(t_small){
		fontSizeInit();
	
		t_small.onclick = function(){
			fontSize(0);
			$('.tc_link').css({'background' : 'white', 'color' : '#000'});
			$(this).css({'background' : '#204297', 'color' : 'white'});
			return false;
		}
		t_medium.onclick = function(){
			fontSize(2);
			$('.tc_link').css({'background' : 'white', 'color' : '#000'});
			$(this).css({'background' : '#204297', 'color' : 'white'});
			return false;
		}
		t_large.onclick = function(){
			fontSize(1);
			$('.tc_link').css({'background' : 'white', 'color' : '#000'});
			$(this).css({'background' : '#204297', 'color' : 'white'});
			return false;
		}
	}
}

function fontSizeInit(s){
	var s = readCookie('fontSize');
	if(s){
		var body = document.getElementById('scalable_textbox');
		if(body){ 
			body.style.fontSize = s+'%';
			if(s > 100){
				$('#t_large').css({'background' : '#204297', 'color' : 'white'});
			}
			if(s < 100){
				$('#t_small').css({'background' : '#204297', 'color' : 'white'});
			}
			if(s == 100){
				$('#t_medium').css({'background' : '#204297', 'color' : 'white'});
				
			}
		}
	}
}

function fontSize(dir) {
	var body = document.getElementById('scalable_textbox');
	if(body.style.fontSize) {
		var s = parseInt(body.style.fontSize.replace('%',''));
	} else {
		var s = 100;
	}
      
	if(dir == 2){
		s = 100;
	}
	else {
		if(dir){ s +=10; }
		else{ s -=10; }
	}
	
	if(s<160 && s>70){
		body.style.fontSize = s+'%';
		createCookie('fontSize', ''+s+'', 10);
	}
}
