
var PhotoGallery = jscore.def ('PhotoGallery', {

	PhotoGallery: function () {
		var photoDrawerOpen = false;
		var height = 355;
	},
	closePhotoDrawer: function () {
		
		if (this.photoDrawerOpen == true) { return; }
		
		$('#ptOuter').animate({
		    height: this.height
		  }, 300, function() {
				$(this).removeClass('extended');
		  });
	},
	init: function () {

		this.height = $('#ptInner').parent().css('height');
		
		var selectImage = function (object) {
			$("#profileGalleryPic").attr("src",$(this).attr("rel"));
			$('.profileThumb').removeClass("thumbSelected");
			$(this).addClass("thumbSelected");
			
			$("a.zoomPhotoButton").hide();

			$("a#zoomPhoto_"+$(this).attr("id")).show();
			
			if ($(this).hasClass("pixelated")) {
				$('#pixelatedInfo').fadeIn();
			} else {
				$('#pixelatedInfo').fadeOut();
			}
			
		}
		var deSelectImage = function () {
		}
		var config = {    
		     sensitivity: 3, // number = sensitivity threshold (must be 1 or higher)    
		     interval: 250, // number = milliseconds for onMouseOver polling interval    
		     over: selectImage, // function = onMouseOver callback (REQUIRED)    
		     timeout: 500, // number = milliseconds delay before onMouseOut    
		     out: deSelectImage // function = onMouseOut callback (REQUIRED)    
		};
		
		if ($('#ptInner').outerHeight()-10 > $('#ptOuter').outerHeight()) {		
		$('#photoBlock').hover(function () { 
			photoGallery.photoDrawerOpen = true;
			$('#ptOuter', $(this)).addClass('extended');
			
			$('#ptOuter', $(this)).animate({
				    height: $('#ptInner', $(this)).outerHeight()
				  }, 300, function() { });
			}, function () {
				photoGallery.photoDrawerOpen = false;
				var fn = function () { 	photoGallery.closePhotoDrawer(); }
				setTimeout(fn, 1000);
		
			});
		}
	
		$('.profileThumb').hoverIntent( config ).click(selectImage);
		
		$("a.zoomPhoto").fancybox({
						"titlePosition"	: "over",
						'overlayColor'		: '#000',
						'overlayOpacity'	: 0.8,
						'onClosed'			: function () { photoGallery.closePhotoDrawer(); },
						"titleFormat"		: function(title, currentArray, currentIndex, currentOpts) {
							return '<span id="fancybox-title-over">Profile Photo ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp;:&nbsp; ' + title : '') + '</span>';
						}
					});
	},
	playIfRequired: function () {

		
	}
});





