function openGalleryPortlet(obj,container) {
	/**
	 * Cache Reference
	 */
	var $portlet	= obj;
	var position	= $portlet.offset();
	var $header		= obj.find('.portlet-header');
	var $content	= obj.find('.portlet-content');
	var $banner		= $header.find('.banner');

	/**
	 * Hide the Small Header Image
	 * so we can swap it with the Big one
	 */
	$portlet.css({'z-index':100});
	$header.css({'opacity':0});
	//$banner.css({'background-image':$banner.css('background-image').replace('small','large')});
	$banner.css({'display':'none'});

	/**
	 * Animate the left position if we're in the last 2 columns
	 */
	var objAnimation = {
		'height':	576,
		'width':	529
	};
	if(position.left - container.offset().left - 4 > 358) {
		objAnimation.left = 358;
	}
	/**
	 * Animate the Outer Container
	 */
	$portlet.animate(objAnimation,1200,function(){
		/**
		 * After animated
		 * - call masonry
		 */
		container.masonry();
	});
	/**
	 * Animate the Header
	 */
	$header.animate({
		//height:		376,
		height:		452,
		width:		519
	},1200,function(){
		/**
		 * Header Resized
		 */
		$(this).animate({'opacity':1},250);

		var arrUrls = new Array();
		$content.find('.popup').each(function(){
			arrUrls[arrUrls.length] = {url:$(this).attr('href'),title:$(this).attr('title')};
			//console.log(arrUrls);
		});
		//console.log('last');
		//console.log(arrUrls);
		if(arrUrls.length > 0) {
			$header.append(loadSlideShow (arrUrls));

			if($('.scrollable').length > 0) {
				$(".slidetabs").tabs(".images > div", {
					// enable "cross-fading" effect
					effect: 'fade',
					fadeOutSpeed: "slow",
					// start from the beginning after the last tab
					rotate: true
					// use the slideshow plugin. It accepts its own configuration
				}).slideshow();
				$(".slidetabs").data("slideshow").play();
				//$(".scrollable").scrollable({circular: true});
				//$(".scrollable").autoscroll({ autoplay: true, interval: 4000 });
				//$(".scrollable").navigator();
			}
		}
	});
	/**
	 * Animate the Banner
	 */
	$banner.animate({
	//	'height':	376,
	//	'width':	519
		'opacity':	0
	},1200,function(){
	//	/**
	//	 * Banner Resized
	//	 */
	});
	/**
	 * Animate the Body
	 */
	$content.animate({
		/*height:	182,*/
		width:	511
	},1200,function(){
		/** 
		 * After animated
		 * - fade in the text area
		 * - fade in the close button
		 */
		$content.find('.portlet-text .body').css({'opacity':0,'display':'block'}).animate({
			opacity:	1
		},1200,function(){
			/**
			 * Text Faded In
			 */
			$portlet.css({'z-index':1}).addClass('opened');
			$content.find('.close').css({'display':'block'});
			$content.find('.popup').unbind('click').bind({
				click:function(){
					$(this).parents('.portlet').find('.opener').trigger('click');
					return false;
				}
			});
			$('html,body').animate({scrollTop: $portlet.offset().top}, {duration:1000,specialEasing:'easeOutBack'});
			animating='no';
		});
	});
}
function closeGalleryPortlet(obj,container,nextPortlet) {
	/**
	 * Cache Reference
	 */
	var $portlet	= obj;
	var position	= $portlet.offset();
	var $header		= obj.find('.portlet-header');
	var $content	= obj.find('.portlet-content');
	var $banner		= $header.find('.banner');

	/**
	 * Hide the Big Header Image
	 * so we can swap it with the Small one
	 */
	$(".slidetabs").data("slideshow").stop();
	$('.slideshow').remove();
	$portlet.find('.header-popups').remove();
	$portlet.css({'z-index':100});
	$header.css({'opacity':0});
	//$banner.css({'background-image':$banner.css('background-image').replace('large','small')});
	$content.find('.close').css({'display':'none'});
	$content.find('.portlet-text .body').css({'opacity':0,'display':'none'});

	/**
	 * Animate the Body
	 */
	$content.animate({
		height:	106,
		width:	153
	},250,function(){
		/** 
		 * After animated
		 */
		$portlet.css({'z-index':1}).removeClass('opened');
	});
	/**
	 * Animate the Banner
	 */
	//$banner.animate({
	//	height:	160,
	//	width:	161
	//},250,function(){
	//	/**
	//	 * Banner Resized
	//	 */
	//});
	/**
	 * Animate the Header
	 */
	$header.animate({
		height:		160,
		width:		161
	},250,function(){
		/**
		 * Header Resized
		 */
		$(this).animate({'opacity':1},250);
		$banner.css({'position':'relative','display':'block'});
		$banner.animate({'opacity':1},250);
	});
	/**
	 * Animate the Outer Container
	 */
	$portlet.animate({
		height:	284,
		width:	171
	},250,function(){
		/**
		 * After animated
		 * - call masonry
		 */
		container.masonry();

		if(nextPortlet && typeof(nextPortlet)=='object') {

			container.data('nextPortlet',nextPortlet);

			setTimeout('portletOpenTrigger()',1200);
		} else {
			//setTimeout(function(){$('html,body').animate({scrollTop: $portlet.offset().top}, {duration:1000,specialEasing:'easeOutBack'});},1200);
			animating='no';
		}
	});
}
