//  TREVORMSTR Tumblr JS
//  Copyright 2010

$(document).ready(function(){
	
	var $tweet = $("#tweets a.tweet"); loadTweet($tweet);
	tweetCheck = setInterval(function(){ loadTweet($tweet,tweetCheck) },20);
	
	$("#nav_about").click(function(){
		toggleAbout(); return false; });

	$("#tweets").click(function(){
		location.href = "http://twitter.com/trev"; return false; });
	
	$("#top_link").click(function(){
		$('html,body').animate({ scrollTop: 0 }, 600); return false; });
		
	$("article.chat").each(function(){
		$(this).find("p:last").css("border-bottom","none"); });
		
/*	$("#tumblr_controls").css("opacity","0").mouseenter(function(){
		$("#fade").animate({ opacity: 1 },200);
		$(this).animate({ opacity: 1 },200);
	}).mouseleave(function(){
		$("#fade").animate({ opacity: 0 },200);
		$(this).animate({ opacity: 0 },200);
	}) */



})

function loadTweet(tweet,tweetCheck){
	
	if (tweet.html() != '') {
		$("#tweets a.tweet").animate({opacity:1});
		$("#tweets .loading").hide();
		clearInterval(tweetCheck); }

}

function toggleAbout(){

	if ($("#about").is(":visible")) {
		$("#about").slideUp();
		$("#tweets").removeClass("open");
		$("#nav_about").removeClass("active");

	} else {
		$("#about").slideDown();
		$("#tweets").addClass("open");
		$("#nav_about").addClass("active"); }

}

/* jQuery.fn.fadeColor = function(set) {
	return this.each(function(){
		var $find = $(this); if (set.element != null) $find = $(this).find(set.element);
		if (set.from == null) set.from = $find.css('color');
		$(this).bind('mouseenter',function(){ $find.css({ color: set.from }).animate({ color: set.to },200); })
			.bind('mouseleave',function(){ $find.animate({ color: set.from },200); });
	});
}; */
