// Wait for jQuery to Initialize

$(function(){
	
	var height = $(window).height();
	$('body').css('height', height+'px')
	
	// Center Elements
	
	$(window).resize(function(){
		
		var $logo = $('.logo'),
				$copy = $('.copy'),
				$share = $('.share');

		$logo.css({
			left: ($(window).width() - $logo.outerWidth()) / 2,
			top: ($(window).height() - $logo.outerHeight()) / 2
		});
		
		$copy.css({
			left: ($(window).width() - $copy.outerWidth()) / 2,
			top: ($(window).height() - $copy.outerHeight()) / 2
		});
		
		var height = $(window).height();
		$('body').css('height', height+'px')

	});

	$(window).resize();
	
	// Fade In Elements
	
	$('.logo').fadeIn('2500');
	$('.nav').fadeIn('2500');
	
	// JS Positioning of Nav
	
	$('.nav li:not(:first-child)').css({
		width:60,
		position:'absolute'
	});
	$('.nav li:nth-child(2)').css({
		right:230
	});
	$('.nav li:nth-child(3)').css({
		right:160
	});
	$('.nav li:nth-child(4)').css({
		right:90
	});
	$('.nav li:nth-child(5)').css({
		right:20
	});
	
	// Nav Click Events
	
	$('a.home').live('click', function(){
		$('.active').fadeOut('1500');
		$('.active').removeClass('active');
		$('div.logo').addClass('active');
		$('div.logo').fadeIn('1500');
	});
	// if($('.logo').hasClass('active')) {
	// 		$.address.value('Home');
	// 	}
	
	$('a.about').live('click', function(){
		$('.active').fadeOut('1500');
		$('.active').removeClass('active');
		$('div.home').addClass('active');
		$('div.home').fadeIn('1500');
	});
	// if($('.home').hasClass('active')) {
	// 		$.address.value('#About');
	// 	}
	
	$('a.gallery').live('click', function(){
		$('.active').fadeOut('1500');
		$('.active').removeClass('active');
		$('div.gallery').addClass('active');
		$('div.gallery').fadeIn('1500');
		$("a#single_image").fancybox();
	});
	// if($('.gallery').hasClass('active')) {
	// 		$.address.value('#Gallery');
	// 	}
	
	$('a.contact').live('click', function(){
		$('.active').fadeOut('1500');
		$('.active').removeClass('active');
		$('div.contact').addClass('active');
		$('div.contact').fadeIn('1500');
	});
	// if($('.contact').hasClass('active')) {
	// 		$.address.value('#Contact');
	// 	}

	$('.gallery ul').jflickrfeed({
		limit: 15,
		qstrings: {
			id: '51220915@N02'
		},
		itemTemplate:
			'<li>' +
				'<a class="group" rel="group1" id="single_image" href="{{image}}">' +
					'<img src="{{image_s}}" />' +
				'</a>' +
			'</li>'
	});
	
	//Address Stuff

	// if($.address.path() == '/') {
	// 		// do nothing
	// 		$('div:not(.active)').hide();
	// 	}
	// 	if($.address.path() == '/Home') {
	// 		// do nothing
	// 		$('div:not(.active)').hide();
	// 	}
	// 	if($.address.path() == '/About') {
	// 		$('a.about').click();
	// 		$('div:not(.active)').hide();
	// 	}
	// 	if($.address.path() == '/Gallery') {
	// 		$('a.gallery').click();
	// 		$('div:not(.active)').hide();
	// 	}
	// 	if($.address.path() == '/Contact') {
	// 		$('a.contact').click();
	// 		$('div:not(.active)').hide();
	// 	}
	
});
