jQuery.noConflict();
jQuery(document).ready(function($) {
	$(".pagenav").children("li").children("ul").children("li").bind("mouseover", function(){
		$(this).children("ul").show();
	});
	$(".pagenav").children("li").children("ul").children("li:not(.current_page_item,.current_page_ancestor)").bind("mouseout", function(){
		$(this).children("ul").hide();
	});
	
	
	//philosophy navigation
	var currentphilosophy = "b";
	var prevphilosophy = "e";
	var nextphilosophy = "r";
	
	$("#prev_slide").bind("click", function(){
		//get the previous letter
		var prevLetter = prevphilosophy;
		
		//hide the current slide
		$(".slide").hide();
		//hide the current image
		$("#slide_" + currentphilosophy + "_image").hide();
		
		//show the previous slide
		$("#slide_" + prevLetter + "_copy").show();
		//show previous image
		$("#slide_" + prevLetter + "_image").show();
		
		//turn off the current letter
		$(".letter").removeClass("on");
		//turn on the next letter
		$("#" + prevLetter).addClass("on");
		
		//reset variables
		nextphilosophy = currentphilosophy;
		currentphilosophy = prevLetter;
		//check to see if this is the last letter. If it is start the loop over.
		if(prevphilosophy = $("#" + prevLetter).prev().attr("id") == "prev_slide"){
			prevphilosophy = "e";
		}else{
			prevphilosophy = $("#" + prevLetter).prev().attr("id");
		}
		
		
	});
	$("#next_slide").bind("click", function(){
		//get the next letter
		var nextLetter = nextphilosophy;
		
		//hide the current slide
		$("#slide_" + currentphilosophy + "_copy").hide();
		//hide the current slide
		$("#slide_" + currentphilosophy + "_image").hide();

		//show the next slide
		$("#slide_" + nextLetter + "_copy").show();
		//show next image
		$("#slide_" + nextLetter + "_image").show();
		
		//turn off the current letter
		$(".letter").removeClass("on");
		//turn on the next letter
		$("#" + nextLetter).addClass("on");
		
		//reset variables
		//check to see if this is the last letter. If it is start the loop over.
		if($("#" + nextLetter).next().attr("id")=="next_slide"){
			nextphilosophy = "b";
		}else{
			nextphilosophy = $("#" + nextLetter).next().attr("id");
		}
		prevphilosophy = currentphilosophy;
		currentphilosophy = nextLetter;
		
	});
	
	//Bark Art functionality
	$(".barkartthumbs").children("img").bind("mouseover",function(){
		var imageId = $(this).attr("id");
		$(".image_big").hide();
		$("#" + imageId + "_big").show();
	});
	
	//The Work functionality
	$(".workIcon").bind("mouseover",function(){
		//get the highlights
		var highlights = $(this).children(".highlights").text();
		
		//reset them all to normal
		$(".rollHighlight").children(".highlighton").hide();
		$(".rollHighlight").children(".highlightOff").hide();
		$(".rollHighlight").children(".highlight").show();
		
		//loop through all of the highlight options
		$.each($(".rollHighlight"), function(i,v) {
			//turn off the normal state
			$(this).children(".highlight").hide();
			
			//if they are in the highlights array then turn them on, otherwise turn them off
			if(highlights.indexOf($(this).attr("id")) > -1){
				$(this).children(".highlighton").show();
			}else{
				$(this).children(".highlightOff").show();
			}
		});
		
		//hide the off image
		$(this).children(".offworkimage").hide();
		
		//show the on image
		$(this).children(".onworkimage").show();
	});
	
	$(".workIcon").bind("mouseout",function(){
		//reset all the highlights to normal
		$(".rollHighlight").children(".highlighton").hide();
		$(".rollHighlight").children(".highlightOff").hide();
		$(".rollHighlight").children(".highlight").show();
		
		//hide the on images
		$(this).children(".onworkimage").hide();
		
		//show the off images
		$(this).children(".offworkimage").show();
	});
	
	//Healthcare clients rollover
	$(".clienttable").children("tbody").children("tr").children("td").bind("mouseover", function(){
		$(this).children("img").hide();
		$(this).children(".clienttext").show();
	});
	$(".clienttable").children("tbody").children("tr").children("td").bind("mouseout", function(){
		$(this).children("img").show();
		$(this).children(".clienttext").hide();
	});
	
	//menu rollover
	$(".page_item").children("a").children("img").bind("mouseover", function(){
		$(this).parent("a").children(".mainNavOff").hide();
		$(this).parent("a").children(".mainNavOn").show();
	});
	$(".page_item").children("a").children("img").bind("mouseout", function(){
		var classname = $(this).parent("a").parent("li").attr("class");

		if (classname.indexOf("current_page_ancestor") < 0) {
			$(this).parent("a").children(".mainNavOff").show();
			$(this).parent("a").children(".mainNavOn").hide();
		}
	});
});

