/* Declare a namespace for the site */
var Site = window.Site || {};

/* Create a closure to maintain scope of the '$'
   and remain compatible with other frameworks.  */
(function($) {

	//same as $(document).ready();
	$(function() {
		$('.sf-menu').superfish();

		$('.before-after li a').fancybox();
		$('.howitworks li a').fancybox();

		$('.vidlink').click(function(){
			$.fancybox({
			'padding'			: 0,
			'autoScale'		: false,
			'transitionIn'		: 'none',
			'transitionOut'	: 'none',
			'title'			: this.title,
			'width'			: 560,
			'height'			: 340,
			'href'			: this.href = this.href.replace(new RegExp("watch\\?v=", "i"), 'v/') + '&autoplay=1',
			'type'			: 'swf',
			});
			return false;

		});

		$("p.message").click(function(){ $(this).slideUp(500); });

		$('#slider ul').cycle({
			fx: 'fade',
			speed: 1200,
			timeout: 4800,
			pause: 1
		});

		// Fix applied so menu appears OVER cycled images
		// Reverses the default z-index stacking order of the elements
		var startIndex = 1500;
		$('div').each(function() {
			$(this).css('zIndex', startIndex);
			startIndex -= 5;
		});

		$('#hiw-slide1').css('display','block');
		$('#hiw-nav a')
			.click(
				function(){
					var x = $(this).attr('href');
					$('.hiw-slide').css('display','none');
					$('#'+x).css('display','block');
					return false;
				}
			)
			.hover(
				function () {
					var hvrTxt = $(this).attr('title');
					$(this).append('<span>'+hvrTxt+'</span>');
				},
				function () {
					$(this).find("span:last").remove();
				}
			);

		$('.bigShow').click(function(){
			var x = $(this).attr('href');
			$('#bigImg').attr('src',x);
			return false;
		});
	});

})(jQuery);
