$(document).ready(function() {
	function urlencode(str) {
		str = escape(str);
		str = str.replace('+', '%2B');
		str = str.replace('%20', ' ');
		str = str.replace('*', '%2A');
		str = str.replace('/', '%2F');
		str = str.replace('@', '%40');
		return str;
	}
	function toUtf8(string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";

		for (var n = 0; n < string.length; n++) {

			var c = string.charCodeAt(n);

			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}

		}

		return utftext;
	}
	function go(txt, rel){
		window.open('http://twitter.com/home?status='+ urlencode(toUtf8(txt))+' '+rel);
	};
	$(".twitter").click(function(){
		var tt = $(".twitter").attr("title");
		var rel = $(".twitter").attr("rel");
		go(tt, rel);		
		return false;		
	});
	$("#image").click(function() {				
		var el = $("#compartilhe");
		var ell = $("#compartilhe_redes");

		el.expose({
			color:'#000', 
			opacity:"0.7", 
			startOpacity:"0.1",
			onBeforeLoad: function(){
				el.fadeIn();						
				$("#form").fadeIn();
			},
			onBeforeClose: function() {
				el.fadeOut();
			}
		});
		$("#close").click(function(){
			$.mask.close();
			$("#form").hide();
		});
		$(".btn_enviar").click(function(){
			$.mask.close();
			$("#form").hide();					
		});
		return false;
	});
	
	$(".email").click(function(){
		$("#compartilhe_redes").hide();
		$("#form").fadeIn();
		return false;
	});	
	var fonte = 12;
	var line_height = 18;
	$(".fonte_maior").click(function(){
		if(fonte < 17){
			fonte = fonte+1;
			line_height = line_height+1;
			$("#conteudo_content_left_conteudo p").css({'font-size' : fonte+'px', 'line-height': line_height+'px', 'font-weight':'normal'});
		}
	});
	 $(".fonte_menor").click(function(){
		if (fonte > 10){
			fonte = fonte-1;
			line_height = line_height-1;
			$("#conteudo_content_left_conteudo p").css({'font-size' : fonte+'px',  'line-height': line_height+'px'});
		}
	});
});
