var $ = jQuery.noConflict(); // hand $ back to jQuery

/* Flash hook for when the timeline thumbnail is clicked */
function timelineClicked(href, caption)
{
	/*jQuery.fn.colorbox({
		href:		href,
		title:		caption,
		open:		true,
		opacity:	0.7,
		rel:		'timeline-images'
	});*/
	
	$('#timeline-images a[href='+ href +']').click();
}

$(document).ready(function() {
	
	$.ifixpng('/wp-content/themes/mm/images/pixel.gif');
	$('#logo a').ifixpng();
	$('.wp-caption img').imageFrame('sharp');
	
	/* setup modal links for timeline */
	$('#timeline-images a').colorbox({
		rel: 'timeline-images',
		opacity:	0.7,
	});
	
	/* open new links in a popup window */
	$('a[rel~=new]').click(function() {		
		window.open($(this).attr('href'));
        return false;
	});

	var defaultSearch = $('#q').val();
	$('#q').focus(function() {
		if ($(this).val() == defaultSearch) $(this).val('');
	}).blur(function() {
		if ($(this).val() == '') $(this).val(defaultSearch);
	});
	
	// join the journey modal
	$(".join").colorbox({
		inline: true, 
		href: 	"#primary",
		width:	'400px',
		opacity:	0.7
	}, function() {
		$('#feed-url').focus(function() {
			$(this).select();
		});
	});
	
	/* timeline flash */
	var flashvars = {
		xml: "/timeline.xml",
	};
	var params = {
		wmode: "transparent"
	};
	var attributes = {};
	
	$.get('/timelineUpdate.php', { maskHeight: $(window).height() }, function(response) {
		swfobject.embedSWF("/wp-content/themes/mm/swf/timeline.swf", "flashcontent", "140", "100%", "8.0.0", "/wp-content/themes/mm/swf/expressInstall.swf", flashvars, params, attributes);
	});
	
	//  move the timeline when the users scrolls
	$(window).scroll(function() {
		$('#timeline').animate({ top: $(this).scrollTop() + "px" }, 
            { queue: false, duration: 1000, easing: 'easeOutCirc' });
	});
	
});