$(document).ready(function() {
	/* Index Init */
	if (jQuery().nivoSlider) {
		$("#slider").hide().delay(300).fadeIn(2000);
		$("#slider").nivoSlider({
			directionNavHide: false,
			effect: "fold",
			pauseTime: 4000,
			controlNav: false
		});
		$("#slideshow-loader").fadeOut("slow");
	}

    $(".modelLineup").jCarouselLite({
        btnNext: ".modelLineupNextBtn",
        btnPrev: ".modelLineupPrevBtn",
		easing: "easeOutQuint",
		speed: 1000,
		scroll: 5,
		visible: 5		
    });
	
    $(".featuredLineup").jCarouselLite({
        btnNext: ".featuredLineupNextBtn",
        btnPrev: ".featuredLineupPrevBtn",
		easing: "easeOutQuint",
		speed: 1000,
		scroll: 1,
		visible: 1
    });
	
	$(".modelLineup").css("left", 900).delay(1200).animate({ "left": 0 }, 1500, "easeOutExpo");
	$(".featuredLineup").hide().delay(2000).fadeIn(2000);
	
	var modelAnimateDuration = 150;
	var modelJumpHeight = "5px";
	$(".modelLineup li").hover(
		function () {
			$(this).stop().animate({ "margin-top": "-=" + modelJumpHeight }, modelAnimateDuration);    
		}, 
		function () {
			 $(this).stop().animate({ "margin-top": 0 }, modelAnimateDuration);

		}
	);
	$(".featuredLineup li").hover(
		function () {
			$(this).stop().animate({ "margin-top": "-=" + modelJumpHeight }, modelAnimateDuration);    
		}, 
		function () {
			 $(this).stop().animate({ "margin-top": 0 }, modelAnimateDuration);

		}
	);
	
	$("a.colorbox").colorbox({
		scrolling: false,
		onComplete: function() {
			$.colorbox.resize();
		}
	});
	
	/* Calendar */
	jQuery(function ($) {
		var minDate, maxDate;
			
		$("input.date").each(function () {
			if ($(this).attr("name").indexOf("dob") === -1) {
				$(this).constrainedCalendar({
					defaultDateDelay: 6,
					allowDaysAhead: 14,
					allowToday: true,
					allowHolidays_US: false,
					allowWeekdays: [
						 true,
						 true,
						 true,
						 true,
						 true,
						 true,
						 true
					]
				});
			}
			else {
				// DOB fields get a different format
				minDate = new Date((new Date()).getFullYear() - 110, 0, 1);
				maxDate = new Date((new Date()).getFullYear() - 12, 0, 1);
				$(this).constrainedCalendar({
					defaultDateDelay: 1,
					allowDaysAhead: 0,
					allowToday: true,
					allowHolidays_US: true,
					allowWeekdays: [true, true, true, true, true, true, true],
					displayDateFormat: "MM/dd/yyyy",
					minDate: minDate,
					maxDate: maxDate,
					customDate: function (date) {
						return [1, ''];
					}
				});
			}
		});
			
		if (jQuery.browser.msie) {
			$("input.date").parent("label").click(function () {
				$("input.date", this).focus();
			});
		}
	});
});