$(function(){
	$.extend($.fn.disableTextSelect = function() {
		return this.each(function(){
			if($.browser.mozilla){//Firefox
				$(this).css('MozUserSelect','none');
			}else if($.browser.msie){//IE
				$(this).bind('selectstart',function(){return false;});
			}else{//Opera, etc.
				$(this).mousedown(function(){return false;});
			}
		});
	});
	$('.noSelect').disableTextSelect();//No text selection on elements with a class of 'noSelect'
});

$(document).ready(function() {
	
	$('.scroller').jScrollPane({scrollbarWidth:6});
	
	$("#mycarousel").jcarousel({
		scroll: 1,
		  animation: "slow",
		  vertical: false,
		  auto: 0
	
	});
	
	$("#mycarousel img").css("display", "");
	
	$("a.popuplink").fancybox({
		'titlePosition'		: 'inside',
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'padding'			: 0,
		'overlayOpacity'	: 0.25,
		'overlayColor'		: '#000',
		'titleShow'			: false

	});
	
	$('#mycarousel').disableTextSelect();
});


function toggleVideo(on) {
	
	//todo: move this into an external file
	
	var slideshow = $('#mycarousel');
	var video = $('#videoreel');
	var showTab = null;
	
	switch(on) {
		case true:
		case 'video': showTab = $('#videoreel'); break;
		case 'showreel': showTab = $('#flashshowreel'); break;
		case 'photos':
		default: // to photos
			showTab = $('#mycarousel');
			break;
	}

	// Skip if the tab is already showing
	if (showTab.css('opacity') == 1) return false;
	
	$('.tabbys').animate({opacity:0}, 500, function() { 
			$(this).not(showTab).css({'position':'absolute', 'left':0, 'display':'none'}); 
			showTab.css('position', 'relative')
				.css({'display':'block', 'left':0})
				.animate({opacity:1},500);  // fade in tab they selected
		});  // fade out tabs
	
	return false;
	/*if (on) {
		//show video
		slideshow.css('position', 'absolute'); //position it absolute and hide it off the screen to work around a problem in IE7 with jcarousel when made display:none
		slideshow.css('left', '-1000px');
		video.css('display', 'block');
	}
	else {
		//show gallery
		slideshow.css('position', 'relative');
		slideshow.css('left', '0');
		video.css('display', 'none');
	}*/
}
