

$(document).ready(function() {
	function window_resize() {
		var h = $(window).height();
		if(h<400) {
			h = 400;
		}
		$('#wrapper').css('height', h);
	}
	
	function orientation_switch() {
		var orientation = window.orientation;
  		window_resize();
  		
  		if(orientation==0 || orientation==180) {
  			$('#gallery_photo img').css('max-height', '322px');
  			$('.person').fadeOut();
  		} else {
  			$('#gallery_photo img').css('max-height', '310px');
  			$('.person').fadeIn();
  		}
	}

	orientation_switch();
		
	$(window).resize(function() {
		window_resize();
	});
	
	window.onorientationchange = function() {
  		orientation_switch();	
	}
	
	
	$('a.gallery_tab').click(function() {
	
	
		$('a.gallery_tab').parent().removeClass('active');
		$(this).parent().addClass('active');
	
		var img_class = '.gallery-image-' + $(this).attr('rel');
		var img_title = $(this).attr('title');
		
		var img = $(img_class);
		
		$('.gallery_image').removeClass('active');
		img.addClass('active');
		
		$('#gallery_title').html(img_title);
		
		//$('.gallery_image').attr('src', img_file);
	
		/*
		//var img = $(img_class);
		
		
		console.log(img_file);
		
		
		$('.gallery_image').fadeOut('slow').attr('src', img_file); //.one("load", function() { 
		
		$('.gallery_image').fadeIn('slow'); //});
		
		
		return false;
		*/
		
		return false;
		
	});
	

		
	
	
});

