var ltie7  = $.browser.msie && /MSIE\s(5\.5|6\.)/.test(navigator.userAgent);

function htmlEntities(string)
{
	return string.replace(/[^\x09\x0A\x0D\x20-\x7F]|[\x21-\x2F]|[\x3A-\x40]|[\x5B-\x60]/g,function(e){
		return '&#'+e.charCodeAt(0)+';'
	});
};

$(document).ready(function() {
  $('#emailFrame').hide();
  $("#email_container a").toggle(
    function () { $("#emailFrame").animate({ height: "show", duration: 1000, easing:"easeInQuad"}); 
    return false; 
  },
    function () { $("#emailFrame").animate({ height: "hide", duration: 1000, easing:"easeOutQuad"}); 
    return false; 
  });
});

$(function(){

	//ScrollToAnchor
	$('a[href*=#header]').click(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
	  		var $target = $(this.hash);
	  		$target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
	  		if ($target.length) {
				var targetOffset = $target.offset().top;
				$('html,body').animate({scrollTop: targetOffset}, 1000, 'easeInQuad');
	   			return false;
	  		}
		}
  	});

	//Links
	var url = "sargacal.com";
	$("DIV.container>DIV.post>DIV.content>P A").not("[href^=/]")
								.not("[href^=#]")
								.not("[href^=" + url + "]")
								.not("[href^=http:\//" + url + "]")
								.not("[href^=www." + url + "]")
								.not("[href^=http:\//www." + url + "]")
								.not("[href^=mailto:]")
								.css("border-bottom","solid thin #D6D5D3");

  	//Processar imagens
	$("DIV.container>DIV.post>DIV.content>P A IMG").each(function(){
		
		var m = "10px";
		var aL = $(this).attr("align");
		if ( aL == "left" ) {
			$(this).css("margin-right", m);
		} else if ( aL == "right" ) {
			$(this).css("margin-left", m);
		}
		//$(this).css("margin-bottom", m);
		$(this).parent().css("border", "0px");

	});

	// Post anterior
	$("DIV.container>DIV.posttopline>P SPAN.previous>A").each(function(){
		var texto = $(this).text().substring(0,35);
		$(this).text(texto + "(...)");
	});

	// Post seguinte
	$("DIV.container>DIV.posttopline>P SPAN.next>A").each(function(){
		var texto = $(this).text().substring(0,35);
		$(this).text(texto + "(...)");
	});
});
