$(document).ready(function(){
	
	/* Fade link color on hover */
	$('.fade').dwFadingLinks({
			color: '#ffffff',
			duration: 700
	});

	// check for cookie anytime a page loads...to maintain the setting from previous page
	if (($.cookie('dsf-dim-bg')) && ($.cookie('dsf-dim-bg') == "true")) {
		$("body").css( 'backgroundImage','url(/images/site/global/20102405gbgd.jpg)' );
		$("#dim-bg").html('Restore Background');
		$.cookie('dsf-dim-bg','true', { path: '/', expires: 31 });
	} else {
		$("body").css( 'backgroundImage','url(/images/site/global/20102405gbg.jpg)' );
		$("#dim-bg").html('Dim Background');
		$.cookie('dsf-dim-bg','false', { path: '/', expires: 31 });
	}
	
	$("#dim-bg").toggle(
		function () {
			if ($.cookie('dsf-dim-bg') != null) {
				if ($.cookie('dsf-dim-bg') == "true") {
					$("body").css( 'backgroundImage','url(/images/site/global/20102405gbg.jpg)' );
					$(this).html('Dim Background');
					$.cookie('dsf-dim-bg','false', { path: '/', expires: 31 });
				} else {
					$("body").css( 'backgroundImage','url(/images/site/global/20102405gbgd.jpg)' );
					$(this).html('Restore Background');
					$.cookie('dsf-dim-bg','true', { path: '/', expires: 31 });
				}
			} else {
				$("body").css( 'backgroundImage','url(/images/site/global/20102405gbgd.jpg)' );
				$(this).html('Restore Background');
				$.cookie('dsf-dim-bg','true', { path: '/', expires: 31 });
			}
		},
		function () {
			if ($.cookie('dsf-dim-bg') != null) {
				if ($.cookie('dsf-dim-bg') == "true") {
					$("body").css( 'backgroundImage','url(/images/site/global/20102405gbg.jpg)' );
					$(this).html('Dim Background');
					$.cookie('dsf-dim-bg','false', { path: '/', expires: 31 });
				} else {
					$("body").css( 'backgroundImage','url(/images/site/global/20102405gbgd.jpg)' );
					$(this).html('Restore Background');
					$.cookie('dsf-dim-bg','true', { path: '/', expires: 31 });
				}
			} else {
				$("body").css( 'backgroundImage','url(/images/site/global/20102405gbg.jpg)' );
				$(this).html('Dim Background');
				$.cookie('dsf-dim-bg','false', { path: '/', expires: 31 });
			}
		}
	);
	
	

	$("#toggle-thumbnails").click(
		function () {
			if ($(".galleria-thumbnails-container").is(':visible')) {				
				$(".galleria-thumbnails-container").fadeToggle("slow");
				$(this).html("Show Thumbnails");
			} else {
				$(".galleria-thumbnails-container").fadeToggle("slow");
				$(this).html("Hide Thumbnails");
			}
			return false;
		}
	);
	
});

/* functions to toggle thumbnails on slideshow */
$.fn.fadeToggle = function(speed, easing, callback) {
	return this.animate({opacity: 'toggle'}, speed, easing, callback);  
};

/* Thanks to David at http://davidwalsh.name/fading-links-jquery-dwfadinglinks */
/* plugin */
$.fn.dwFadingLinks = function(settings) {
	settings = $.extend({
		color: '#ffffff',
		duration: 500
	}, settings);
	return this.each(function() {
		var original = $(this).css('color');
		$(this).mouseover(function() { $(this).animate({ color: settings.color },settings.duration); });
		$(this).mouseout(function() { $(this).animate({ color: original },settings.duration); });
	});
};
