/* The following is used to comply with XHTML Strict ruels of now Target attributes for anchor elements */
function externalLinks() {
	jQuery('a[rel~="external"]').click(function(){
		jQuery(this).attr({
			"target":"_blank"
		});
	});
}

//This addiitonal piece helps JQuery work within Silverstripe and the legacy fragments of Prototype
;(function($) {
	$(document).ready(function() {
  		/* Local Scroll */
  		$('a').smoothScroll({exclude:['.header .hgroup h1 a', '#PageCommentsPagination p a', '#PageNumbers p span a', 'a.next', 'a.prev', 'li.search-link a']});
		
		//Run to set up external links
		externalLinks();
		
		//Hide list item > 5 in the Sub Main Navigation
		$('ul.subNav').each(function(i){
			$(this).find('li:gt(4)').hide();
		});
		
		

		
		
		//Subscribe Modal
		//$(".subscribe").colorbox({width:"50%", inline:true, href:"#mc_embed_signup"});
		$(".subscribe").colorbox({href:"contact-us/subscribe-to-our-free-email-newsletter/ div#mailChimp"});
		
		//Search Box Toggle		
		$("#search-box").hide().find('input.text').val('Search');
		$("#search-box").css('top' , '1px');
		
		$("#SearchForm_SearchForm_Search").focus(function() {
			if($(this).val() == "Search") $(this).val("");
		}).blur(function() {
			if($(this).val() == "") $(this).val("Search");
		});
		
		$('li.search-link a').bind("click", function(event){
			$(this).toggleClass('active');
			$("#search-box").toggle().find('input.text').val("").focus();
			return false;
		});
		
		
		//Toggle the lights for Blog Post
		$('a.lightit').bind("click", function(event){
			$('body').toggleClass('light');
			return false;
		});
		
	// Standard jQuery footer
	});
})(jQuery);
