$(document).ready(function() {
	//google.load("jquery", "1.4.2");
	var newThreadCount = 0;

	$("#popout").tipTip({ delay: 0, fadeOut: 300, defaultPosition: "top" });
	$(".unreadThread").tipTip({ delay: 0, fadeOut: 300, defaultPosition: "top", content: "There are unread posts in this thread" });
	$(".readThread").tipTip({ delay: 0, fadeOut: 300, defaultPosition: "top", content: "You have read all the posts in this thread" });
	$(".authorAvatar").tipTip({ delay: 0, fadeOut: 300, defaultPosition: "top" });
	$(".goToLatest").tipTip({ delay: 0, fadeOut: 300, defaultPosition: "top", content: "Go to the latest unread post" });
	
	$("#newThreadTitle").keyup(function(event) {
		if ($(this).val() != "" && newThreadCount == 0) {
			var newThread = '<textarea name="message" id="newThreadBody" placeholder="Type the body of the thread here..."></textarea> <p id="newThreadControls"><button type="submit" name="sbutton"><img src="http://cdn.iconfinder.net/data/icons/icojoy/noshadow/standart/gif/24x24/001_06.gif" alt="" /> Create new thread</button> <button name="preview" disabled="disabled"><img src="http://cdn.iconfinder.net/data/icons/icojoy/noshadow/standart/gif/24x24/001_21.gif" alt="" /> Preview thread</button></p>';
			$("#newThread").css("height", "240px").animate();
			$("#newThread form").append(newThread);
			newThreadCount = newThreadCount + 1;
		}
		else if ($(this).val() == "" && $("textarea#newThreadBody").val() == "") {
			$("#newThread form textarea").slideDown('normal', function() {$(this).remove();}).animate({opacity:"1.0"}, 3000);
			$("#newThread form p").slideDown('normal', function() {$(this).remove();}).animate({opacity:"1.0"}, 3000);
			$("#newThread").css("height", "35px");
			newThreadCount = 0;
		}
	});
	
	$("#popout").click(function() {
		window.open('http://www.shoutmix.com/?g4andrex','GforumChat',
			'width=325,height=500,toolbar=no,location=no,directories=no,status=no,menubar=no');
	});
});