// JavaScript Document

$().ready(function() {
	$("#top").click(function() {
		$("html").animate({scrollTop:0}, 'slow');
	});
	$("#contact, #about").click(function() {
		$("html").animate({scrollTop:$(document).height()}, 'slow');
	});

	$("form img").hide();
	$("form#contactForm").submit(function(){
		$("form img").show("slow");
		var str = $("form#contactForm").serialize();
		$.ajax({
			type: "POST",
			url: "contact.php",
			data: str,
			success: function(msg){
				$("#note").ajaxComplete(function(event, request, settings){
				$("form img").hide("slow");
				if(msg == 'OK') // Message Sent? Show the 'Thank You' message and hide the form
				{
					$("div#note").addClass("notification_ok");
					result = 'Your message has been sent. Thanks!';
					//$("#fields").hide();
					$("input#submit").hide("slow");
				}
				else
				{
					result = msg;
				}
				$(this).html(result);
				$("div#note").addClass("notification_error");
			});
		}
	});
	return false;
	});
});

// Initially set opacity on thumbs and add
// additional styling for hover effect on thumbs
var onMouseOutOpacity = 0.67;
$('#thumbs-adv ul.thumbs li').css('opacity', onMouseOutOpacity)
	.hover(
		function () {
			$(this).not('.selected').fadeTo('fast', 1.0);
		}, 
		function () {
			$(this).not('.selected').fadeTo('fast', onMouseOutOpacity);
		}
	);

$(document).ready(function() {
	// Initialize Advanced Galleriffic Gallery
	var galleryAdv = $('#gallery-adv').galleriffic('#thumbs-adv', {
		delay:                  4000,
		numThumbs:              12,
		preloadAhead:           10,
		enableTopPager:         true,
		enableBottomPager:      true,
		imageContainerSel:      '#slideshow-adv',
		controlsContainerSel:   '#controls-adv',
		captionContainerSel:    '#caption-adv',
		loadingContainerSel:    '#loading-adv',
		renderSSControls:       true,
		renderNavControls:      true,
		playLinkText:           'Play Slideshow',
		pauseLinkText:          'Pause Slideshow',
		prevLinkText:           '&lsaquo; Previous Photo',
		nextLinkText:           'Next Photo &rsaquo;',
		nextPageLinkText:       'Next &rsaquo;',
		prevPageLinkText:       '&lsaquo; Prev',
		enableHistory:          true,
		autoStart:              false,
		onChange:               function(prevIndex, nextIndex) {
			$('#thumbs-adv ul.thumbs').children()
				.eq(prevIndex).fadeTo('fast', onMouseOutOpacity).end()
				.eq(nextIndex).fadeTo('fast', 1.0);
		},
		onTransitionOut:        function(callback) {
			$('#slideshow-adv, #caption-adv').fadeOut('fast', callback);
		},
		onTransitionIn:         function() {
			$('#slideshow-adv, #caption-adv').fadeIn('fast');
		},
		onPageTransitionOut:    function(callback) {
			$('#thumbs-adv ul.thumbs').fadeOut('fast', callback);
		},
		onPageTransitionIn:     function() {
			$('#thumbs-adv ul.thumbs').fadeIn('fast');
		}
	});
	
	// Initialize Minimal Galleriffic Gallery
	var galleryMin = $('#gallery-min').galleriffic('#thumbs-min', {
		imageContainerSel:      '#slideshow-min',
		controlsContainerSel:   '#controls-min'
	});
});