// JavaScript Document
$(function() {
	
bindLB();
	
function bindLB() {	
	$('#gallery a[rel="lightbox"]').lightBox(); 
	$('#gallery a[rel="lightbox"] img').hover(
		function(){
			$(this).fadeTo('fast', 1.0);
		},
		function() {
			$(this).fadeTo('fast', 0.75);
		});
}
		
		
//Search for link with REL set to ajax
$('a[rel=ajax]').click(function () {
								  
	//clear the selected class and add the class to the selected link
	$('a[rel=ajax]').removeClass('active');
	$(this).addClass('active');
		
	
	//grab the album ID text
	var aid = $(this).attr('attr');
		
	//hide the content
	$('#gallery').hide();
	$('#loading').show();
	
	//run the ajax
	getPage(aid);
			
	//cancel the anchor tag behaviour
	return false;
});	


function getPage(aid) {
	
	//generate the parameter for the php script
	var data = 'aid=' + aid;
	$.ajax({
		url: "/includes/classes.php",	
		type: "POST",		
		data: data,		
		cache: false,
		success: function (html) {	
					
			//add the content retrieved from ajax and put it in the #gallery div
			$('#gallery').html(html);
			$('#loading').hide();
			
			//display the body with fadeIn transition
			$('#gallery').fadeIn('slow');
			bindLB();
		}		
	});
}
		
		
		
});

