$(function() {  
  
  // fit home photos module text
	$('.module.home-photos li span').fitText(.7);
	
	// add jcarousel to photo set	
	$('.cdv-gal').jcarousel({	visible: 8 });
	$('.photoset').css('visibility', 'visible');
	
	$('.ss1').cycle({
		fx: 'fade',
		speed: 1400,
		random: 1,
		fit: 1,
		delay: 1000,
		timeout: 4000
	});
	
	$('.ss2').cycle({
		fx: 'fade',
		speed: 1400,
		random: 1,
		fit: 1,
		delay: 2500,
		timeout: 3000
	});
	
	$('.ss3').cycle({
		fx: 'fade',
		speed: 1400,
		random: 1,
		fit: 1,
		delay: 500,
		timeout: 5000
	});
	
	// scroll gala and about
	$('.gala-main .sub-nav, .about-main .sub-nav').localScroll({
		offset: {left: 0, top: -170},
		easing: 'easeInOutExpo'
	});	
	
	// scroll photos
	$('.sub-nav-photos').localScroll({
		offset: {left: 0, top: -180},
		easing: 'easeInOutExpo'
	});
	
	// add jancybox
	$('.hdr-video, .open-video').fancybox({
		'frameWidth'	: 800,
		'frameHeight': 453
	});	
	
	// cleartype fix
	$('h1, h2, h3, h4, h5, p, li').ieffembedfix();
  
  // set the waypoint to highlight the sub-navs
  $('#content > section, #cdv-photos > section').waypoint({ offset: 400 });
	
	$('body').delegate('#content > section, #cdv-photos > section', 'waypoint.reached', function(event, direction) {
		var $active = $(this);
		
		if (direction === "up") {
			$active = $active.prev();
		}
		if (!$active.length) $active.end();
		
		$('.section-active').removeClass('section-active');
		$active.addClass('section-active');
		
		$('.link-active').removeClass('link-active');
		$('a[href=#'+$active.attr('id')+']').addClass('link-active');
	});
	
	$('.sub-nav a').click(function() {
		$(this).addClass('link-active');
	}).eq(0).addClass('link-active');
	
	
	// cross browser placeholder text
	if(!Modernizr.input.placeholder){	 
		$('[placeholder]').focus(function() {
		  var input = $(this);
		  if (input.val() == input.attr('placeholder')) {
			input.val('');
			input.removeClass('placeholder');
		  }
		}).blur(function() {
		  var input = $(this);
		  if (input.val() == '' || input.val() == input.attr('placeholder')) {
			input.addClass('placeholder');
			input.val(input.attr('placeholder'));
		  }
		}).blur();
		$('[placeholder]').parents('form').submit(function() {
		  $(this).find('[placeholder]').each(function() {
			var input = $(this);
			if (input.val() == input.attr('placeholder')) {
			  input.val('');
			}
		  })
		});	 
	}	
	
});

