var menuHomePage = "index.shtml";
var menuSite = "/";

$(document).ready(function(){
	handleMenu();
	handleBanner();
	handleAreas();
	handlePrettyPhoto();
	handleSlides();
	handleFaders();
});
function handleBanner() {
	$("#banner").css("cursor","pointer").click(function(){window.location="/";});
}
function handleAreas() {
	// in the main content area, put in a link to Top below each.
	$("#left-column .area").after("<div class='topLink'><a href='#top'>^ Top</a></div>");
	// make sure the bottom clears
	$(".area").append("<div class='clear'></div>");
}
function handlePrettyPhoto() {
	$("a[rel^='prettyPhoto[overview]']").prettyPhoto({
		theme: 'light_rounded',
		opacity: 0.30,
		default_width: 288
	});
}
function handleSlides() {
	$('.slides').innerfade({ speed: 'slow', timeout: 2500, type: 'sequence' });
}
function handleFaders() {
	$('.faders').innerfade({ speed: 'slow', timeout: 14000, type: 'sequence' });
	$('.faders-random').innerfade({ speed: 'slow', timeout: 14000, type: 'random' });
}
function handleMenu() {
	var currentPathname = location.pathname;
	if (currentPathname && currentPathname != "") {

		// If the currentPathname ends with "/", add on "index.shtml"
		if (currentPathname.substring(currentPathname.length-1) == "/") currentPathname += menuHomePage;

		// If the currentPathname includes "/farms/", set the current page to farms home page
		if (currentPathname.indexOf("/farms/") > -1) currentPathname = menuSite + "farms/index.shtml";

		// Look for a link that begins with the currentPathname
		var anchorSelector = "a[href^='" + currentPathname + "']";
		$("#main-menu ul.menu " + anchorSelector).addClass("current");
		$("#top-menu ul.menu " + anchorSelector).addClass("current");
	}
}

