(function($) {
    $(function() {
		(function(){
			$('#gallery-thumb li a').bind('click', function(){
				$('#gallery-thumb li a.active').removeClass('active');

				var $this = $(this), $href = $this.attr('href');
				$this.addClass('active');
				var newPic = new Image();
				newPic.src = $href;
				$('#gallery-showcase img').animate({opacity: 'hide'},{
					complete: function(){
						$('#gallery-showcase img').remove();
						$('#gallery-showcase').append(newPic);
					}
				});
				return false;
			});
		})();
    });
})(jQuery);

var popup = (function(){
	function initPopup(){
		var links = document.getElementsByTagName('a');
		for(var i = 0, len = links.length; i < len; i++){
			if(links[i].getAttribute('rel') && links[i].getAttribute('rel').indexOf('window') === 0){
				links[i].onclick = popup.open;
			}
		}
	}
	window.onload = initPopup;
	return {
		open: function(){
			open(this.href,new Date().getTime(),'width=640,height=700 ,toolbar=no, scrollbars=yes, menubar=no,locationbar=no');
			return false;
		}
	};
})();
