var $hf = 
{
	count: {},
	form: {},
	height:0,
	init: function()
	{
		$hf.request_done($hf.count);
	},
	pagination_opts:function()
	{
		return {
			items_per_page:1,
			num_display_entries:10,
			current_page:0,
			num_edge_entries:0,
			link_to:"javascript:;",
			prev_text:"&nbsp;",
			next_text:"&nbsp;",
			ellipse_text:"...",
			prev_show_always:false,
			next_show_always:false,
			callback: $hf.populate
		};
	},
	request_done: function(count)
	{
		$("#home-feat .home-feat-pagination").hide();
		if(count > 1)
		{
			$("#home-feat .home-feat-pagination").show();
		}
		
		$("#home-feat .home-feat-pagination").pagination(count, $hf.pagination_opts());
		if(count==1) {$("#home-feat .home-feat-inner").css({paddingBottom:'40px'});return;}
		$("#home-feat .home-feat").each(function(i)
		{
			var height = $(this).show().find(".home-feat-inner").outerHeight();
			if(i>0) $(this).hide();
			if(height > $hf.height) $hf.height = height;
		});
		
		$(".home-feat-inner").height($hf.height);
		if($.browser.msie)
		{
			$("#home-feat .home-feat-pagination").css({bottom:0}).css({bottom:'25px'});
		}
	},
	populate: function(page_index,jq)
	{
		var current = $("#home-feat .home-feat").hide().eq(page_index).show();
	}
	
};

window.onload = $hf.init;


var $wc_anim = 
{
	slide: function(){return $("#webcasts-container-slides");},
	init: function()
	{
		$wc_anim.items = $(".webcasts-slide");
		if($wc_anim.items.length==0) return this;
		
		$wc_anim.slide().width($wc_anim.items.length*608);
		$wc_anim.arrows();
		return this;
	},
	anime_left: function()
	{
		$(".webcasts-arrow-left").unbind('click',$wc_anim.anime_left);
		$wc_anim.slide().animate({marginLeft:'+=608px'},300,'',$wc_anim.arrows);
		return false;
	},
	anime_right: function()
	{
		$(".webcasts-arrow-right").unbind('click',$wc_anim.anime_right);
		$wc_anim.slide().animate({marginLeft:'-=608px'},300,'',$wc_anim.arrows);
		return false;
	},
	arrows: function()
	{
		var container = $wc_anim.slide();
		var slides = $wc_anim.items;
		var length = slides.length;
		var left = parseInt(container.css('marginLeft').replace('px',''));
				
		if(left == 0 || length == 1)
		{
			$(".webcasts-arrow-left").css({opacity:0.5,cursor:'default'});	
		}
		else if(length>1)
		{
			$(".webcasts-arrow-left").bind('click',$wc_anim.anime_left).css({opacity:1,cursor:'pointer'});	
		}

		if(left == -((length-1)*608) || length == 1)
		{
			$(".webcasts-arrow-right").css({opacity:0.5,cursor:'default'});
		}
		else if(length>1)
		{
			$(".webcasts-arrow-right").bind('click',$wc_anim.anime_right).css({opacity:1,cursor:'pointer'});;
		}

		var current = slides.removeClass('slide-active').eq(-left/608).addClass('slide-active');
		return this;
	}
};

$($wc_anim.init);
