	jQuery(function() {
		jQuery(".comment_button").click(function()
		{
			var element = jQuery(this);
		    var blog = jQuery("#blogarea").val();
		    var eventid = jQuery("#eventselectbox").val();
		    var dataString = 'blog='+ blog+ '&eventid='+eventid;
			if(blog=='')
			{
				alert("Please Enter Some Text");
			}
			else
			{
			jQuery.ajax({
				type: "POST",
 				url: "index.php?option=com_htmicroblog&amp;task=addblog",
   				data: dataString,
  				cache: false,
  				success: function(html){

 				jQuery("table#update").prepend(html);
  				jQuery("table#update").slideDown("slow");
   					document.getElementById('blogarea').value='';
  			}
 			});
		}
		return false;
		});


		jQuery(".morebutton").click(function()
		{
		    jQuery("#flashmore").show();
			jQuery("#flashmore").fadeIn(400).html('<span class="loading">Loading Update...</span>');
			var ID = jQuery(this).attr("id");
			var pos = ID.search(";");
			var buser = ID.slice(0,pos)
			var page = ID.slice(pos+1)
		    var dataString = 'buser='+ buser;

			jQuery.ajax({
				type: "POST",
 				url: "index.php?option=com_htmicroblog&amp;task=more&amp;limit=no&amp;page="+page+"",
   				data: dataString,
  				cache: false,
  				success: function(html){

  				jQuery("#flashmore").hide();
 				jQuery("table.microbloglist").replaceWith(html);
  				jQuery("table.microbloglist").slideDown("slow");
  			}
 			});

		return false;
		});

		jQuery(".search_button").click(function()
		{
		    var search = jQuery("#search_box").val();
		    
		    if(search==""){}
		    else{
		    jQuery("#flash").show();
			jQuery("#flash").fadeIn(400).html('<span class="loading">Loading Results...</span>');

		    var dataString = 'searchterm='+ search;

			jQuery.ajax({
				type: "POST",
 				url: "index.php?option=com_htmicroblog&amp;task=search",
   				data: dataString,
  				cache: false,
  				success: function(html){

 				jQuery("table.microbloglist").replaceWith(html);
  				jQuery("table.microbloglist").slideDown("slow");
  				jQuery("#flash").hide();

  			}
 			});
			}
		return false;
		});

		jQuery('.deletebutton').live("click",function()
		{
			var ID = jQuery(this).attr("id");
 			var dataString = 'bid='+ ID;
			if(confirm("Sure you want to delete this update? There is NO undo!"))
			{

				jQuery.ajax({
					type: "POST",
 					url: "index.php?option=com_htmicroblog&amp;task=delete",
  					data: dataString,
 					cache: false,
 					success: function(html){
 					jQuery("#microblog"+ID).slideUp('slow', function() {jQuery(this).remove();});
 				}
			});
		}
		return false;
		});

		jQuery('.minusbutton').live("click",function()
		{
			var ID = jQuery(this).attr("id");
 			var dataString = 'bid='+ ID;
				jQuery.ajax({
					type: "POST",
 					url: "index.php?option=com_htmicroblog&amp;task=negativevote",
  					data: dataString,
 					cache: false,
 					success: function(html){
 					jQuery("#microblog"+ID).replaceWith(html);
 				}
			});
		return false;
		});

		jQuery('.plusbutton').live("click",function()
		{
			var ID = jQuery(this).attr("id");
 			var dataString = 'bid='+ ID;
				jQuery.ajax({
					type: "POST",
 					url: "index.php?option=com_htmicroblog&amp;task=positivevote",
  					data: dataString,
 					cache: false,
 					success: function(html){
 					jQuery("#microblog"+ID).replaceWith(html);
 				}
			});
		return false;
		});

		jQuery('.followbutton').live("click",function()
		{
			var ID = jQuery(this).attr("id");
 			jQuery("#follow"+ ID).hide();
 			var dataString = 'uid='+ ID;
				jQuery.ajax({
					type: "POST",
 					url: "index.php?option=com_htmicroblog&amp;task=follow",
  					data: dataString,
 					cache: false,
 					success: function(html){
 					jQuery("#follow"+ ID).replaceWith(html);
 				}
			});
		return false;
		});

		jQuery('.unfollowbutton').live("click",function()
		{
			var ID = jQuery(this).attr("id");
			jQuery("#follow"+ ID).hide();
 			var dataString = 'uid='+ ID;
				jQuery.ajax({
					type: "POST",
 					url: "index.php?option=com_htmicroblog&amp;task=unfollow",
  					data: dataString,
 					cache: false,
 					success: function(html){
 					jQuery("#follow"+ ID).replaceWith(html);
 				}
			});
		return false;
		});

		jQuery('.replybutton').live("click",function()
		{
			var ID = jQuery(this).attr("id");
 			document.getElementById('blogarea').value='@'+ID+' ';
 			document.getElementById('blogarea').focus();
 			jQuery("#hidden").show("slow");
			return false;
		});


   $("#stars-wrapper1").stars({
       cancelShow: false,
       captionEl: $("#stars-cap"),
       callback: function(ui, type, value)
       {
           $.getJSON("/new/components/com_htmicroblog/assets/rating.php", {rate: value, userid: document.getElementById('user_1122').value, pageid: document.getElementById('page_1122').value}, function(json)
          {
               $("#fake-stars-on").width(Math.round( $("#fake-stars-off").width() / ui.options.items * parseFloat(json.avg) ));
               $("#fake-stars-cap").text(json.avg + " (" + json.votes + ")");
           });
       }
   });



	});