// load typekit

try{Typekit.load();}catch(e){}

// when ready

$(document).ready(function() {

	var height = $('.sidebar.right #portfolios .clip img').height();
	$('.sidebar.right #portfolios .clip img').css( 'margin-top', ( height / 2 - height ) ).show();

	$('input[placeholder], textarea[placeholder]').placeholder();

	$('.sidebar #diary li:nth-child(even)').addClass('odd');

	});

// when finished loading

$(window).load(function () {

	if ( $('.clip img').height() > 266 ) {
		vHeight = 266;
	} else {
		vHeight = $('.clip img').height();
		}

	$('.clip').height(vHeight);
	$('.clip img').remove();

	$.getJSON('http://api.flickr.com/services/feeds/photos_public.gne?id=63808967@N05&lang=en-us&format=json&jsoncallback=?', function(data){

		$.each(data.items, function(i,item){
			$('<span>').attr('style', 'background-image: url(' + item.media.m + ');').appendTo('#slideshow');
			if ( i+1 == 5 ) return false;
			});

		$('#slideshow').cycle({
			fx: 'scrollHorz',
			prev: '#gallery nav a:first-child',
			next: '#gallery nav a:last-child',
			random: 1,
			timeout: 0
			});

		});

	$.getJSON('http://api.flickr.com/services/feeds/photos_public.gne?id=63808967@N05&lang=en-us&format=json&jsoncallback=?', function(data){

		$.each(data.items, function(i2,item){
			$('<span/>').attr('style', 'background-image: url(' + item.media.m + ');').appendTo('#main #gallery').wrap('<a href="' + item.link + 'lightbox/" target="_blank"></a>');
			if ( i2+1 == 20 ) return false;
			});

		});

	$('nav a').click( function() {
		$('nav a').removeAttr('class');
		$(this).addClass('active');
		});

	});
