;(function($) {
$(document).ready(function() {
	
	$('#nav ul li.topnav').hoverIntent({
		over: function() {
			var navitem = $(this);
			navitem.toggleClass('hover')
			navitem.children('div.dropdown').slideToggle(500);
		},
		out: function() {
			var navitem = $(this);
			if(navitem.children('div.dropdown').length) {
				navitem.children('div.dropdown').slideToggle(500,function() {
					navitem.toggleClass('hover');
				});
			} else {
				navitem.toggleClass('hover');
			}
		},
		timeout: 50
	});
	
	if($('#whats-happening').length) {
		$.getScript('/js/jquery.tools.tab.slideshow.min.js', function(data, textStatus){
			$('#whats-happening ul.tabs').tabs('#whats-happening div.panes > div.pane', {
				effect: 'fade',
				rotate: true
			}).slideshow({
				prev: '#whats-happening .nav .prev a',
				next: '#whats-happening .nav .next a',
				autoplay: true,
				interval: 8000
			});
		});
	}
	
	if($('#slider').length) {
		$.getScript('/js/jquery.nivo.slider.pack.js', function(data, textStatus){
			var startslide = Math.floor(Math.random() * $('#slider img').length);
			$('#slider').nivoSlider({
				effect:'random', // Specify sets like: 'fold,fade,sliceDown'
				slices:15, // For slice animations
				boxCols: 8, // For box animations
				boxRows: 4, // For box animations
				animSpeed:500, // Slide transition speed
				pauseTime:3000, // How long each slide will show
				startSlide:startslide, // Set starting Slide (0 index)
				directionNav:true, // Next & Prev navigation
				directionNavHide:false, // Only show on hover
				controlNav:true, // 1,2,3... navigation
				controlNavThumbs:false, // Use thumbnails for Control Nav
				controlNavThumbsFromRel:false, // Use image rel for thumbs
				controlNavThumbsSearch: '.jpg', // Replace this with...
				controlNavThumbsReplace: '_thumb.jpg', // ...this in thumb Image src
				keyboardNav:true, // Use left & right arrows
				pauseOnHover:false, // Stop animation while hovering
				manualAdvance:false, // Force manual transitions
				captionOpacity:0.8, // Universal caption opacity
				prevText: '', // Prev directionNav text
				nextText: '', // Next directionNav text
				beforeChange: function(){}, // Triggers before a slide transition
				afterChange: function(){}, // Triggers after a slide transition
				slideshowEnd: function(){}, // Triggers after all slides have been shown
				lastSlide: function(){}, // Triggers when last slide is shown
				afterLoad: function(){} // Triggers when slider has loaded
			});
		});
	}

	/*
	$('#facebook').attr('href', function(i, val) {
		return val + '?u=' + encodeURIComponent(document.location) + '&t=' + encodeURIComponent(document.title) + '';
	});
	$('#twitter').attr('href', function(i, val) {
		return val + '?url=' + encodeURIComponent(document.location);
	});
	*/
	$('#search #CAT_Search').blur(function() {
		if($(this).val()=='') $(this).val('Search Our Site').css('color','#777');
	}).focus(function() {
		if($(this).val()=='Search Our Site') $(this).val('').css('color','#000');
	});
	$('#footer .newsletter #CLFullName').blur(function() {
		if($(this).val()=='') $(this).val('Name').css('color','#666');
	}).focus(function() {
		if($(this).val()=='Name') $(this).val('').css('color','#000');
	});
	$('#footer .newsletter #CLEmailAddress').blur(function() {
		if($(this).val()=='') $(this).val('Email Address').css('color','#666');
	}).focus(function() {
		if($(this).val()=='Email Address') $(this).val('').css('color','#000');
	});
})
})(jQuery);

function checkWholeForm81432(theForm) {
	var why = "";
	if (theForm.EmailAddress) why += checkEmail(theForm.EmailAddress.value);
	//if (theForm.CaptchaV2) why += isEmpty(theForm.CaptchaV2.value, "Enter Word Verification in box below");
	if (why != "") {
		alert(why);
		return false;
	}
	theForm.submit();
	return false;
}

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-21717607-1']);
  _gaq.push(['_trackPageview']);

  (function() {
	var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
	ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
	var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
