addBehaviors = new Class

({



initialize: function(thumbContainer,scrollBoundry,scrollSpeed,thumbTable,fade,main,

largeImgDiv,host,galleryFolder,imageFolder,imgFileNameArray,lightbox,desContainer,

lightboxWidth,darkDiv,whiteDiv,closeImage,lboxLargeImgDiv,preload,

upArrow,downArrow,leftArrow,rightArrow,showUpDown,showLeftRight,lboxObject,magnify,numPics,

lboxPreload,lboxDesContainer,allowComments,allowRating,idArray,guest,ratingsContainer,

ratingsInfoDiv,ratingForm,ratingFormImgId,ratingFormImgRating,ratingsMessageContainer,

ratedContainer,numRatingsSpan,commentsAmountDiv,commentsDataContainer,commentsContainer,

commentsForm,commentsTextarea,commentsImgId,commentsGif,commentsMessageContainer,lboxRatingsInfoDiv,lboxRatingForm,

lboxRatingFormImgId,lboxRatingFormImgRating,lboxRatingsMessageContainer,lboxNumRatingsSpan,

lboxCommentsForm,lboxCommentsAmountDiv,lboxCommentsContainer,lboxCommentsForm,lboxCommentsTextarea,

lboxCommentsImgId,lboxCommentsGif,lboxAllowComments,lboxAllowRating,showLargeImage,slideShow,lboxSlideShow,

lboxSlideshowAutostart,mainCommentsMessageContainer,lboxCommentsMessageContainer,

showThumbs,mainShowThumbs,lboxShowThumbs,

showDescriptions,mainShowDescriptions,lboxShowDescriptions,imgholder,lboxSlideshow)

{

	

	this.thumbContainer = thumbContainer;

	this.scrollBoundry = scrollBoundry;

	this.scrollSpeed = scrollSpeed;

	this.thumbTable = thumbTable;

	this.fade = fade;

	this.main = main;

	this.largeImgDiv = largeImgDiv;

	this.host = host;

	this.galleryFolder = galleryFolder;

	this.imageFolder = imageFolder;

	this.imgFileNameArray = imgFileNameArray;

	this.lightbox = lightbox;

	this.desContainer = desContainer;

	this.lightboxWidth = lightboxWidth;

	this.darkDiv = darkDiv;

	this.whiteDiv = whiteDiv;

	this.closeImage = closeImage;

	this.lboxLargeImgDiv = lboxLargeImgDiv;

	this.preload = preload;

	this.upArrow = upArrow;

	this.downArrow = downArrow;

	this.leftArrow = leftArrow;

	this.rightArrow = rightArrow;

	this.showUpDown = showUpDown;

	this.showLeftRight = showLeftRight;

	this.lboxObject = lboxObject;

	this.magnify = magnify;

	this.numPics = numPics;

	this.lboxPreload = lboxPreload;

	this.lboxDesContainer = lboxDesContainer;

	this.allowComments = allowComments;

	this.allowRating = allowRating;

	this.idArray = idArray;

	this.guest = guest;

	this.ratingsContainer = ratingsContainer;

	this.ratingsInfoDiv = ratingsInfoDiv;

	this.ratingForm = ratingForm;

	this.ratingFormImgId = ratingFormImgId;

	this.ratingFormImgRating = ratingFormImgRating;

	this.ratingsMessageContainer = ratingsMessageContainer;

	this.ratedContainer = ratedContainer;

	this.numRatingsSpan = numRatingsSpan;

	this.commentsAmountDiv = commentsAmountDiv;

	this.commentsDataContainer = commentsDataContainer;

	this.commentsContainer = commentsContainer;

	this.commentsForm = commentsForm;

	this.commentsTextarea = commentsTextarea;

	this.commentsImgId = commentsImgId;

	this.commentsGif = commentsGif;

	this.commentsMessageContainer = commentsMessageContainer;

	this.lboxRatingsInfoDiv = lboxRatingsInfoDiv;

	this.lboxRatingForm = lboxRatingForm;

	this.lboxRatingFormImgId = lboxRatingFormImgId;

	this.lboxRatingFormImgRating = lboxRatingFormImgRating;

	this.lboxRatingsMessageContainer = lboxRatingsMessageContainer;

	this.lboxNumRatingsSpan = lboxNumRatingsSpan;

	this.lboxCommentsForm = lboxCommentsForm;

	this.lboxCommentsAmountDiv = lboxCommentsAmountDiv;

	this.lboxCommentsContainer = lboxCommentsContainer;

	this.lboxCommentsForm = lboxCommentsForm;

	this.lboxCommentsTextarea = lboxCommentsTextarea;

	this.lboxCommentsImgId = lboxCommentsImgId;

	this.lboxCommentsGif = lboxCommentsGif;

	this.lboxAllowComments = lboxAllowComments;

	this.lboxAllowRating = lboxAllowRating;

	this.showLargeImage = showLargeImage;

	this.slideShow = slideShow;

	this.lboxSlideShow = lboxSlideShow;

	this.lboxSlideshowAutostart = lboxSlideshowAutostart;

	this.mainCommentsMessageContainer = mainCommentsMessageContainer;

	this.lboxCommentsMessageContainer = lboxCommentsMessageContainer;

	this.showThumbs = showThumbs;

	this.mainShowThumbs = mainShowThumbs;

	this.lboxShowThumbs = lboxShowThumbs;

	this.showDescriptions = showDescriptions;

	this.mainShowDescriptions = mainShowDescriptions;

	this.lboxShowDescriptions = lboxShowDescriptions;

	this.imgholder = imgholder;

	this.lboxSlideshow = lboxSlideshow;

	

	//make the mootools scroller for the thumbnails

	this.thumbScroller = new Scroller(this.thumbContainer, {area: this.scrollBoundry, velocity: this.scrollSpeed});

	$(this.thumbTable).addEvent('mouseenter', this.thumbScroller.start.bind(this.thumbScroller));

	$(this.thumbTable).addEvent('mouseleave', this.thumbScroller.stop.bind(this.thumbScroller));

	

	//add the behaviors to the up/down left right arrows

	if(this.showUpDown == 1)

	{

		this.upArrowClass = new addArrowBehaviors(this.upArrow, -200,'vertical',this.thumbContainer);

		this.downArrowClass = new addArrowBehaviors(this.downArrow, 200,'vertical',this.thumbContainer);

	}	    

			

	if(this.showLeftRight == 1)

	{

		this.rightArrowClass = new addArrowBehaviors(this.rightArrow, 200,'horizontal',this.thumbContainer);

		this.leftArrowClass = new addArrowBehaviors(this.leftArrow, -200,'horizontal',this.thumbContainer);

	}

	

	//preload large images for main gallery

	if(this.preload == 1 && this.main == 1)

	{

		this.counter = 0;

		this.preloaderClass = new preloaderClass(this.host,this.galleryFolder,'large',this.imgFileNameArray,this.numPics);

	}

	

	this.linksArray = $(this.thumbTable).getElements('a');

	

	//add behaviors for each thumbnail

	this.linksArray.each(function(el,index)

	{	

		el.addEvent('click', function(e)

		{	

			e = new Event(e).stop();

			

			if(this.slideShow != null)

			{

				this.slideShow.clearSlideShow();

				this.slideShow.index = index + 1;

				if(this.slideShow.index >= this.numPics)

				{

					this.slideShow.index = 0;

				}

				

			}

			

			if(this.lboxSlideShow != null && this.main != true)

			{

				this.lboxSlideShow.clearSlideShow();

				this.lboxSlideShow.index = index + 1;

				if(this.lboxSlideShow.index >= this.numPics)

				{

					this.lboxSlideShow.index = 0;

				}

				

			}

			

			//show the correct rating/comment

			if(this.allowRating == 1)

			{

				this.mainRatings = new ratingsClass(this.guest,this.idArray,this.host,index,this.ratingsContainer,

				this.ratingsInfoDiv,this.ratingForm,this.ratingFormImgId,this.ratingFormImgRating,this.ratingsMessageContainer,

				this.ratedContainer,this.numRatingsSpan);

			}

			

			if(this.allowComments == 1)

			{

				this.mainComments = new commentsClass(this.guest,this.idArray,this.host,this.commentsAmountDiv,

				this.commentsDataContainer,this.commentsContainer,

				this.commentsForm,this.commentsTextarea,this.commentsImgId,this.commentsGif,index,

				this.darkDiv,this.commentsMessageContainer,this.lightbox);

			}

			

			if(this.showLargeImage == 0 && this.main == true)

			{

				this.igniteLightBox(index);

			}

			else

			{

				//do the fade transition

				if(this.fade == 1)

				{

					this.imgFader = new imageFaderClass(this.main,this.magnify,this.largeImgDiv,this.host,this.galleryFolder,this.imageFolder,

					this.imgFileNameArray,index,true,false,this.imgholder);

				}

				

				//do the instant transition

				else

				{

					this.imgFader = new imageFaderClass(this.main,this.magnify,this.largeImgDiv,this.host,

					this.galleryFolder,this.imageFolder,this.imgFileNameArray,index,false,false,this.imgholder);

				}

				

				//set the behavior for the main image

				if (this.main == true)

				{

					

					this.linkClass = el.getProperty('class');

					this.linkTarget = el.getProperty('target');

					if(this.linkClass == 'picture_link')

					{	

						$(this.largeImgDiv).setStyle('cursor', 'pointer');

						$(this.largeImgDiv).removeEvents('click');

						$(this.largeImgDiv).addEvent('click', function(e)

						{

							if (this.linkTarget == '_blank') 

							{

								window.open(el);

							}

							else

							{

								window.location = el;

							}

							

						}.bind(this));

					}

					

					if(this.lightbox == 1 && this.linkClass == 'no_link' )

					{

						$(this.largeImgDiv).removeEvents('click');

						

						$(this.largeImgDiv).setStyle('cursor', 'pointer');

						

						$(this.largeImgDiv).addEvent('click', function(e)

						{	

							this.igniteLightBox(index);

						}.bind(this));

					}

				}

			}



			//show the correct description

			if(this.showDescriptions == 1)

			{

				this.descriptionDivs = $(this.desContainer).getElements('div[class=des_div]');

				this.descriptionDivs.each(function(el,index)

				{

					el.setStyle('display', 'none');

				});

				$(this.desContainer).scrollTo(0,0);

				this.descriptionDivs[index].setStyle('display', 'block');

			}

			

					

		}.bind(this));

	}.bind(this));

},



igniteLightBox : function(index)

{

	//preload the large lightbox images

	if(this.lboxPreload == 1)

	{

		this.counter = 0;

		this.lboxPreloaderClass = new preloaderClass(this.host,this.galleryFolder,'lightbox',this.imgFileNameArray,this.numPics);

	}

	

	//inject and show the white div

	this.bodyTag = document.getElementsByTagName("body").item(0);

	this.scrolledDown = Window.getScrollTop();

	this.totalScrollHeight = Window.getScrollHeight();

	this.totalWidth = Window.getWidth();

	this.whiteDivLeftMargin = (this.totalWidth/2) - ( (this.lightboxWidth)/2);

	$(this.whiteDiv).injectTop(this.bodyTag);

	$(this.whiteDiv).setStyles

	({

		'top': this.scrolledDown + 30,

        'left': this.whiteDivLeftMargin,

        'opacity': '0',

		'display': 'block',

		'z-index': 1040

	});

	

	//inject and show the dark div

	this.scrolledDown = Window.getScrollTop();

	this.totalScrollHeight = Window.getScrollHeight();

	this.totalWidth = Window.getWidth();

	$(this.darkDiv).injectTop(this.bodyTag);

	$(this.darkDiv).setStyles

	({

		'width': this.totalWidth,

        'height': this.totalScrollHeight + 30,

        'top': '0px',

        'left': '0px',

        'opacity': '0',

		'display': 'block',

		'z-index': 1030

	});

	this.darkDivFadeIn = new Fx.Style($(this.darkDiv), 'opacity').start(0,.7);

	this.whiteDivFadeIn = new Fx.Style($(this.whiteDiv), 'opacity').start(0,1);

	

	

	//inject and fade in the first image

	this.imgFader = new imageFaderClass(false,null,this.lboxLargeImgDiv,this.host,this.galleryFolder,'lightbox',

	this.imgFileNameArray,index,true,true,this.imgholder);

	

	

	//show the correct description

	if(this.lboxShowDescriptions == 1)

	{

		this.lboxDescriptionDivs = $(this.lboxDesContainer).getElements('div[class=des_div]');

		this.lboxDescriptionDivs.each(function(el,index)

		{

			el.setStyle('display', 'none');

		});

		$(this.lboxDesContainer).scrollTo(0,0);

		this.lboxDescriptionDivs[index].setStyle('display', 'block');

	}

	

	

	

	

	//add the close image behavior

	$(this.closeImage).addEvent('click', function(e)

	{

		if(this.lboxSlideShow != null)

		{

			this.lboxSlideShow.clearSlideShow();

		}

		

		//remove the dark div

		this.darkFadeOut = new Fx.Style($(this.darkDiv), 'opacity').start(0.7,0).chain(function()

		{

			$(this.darkDiv).setStyle('display','none');

		}.bind(this));

		

		//remove the white div

		this.whiteFadeOut = new Fx.Style($(this.whiteDiv), 'opacity').start(1,0).chain(function()

		{

			$(this.lboxLargeImgDiv).setHTML('');

			$(this.whiteDiv).setStyle('display','none');

		}.bind(this));

		

		//recaculate the ratings/comments for the main gallery

		if(this.allowRating == 1)

		{

			this.mainRatings = new ratingsClass(this.guest,this.idArray,this.host,index,this.ratingsContainer,

			this.ratingsInfoDiv,this.ratingForm,this.ratingFormImgId,this.ratingFormImgRating,this.ratingsMessageContainer,

			this.ratedContainer,this.numRatingsSpan);

		}

		

		if(this.allowComments == 1)

		{

			this.mainComments = new commentsClass(this.guest,this.idArray,this.host,this.commentsAmountDiv,

			this.commentsDataContainer,this.commentsContainer,

			this.commentsForm,this.commentsTextarea,this.commentsImgId,this.commentsGif,index,

			this.darkDiv,this.mainCommentsMessageContainer,this.lightbox);

		}

		

	}.bind(this));

	

	

	//show the ratings comments for this lightbox image

	if(this.lboxAllowRating == 1)

	{

		this.mainRatings = new ratingsClass(this.guest,this.idArray,this.host,index,this.ratingsContainer,

		this.lboxRatingsInfoDiv,this.lboxRatingForm,this.lboxRatingFormImgId,this.lboxRatingFormImgRating,this.lboxRatingsMessageContainer,

		this.ratedContainer,this.lboxNumRatingsSpan);

	}

	

	if(this.lboxAllowComments == 1)

	{

		this.mainComments = new commentsClass(this.guest,this.idArray,this.host,this.lboxCommentsAmountDiv,

		this.commentsDataContainer,this.lboxCommentsContainer,

		this.lboxCommentsForm,this.lboxCommentsTextarea,this.lboxCommentsImgId,

		this.lboxCommentsGif,index,this.darkDiv,this.lboxCommentsMessageContainer,this.lightbox);

	}

	

	if(this.lboxSlideshowAutostart == 1)

	{

		this.lboxSlideShow.startSlideShow(true);

	}

	

	

}



});
