/* onload functions */
$(document).ready(function() {

	// ensure some links open in new window						
	$('a.external').click( function() { 
		window.open(this.href);
		return false;
	});

	if ( $('#home-rotation').length ) {
	
		$('#home-rotation').append('<ol id="home-rotation-nav"></ol>');
		
		$('#home-rotation-images').cycle({
			speed:  2000,
			timeout: 7000,
			delay: -2000,
			fastOnEvent: 700,
			pager: '#home-rotation-nav',
			pagerAnchorBuilder: function(i, slide) {
				return '<li>' + i + '</li>';
			},
			slideExpr: 'li'
		});
	}
	
	$("a.enlarge").fancybox();
	
	$("a.video").click(function() {
		$.fancybox({
				'padding'		: 0,
				'autoScale'		: false,
				'transitionIn'	: 'none',
				'transitionOut'	: 'none',
				'title'			: this.title,
				'width'		: 680,
				'height'		: 495,
				'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
				'type'			: 'swf',
				'swf'			: {
				   	 'wmode'		: 'transparent',
					'allowfullscreen'	: 'true'
				}
			});
		return false;
	});
	
});

