jQuery(document).ready(function() {

	/*
	*   Examples - images
	*/
	
	$("a#example1").fancybox({
		'titleShow'     	: true,
		'titlePosition' 	: 'below',
	});
		
	$("a#example2").fancybox({
		'titleShow'     : false,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
		'easingIn'      : 'easeOutBack',
		'easingOut'     : 'easeInBack'
	});
	
	$("a#example3").fancybox({
	    'titleShow'     : false,
		'transitionIn'	: 'none',
		'transitionOut'	: 'none'
	});
	
	$("a#example4").fancybox();
	
	$("a#example5").fancybox({
		'titlePosition'  : 'inside'
	});
	
	$("a#example6").fancybox({
		'titlePosition'  : 'over'
	});
	
	
	$("a[rel=example_group]").fancybox({
			'padding'			: 0,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'type'              : 'image',
			'changeFade'        : 0,
		'titlePosition' 	: 'below',
		'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
		    return '<div id="tip11-title">Image ' +  (currentIndex + 1) + ' / ' + currentArray.length + ' ' + title + '</div>';
		}
	});
	
	/*
	*   Examples - various
	*/
	
	$("#various1").fancybox({
		'titlePosition'		: 'inside',
		'transitionIn'		: 'none',
		'transitionOut'		: 'none'
	});
	
	$("#various2").fancybox({
		'modal' : true
	});
	
	$("#various3").fancybox({
		ajax : {
		    type	: "POST",
		    data	: 'mydata=test'
		}
	});

	$("#various4").fancybox({
		ajax : {
		    type	: "POST"
		}
	});
			
	$("#various5").fancybox({
		'width'				: '75%',
		'height'			: '75%',
        'autoScale'     	: false,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
	});
	
	$("#various6").fancybox({
	    'padding'           : 0,
        'autoScale'     	: false,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none'
	});
	
	$("#various7").fancybox({
		onStart		:	function() {
			return window.confirm('Continue?');
		},
		onCancel	:	function() {
			alert('Canceled!');
		},
		onComplete	:	function() {
            alert('Completed!');
		},
		onCleanup	:	function() {
            return window.confirm('Close?');
		},
		onClosed	:	function() {
            alert('Closed!');
		}
	});
	
	$("#various8, #various9").fancybox();
	
	/*
	*   Examples - manual call
	*/

	$("#manual1").click(function() {
		$.fancybox({
			//'orig'			: $(this),
			'padding'		: 0,
			'href'			: 'artwork/spiritspiders/eee_booklet.jpg',
			'title'   		: 'Lorem ipsum dolor sit amet',
			'transitionIn'	: 'elastic',
			'transitionOut'	: 'elastic'
		});
    });
	
	function formatTitle4(title, currentArray, currentIndex, currentOpts) {
    return '<div id="tip11-title">' + (title && title.length ? '' + title + '&nbsp;' : '' ) + '(' + (currentIndex + 1) + '/' + currentArray.length + ')' + '</div>';
}

    $("#eeee").click(function() {
		$.fancybox([
			{
				'href'	: 'artwork/spiritspiders/eee_booklet.jpg',
				'title'	: 'EVOLUTION:ELATION:EXTINCTION  PDF booklet (2009)'
			},
						{
				'href'	: 'artwork/spiritspiders/eee_cover.jpg',
				'title'	: 'PDF booklet (2009)'
			},
						{
				'href'	: 'artwork/spiritspiders/eee_lyrics_1.jpg',
				'title'	: 'PDF booklet (2009)'
			},
						{
				'href'	: 'artwork/spiritspiders/eee_lyrics_2.jpg',
				'title'	: 'PDF booklet (2009)'
			},
						{
				'href'	: 'artwork/spiritspiders/eee_credits.jpg',
				'title'	: 'PDF booklet (2009))'
			},
						{
				'href'	: 'artwork/spiritspiders/eee_cd.jpg',
				'title'	: 'PDF Booklet - "decoder ring" cd label (2009)'
			},
						{
				'href'	: 'artwork/spiritspiders/homicidal.jpg',
				'title'	: 'MP3 - single for "Homicidal" (2009)'
			},
						{
				'href'	: 'artwork/spiritspiders/eee_ad.jpg',
				'title'	: '1/8 page advertisement in NoisyNeighbors magazine No. 28 (2009)'
			},
						{
				'href'	: 'artwork/spiritspiders/eee_ad_photo.jpg',
				'title'	: 'NoisyNeighbors magazine No. 28 - page 13 (2009)'
			}
		], {
			'padding'			: 0,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'type'              : 'image',
			'changeFade'        : 0,
			'titlePosition' 	: 'below',
			'titleFormat'		: formatTitle4
		});
	});
	
	
$("#insurrection").click(function() {
		$.fancybox([
			{
				'href'	: 'artwork/spiritspiders/insurrection_front.jpg',
				'title'	: 'MP3 art/cover (2009)'
			},
						{
				'href'	: 'artwork/spiritspiders/insurrection_back.jpg',
				'title'	: 'MP3 art/back (2009)'
			},
						{
				'href'	: 'artwork/spiritspiders/insurrection_sketch.jpg',
				'title'	: 'concept sketch (2009)'
			}
		], {
			'padding'			: 0,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'type'              : 'image',
			'changeFade'        : 0,
			'titlePosition' 	: 'below',
			'titleFormat'		: formatTitle4
		});
	});

  $("#jupiter").click(function() {
		$.fancybox([
			{
				'href'	: 'artwork/spiritspiders/jupiter_photo1.jpg',
				'title'	: 'Jupiter Rising - Digipak (2008) (1/10)'
			},
						{
				'href'	: 'artwork/spiritspiders/jupiter_cover.jpg',
				'title'	: 'Jupiter Rising - Digipak cover (2008)'
			},
						{
				'href'	: 'artwork/spiritspiders/jupiter_back.jpg',
				'title'	: 'Jupiter Rising - Digipak back/spine (2008)'
			},
						{
				'href'	: 'artwork/spiritspiders/jupiter_inside_cover.jpg',
				'title'	: 'Jupiter Rising - Digipak inside cover (2008)'
			},
						{
				'href'	: 'artwork/spiritspiders/jupiter_inside_back.jpg',
				'title'	: 'Jupiter Rising - Digipack inside back (2008)'
			},
						{
				'href'	: 'artwork/spiritspiders/jupiter_photo3.jpg',
				'title'	: 'Jupiter Rising - Digipack inside (2008)'
			},
			
						{
				'href'	: 'artwork/spiritspiders/jupiter_photo4.jpg',
				'title'	: 'Jupiter Rising - Digipack inside without CD and insert (2008)'
				
			},
						{
				'href'	: 'artwork/spiritspiders/jupiter_booklet_cover.jpg',
				'title'	: 'Jupiter Rising - Booklet front (2008)'
			},
						{
				'href'	: 'artwork/spiritspiders/jupiter_booklet_inside.jpg',
				'title'	: 'Jupiter Rising - Booklet back (2008)'
			},
						{
				'href'	: 'artwork/spiritspiders/jupiter_cd.jpg',
				'title'	: 'Jupiter Rising - CD label (2008)'
			}
		], {
			'padding'			: 0,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'type'              : 'image',
			'changeFade'        : 0,
			'titlePosition' 	: 'below',
			'titleFormat'		: formatTitle4
		});
	});
	
 $("#flyer").click(function() {
		$.fancybox([
			{
				'href'	: 'artwork/spiritspiders/alchemy_flyer_photo.jpg',
				'title'	: 'Flyer - 4 1/8" W x 5 7/8" H" (2007)'
			},
						{
				'href'	: 'artwork/spiritspiders/alchemy_front.jpg',
				'title'	: 'Flyer - 4 1/8" W x 5 7/8" H - front (2007)'
			},
						{
				'href'	: 'artwork/spiritspiders/alchemy_back.jpg',
				'title'	: 'Flyer - 4 1/8" W x 5 7/8" H - back (2007)'
			}
		], {
			'padding'			: 0,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'type'              : 'image',
			'changeFade'        : 0,
			'titlePosition' 	: 'below',
			'titleFormat'		: formatTitle4
		});
	});			
$("#apollo").click(function() {
		$.fancybox([
			{
				'href'	: 'artwork/spiritspiders/apollo_photo.jpg',
				'title'	: 'Apollo - slim case (2007)'
			},
						{
				'href'	: 'artwork/spiritspiders/apollo_front.jpg',
				'title'	: 'Slim case insert - front (2007)'
			},
						{
				'href'	: 'artwork/spiritspiders/apollo_back.jpg',
				'title'	: 'Slim case insert - reverse (2007)'
			},
						{
				'href'	: 'artwork/spiritspiders/apollo_cd.jpg',
				'title'	: 'CD label (2007)'
			}
		], {
			'padding'			: 0,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'type'              : 'image',
			'changeFade'        : 0,
			'titlePosition' 	: 'below',
			'titleFormat'		: formatTitle4
		});
	});	

$("#mercury").click(function() {
		$.fancybox([
			{
				'href'	: 'artwork/spiritspiders/mercury_photo.jpg',
				'title'	: 'Mercury - slim case (2007)'
			},
						{
				'href'	: 'artwork/spiritspiders/mercury_front.jpg',
				'title'	: 'Slim case insert - front (2007)'
			},
						{
				'href'	: 'artwork/spiritspiders/mercury_back.jpg',
				'title'	: 'Slim case insert - reverse (2007)'
			},
						{
				'href'	: 'artwork/spiritspiders/mercury_cd.jpg',
				'title'	: 'CD label (2007)'
			}
		], {
			'padding'			: 0,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'type'              : 'image',
			'changeFade'        : 0,
			'titlePosition' 	: 'below',
			'titleFormat'		: formatTitle4
		});
	});	

$("#promosticker").click(function() {
		$.fancybox([
			{
				'href'	: 'artwork/spiritspiders/spiders_sticker_photo.jpg',
				'title'	: 'Sticker - 4 1/8" W x 2 7/8" H" (2006)'
			},
						{
				'href'	: 'artwork/spiritspiders/sticker.jpg',
				'title'	: 'Sticker - 4 1/8" W x 2 7/8" H" (2006)'
			}
		], {
			'padding'			: 0,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'type'              : 'image',
			'changeFade'        : 0,
			'titlePosition' 	: 'below',
			'titleFormat'		: formatTitle4
		});
	});			


$("#juno").click(function() {
		$.fancybox([
			{
				'href'	: 'artwork/spiritspiders/juno_photo.jpg',
				'title'	: 'Juno - slim case (2005)'
			},
						{
				'href'	: 'artwork/spiritspiders/juno_cover.jpg',
				'title'	: 'Slim case insert - front (2005)'
			},
						{
				'href'	: 'artwork/spiritspiders/juno_back.jpg',
				'title'	: 'Slim case insert - reverse (2005)'
			},
						{
				'href'	: 'artwork/spiritspiders/juno_cd.jpg',
				'title'	: 'CD label (2005)'
			}
		], {
			'padding'			: 0,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'type'              : 'image',
			'changeFade'        : 0,
			'titlePosition' 	: 'below',
			'titleFormat'		: formatTitle4
		});
	});		

function formatTitle3(title, currentArray, currentIndex, currentOpts) {
    return '<div id="tip11-title">' + (title && title.length ? '' + title : '' ) + '</div>';
}

$("a#blah").fancybox({
			'padding'			: 0,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'type'              : 'image',
			'changeFade'        : 0,
			'titlePosition' 	: 'below',
			'titleFormat'		: formatTitle3
	});

	function formatTitle2(title, currentArray, currentIndex, currentOpts) {
    return '<div id="tip11-title">' + (title && title.length ? '' + title + '&nbsp;' : '' ) + '(' + (currentIndex + 1) + '/' + currentArray.length + ')' + '</div>';
}


$("#bcards").click(function() {
		$.fancybox([

			{
				'href'	: 'artwork/design/leroy_bc.jpg',
				'title'	: 'Personal Business Card'
			},
						{
				'href'	: 'artwork/design/andys_bc.jpg',
				'title'	: 'News of the Highlands, Inc.'
			},
						{
				'href'	: 'artwork/design/castle_bc.jpg',
				'title'	: 'News of the Highlands, Inc.'
			},
						{
				'href'	: 'artwork/design/farmside_bc.jpg',
				'title'	: 'News of the Highlands, Inc.'
			},
						{
				'href'	: 'artwork/design/trumpet_bc.jpg',
				'title'	: 'News of the Highlands, Inc.'
			},
						{
				'href'	: 'artwork/design/foley_bc.jpg',
				'title'	: 'News of the Highlands, Inc.'
			}
		], {
			'padding'			: 0,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'type'              : 'image',
			'changeFade'        : 0,
			'titlePosition' 	: 'below',
			'titleFormat'		: formatTitle2
		});
	});

$("#adverts").click(function() {
		$.fancybox([

			{
				'href'	: 'artwork/design/ark_of_learning.jpg',
				'title'	: 'News of the Highlands, Inc. (2010)'
			},
						{
				'href'	: 'artwork/design/marchese_chevrolet.jpg',
				'title'	: 'News of the Highlands, Inc. (2010)'
			},
						{
				'href'	: 'artwork/design/gnso.jpg',
				'title'	: 'News of the Highlands, Inc. (2010)'
			},
						{
				'href'	: 'artwork/design/holiday_traditions.jpg',
				'title'	: 'News of the Highlands, Inc. (2009)'
			},
						{
				'href'	: 'artwork/design/fallfest.jpg',
				'title'	: 'News of the Highlands, Inc. (2009)'
			},
						{
				'href'	: 'artwork/design/fair.jpg',
				'title'	: 'News of the Highlands, Inc. (2009)'
			},
						{
				'href'	: 'artwork/design/federal_savings.jpg',
				'title'	: 'News of the Highlands, Inc. (2008)'
			},
						{
				'href'	: 'artwork/design/covac.jpg',
				'title'	: 'News of the Highlands, Inc. (2008)'
			},
						{
				'href'	: 'artwork/design/park_restuarant.jpg',
				'title'	: 'News of the Highlands, Inc. (2006)'
			}
		], {
			'padding'			: 0,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'type'              : 'image',
			'changeFade'        : 0,
			'titlePosition' 	: 'below',
			'titleFormat'		: formatTitle2
		});
	});

$("#identity").click(function() {
		$.fancybox([

			{
				'href'	: 'artwork/design/sugarcakeshop_logo.jpg',
				'title'	: 'Sugar Cake Shop logo (2011)'
			},
						{
				'href'	: 'artwork/design/daisys_logo.jpg',
				'title'	: "Daisy's logo (2010)"
			},
						{
				'href'	: 'artwork/design/daisys_pricelist.jpg',
				'title'	: 'PDF price list '
			},
						{
				'href'	: 'artwork/design/daisys_brochure_front.jpg',
				'title'	: 'Tri-fold brochure (outside)'
			},
						{
				'href'	: 'artwork/design/daisys_brochure_back.jpg',
				'title'	: 'Tri-fold brochure (inside)'
			}
		], {
			'padding'			: 0,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'type'              : 'image',
			'changeFade'        : 0,
			'titlePosition' 	: 'below',
			'titleFormat'		: formatTitle2
		});
	});

$("#pagedesign").click(function() {
		$.fancybox([

			{
				'href'	: 'artwork/design/holiday_1.jpg',
				'title'	: 'News of the Highlands, Inc. (2010)'
			},
						{
				'href'	: 'artwork/design/holiday_3.jpg',
				'title'	: 'News of the Highlands, Inc. (2010)'
			},
						{
				'href'	: 'artwork/design/holiday_2.jpg',
				'title'	: 'News of the Highlands, Inc. (2010)'
			},
						{
				'href'	: 'artwork/design/spring_1.jpg',
				'title'	: 'News of the Highlands, Inc. (2010)'
			},
						{
				'href'	: 'artwork/design/spring_2.jpg',
				'title'	: 'News of the Highlands, Inc. (2010)'
			},
						{
				'href'	: 'artwork/design/gift_guide_09.jpg',
				'title'	: 'News of the Highlands, Inc. (2009)'
			},
						{
				'href'	: 'artwork/design/business_profiles.jpg',
				'title'	: 'News of the Highlands, Inc. (2009)'
			}
		], {
			'padding'			: 0,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'type'              : 'image',
			'changeFade'        : 0,
			'titlePosition' 	: 'below',
			'titleFormat'		: formatTitle2
		});
	});

$("#invites").click(function() {
		$.fancybox([

			{
				'href'	: 'artwork/design/invitation1.jpg',
				'title'	: 'Inside invite - 5" x 5"'
			},
						{
				'href'	: 'artwork/design/invitation2.jpg',
				'title'	: 'Response card - 5" x 3.5"'
			},
						{
				'href'	: 'artwork/design/invitation3.jpg',
				'title'	: 'Directions card - 6" x 5"'
			}
		], {
			'padding'			: 0,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'type'              : 'image',
			'changeFade'        : 0,
			'titlePosition' 	: 'below',
			'titleFormat'		: formatTitle2
		});
	});

$("#tarot").click(function() {
		$.fancybox([

			{
				'href'	: 'artwork/design/cubes1.jpg',
				'title'	: '3D educational acetate cubes (2008)'
			},
						{
				'href'	: 'artwork/design/cubes2.jpg',
				'title'	: '3D educational acetate cubes (2008)'
			},
						{
				'href'	: 'artwork/design/cubes3.jpg',
				'title'	: '3D educational acetate cubes (2008)'
			},
						{
				'href'	: 'artwork/design/cubes4.jpg',
				'title'	: '3D educational acetate cubes (2008)'
			}
		], {
			'padding'			: 0,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'type'              : 'image',
			'changeFade'        : 0,
			'titlePosition' 	: 'below',
			'titleFormat'		: formatTitle2
		});
	});

$("#misc").click(function() {
		$.fancybox([

			{
				'href'	: 'artwork/design/cubes1.jpg',
				'title'	: '3D educational acetate cubes (2008)'
			},
						{
				'href'	: 'artwork/design/cubes2.jpg',
				'title'	: '3D educational acetate cubes (2008)'
			},
						{
				'href'	: 'artwork/design/cubes3.jpg',
				'title'	: '3D educational acetate cubes (2008)'
			},
						{
				'href'	: 'artwork/design/cubes4.jpg',
				'title'	: '3D educational acetate cubes (2008)'
			}
		], {
			'padding'			: 0,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'type'              : 'image',
			'changeFade'        : 0,
			'titlePosition' 	: 'below',
			'titleFormat'		: formatTitle2
		});
	});

$("#heart").click(function() {
		$.fancybox([

			{
				'href'	: 'artwork/illustration/heart_print.jpg',
				'title'	: 'The Magician\'s Heart - linoleum block print (2011)'
			},
						{
				'href'	: 'artwork/illustration/heart_print_wip.jpg',
				'title'	: 'The Magician\'s Heart - linoleum block print (2011)'
			}
		], {
			'padding'			: 0,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'type'              : 'image',
			'changeFade'        : 0,
			'titlePosition' 	: 'below',
			'titleFormat'		: formatTitle2
		});
	});

	/*
	*   Tips & Tricks
	*/
	
	$("#tip3").fancybox({
	    'transitionIn'	: 'none',
		'transitionOut'	: 'none',
		'titlePosition'	: 'over',
		'onComplete'	: function() {
			$("#fancybox-wrap").hover(function() {
				$("#fancybox-title").show();
			}, function() {
				$("#fancybox-title").hide();
			});
		}
	});

	$("#tip4").click(function() {
		$.fancybox({
			'padding'		: 0,
			'autoScale'		: false,
			'transitionIn'	: 'none',
			'transitionOut'	: 'none',
			'title'			: this.title,
			'width'			: 680,
			'height'		: 495,
			'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type'			: 'swf',
			'swf'			: {
			    'wmode'				: 'transparent',
				'allowfullscreen'	: 'true'
			}
		});

		return false;
	});

    $("#tip5").fancybox({
		'scrolling' : 'no',
		'titleShow'	: false,
		'onClosed'	: function() {
		    $("#login_error").hide();
		}
	});
    
	$("#login_form").bind("submit", function() {
	
	    if ($("#login_name").val().length < 1 || $("#login_pass").val().length < 1) {
	        $("#login_error").show();
	        $.fancybox.resize();
	        return false;
	    }
	    
	    $.fancybox.showActivity();

		$.ajax({
			type	: "POST",
			cache	: false,
			url		: "/data/login.php",
			data	: $(this).serializeArray(),
			success: function(data) {
				$.fancybox(data);
			}
		});

		return false;
	});
	
	$("#tip6").fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'autoScale'     	: false,
		'type'				: 'iframe',
		'width'				: 500,
		'height'			: 500,
		'scrolling'   		: 'no'
	});
	
	function formatTitle(title, currentArray, currentIndex, currentOpts) {
	    return '<div id="tip7-title"><span><a href="javascript:;" onclick="$.fancybox.close();"><img src="/data/closelabel.gif" /></a></span>' + (title && title.length ? '<b>' + title + '</b>' : '' ) + 'Image ' + (currentIndex + 1) + ' of ' + currentArray.length + '</div>';
	}

	$(".tip7").fancybox({
	    'showCloseButton'   : false,
		'titlePosition' 	: 'inside',
		'titleFormat'		: formatTitle
	});
	
	
	// Next JS snippets are only for fancybox.net
	
	/*
	*   Donate link
	*/
	$("a#donate").bind("click", function() {
		$("#donate_form").submit();
		return false;
	});

	/*
	*   Zebra-stripping table
	*/
	
	$("table.options tr:even").addClass('even');

});
