$().ready(function(){
	// use the search form's label to fade in/out on click
	if ($("#searchtxt").val()=="") {
		$("#search label").css("visibility","visible");
	}
	$("#searchtxt").focus( function() {
		$("#search label").fadeOut("fast");
	});
	$("#searchtxt").blur( function() {
		if ($("#searchtxt").val()=="") {
			$("#search label").fadeIn("fast");
		}
	});
	
	// cycle thru feature images on homepage
	$('#feature').cycle({ 
	    fx:     'fade', 
	    speed:  'fast', 
	    next:   '#next', 
		prev:   '#prev',
	    timeout: 8000 
	});
	
	$(".box h3").hover(function(){
		$(this).parent(".box").children("div.img").children("a").css("filter",".3");
	},function(){
		$(this).parent(".box").children("div.img").children("a").css("filter","0");
	});
	
	// add class to first event box to create right margin
	$("#boxes .events div.event").eq(0).addClass("event1");
	
	// create two <ul> columns from columns with a class of "twoCol"
	$("ul.twoCol").each( function() {
		$(this).addClass("leftCol");
		listCols($(this).attr("id"));
	});
	
	// add class to #main if 3-column layout is needed
	var sidebarCount = $("#content").find(".page-sidebar").length;
	if (sidebarCount>0) {
		$("body").addClass("col3");
	}
	
	// use the search form's label to fade in/out on click
	if ($("#q").val()=="") {
		$("#search label").css("visibility","visible");
	}
	$("#q").focus( function() {
		$("#search label").fadeOut("fast");
	});
	$("#q").blur( function() {
		if ($("#q").val()=="") {
			$("#search label").fadeIn("fast");
		}
	});
	
	// Capture click on footer newsletter subscribe link and display subscribe form
	$("#newsletter a").click( function() {
		$(this).css("display","none");
		$("#newsletter #subscribeForm").css("display","block");
		return false;
	});
	
	// use the subscribe form's label to fade in/out on click
	if ($("#jrbiu-jrbiu").val()=="") {
		$("#subscribeForm label").css("visibility","visible");
	}
	$("#jrbiu-jrbiu").focus( function() {
		$("#subscribeForm label").fadeOut("fast");
	});
	$("#jrbiu-jrbiu").blur( function() {
		if ($("#jrbiu-jrbiu").val()=="") {
			$("#subscribeForm label").fadeIn("fast");
		}
	});
	
	
});

function listCols(id) {
	$("ul#"+id).after('<ul id="'+id+'2" class="rightCol"></ul>');
	var num = $("ul#"+id+" li").length;
	var numHalf = Math.round(num/2);
	for (i=numHalf; i<num; i++) {
		var item = $("ul#"+id+" li").get(numHalf);
		$(item).appendTo('ul#'+id+'2');
	}
}
