// JavaScript Document

$(window).load(function() {
	//subheader slider
	$('#subheader').nivoSlider({
		effect:'fade', //sliceDown,sliceDownLeft,sliceUp,sliceUpLeft,sliceUpDown,sliceUpDownLeft,fold,fade,random,slideInRight,slideInLeft

		//# sliceDown # sliceDownLeft # sliceUp # sliceUpLeft # sliceUpDown # sliceUpDownLeft # fold # fade
		slices: 3,
		animSpeed: 750,
		pauseTime: 4500,
		startSlide: 0, //Set starting Slide (0 index)
		directionNav: false, //Next & Prev
		directionNavHide: false, //Only show on hover
		controlNav: false, //1,2,3... //false for home page, true for product pages
		controlNavThumbs: true, //Use thumbnails for Control Nav
		controlNavThumbsSearch: 'large', //Replace this with...
		controlNavThumbsReplace: 'small', //...this in thumb Image src
		keyboardNav: true, //Use left & right arrows
		pauseOnHover: false, //Stop animation while hovering
		manualAdvance: false, //Force manual transitions
		captionOpacity: 1, //Universal caption opacity
		beforeChange: function(e){
			//$('a.nivo-control.active').animate({backgroundColor: '#FFF'});
			//$('a.nivo-control div').fadeOut();

		},
		afterChange: function(){
			//$('a.nivo-control:not(.active) div').fadeOut();
		},
		slideshowEnd: function(){} //Triggers after all slides have been shown
	});
	
	//home slider
	$('#slider').nivoSlider({
		effect:'fade', //sliceDown,sliceDownLeft,sliceUp,sliceUpLeft,sliceUpDown,sliceUpDownLeft,fold,fade,random,slideInRight,slideInLeft

		//# sliceDown # sliceDownLeft # sliceUp # sliceUpLeft # sliceUpDown # sliceUpDownLeft # fold # fade
		slices: 3,
		animSpeed: 500,
		pauseTime: 4500,
		startSlide: 0, //Set starting Slide (0 index)
		directionNav: (window.location.pathname != '/'), //Next & Prev
		directionNavHide: false, //Only show on hover
		controlNav: false, //1,2,3... //false for home page, true for product pages
		controlNavThumbs: true, //Use thumbnails for Control Nav
		controlNavThumbsSearch: 'large', //Replace this with...
		controlNavThumbsReplace: 'small', //...this in thumb Image src
		keyboardNav: true, //Use left & right arrows
		pauseOnHover: false, //Stop animation while hovering
		manualAdvance: false, //Force manual transitions
		captionOpacity: 1, //Universal caption opacity
		beforeChange: function(e){
			//$('a.nivo-control.active').animate({backgroundColor: '#FFF'});
			//$('a.nivo-control div').fadeOut();

		},
		afterChange: function(){
			//$('a.nivo-control:not(.active) div').fadeOut();
		},
		slideshowEnd: function(){} //Triggers after all slides have been shown
	});
	
	//home intro
	if (window.location.pathname == '/') {
		$('div.nivo-caption, a.logo img, #nav, #home_content, #footer_left, #footer_right').hide().stop(true, true).delay(2100).fadeIn('slow'); //stop is for the slider caption
		$('#white_mask').show().animate({
			width: 0
		}, 1000);
		$('#intro').height(0).delay(700).animate({
			height: 600
		}, 800);
		$('#home_content_container').width(0).delay(1200).animate({
			width: '100%'
		}, 900);
		$('#home_content_container').delay(1200).animate({
			left: 0
		}, 890);
		//gallery
	}
	
	//subpage intro
	//$('div.page_title').width(0).animate({width: 590}, 1000);
	
	//project_gallery hover effect
	$('div.project_gallery a').hover(
		function() {
			$(this).animate({color: '#009FE2'}, 150).children(':first').stop().fadeTo(150, .5);
		},
		function () {
			$(this).animate({color: '#373D41'}, 'slow').children(':first').fadeTo('slow', 1);
		}
	);
	
	//contact
	$('#contact_submit').click(function() {
		$.post('ajax_contact.php', $('#contact_form').serialize(), function(response) {
			if (response == 'Message sent!') {
				$('#contact_form :input').val('');
			}
			$('#contact_message div').fadeOut('fast', function() {
				$(this).html(response).fadeIn('fast');
			});
		});
		return false;
	});
});
