jQuery.noConflict();

jQuery(function($){
/* home */
	$('#home_pics').tabs('div', {
		effect: 'fade',
		fadeInSpeed: homeFade,
		fadeOutSpeed: homeFade,
		rotate: true
	}).slideshow({
		autoplay: true,
		interval: homeInterval
	});

/* news */
	$('#news').scrollable({
		size: 1,
		items: '#news_scroll',
		speed: newsSpeed,
		circular: true
	}).autoscroll(newsInterval);

/* scrollbars */
	var jSPOptions = {
		scrollbarWidth: 5,
		reinitialiseOnImageLoad: true
	};
	$('.scrollpane').jScrollPane(jSPOptions);

/* work */
	$('.work li a').click(function(){
		$('.work li a').removeClass('current');
		var tmpContentID = $(this).attr('href'),
			tmpContent = $(tmpContentID).html();
		$('#work_content').fadeOut(200, function(){
			$('#work_content').html(tmpContent);
			var pics = $('#work_content .work-pics');
			pics.tabs('img', {
				effect: 'fade',
				fadeInSpeed: workFade,
				fadeOutSpeed: workFade,
				rotate: true
			}).slideshow({
				autoplay: true,
				interval: workInterval
			});
			var picsNav = $('#work_content .work-pics-nav');
			$('#work_content .work-pics-container').hover(
				function(){
					picsNav.fadeIn();
				},
				function(){
					picsNav.fadeOut();
				}
			);
			$('#work_content .post-content').jScrollPane(jSPOptions);
		});
		$('#work_content').fadeIn(400);
		$(this).addClass('current');
		return false;
	});
	$('.work li:first a').click();

/* client photos */
	if ($('#client_thumbs a').size()){
		var img = $('#client_thumbs a');
		$('#gallery_link').attr('href', function(){ return img.attr('rel'); });
		$('#gallery_img').attr('src', function(){ return img.attr('href'); });
		$('#client_thumbs a:first').addClass('active');
		$('#client_thumbs a').click(function(){
			var img = $(this);
			if (img.hasClass('active')) { return false; }
			$('#gallery').fadeOut('', function(){
				$('#gallery_link').attr('href', function(){ return img.attr('rel'); });
				$('#gallery_img').attr('src', function(){ return img.attr('href'); });
				$('#gallery').fadeIn();
			});
			$('#client_thumbs a').removeClass("active");
			img.addClass('active');
			return false;
		});
		$('#gallery_link').click(function(){
			var img = $(this);
			$('#big_gallery_img').attr('src', function(){ return img.attr('href'); });
		})
			.overlay({
			top: '5%',
			mask: {
				color: '#fcd2ea',
				loadSpeed: 200,
				opacity: 0.9
			},
			target: '#big_gallery'
		});
	}
});
