function xlogin(uid)
{
	var user_id=uid;
	if(user_id==0)
	{
		alert("Please sign in to use this feature.");
		return false;
	}
}
function reply_user(username)
    {
    document.getElementById("status_new5").focus();
    document.getElementById("status_new5").value = "@" + username + " ";
    
    }

	function chk_user(uid)
	{
		var user_id=uid;
		if(user_id==0)
		{
			alert("Please sign in first to submit it...");
			return false;
		}
		else 
		{
			document.search_form2.submit();
		document.getElementById("status_new5").value = "What's entertaining you?";
		return false;
		}
		
	}
	var reply_global;
	function chkinitial()
	{
		if(document.getElementById("status_new5").value=="What's entertaining you?")
		     document.getElementById("status_new5").value="";
	}
	function chkinitial2()
	{
		if(document.getElementById("status_new5").value=="")
		     document.getElementById("status_new5").value="What's entertaining you?";
	}	
	 function show_comments(rtid)
	   {
	   	$j("#comments_"+rtid).slideDown("slow");
	   }
	   function ilikeit(type,feed_type,uid,rtid)
	   {
	   		var user_id=uid;
			if(user_id==0)
			{
				alert("Please sign in first to do this...");
				return false;
			}
			else 
			{
				var url_status = (uCom)+'&likeit';
				var req = new Request({
				method: 'post',
				url: url_status ,
				data: { 'id' : rtid , 'type' : type , 'feed_type' : feed_type },
				onRequest: function() {  },
				onComplete: function(response) {status_res=response.split("##");
				document.getElementById('likediv_'+rtid).innerHTML = status_res[0];
				document.getElementById('like_count_'+rtid).innerHTML = status_res[1];
				$j('#reply_box_'+rtid).slideDown("slow");
				$j('#like_count_'+rtid).slideDown("slow");
				}
				}).send();
				return false;
			}
	   }
	 function show_reply_box(uid,rtid)
	   {
	   		var user_id=uid;
			if(user_id==0)
			{
				alert("Please sign in first to do this...");
				return false;
			} 
			else
			{
				document.getElementById("reply_box_"+rtid).style.display="block";
				return false;
			}
			
		}
		function hide_reply(rtid)
		{
			document.getElementById("reply_box_"+rtid).style.display="none";
			return false;
		}
		function show_reply_box_right(uid,rtid)
	   {
	   		var user_id=uid;
			if(user_id==0)
			{
				alert("Please sign in first to do this...");
				return false;
			} 
			else
			{
				document.getElementById("reply_box_"+rtid).style.display="block";
				document.getElementById("reply_sec_"+rtid).style.display="block";
				return false;
			}
			
		}
		function hide_reply_right(rtid)
		{
			document.getElementById("reply_box_"+rtid).style.display="none";
			document.getElementById("reply_sec_"+rtid).style.display="none";
			return false;
		}
		
		function chk_twitter()
		{
			TB_show("Twitter User Info", "#TB_inline?height=200&width=300&inlineId=confirmtwitter", "", "./templates/default/images/realtime/trans.gif");
			
		}
		function chk_twit(user_name,password)
		{
			if(user_name== "" || password == "")
			{
				alert("Please enter user name and password");
				return false;
			}
			else
			{
				
				var url_status = '../twitter_activity.php';
				var req = new Request({
				method: 'post',
				url: url_status ,
				data: { 'twitter_username' : user_name ,'twitter_password' : password ,'twitter_msg' : reply_global},
				onRequest: function() {  },
				onComplete: function(response) {return false;}
				}).send();
				parent.TB_remove();
				return false;
				
			}
		}
		function delete_user_action(rtid,type)
    	{
    			var url_status = '/delete_actions.php';
				var req = new Request({
				method: 'post',
				url: url_status ,
				data: { 'id' : rtid , 'type' : type  },
				onRequest: function() {  },
				onComplete: function(response) {
				if(type==1)
				{
					$j('#action_'+rtid).slideUp(1000);

					//document.getElementById('action_'+rtid).style.display = 'none';
				}
				else
				{
					$j('#comment_'+rtid).slideUp(1000);
					//document.getElementById('comment_'+rtid).style.display = 'none';	
				}	
				}
				}).send();
				return false;

     	}


	   function replyonit(type,feed_type,rtid,fid,tid)
	   {
	   		var reply_text;
			reply_global='';
			var send_twitter; 
			send_twitter=0;
			
			reply_text=document.getElementById('reply_area_'+rtid).value;
			if(reply_text!="")
			{
				reply_global=reply_text;
				
				if(document.getElementById('reply_twitter_'+rtid).checked ==true)
				{
					if(tid==0)
					{
						chk_twitter();	
					}
					else 
					{
						send_twitter=1;
					}
					
				}
				  
				document.getElementById('reply_area_'+rtid).value="";
				if(fid>0)
				{
				if(document.getElementById('reply_face_'+rtid).checked ==true)
					facebook_publish_feed_story(FEEDNUMBER,{"actor":"","body":reply_text});
				}
				var url_status = (uCom)+'&replyonit&primary';
				var req = new Request({
				method: 'post',
				url: url_status ,
				data: { 'id' : rtid ,'type' : type ,'feed_type': feed_type , 'reply_text' : reply_text, 'send_twitter' : send_twitter },
				onRequest: function() {  },
				onComplete: function(response) {
					
					status_res=response.split("##");
					
					if(status_res[0]>1)
					$j('#reply_sec_'+rtid).html($j('#reply_sec_'+rtid).html()+ status_res[1]);
					else
					$j('#reply_sec_'+rtid).html("<ul>"+ status_res[1]+"</ul>"+$j('#reply_sec_'+rtid).html());	
					 $j('#reply_sec_'+rtid).slideDown("slow");
					}
				}).send();
				return false;
			
			}
			else
			{
			return false;
			}
	   }
	   
	   function replyonit_right(type,feed_type,rtid,fid,uid,tid)
	   {
		   if(uid>0)
		   {
	   		var reply_text;
			reply_global='';
			var send_twitter; 
			send_twitter=0;
			
			reply_text=document.getElementById('reply_area_'+rtid).value;
			if(reply_text!="")
			{
				reply_global=reply_text;
				
				if(document.getElementById('reply_twitter_'+rtid).checked ==true)
				{
					if(tid==0)
					{
						chk_twitter();	
					}
					else 
					{
						send_twitter=1;
					}
					
				}
				  
				//document.getElementById("reply_box_"+rtid).style.display="none";
				document.getElementById('reply_area_'+rtid).value="";
				if(fid>0)
				{
				if(document.getElementById('reply_face_'+rtid).checked ==true)
					facebook_publish_feed_story(113739464006,{"actor":"","body":reply_text});
				}
				//reply_text=encodeURIComponent(reply_text);
				var url_status = (uCom)+'&replyonit';
				var req = new Request({
				method: 'post',
				url: url_status ,
				data: { 'id' : rtid ,'type' : type ,'activity': feed_type , 'is_status' : reply_text, 'send_twitter' : send_twitter },
				onRequest: function() {  },
				onComplete: function(response) {
					
					status_res=response.split("##");
					
					//document.getElementById('count_reply_'+rtid).innerHTML =  status_res[0] + " Comments - ";
					if(status_res[0]>1)
					$j('#reply_sec_'+rtid).html($j('#reply_sec_'+rtid).html()+ status_res[1]);
					else
					$j('#reply_sec_'+rtid).html("<ul>"+ status_res[1]+"</ul>"+$j('#reply_sec_'+rtid).html());	
					 $j('#reply_sec_'+rtid).slideDown("slow");
					}
				}).send();
				return false;
			
			}
			else
			{
			return false;
			}
		   }
		   else
		   {
			   	alert("Please sign in first to do this...");
			   return false;
		   }
	   }
	   

	 	function delete_user_action(rtid,type)
		{
					var url_status = '/delete_actions.php';
					var req = new Request({
					method: 'post',
					url: url_status ,
					data: { 'id' : rtid , 'type' : type  },
					onRequest: function() {  },
					onComplete: function(response) {
					if(type==1)
					{
						$j('#action_'+rtid).slideUp(1000);
	
						//document.getElementById('action_'+rtid).style.display = 'none';
					}
					else
					{
						$j('#comment_'+rtid).slideUp(1000);
						//document.getElementById('comment_'+rtid).style.display = 'none';	
					}	
					}
					}).send();
					return false;
	
		}

	 function show_reply_box_right(uid,rtid)
	   {
	   		//type 1 for like 2 for dislike
	   		var user_id=uid;
			if(user_id==0)
			{
				alert("Please sign in first to do this...");
				return false;
			} 
			else
			{
				document.getElementById("reply_box_"+rtid).style.display="block";
				document.getElementById("reply_sec_"+rtid).style.display="block";
				return false;
			}
			
		}
		function show_likes(rtid,type)
	   {
	   	var url_status = '/likes_show.php';
				var req = new Request({
				method: 'post',
				url: url_status ,
				data: { 'id' : rtid , 'type' : type  },
				onRequest: function() {  },
				onComplete: function(response) {document.getElementById('like_'+rtid).innerHTML = response;
				$j("#like_"+rtid).slideDown("slow");}
				}).send();
				return false;
	   
	   }
	   function ilikeit(type,feed_type,uid,rtid)
	   {
	   		//type 1 for like 2 for dislike
			
	   		var user_id=uid;
		if(user_id==0)
		{
			alert("Please sign in first to do this...");
			return false;
		}
		else 
		{
			
			var url_status = (uCom)+'&likeit';
			var req = new Request({
			method: 'post',
			url: url_status ,
			data: { 'id' : rtid , 'type' : type , 'feed_type' : feed_type },
			onRequest: function() {  },
			onComplete: function(response) {
			
			status_res=response.split("##");
				document.getElementById('likediv_'+rtid).innerHTML = status_res[0];
				document.getElementById('like_count_'+rtid).innerHTML = status_res[1];
				$j('#reply_box_'+rtid).slideDown("slow");
				$j('#like_count_'+rtid).slideDown("slow");
				}
			}).send();
			return false;
			
		}
	   	
	   }
	   
	    function replyonit_right(type,feed_type,rtid,fid,uid,tid)
	   {
		   if(uid>0)
		   {
	   		var reply_text;
			reply_global='';
			var send_twitter; 
			send_twitter=0;
			
			reply_text=document.getElementById('reply_area_'+rtid).value;
			if(reply_text!="")
			{
				reply_global=reply_text;
				t=reply_global;
				if(document.getElementById('reply_twitter_'+rtid).checked ==true)
				{
					if(tid==0)
					{
						chk_twitter();	
					}
					else 
					{
						send_twitter=1;
					}
					
				}
				  
				//document.getElementById("reply_box_"+rtid).style.display="none";
				document.getElementById('reply_area_'+rtid).value="";
				if(fid>0)
				{
				if(document.getElementById('reply_face_'+rtid).checked ==true)
					facebook_publish_feed_story_new({"description":reply_text});
				}	
				
				else
				{
					if(document.getElementById('reply_face_'+rtid).checked ==true)
					window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
					
				}
				
				//reply_text=encodeURIComponent(reply_text);
				var url_status = (uCom)+'&replyonit';
				var req = new Request({
				method: 'post',
				url: url_status ,
				data: { 'id' : rtid ,'type' : type ,'feed_type': feed_type , 'reply_text' : reply_text, 'send_twitter' : send_twitter },
				onRequest: function() {  },
				onComplete: function(response) {
					
					status_res=response.split("##");
					
					//document.getElementById('count_reply_'+rtid).innerHTML =  status_res[0] + " Comments - ";
					if(status_res[0]>1)
					$j('#reply_sec_'+rtid).html($j('#reply_sec_'+rtid).html()+ status_res[1]);
					else
					$j('#reply_sec_'+rtid).html("<ul>"+ status_res[1]+"</ul>"+$j('#reply_sec_'+rtid).html());	
					 $j('#reply_sec_'+rtid).slideDown("slow");
					}
				}).send();
				return false;
			
			}
			else
			{
			return false;
			}
		   }
		   else
		   {
			   	alert("Please sign in first to do this...");
			   return false;
		   }
	   }
	   
	   
	   function changeStatus(uid) {
		   
		if(uid != 0 )
		{
				var url_status = (uCom);
				var reply_text_main;
				var twit_id=0;
				var t;
				//var k=$j('realtime_status').value;
				reply_text_main = document.getElementById('realtime_status').value;
				if(reply_text_main!="" && reply_text_main !='What would you like to say?')
				{	
						reply_global = reply_text_main;
						t=reply_global;
						
					if(fuid>0)
					{
						if(document.getElementById('check-facebook').checked ==true)
						facebook_publish_feed_story_new({"description":reply_text_main});
					}
					else
					{
						if(document.getElementById('check-facebook').checked ==true)
						window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
						
					}
					if(document.getElementById('check-twitter').checked ==true)
						twit_id=1;
						if(twit_enable==0 && twit_id==1) {
							chk_twitter();
						}
						else {
							send_twitter=1;
						}
							
						$j.ajax({
							   type: "POST",
							   url: url_status ,
							   data: 'status=' + reply_text_main +'&send_twitter=' + send_twitter,
							   success: function(msg){
										show_hidden_feeds(action_new_id);
							   }
							 });  		
							 document.getElementById("realtime_status").value = "What would you like to say?";
				}
				else
				{
					alert("The input box can't be left blank. Please insert text and try again");
					 return false;
				}
				
		}
		else
		{
			alert("Please log in first");
		 return false;
		}
		return false;


	  }
	  function changeStatus2(uid) {
		   
		if(uid != 0 )
		{
				var url_status = (uCom);
				var reply_text_main;
				var twit_id=0;
				var t;
				//var k=$j('realtime_status').value;
				reply_text_main = document.getElementById('status').value;
				if(reply_text_main!="" && reply_text_main !='What would you like to say?')
				{	
						reply_global = reply_text_main;
						t=reply_global;
						
					if(fuid>0)
					{
						if(document.getElementById('check-facebook').checked ==true)
						facebook_publish_feed_story_new({"description":reply_text_main});
					}
					else
					{
						if(document.getElementById('check-facebook').checked ==true)
						window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
						
					}
					if(document.getElementById('check-twitter').checked ==true)
						twit_id=1;
						if(twit_enable==0 && twit_id==1) {
							chk_twitter();
						}
						else {
							send_twitter=1;
						}
							
						$j.ajax({
							   type: "POST",
							   url: url_status ,
							   data: 'status=' + reply_text_main +'&send_twitter=' + send_twitter,
							   success: function(msg){
										show_hidden_feeds(action_new_id);
							   }
							 });  		
							 document.getElementById("status").value = "What would you like to say?";
				}
				else
				{
					alert("The input box can't be left blank. Please insert text and try again");
					 return false;
				}
				
		}
		else
		{
			alert("Please log in first");
		 return false;
		}
		return false;


	  }	  
	  function shownew_feeds(action_id)
	  {
	  	var url_status = (uCom)+'&updatefeeds';
		 $j.ajax({
				   type: "POST",
				   url: url_status ,
				   data: 'rtid=' + action_new_id +'&tid=' + action_new_twit+ '&show_action_type='+show_action_type+'&show_id='+show_id+'&show_page='+ show_page+'&show_text='+show_text,
		 		   success: function(msg){
				   			
				 		  $j('#show_count').html(msg);
						 
				   }
				 });
		
	 		setTimeout(function(){shownew_feeds(action_new_id)},12000);
	  }
	   
	  function show_hidden_feeds(action_id){
	  	var url_status = (uCom);
			var status=$j('#realtime_status').val();
			
			 $j.ajax({
				   type: "POST",
				   url: url_status ,
				    data: 'rtid=' + action_new_id +'&tid=' + action_new_twit+ '&show_action_type='+show_action_type+'&show_id='+show_id+'&show_page='+ show_page+'&show_text='+show_text,
				   success: function(msg){
				    status_res=msg.split("##");
					action_new_id = status_res[0];
					action_new_twit=status_res[2];
					 $j('#all_div').html(  status_res[1]);
					 $j("#show_feeds_" + action_new_id).slideDown("slow");
					  
					  shownew_feeds(action_new_id);
					  $j('div.comments textarea').each(function(){
					var _hold = $j(this).parents('div.comments:eq(0)');
					var _text = this.value;
					this.onfocus = function(){
						
						_hold.addClass('active-text');
						_hold.addClass('active-text');
						
						if(this.value == _text) this.value = '';
					}
					this.onblur = function(){
						if(this.value == '') this.value = _text;
					}
			    });
					  
				   }
				 });
				// setTimeout(function(){shownew_feeds(action_new_id)},12000);
			  return false;
	  
	  } 