function rollOn() {
	$(this).find('span').stop().fadeTo(250, 0);
}

function rollOff() {
	$(this).find('span').stop().fadeTo(250, 0.7);
}

function showLoader(update_area) {
	update_area.ajaxStart(function() {
		update_area.show();
		$(this).html('<img id="loader" src="images/loader.gif" alt="loading" />');
	});
}	

function loadVideo() {
	video_area = $('#contentWrap');
	video_clip_id = $(this).attr('href');
	$('#mycarousel li').removeClass('on');
	$(this).parent('li').addClass('on');
	video_embed_code = '<object width="520" height="345"><param name="wmode" value="transparent"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=' + video_clip_id + '&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00adef&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=' + video_clip_id + '&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00adef&amp;fullscreen=1" wmode="transparent" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="520" height="345"></embed></object>';
	video_area.html(video_embed_code);

	notes_wrap_divs = $('#notesWrap div');
	$.each(notes_wrap_divs, function() {
		$(this).hide();
		if($(this).attr('id') == video_clip_id) {
			$(this).fadeIn('slow');
		}
	});
	return false;
}
var loadVideosCounter = 5;
function loadVideos() {

	$.ajax({
		type: "GET",
		url: 'vimeo.php',
		success: videosLoaded,
		error: reloadVideos
	});
}

function reloadVideos() {

	loadVideosCounter--;
	if (loadVideos) {
		setTimeout("loadVideos()", 1500);
	} else {
		$('#video_content').html('Unable to load videos. Try again later.');
	}

}

function videosLoaded(reply) {

	$('#video_content').html(reply);
	$('#notesWrap div:first').fadeIn(1000);
	
}

//video_content
function loadAudio() {
	audio_area = $('#audioplayerWrap');
	title_h2 = $('#rightCol h2:first');
	notes_area = $('#audioNotesWrap div');
	audio_clip_file = $(this).attr('href');
	audio_clip_title = $(this).attr('title');
	audio_clip_desc = $(this).attr('rel');
	audio_embed_code = "<div id=\"audioplayer\">This text will be replaced</div><script type='text/javascript'>var so = new SWFObject('/player/player.swf','mpl','330','24','9');so.addParam('allowfullscreen','true');so.addParam('allowscriptaccess','always');so.addParam('wmode','transparent');so.addVariable('author','Steven J. Kukla');so.addVariable('file','http://www.kuklamusic.com/media/audio/" + audio_clip_file + "');so.addVariable('backcolor','FFFFFF');so.addVariable('frontcolor','666666');so.addVariable('autostart', 'true');so.addVariable('volume','90');so.write('audioplayer');</script>";
	$('#leftCol li').removeClass('on');
	$(this).parent('li').addClass('on');
	title_h2.replaceWith('<h2>' + audio_clip_title + '</h2>');
	audio_area.html(audio_embed_code);
	notes_area.html(audio_clip_desc).hide().fadeIn(1000);
	return false;
}

function mycarousel_initCallback(carousel) {
	$('a.mycarousel-next').bind('click', function() {
		carousel.next();
		return false;
	});
	$('a.mycarousel-prev').bind('click', function() {
		carousel.prev();
		return false;
	});
}

function initCarousel() {
	$(this).jcarousel({
		initCallback: mycarousel_initCallback,
		// This tells jCarousel NOT to autobuild prev/next buttons
		buttonNextHTML: null,
		buttonPrevHTML: null,
		wrap: 'last'
	}); 
}
