$(document).ready(function() {

	$('.outer').hover(function() {
		$(this).stop(true, false).delay(15).animate({width:"160px"},350);
	}, function() {
		$(this).stop(true, false).delay(15).animate({width:"60px"},250);
	});
	
	$('#galleryOuterBox').attr('unselectable', 'on')
   .css('-moz-user-select', 'none')
   .each(function() { 
	   this.onselectstart = function() { return false; };
	});

	$("#gallery_1").jCarouselLite({btnNext: "#right1", btnPrev: "#left1"});
	$("#gallery_2").jCarouselLite({btnNext: "#right2", btnPrev: "#left2"});
	$("#gallery_3").jCarouselLite({btnNext: "#right3", btnPrev: "#left3"});
	$("#gallery_4").jCarouselLite({btnNext: "#right4", btnPrev: "#left4"});
	$("#gallery_5").jCarouselLite({btnNext: "#right5", btnPrev: "#left5", circular: false});
	
	$('#tabs div').hover(function() {
		$(this).addClass('tabHover');
	}, function() {
		$(this).removeClass('tabHover');
	});

	$('#tabs div').click(function(){
		if (!($(this).hasClass('tabCurrent'))) {
			$('.tabCurrent').removeClass('tabCurrent');
			$(this).addClass('tabCurrent');
			var IDnum = $(this).attr('id').substr(3,1);
			$('.activeGallery').stop(true,false).animate({top:-300});
			$('.activeGallery').animate({top:300},0);
			$('.activeGallery').removeClass('activeGallery');
			$('#gallery' + IDnum).addClass('activeGallery');
			$('.activeGallery').animate({top:0});
			$('#left1, #left2, #left3, #left4, #left5, #right1, #right2, #right3, #right4, #right5').hide();
			$('#left' + IDnum).show();
			$('#right' + IDnum).show();
		}
	});

	$('#left2, #left3, #left4, #left5, #right2, #right3, #right4, #right5').hide();
	
	$('.galleryItem').click(function(){
		if ($(this).attr('id')) {
			var cat = String($(this).attr('id')).substring(2,String($(this).attr('id')).indexOf('-',0));
			var img = String($(this).attr('id')).substring(String($(this).attr('id')).indexOf('-',0)+1);
			$('#modalDetails').jqm({ajax:'modalContent.php?cat=' + cat + '&img=' + img});
			$('#modalDetails').jqmShow();
		}
	});

});
