/* From the old header file */
var pause = 8000;
var hold = 8000;
var speed = 1000;
var snap = 000;
var n = 4; //number of boards
var i = 0;
var j;
var t;
var decks;
var tabs;
var m = n - 1;
function next() {
	// make the next one active
	if (i < m) {
		j = i + 1;
	} else {
		j = 0;
	}
	$(decks[i]).fadeOut(speed/2,function(){
		$(tabs[i]).removeClass("active");
		$(tabs[j]).addClass("active");
		$(decks[j]).fadeIn(speed/2,function(){
			i = j;
			clearTimeout(t);
			t = setTimeout("next()",pause);
		});
	});
}
/**
* hoverIntent r5 // 2007.03.27 // jQuery 1.1.2+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
* 
* @param  f  onMouseOver function || An object with configuration options
* @param  g  onMouseOut function  || Nothing (use configuration options object)
* @author    Brian Cherne <brian@cherne.net>
*/
(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY;};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev]);}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev]);};var handleHover=function(e){var p=(e.type=="mouseover"?e.fromElement:e.toElement)||e.relatedTarget;while(p&&p!=this){try{p=p.parentNode;}catch(e){p=this;}}if(p==this){return false;}var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);}if(e.type=="mouseover"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob);},cfg.timeout);}}};return this.mouseover(handleHover).mouseout(handleHover);};})(jQuery);
Cufon.replace("#nav a.top", { hover: true });
jQuery(document).ready(function($){

	//$("#field_2304_0").click(function(){
		//$("#signup_submit").toggle();
		// $(this).attr('checked','checked');
		// return false;
	//});

	$(".hidden").hide();
	$("#fade").appendTo("body");
	$("#recipes_advanced_search").appendTo("body");
	$("#health_advanced_search").appendTo("body");
	// $("#contact_form").validate();
	//$(".content .post:last").css({borderBottom: 'none'});
	
	$("#feeder").feeder({ count: 1, pause: 10000, speed: 500, animation: 'fade' });
	$("#twitter-rotator").feeder({ count: 1, pause: 10000, speed: 500, animation: 'fade', activeclass: 'twitter-active' });
	$(".community-activity").feeder({ count: 3, pause: 12000, speed: 250, activeclass: 'community-activity-active' });
/* Moved to the bottom of nav.php */
/*
	$("#nav").addClass("jquery");
	$("#nav li .box").hide().css("left","0");
	$("#nav li").hoverIntent({
		sensitivity: 3, 
		interval: 200, 
		over: showNav, 
		timeout: 500, 
		out: hideNav
	});
*/
	$("a.signin").click(function(){
		$("#lightbox").show();
		return false;
	});
	$("#lightbox a.close").click(function(){
		$("#lightbox").hide();
		return false;
	});
	
	
	
	$(".tabs").tabs();
	
	$("#ads-features").tabs({ fx: { opacity: 'toggle' } }).tabs("rotate", 8000, false);
		
	//	$("#adstabs").tabs({ fx: { opacity: 'toggle' } }).tabs("rotate", 8000, false);
		
	// $("#ads-features").tabs({ fx: { opacity: 'toggle' } });
	
	
	
	
	
	
	$(".rotator:first").each(function(){
		decks = $(".rotator").children("div");
		tabs = $(".rotator ul").children("li:not('.play'):not('.pause')");
		n = decks.length;
		m = n - 1;
		$(decks).hide();
		$(decks[0]).show();
		$(tabs[0]).addClass("active");
		t = setTimeout("next()",pause);
	});
	$(".rotator>ul>li.pause>a").css("display","block").click(function(){
		clearTimeout(t);
		$(this).css("display","none");
		$(".rotator>ul>li.play>a").css("display","block");
		return false;
	});
	$(".rotator>ul>li.play>a").click(function(){
		next();
		clearTimeout(t);
		t = setTimeout("next()",hold);
		$(this).css("display","none");
		$(".rotator>ul>li.pause>a").css("display","block");
		return false;
	});
	$(".rotator>ul>li:not('.play'):not('.pause')>a").each(function(index){
		$(this).click(function(){
			clearTimeout(t);
			$(decks[i]).fadeOut(snap);
			$(decks[index]).fadeIn(snap);
			$(tabs[i]).removeClass("active");
			$(tabs[index]).addClass("active");
			i = index;
			t = setTimeout("next()",hold);
			return false;
		});
	});
	var editfields = $(".editfield");
	$(editfields[5]).hide();
	$(editfields[6]).hide();
});
function showNav() {
	jQuery(this).children("div.box").show();
	jQuery(this).addClass("active");
	Cufon.refresh('#nav a.top');
/*
	$("#nav li").hoverIntent({
		sensitivity: 3, 
		interval: 0, 
		over: showNav, 
		timeout: 0, 
		out: hideNav
	});
*/
}
function hideNav() {
	jQuery(this).children("div.box").hide();
	jQuery(this).removeClass("active");
	Cufon.refresh('#nav a.top');
/*
	$("#nav li").hoverIntent({
		sensitivity: 3, 
		interval: 200, 
		over: showNav, 
		timeout: 500, 
		out: hideNav
	});
*/
}
var addthis_config = {
	services_compact: 'email, facebook, twitter, more',
	services_exclude: 'print'
}
