igalleryclass = new Class
({

initialize: function(preload,lboxPreload,host,galleryFolder,numPics,thumbContainer,
lboxThumbContainer,thumbTable,lboxThumbTable,desContainer,lboxDesContainer,
largeImgDiv,lboxLargeImgDiv,scrollBoundry,scrollSpeed,
lboxScrollBoundry,lboxScrollSpeed,fade,lboxFade,lightbox,
lightboxWidth,showScrollBar,showLboxScrollBar,desScrollBack,desScrollHandle,
lboxDesScrollBack,lboxDesScrollHandle,thumbScrollBack,thumbScrollHandle,
lboxThumbScrollBack,lboxThumbScrollHandle,thumbVScrollBack,thumbVScrollHandle,
lboxThumbVScrollBack,lboxThumbVScrollHandle,darkDiv,whiteDiv,closeImage,upArrow,
downArrow,leftArrow,rightArrow,lboxUpArrow,lboxDownArrow,lboxLeftArrow,lboxRightArrow,
showUpDown,showLeftRight,lboxShowUpDown,lboxShowLeftRight,magnify,scrollLeftArrow,
scrollRightArrow,scrollUpArrow,scrollDownArrow,lboxScrollLeftArrow,lboxScrollRightArrow,
lboxScrollUpArrow,lboxScrollDownArrow,desUpArrow,desDownArrow,
lboxDesUpArrow,lboxDesDownArrow,allowComments,allowRating,lboxAllowComments,lboxAllowRating,
idArray,guest,ratingsContainer,ratingsInfoDiv,ratingForm,
ratingFormImgId,ratingFormImgRating,ratingsMessageContainer,
ratedContainer,numRatingsSpan,commentsAmountDiv,commentsDataContainer,commentsContainer,commentsForm,commentsTextarea,
commentsImgId,commentsGif,
lboxRatingsContainer,lboxRatingsInfoDiv,lboxRatingForm,lboxRatingFormImgId,lboxRatingFormImgRating,
lboxRatingsMessageContainer,lboxRatedContainer,lboxNumRatingsSpan,lboxCommentsAmountDiv,
lboxCommentsContainer,lboxCommentsForm,lboxCommentsTextarea,lboxCommentsImgId,lboxCommentsGif)
{
	
	
	this.preload = preload;
	this.lboxPreload = lboxPreload;
	this.host = host;
	this.galleryFolder = galleryFolder;
	this.numPics = numPics;
	this.thumbContainer = thumbContainer;
	this.lboxThumbContainer = lboxThumbContainer;
	this.thumbTable = thumbTable;
	this.lboxThumbTable = lboxThumbTable;
	this.desContainer = desContainer;
	this.lboxDesContainer = lboxDesContainer;
	this.largeImgDiv = largeImgDiv;
	this.lboxLargeImgDiv = lboxLargeImgDiv;
	this.scrollBoundry = scrollBoundry;
	this.scrollSpeed = scrollSpeed;
	this.lboxScrollBoundry = lboxScrollBoundry;
	this.lboxScrollSpeed = lboxScrollSpeed;
	this.fade = fade;
	this.lboxFade = lboxFade;
	this.lightbox = lightbox;
	this.lightboxWidth = lightboxWidth;
	this.showScrollBar = showScrollBar;
	this.showLboxScrollBar = showLboxScrollBar;
	this.desScrollBack = desScrollBack;
	this.desScrollHandle = desScrollHandle;
	this.lboxDesScrollBack = lboxDesScrollBack;
	this.lboxDesScrollHandle = lboxDesScrollHandle;
	this.thumbScrollBack = thumbScrollBack;
	this.thumbScrollHandle = thumbScrollHandle;
	this.lboxThumbScrollBack = lboxThumbScrollBack;
	this.lboxThumbScrollHandle = lboxThumbScrollHandle;
	this.thumbVScrollBack = thumbVScrollBack;
	this.thumbVScrollHandle = thumbVScrollHandle;
	this.lboxThumbVScrollBack = lboxThumbVScrollBack;
	this.lboxThumbVScrollHandle = lboxThumbVScrollHandle;
	this.darkDiv = darkDiv;
	this.whiteDiv = whiteDiv;
	this.closeImage = closeImage;
	this.upArrow = upArrow;
	this.downArrow = downArrow;
	this.leftArrow = leftArrow;
	this.rightArrow = rightArrow;
	this.lboxUpArrow = lboxUpArrow;
	this.lboxDownArrow = lboxDownArrow;
	this.lboxLeftArrow = lboxLeftArrow;
	this.lboxRightArrow = lboxRightArrow;
	this.showUpDown = showUpDown;
	this.showLeftRight = showLeftRight;
	this.lboxShowUpDown = lboxShowUpDown;
	this.lboxShowLeftRight = lboxShowLeftRight;
	this.magnify = magnify;
	this.scrollLeftArrow = scrollLeftArrow;
	this.scrollRightArrow = scrollRightArrow;
	this.scrollUpArrow = scrollUpArrow;
	this.scrollDownArrow = scrollDownArrow;
	this.lboxScrollLeftArrow = lboxScrollLeftArrow;
	this.lboxScrollRightArrow = lboxScrollRightArrow;
	this.lboxScrollUpArrow = lboxScrollUpArrow;
	this.lboxScrollDownArrow = lboxScrollDownArrow;
	this.desUpArrow = desUpArrow;
	this.desDownArrow = desDownArrow;
	this.lboxDesUpArrow = lboxDesUpArrow;
	this.lboxDesDownArrow = lboxDesDownArrow;
	this.allowComments = allowComments;
	this.allowRating = allowRating;
	this.lboxAllowComments = lboxAllowComments;
	this.lboxAllowRating = lboxAllowRating;
	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.lboxRatingsContainer = lboxRatingsContainer;
	this.lboxRatingsInfoDiv = lboxRatingsInfoDiv;
	this.lboxRatingForm = lboxRatingForm;
	this.lboxRatingFormImgId = lboxRatingFormImgId;
	this.lboxRatingFormImgRating = lboxRatingFormImgRating;
	this.lboxRatingsMessageContainer = lboxRatingsMessageContainer;
	this.lboxRatedContainer = lboxRatedContainer;
	this.lboxNumRatingsSpan = lboxNumRatingsSpan;
	
	this.lboxCommentsAmountDiv = lboxCommentsAmountDiv;
	this.lboxCommentsContainer = lboxCommentsContainer;
	this.lboxCommentsForm = lboxCommentsForm;
	this.lboxCommentsTextarea = lboxCommentsTextarea;
	this.lboxCommentsImgId = lboxCommentsImgId;
	this.lboxCommentsGif = lboxCommentsGif;

	
	this.thumbPathsArray = $(this.thumbTable).getElements('img');
	this.imgFileNameArray = new Array();
	
	this.thumbPathsArray.each(function(el,index)
	{
		this.imgPathParts = el.src.split("/");
		this.imgFileName = this.imgPathParts.pop();
		this.imgFileNameArray[index] = this.imgFileName;
	}.bind(this));
	
	if(this.lightbox == 1)
	{	
			this.lboxBehaviors = new addBehaviors(this.lboxThumbContainer,this.lboxScrollBoundry,this.lboxScrollSpeed,
			this.lboxThumbTable,this.lboxFade,false,this.lboxLargeImgDiv,this.host,this.galleryFolder,
			'lightbox',this.imgFileNameArray,this.lightbox,this.lboxDesContainer,
			this.lightboxWidth,this.lboxDesScrollBack,this.lboxDesScrollHandle,this.darkDiv,
			this.whiteDiv,this.closeImage,this.lboxLargeImgDiv,this.lboxPreload,
			this.lboxUpArrow,this.lboxDownArrow,this.lboxLeftArrow,this.lboxRightArrow,
			this.lboxShowUpDown,this.lboxShowLeftRight,this.lboxThumbScrollBack,this.lboxThumbScrollHandle,
			this.lboxThumbVScrollBack,this.lboxThumbVScrollHandle,null,0,
			this.lboxScrollLeftArrow,this.lboxScrollRightArrow,this.lboxScrollUpArrow,
			this.lboxScrollDownArrow,this.lboxDesUpArrow,this.lboxDesDownArrow,this.numPics,
			this.lboxPreload,this.lboxThumbScrollHandle,this.lboxThumbVScrollHandle,this.lboxDesContainer,
			this.lboxAllowComments,this.lboxAllowRating,this.idArray,this.guest,this.ratingsContainer,
			this.lboxRatingsInfoDiv,this.lboxRatingForm,this.lboxRatingFormImgId,this.lboxRatingFormImgRating,
			this.lboxRatingsMessageContainer,this.ratedContainer,this.lboxNumRatingsSpan,this.lboxCommentsAmountDiv,
			this.commentsDataContainer,this.lboxCommentsContainer,this.lboxCommentsForm,this.lboxCommentsTextarea,this.lboxCommentsImgId,this.lboxCommentsGif,
			this.lboxRatingsInfoDiv,this.lboxRatingForm,this.lboxRatingFormImgId,this.lboxRatingFormImgRating,
			this.lboxRatingsMessageContainer,this.lboxNumRatingsSpan,this.lboxCommentsForm,this.lboxCommentsAmountDiv,this.lboxCommentsContainer,
			this.lboxCommentsForm,this.lboxCommentsTextarea,this.lboxCommentsImgId,this.lboxCommentsGif,
			this.lboxAllowComments,this.lboxAllowRating);
		
	}
	
	new Asset.images([this.host + 'images/stories/igallery/' + this.galleryFolder + '/large/' + this.imgFileNameArray[0] ], 
	{
		onComplete: function()
		{
			$(this.largeImgDiv).setHTML('<img src="' + this.host + 'images/stories/igallery/' + this.galleryFolder + '/large/' + this.imgFileNameArray[0] + '" class="large_img" />');
			
			
			
			
			this.mainBehaviors = new addBehaviors(this.thumbContainer,this.scrollBoundry,this.scrollSpeed,
			this.thumbTable,this.fade,true,this.largeImgDiv,this.host,this.galleryFolder,
			'large',this.imgFileNameArray,this.lightbox,this.desContainer,
			this.lightboxWidth,this.desScrollBack,this.desScrollHandle,this.darkDiv,this.whiteDiv,
			this.closeImage,this.lboxLargeImgDiv,this.preload,this.upArrow,this.downArrow,
			this.leftArrow,this.rightArrow,this.showUpDown,this.showLeftRight,this.thumbScrollBack,
			this.thumbScrollHandle,this.thumbVScrollBack,this.thumbVScrollHandle,null,this.magnify,
			this.scrollLeftArrow,this.scrollRightArrow,this.scrollUpArrow,
			this.scrollDownArrow,this.desUpArrow,this.desDownArrow,this.numPics,
			this.lboxPreload,this.lboxThumbScrollHandle,this.lboxThumbVScrollHandle,this.lboxDesContainer,
			this.allowComments,this.allowRating,this.idArray,this.guest,this.ratingsContainer,
			this.ratingsInfoDiv,this.ratingForm,this.ratingFormImgId,this.ratingFormImgRating,
			this.ratingsMessageContainer,this.ratedContainer,this.numRatingsSpan,this.commentsAmountDiv,
			this.commentsDataContainer,this.commentsContainer,this.commentsForm,this.commentsTextarea,this.commentsImgId,this.commentsGif,
			this.lboxRatingsInfoDiv,this.lboxRatingForm,this.lboxRatingFormImgId,this.lboxRatingFormImgRating,
			this.lboxRatingsMessageContainer,this.lboxNumRatingsSpan,this.lboxCommentsForm,this.lboxCommentsAmountDiv,this.lboxCommentsContainer,
			this.lboxCommentsForm,this.lboxCommentsTextarea,this.lboxCommentsImgId,this.lboxCommentsGif,
			this.lboxAllowComments,this.lboxAllowRating);
			
			this.imgToChain = $(this.largeImgDiv).getElement('img');
			this.imgChain = new Fx.Style(this.imgToChain, 'opacity',{duration:200}).start(1,1).chain(function()
			{
				if (this.magnify == 1) 
				{
					this.mainBehaviors.insertMagnify();
				}
				
			}.bind(this));
			
			
			this.firstThumbLink = $(this.thumbTable).getElement('a')
			this.linkClass = this.firstThumbLink.getProperty('class');
			this.linkTarget = this.firstThumbLink.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(this.firstThumbLink);
					}
					else
					{
						window.location = this.firstThumbLink;
					}
				}.bind(this));
			}
			
			if(this.lightbox == 1)
			{
				
				if(this.linkClass == 'no_link' )
				{
					$(this.largeImgDiv).removeEvents('click');
					
					$(this.largeImgDiv).setStyle('cursor', 'pointer');
					
					$(this.largeImgDiv).addEvent('click', function(e)
					{	
						this.mainBehaviors.igniteLightBox(0);
						
						this.lboxDesScrollbar = new scrollBarClass(this.lboxDesContainer,this.lboxDesScrollBack,this.lboxDesScrollHandle,'y','vertical','top');
			
						if(this.showLboxScrollBar == 1)
						{
							this.LboxHScrollbar = new scrollBarClass(this.lboxThumbContainer,this.lboxThumbScrollBack,this.lboxThumbScrollHandle,'x','horizontal','left');
							this.LboxVScrollbar = new scrollBarClass(this.lboxThumbContainer,this.lboxThumbVScrollBack,this.lboxThumbVScrollHandle,'y','vertical','top');
						}
					}.bind(this));
				}
			
			}
			
		}.bind(this)
	});
	
	
	this.mainDesScrollbar = new scrollBarClass(this.desContainer,this.desScrollBack,this.desScrollHandle,'y','vertical','top');
	if(this.showScrollBar == 1)
	{
		this.mainThumbHScrollbar = new scrollBarClass(this.thumbContainer,this.thumbScrollBack,this.thumbScrollHandle,'x','horizontal','left');
		this.mainThumbVScrollbar = new scrollBarClass(this.thumbContainer,this.thumbVScrollBack,this.thumbVScrollHandle,'y','vertical','top');
	}
	
	if(this.allowRating == 1)
	{
		this.mainRatings = new ratingsClass(this.guest,this.idArray,this.host,0,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,0,this.darkDiv,this.lightbox);
	}
	
	if(this.lboxAllowRating == 1)
	{
		this.mainRatings = new ratingsClass(this.guest,this.idArray,this.host,0,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,0,
		this.darkDiv,this.lightbox);
	}
	
	
}





});//end igallery class

	

