function loadTab() {
	showLoader(update_area);
	tabs.removeClass('on').removeClass('active');
	this_tab = $(this);
	tab_id = this_tab.attr('id');
	this_tab.addClass('on');
	if(tab_id == 'tab1') {
		page = 'vimeo.php';
	} else {
		page = 'flickr.php';
	}
	//update_area.load(page);
	$.ajax({
	  url: page,
	  cache: false,
	  success: function(html){
	    update_area.html(html);
	    if (tab_id == 'tab2') {
	    	$("a.group").fancybox({ 
	    		'zoomSpeedIn': 300, 
	    		'zoomSpeedOut': 300, 
	    		'centerOnScroll': false,
	    		'overlayShow': false });
	    }
	  }
	});

	return false;
}

function changePhotoPage() {
	href = $(this).attr('href');
	$.ajax({
	  url: 'flickr.php' + href,
	  cache: false,
	  success: function(html){
	    update_area.html(html);
	    if (tab_id == 'tab2') {
	    	$("a.group").fancybox({ 
	    		'zoomSpeedIn': 300, 
	    		'zoomSpeedOut': 300, 
	    		'centerOnScroll': false,
	    		'overlayShow': false });
	    }
	  }
	});
	return false;
}

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

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

function tabOn() {
	if($(this).attr('class') != 'active') {
		$(this).addClass('active');
	}	
}

function tabOff() {
	if($(this).attr('class') == 'active') {
		$(this).removeClass('active');
	}	
}

function loadVideo() {
	video_clip_id = $(this).attr('href');
	$('.video_list li').removeClass('on');
	$(this).parent('li').addClass('on');
	video_embed_code = '<object width="550" height="365"><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="540" height="365"></embed></object>';
	video_area = $('.video');
	video_area.html(video_embed_code);
	return false;
}

function toggleThis() {
	$(this).siblings('ul:first').slideToggle('slow');
	$(this).parent().toggleClass('on');
	expand_symbol = $(this).find('strong:first');
	if(expand_symbol.text() == '-') {
		expand_symbol.text('+');
	} else {
		expand_symbol.text('-');
	}
}

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

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'
	}); 
}