$(document).ready(function() {

	// opens external links in a new tab
	$("a[href*='http://']:not([href*='"+location.hostname+"'])").attr("target","_blank");

	// opens launch site links in new tab
	$(".launch a").attr("target","_blank");

	// border radius (TL, BR)
	$('.title, #portfolio dl dd.launch a').css({'-moz-border-radius-topleft':'10px', '-webkit-border-top-left-radius':'10px', '-moz-border-radius-bottomright':'10px', '-webkit-border-bottom-right-radius':'10px'})

	// border radius (full)
	$('#content .more-link').css({'-moz-border-radius-topleft':'5px', '-webkit-border-top-left-radius':'5px', '-moz-border-radius-topright':'5px', '-webkit-border-top-right-radius':'5px', '-moz-border-radius-bottomright':'5px', '-webkit-border-bottom-right-radius':'5px', '-moz-border-radius-bottomleft':'5px', '-webkit-border-bottom-left-radius':'5px'})

	// social panel switch
	$('#header-right #switch a').toggle( function() {
		$('#header-right ul#twitter_update_list').hide();
		$('#header-right ul#lastfm').fadeIn();
		$('#header-right a.twitterlink').css('background', 'transparent');
		$('#header-right a.lastfmlink').css('background', '#343740');
	}, function() {
		$('#header-right ul#lastfm').hide();
		$('#header-right ul#twitter_update_list').fadeIn();
		$('#header-right a.lastfmlink').css('background', 'transparent');
		$('#header-right a.twitterlink').css('background', '#343740');
	});

	// switch button opacity
	$('#header-right #switch a').css({'opacity':'1'})
	$('#header-right #switch a:hover').css({'opacity':'0.5'})

	// initializes jquery fancybox
	$("a.image").fancybox({
		'transitionIn'	:	'fade',
		'transitionOut'	:	'fade',
		'titlePosition' :	'inside',
		'showNavArrows' :	true,
		'enableEscapeButton' :	true,
		'autoScale'	:	true,
		'hideOnContentClick' :	false,
		'hideOnOverlayClick' :	true,
		'overlayColor'	:	'#000',
		'overlayOpacity':	0.5,
		'speedIn'	:	500,
		'centerOnScroll' :	true
	});
	$("a.vimeo").click(function(){
		$.fancybox({
			'padding' :		0,
			'frameWidth' :		620,
			'frameHeight' :		349,
			'enableEscapeButton' :	true,
			'hideOnContentClick' :	false,
			'hideOnOverlayClick' :	true,
			'overlayColor'	:	'#000',
			'overlayOpacity' :	0.5,
			'href' :		this.href.replace(new RegExp("([0-9])","i"),'moogaloop.swf?server=vimeo.com\&show_title=1\&show_byline=1\&show_portrait=1\&color=ffdc5e\&fullscreen=1\&clip_id=$1'),
			'type' :		'swf',
			'swf' : {
				'wmode' :		'transparent',
				'allowfullscreen' :	'true'
			}
		});
		return false;
	});

	$("a.youtube").click(function(){
		$.fancybox({
			'padding' :		1,
			'frameWidth' :		620,
			'frameHeight' :		349,
			'enableEscapeButton' :	true,
			'hideOnContentClick' :	false,
			'hideOnOverlayClick' :	true,
			'overlayColor'	:	'#000',
			'overlayOpacity' :	0.5,
			'href' :		this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type' :		'swf',
			'swf' : {
				'wmode' :		'transparent',
				'allowfullscreen' :	'true'
			}
		});
		return false;
	});
	
});
