/* Tips and techniques page Javascript */

/* Load-time stuff */
$(document).ready(function() {
	//Hide all of the tips initially
	$("dl").hide();
	
	//Show the relevant section when a link is clicked, hide the others.
	//And scroll to the clicked tip.
	$("li a").click(function(){
		//If this is a link, just jump site.
		if ($(this).parent().hasClass("externalLink")) {
			return true;
		}
		
		//return false;
		
		//There are four sections: tips, faqs, techniques and links.
		//If the link is in the links section we don't need to do anything because we'll have already jumped site
		//Work out which section the clicked link is in, show that, and hide the rest.
		var item = $(this);
		
		if ($(this).parent().hasClass("tips")) {
			$("#tips").show(1,function(){scrollToElement(item);});
			$("#faqs").hide(1);
			$("#techniques").hide(1);
		}
		else if ($(this).parent().hasClass("faqs")) {
			$("#tips").hide(1);
			$("#faqs").show(1,function(){scrollToElement(item);});
			$("#techniques").hide(1);
		}
		else if ($(this).parent().hasClass("techniques")) {
			$("#tips").hide(1);
			$("#faqs").hide(1);
			$("#techniques").show(1,function(){scrollToElement(item);});
		}
		return false;
	});
	
});

