 $(document).ready(function(){
		$(".entrytopic").click(
		    	function() {
		    		clearTimeout(t);
		    		var id = $(this).attr("title");
		    		if($("#"+id).css("display") == "none") {
		    			$("td.entry:not(#td"+id+")").css('display', 'none');
		    			$("#"+id).show("slow");
		    		} else {
		    			$("#"+id).hide("slow");
		    			$("#comm"+id).hide("slow");
		    			$("#frm"+id).attr('src','');
		    			$("td.entry").css('display', 'table-cell');
		    		}
		    	}
		    );
		
		$(".framelink").click(
		    	function() {
		    		clearTimeout(t);
		    		var id = $(this).attr("title");
		    		if($("#"+id).css("display") == "none") {
		    			$(".frametext").hide("slow");
		    			$(".framelink").css('color','#FFF');
		    			$("#"+id).show("slow");
		    			$(this).css('color', '#FFF500');
		    		} else {
		    			$("#"+id).hide("slow");
		    			$(this).css('color', '#FFF');
		    		}
		    	}
		    );
		
		$(".commlink").click(
				function() {
					var id = $(this).attr("title");
		    		if($("#comm"+id).css("display") == "none") {
		    			$("#comm"+id).show("slow");
		    			$("#frm"+id).attr('src','entercomm.php?id='+id);
		    		} else {
		    			$("#comm"+id).hide("slow");
		    			$("#frm"+id).attr('src','');
		    		}
				}
			);
		
		$(".close").click(
		    	function() {
		    		var id = $(this).attr("title");
		    		$("#"+id).hide("slow");
		    		$("#comm"+id).hide("slow");
	    			$("#frm"+id).attr('src','');
	    			$("td.entry").css('display', 'table-cell');
		    	}
		    );
  });
 
 var t;
 
 // if get ID
 function openID(id) {
	if($("#"+id).attr("class") == 'entrytext') {
		$("td.entry").css('display', 'none');
		$("#td"+id).css('display', 'table-cell');
		$("#"+id).show("slow");
	} else if($("#"+id).attr("class") == 'frametext') {
		$(".frametext").hide("slow");
		$(".framelink").css('color','#FFF');
		$("#"+id).show("slow");
		$("[title="+id+"]").css('color','#fff500');
	}
}
 
 // for the first article
 function openFirst(id) {
	 t = setTimeout("openID("+id+")",3000);
 }
 
 // for twitter app
 function relative_time(time_value) {
     var parsed_date = Date.parse(time_value);

     var relative_to = (arguments.length > 1) ? arguments[1] : new Date();
     var delta = parseInt((relative_to.getTime() - parsed_date) / 1000);

     if(delta < 60) {
         return 'less than a minute ago';
     } else if(delta < 120) {
         return 'about a minute ago';
     } else if(delta < (45*60)) {
         return (parseInt(delta / 60)).toString() + ' minutes ago';
     } else if(delta < (90*60)) {
         return 'about an hour ago';
     } else if(delta < (24*60*60)) {
         return 'about ' + (parseInt(delta / 3600)).toString() + ' hours ago';
     } else if(delta < (48*60*60)) {
         return '1 day ago';
     } else {
         return (parseInt(delta / 86400)).toString() + ' days ago';
     }
  }
  
 function twitterCallback(obj) {
	var tweetblock = "<table>";
	for(var i=0;i<5;i++) {
		tweetblock += "<tr>" +
				"<td class='twitter'>" +
					"<div class='twitter'>" +
						"<span class='twitter'>"+obj[i].text+"</span><br>" +
						"<span class='twitcom'><a href='http://twitter.com/ishmael/status/"+obj[i].id+"' target='_blank'>"+relative_time(obj[0].created_at)+"</a></span>" +
					"</div>" +
				"</td>" +
				"</tr>";
	}
	tweetblock += "</table>";
	$("#tweetblock").html(tweetblock);
 }
