
		
function switch_slides($current_id, $next_id)
	{	
		$old_post_id = $current_id.replace("image-", "post-");
		$new_post_id = $next_id.replace("image-", "post-");
		
		$($current_id).fadeOut("fast");
		$($next_id).addClass("floatleft");
		$($old_post_id).slideUp("slow");
		
		setTimeout(
			function()
				{
					$($next_id).fadeIn("slow");
					$($new_post_id).slideDown("slow").addClass("feature-post-content").addClass("clearfix");
					$.busy = 0;
				}
		,100);

	}

$(document).ready(function()
	{
		/***********************************************/
		/* All functions for the featured posts Widget */
		$.current_slide = $(".feature-post-image .floatleft").attr("id");
		$.current_slide_no = 1;
		$.busy = 0;
		$.max_clicks  = $(".feature-post-image div").length;
		$("#scroller-right-btn").click(function()
			{
				if($.busy == 0)
					{
						$.busy = 1;
						if($.current_slide_no < $.max_clicks)
							{
								$current_id = "#"+$.current_slide;
								$next_id = "#"+$($current_id).next().attr("id");
								$.current_slide = $($current_id).next().attr("id");
								$.current_slide_no++;
							}
						else
							{
								$current_id = "#"+$.current_slide;
								$next_id = "#"+$(".feature-post-image div:nth-child(1)").attr("id");
								$.current_slide = $(".feature-post-image div:nth-child(1)").attr("id");
								$.current_slide_no = 1;
							}
						switch_slides($current_id, $next_id);
					}
				return false;
			});
		
		$("#scroller-left-btn").live("click", function()
			{
				if($.current_slide_no > 1)
					{
						$current_id = "#"+$.current_slide;
						$next_id = "#"+$($current_id).prev().attr("id");
						$.current_slide = $($current_id).prev().attr("id");	
						$.current_slide_no--;					
					}
				else
					{
						$current_id = "#"+$.current_slide;
						$next_id = "#"+$(".feature-post-image div:nth-child("+$.max_clicks+")").attr("id");
						$.current_slide = $(".feature-post-image div:nth-child("+$.max_clicks+")").attr("id");
						$.current_slide_no = $.max_clicks;
					}
				switch_slides($current_id, $next_id);
				return false;
			});
		$("[id^=feature-link-]").click(function(){
			if($("#feature-content"))
				{
					$id = $(this).attr("id").replace("feature-link-", "")
					$("#feature-content").slideUp("fast", function(){$("#feature-content").load($("#template-directory").html()+"/ajax.php?fetch_feature=1&id="+$id, function(){$("#feature-content").slideDown("fast");});})
					return false;
				}
		});
		
		
	});