(function ($) {

	//window.onLoad for positioning images
	$(window).load(function () {
		//add contact info
		$('a.contact').attr('href', 'mailto:brunowerzinski@gmail.com');
	});

	//DOM ready
	$(function () {
		
		var Gallery = (function () {
		
			var	$images = $('.image'),
				
				showNext = function ($el) {
					$el.removeClass('active');
					
					if ($el.is($images.last())) {
						$images.first().addClass('active');
						showTitle($images.first().find('img'));
					} else {
						$el.next().addClass('active');
						showTitle($el.next().find('img'));
					}
				},
				
				showTitle = function ($el) {
					var title = $el.attr('alt');
					
					if (title) {
						$('div#title').text(title);
					}
				},
			
				init = function () {
					if ($images.length) {
						//positionImages();
						showTitle($images.first().find('img'));
						
						if ($images.length > 1) {
							$images.click(function () {
								showNext($(this));
							});
						}
					}
				};
			
			return {
				init: init()
			}
		
		})();
		
	});

})(jQuery);
