jQuery.event.add(window, "load", function(){ $('#social ul li').show(); } );

$(function($){
	var $socials = $('#social ul li');
	$socials.css({ 'top':"-90px" });
	$socials.hide();
	
	$socials.delay(1000).each( function(){
		$(this).css({
			'position':'relative'
		});
		var rnd = Math.floor( Math.random() * -40 );
		$(this).animate({
			top: rnd + 'px'
		},Math.floor( Math.random() * 2000 )+ 1000, 'swing' );
	});
	
	$('#social ul li a').tipsy({
		gravity:'n',
		opacity:1,
		fade:true,
		offset:6
	});
	
	$('#menu-navigation-menu .menu-item a').tipsy({
		gravity:'n',
		opacity:1,
		fade:true
	});
	
	$('#home').tipsy({
		gravity:'nw',
		opacity:1,
		fade:true,
		offset:-6
	});
	
	/* lightbox */
	$('a.lightbox').lightBox();
	$('a.thumbnail img').each( function(){
		$(this).parent().lightBox();
		var alt = $(this).attr('alt');
		if( alt != "" ){
			$(this).parent().append( '<br /><div style="text-align:center">' + alt + '</div>' );
		}
	});
	
	
	/* page arrow */
	$('#wp_page_numbers ul li a').filter(function(index){
		return $(this).text() == "<";
	}).html('&nbsp;').addClass('arrowleft');
	
	$('#wp_page_numbers ul li a').filter(function(index){
		return $(this).text() == ">";
	}).html('&nbsp;').addClass('arrowright');
	
	$('#takeMeUpContainer').attr('style','').addClass('arrowup');
});

$(function() {
	$('.eyecatch .wp-post-image').each(function(){
		var src = $(this).attr('src');
		var h = $(this).attr('height');
		$(this).parent().css({
			'background-image':'url(' + src + ')',
			'height':h
		});
		$(this).remove();
	});
});

/** GA */
$(function(){
	$('a').click(function(){
		var url = $(this).attr('href');
		if(
			(url.match(/^http(s?):\/\//))
			&&(url.indexOf(window.location.host) == -1)
			){
			_gaq.push(['_trackPageview','/outlinks/' + encodeURI($(this).attr('href'))]);
			_gaq.push(['_trackEvent','click','link',$(this).attr('href')]);
		}

	});
});
