$(document).ready(function(){

	// bind clicks on thumbnails
	var bindClickThumbnails = function() {

		$('#musicWrap img').each(

			// For each item, bind the onclick behavior.
			function() {

				// Bind the onclick event 
				$(this).click(
					function() {
						
						var theId = $(this).attr('id'); // get ID of clicked element
						
						// load discog information for this release
						$('#middleColAjax').load('/ajax/merch/' + theId + '.html', null, function(){
							tb_init('a.thickbox, area.thickbox, input.thickbox'); // re-bind thickbox to new discog images
						});


						return false; // return false so the link doesn't actually click anywhere

					}
				);
			}
		);
	};
	
	// bind onclick events on initial pageload
	bindClickThumbnails();

});