$(document).ready(function() {
	var gridAlbums = $('.photos-page-block');
	jQuery.each(gridAlbums, function() {
		var img = $('img', this)[0];
		if ($(img).parent().attr('href') == undefined) { //image isn't already linked
			var newSrc = $(img).attr('src').replace(/small_/, "");
			$(img).wrap("<div class='photo-mask'></div>");
			$(img).wrap("<a href='"+newSrc+"' class='thickbox' rel='gallery-album'></a>");
		}
		$(this).bind("mouseenter",function(){
			$('.photo-mask', this).animate({opacity:0.7}, 100);
    	}).bind("mouseleave",function(){
			$('.photo-mask', this).animate({opacity:1}, 300);
		}).click(function(){
		  if ($(this).find("a", this).attr("href") != undefined) {
		  	window.location=$(this).find("a", this).attr("href"); return false;
		  }	
		});
	});
	var gridAlbums = $('.gallery-list li');
	jQuery.each(gridAlbums, function() {
		var img = $('img', this)[0];
		if ($(img).parent().attr('href') == undefined) { //image isn't already linked
			var newSrc = $(img).attr('src').replace(/small_/, "");
			$(img).wrap("<div class='photo-mask'></div>");
			$(img).wrap("<a href='"+newSrc+"' class='thickbox' rel='gallery-album'></a>");
		}
		$(this).bind("mouseenter",function(){
			$('.photo-mask', this).animate({opacity:0.7}, 100);
    	}).bind("mouseleave",function(){
			$('.photo-mask', this).animate({opacity:1}, 300);
		}).click(function(){
		  if ($(this).find("a", this).attr("href") != undefined) {
		  	window.location=$(this).find("a", this).attr("href"); return false;
		  }	
		});
	});
	
	$("a.thickbox").fancybox();
}); //end document ready
