$(document).ready(function(){

			

	$('a[rel*=facebox]').facebox();

	

	// Set up the Slider

	var slideID = 1; // The initial slide (First one)

	var animation_active = false;

	

	var totalSlides = 100;		// IMPORTANT: There are 3 gallery entries PER SLIDE,

								// so this number should be the total number of SLIDES.

								// Example: 2 slides would equal 6 gallery entries (3 per slide)

							

	totalgalleryEntries = totalSlides * 3;

	

	// This sets up the slider panels when you hover over the gallery thumbs

	for (tempgalleryNum=1;tempgalleryNum<=totalgalleryEntries;tempgalleryNum=tempgalleryNum+1) 

	{

		if (animation_active == false) {

			$("div.hoverBlock4 #galleryEntry_"+tempgalleryNum).hover(function(){

				$(this).find("img").animate({top:"290px"},{queue:false,duration:250});

			}, function(){

				$(this).find("img").animate({top:"0px"},{queue:false,duration:400});

			});

		}

	}

	

	// Bump the slides over to fix an alignment problem

	for (tempSlideNum=1;tempSlideNum<=totalSlides;tempSlideNum=tempSlideNum+1) 

	{

		$("#slide-"+tempSlideNum).find(".entry-1").animate({left:"10px"},{duration:0});

		$("#slide-"+tempSlideNum).find(".entry-2").animate({left:"10px"},{duration:0});

		$("#slide-"+tempSlideNum).find(".entry-3").animate({left:"10px"},{duration:0});

	}

	

	// This initially hides all of the slides except the first one

	for (tempSlideNum=2;tempSlideNum<=totalSlides;tempSlideNum=tempSlideNum+1) 

	{

		$("#slide-"+tempSlideNum).hide();

		$("#slide-"+tempSlideNum).find(".grid_44").hide();

	}

	

	// NEXT SLIDE

	$("div.pagination").click(function(event){

														  

		if (this.id != slideID && animation_active == false) {

			

			animation_active = true;

			

			if (this.id == "next") {

				if (slideID != totalSlides) {

					whatClicked = "next";

					newslideID = slideID + 1;

					abort = false;

					if (newslideID != totalSlides) {

						$("#gallery").find('#next').removeClass("inactive");

						$("#gallery").find('#previous').removeClass("inactive");

					} else {

						$("#gallery").find('#next').addClass("inactive");

						$("#gallery").find('#previous').removeClass("inactive");

					}

				} else {

					abort = true;

				}

			} else {

				if (slideID != 1) {

					whatClicked = "previous";

					newslideID = slideID - 1;

					abort = false;

					if (newslideID != 1) {

						$("#gallery").find('#previous').removeClass("inactive");

						$("#gallery").find('#next').removeClass("inactive");

					} else { 

						$("#gallery").find('#previous').addClass("inactive");

						$("#gallery").find('#next').removeClass("inactive");

					}

				} else {

					abort = true;

				}

			}

			

			if (abort == true) {

				animation_active = false;

			} else {

				

				if (whatClicked == "next") {

					positionOne = "-1200px";

					positionTwo = "1200px";

					positionThree = "10px";

					speedOne = 500;

					speedTwo = 550;

					speedThree = 600;

					entryOne = 1;

					entryThree = 3;

				}

				

				if (whatClicked == "previous") {

					positionOne = "1200px";

					positionTwo = "-1200px";

					positionThree = "10px";

					speedOne = 500;

					speedTwo = 550;

					speedThree = 600;

					entryOne = 3;

					entryThree = 1;

				}

		

				$("#slide-"+slideID).find(".entry-"+entryOne).animate({left:positionOne},{duration:500, easing:"easeInQuint"});

				$("#slide-"+slideID).find(".entry-2").animate({left:positionOne},{duration:550, easing:"easeInQuint"});

				$("#slide-"+slideID).find(".entry-"+entryThree).animate({left:positionOne},600, "easeInQuint", function(){

																

					$("#slide-"+slideID).hide();

					$("#slide-"+slideID).find(".grid-44").hide();

					

					// Wait until the above has finished, then do the rest

		

					slideID = newslideID;

					

					$("#slide-"+slideID).find(".entry-1").css("left",positionTwo);

					$("#slide-"+slideID).find(".entry-2").css("left",positionTwo);

					$("#slide-"+slideID).find(".entry-3").css("left",positionTwo);

					

					$("#slide-"+slideID).show();

					$("#slide-"+slideID).find(".entry-1").show();

					$("#slide-"+slideID).find(".entry-2").show();

					$("#slide-"+slideID).find(".entry-3").show();

					

					$("#slide-"+slideID).find(".entry-"+entryOne).animate({left:positionThree},{duration:500, easing:"easeOutExpo"});

					$("#slide-"+slideID).find(".entry-2").animate({left:positionThree},{duration:550, easing:"easeOutExpo"});

					$("#slide-"+slideID).find(".entry-"+entryThree).animate({left:positionThree},600, "easeOutExpo", function(){

					

						animation_active = false;



					});

					

				});

			

			}

		

		}

		

	});



});
