$(function() {
	// Navigation hover effects and clicks
	$("#nav > li").hover(
		 function() { $(this).addClass("hover"); }
		,function() { $(this).removeClass("hover"); }
	);
	
	
	// Random quotes
	$("#pushquote .quote-entry:eq("+quote_current+")").show();
	
	
	
	// Equal height boxes
	equalize_heights();
	
	// Remove default text for newsletter email
	$("#follow-form input[name=sts_email]").focus(function() {
		if ($(this).attr("alt") == 0) {
			$(this).val("");
			$(this).attr("alt", "1");
		} //end if
	});
	
	// Hidden input
	$("input[type=hidden]").css('display', 'none');
	
	
	// Comments
	$(".prog a.ask-question").click(function() {
		$(this).parent().children(".comment-frm").slideToggle();
		return false;
	});
	$(".comment-frm a.toggle").click(function() {
		$(this).parent().children("form").slideToggle();
		return false;
	});
	
	
	// Main headlines
	$("#main h2").each(function() {
		//console.log($(this).height());
		if ($(this).height() > 50) $(this).addClass("r2");
	});
	
});

function equalize_heights() {
	//console.log("Equalizing...");
	//$("#main, #sidebar").equalHeight();
} //end equalize_heights();

$.fn.equalHeight = function() {
	var tallest = 0;
	$(this).each(function() {
		$(this).css("min-height", "0");
		$(this).css("height", "auto");
		var this_height = $(this).height();
		if (this_height > tallest) {
			tallest = this_height;
		} //end if
	});
	$(this).css("min-height", tallest+"px");
	//$(this).height(tallest);
};

var quote_current = 0;
var quote_speed = 7000;
var quote_interval = setTimeout(crossfade_quotes, quote_speed);

function crossfade_quotes() {
	// Clear the interval
	clearTimeout(quote_interval);
	
	var quote_count = $("#pushquote .quote-entry").length;
	
	if (quote_count > 1) {
		$("#pushquote .quote-entry:eq("+quote_current+")").fadeOut(500, function() {
			quote_current++;
			
			if (quote_current >= $("#pushquote .quote-entry").length) quote_current = 0;
			
			// Show next quote
			$("#pushquote .quote-entry:eq("+quote_current+")").fadeIn(500);
			
			// Start new interval
			quote_interval = setTimeout(crossfade_quotes, quote_speed);
		});
	} //end if
	
} //end crossfade_quotes()
