function setHover(){
	
	$(".card").hover(
		function (){$(this).find(".msg-actions").show();},
		function (){$(this).find(".msg-actions").hide();}
	);
	
	$(".following").each(
		function(){
			var idname = $(this).attr('id');
			if (idname!=''){
				$('#'+idname).load("friendship.php",{"theid":idname},function(responseText){
					if (responseText!=''){
						$(this).parent().find('.action-follow').css("visibility","hidden");
					}
				});
			}
		}
	);
	
}
function setTooltip(){
	$(".action-follow").tooltip({
							showBody: " - ",track: true, delay: 0, showURL: false, opacity: 1, fixPNG: true, 
					    extraClass: "smalltooltip smalltooltiptext", top: -15, left: 15 ,
							bodyHandler:function(){	return "Follow";} });
	$(".action-lists").tooltip({
							showBody: " - ",track: true, delay: 0, showURL: false, opacity: 1, fixPNG: true, 
					    extraClass: "smalltooltip smalltooltiptext", top: -15, left: 15 ,
							bodyHandler:function(){	return "Twitter Lists";} });
	$(".action-reply").tooltip({
							showBody: " - ",track: true, delay: 0, showURL: false, opacity: 1, fixPNG: true, 
					    extraClass: "smalltooltip smalltooltiptext", top: -15, left: 15 ,
							bodyHandler:function(){	return "Reply";} });
	$(".action-quote").tooltip({
							showBody: " - ",track: true, delay: 0, showURL: false, opacity: 1, fixPNG: true, 
					    extraClass: "smalltooltip smalltooltiptext", top: -15, left: 15 ,
							bodyHandler:function(){	return "Retweet (old)";} });
	$(".action-rt").tooltip({
							showBody: " - ",track: true, delay: 0, showURL: false, opacity: 1, fixPNG: true, 
					    extraClass: "smalltooltip smalltooltiptext", top: -15, left: 15 ,
							bodyHandler:function(){	return "Retweet (new)";} });
	$("#googlelink").tooltip({
							showBody: " - ",track: true, delay: 0, showURL: false, opacity: 1, fixPNG: true, 
					    extraClass: "smalltooltip smalltooltiptext", top: -15, left: 15 ,
							bodyHandler:function(){	return "Related search results from Google";} });
	$("#binglink").tooltip({
							showBody: " - ",track: true, delay: 0, showURL: false, opacity: 1, fixPNG: true, 
					    extraClass: "smalltooltip smalltooltiptext", top: -15, left: 15 ,
							bodyHandler:function(){	return " Related search results from Bing";} });
}

function follow(sname){
	removeAllFollow(sname);
	insertFollowLoading(sname);
	$.post('./followuser.php',{"tofollow":sname},function(data){
		
		if (data == 'ok'){
			insertFollowing(sname);
		}
		else {
			clearLoading(sname);
			enableFollowing(sname);
		}
	});
}

function lists(sname){
	$("#youTubeContent").hide();
	$.fn.colorbox({width:"600px",height:"530px",opacity:"0.60",open:true,href:"lists.php?sname="+sname,"iframe":true},function(){
		$(this).bind('cbox_closed',function(){
			$("#youTubeContent").show();
		});
	});
}

function removeAllFollow(sname){
	$("."+sname).each(function(){
		$(this).find('.action-follow').css("visibility","hidden");
	});
}
function removeRtAction(innerid){
	$("#"+innerid).parent().find('.action-rt').css("visibility","hidden");
	theinner = $("#"+innerid).parent().parent().find('.msgplace-content');
	theinner.append("&nbsp;<img id='img"+innerid+"' src='./images/folloader.gif' />");
}
function insertRetweeted(innerid){
	theinner = $("#"+innerid).parent().parent().find('.msgplace-content');
	theinner.find("#img"+innerid).remove();
	theinner.append("&nbsp;<img src='./images/rted.gif' title='retweeted by you' />");
}
function enableFollowing(sname){
	$("."+sname).each(function(){
		$(this).find('.action-follow').css("visibility","visible");
	});
}
function insertFollowing(sname){
	$("."+sname).each(function(){
		$(this).find('.following').html("<img src='./images/following.png' />");
	});
}
function insertFollowLoading(sname){
	$("."+sname).each(function(){
		$(this).find('.following').html("<div><img src='./images/folloader.gif' /></div>");
	});
}
function clearRtLoading(innerid){
	theinner = $("#"+innerid).parent().parent().find('.msgplace-content');
	theinner.find("#img"+innerid).remove();
	$("#"+innerid).parent().find('.action-rt').css("visibility","visible");
}
function clearLoading(sname){
	$("."+sname).each(function(){
		$(this).find('.following').html("<div style='visibility:hidden'><img src='./images/folloader.gif' /></div>");
	});
}
function quote(msg){
	$.fn.colorbox({width:"500px",height:"300px",opacity:"0.60",open:true,href:"retweet.php?msg="+escape(msg),"iframe":true,"scrolling":false});
}

function tweetThis(msg){
	$.fn.colorbox({width:"500px",height:"300px",opacity:"0.60",open:true,href:"tweetit.php?msg="+escape(msg),"iframe":true,"scrolling":false});
}

function retweet(innerid,msgid){
		$.post('./specialretweet.php',{"msgid":msgid},function(data){
		if (data == 'ok'){
			insertRetweeted(innerid);
		}
		else {
			clearRtLoading(innerid);
		}
	});
}

function reply(msg,tweetid){
	$.fn.colorbox({width:"500px",height:"300px",opacity:"0.60",open:true,href:"reply.php?replyid="+tweetid+"&msg="+escape(msg),"iframe":true,"scrolling":false});
}
function openDetails(user){
	$.fn.colorbox({width:"500px",height:"270px",opacity:"0.60",open:true,href:"userdetails.php?user="+user,"iframe":true,"scrolling":false});
}
function openYouTubeVideoList(query){
	$.fn.colorbox({width:"800px",height:"540px",opacity:"0.60",open:true,href:"youtubevideolist.php?q="+query,"iframe":true,"scrolling":false});
}
function openTopTweeps(query){
	$.fn.colorbox({width:"580px",height:"640px",opacity:"0.60",open:true,href:"./ajaxserv/gettweeps.php?q="+query,"iframe":true,"scrolling":true});
}


