
function mycarousel_initCallback(carousel)
{
	carousel.buttonNext.bind('click', function(){
		carousel.startAuto(0);
	});
		
	carousel.buttonPrev.bind('click', function(){
		carousel.startAuto(0);
	});
		
	carousel.clip.hover(function(){
		carousel.stopAuto();
	}, function(){
		carousel.startAuto();
	});
};


var j = jQuery.noConflict();


j(document).ready(function(){
	
	var shareOpen = false;
	
	j('#albumThumbs ul').jcarousel({
		start: photoStart,
		visible: 5,
		size: numThumbs,
        wrap: 'last',
        initCallback: mycarousel_initCallback
    });
	
	j('.loadingThumbs').fadeOut('fast');
	
	j('#albumThumbs img').fadeTo("slow", 0.50,function(){
		j('#albumThumbs .selected img').fadeTo("slow", 1);
	});
	
	
	j('#albumThumbs img').hover(function(){
			j(this).fadeTo("fast", 1);
		},function(){
			j(this).fadeTo("slow", 0.50);
	});
	
	
	j('#albumThumbs a img,#simplePaging a').click(function(){
		j(document.body).append('<div id="loadingPage"></div>');
	});
	
	
	j('a.comments').click(function(){
		j('#albumComments').slideDown('slow');
	});
	
	
	j('a.share').click(function(){
		j('#imageShare').slideDown('slow',function(){
			shareOpen = true;
		});
	});
	
	
	j(document).click(function(){
		if(shareOpen==true){
			j('#imageShare').slideUp('fast');
			shareOpen = false;
		}
	});
	
	
	j('#postComment').submit(function(){
		var cName = j('#postComment #name');
		var cEmail = j('#postComment #email');
		var cComment = j('#postComment #comment');
		
		if(!cName.val()){
			alert('Name Required!');
			cName.focus();
			return false;
		} else if(!cEmail.val()){
			alert('Email Required!');
			cEmail.focus();
			return false;
		} else if(!cComment.val()){
			alert('Comment Required!');
			cComment.focus();
			return false;
		} else {
			j('#postComment').submit();
			return true;
		}
	});
	
	
});