$(document).ready(function() {	

	newArtist("#dennison_griffith");

	//START ARTIST GALLERY PAGE CHOOSER
	$("#artist_gallery_title").click(function(e) {
												
		if($(e.target).hasClass("pagination")) {
			$("#artist_gallery_thumbs img").css("display", "none");
			var nextPage = $(e.target).attr("href");
			nextPage = nextPage.substring(1);
			$("#artist_gallery_thumbs img."+nextPage).css("display", "inline");
			$("#artist_gallery_title a").removeClass("active");
			$(e.target).addClass("active");
		};
		return false;
	
	});//END ARTIST GALLERY PAGE CHOOSER
	
	
	//START ARTIST GALLERY THUMBNAIL CLICK
	$("#artist_gallery_thumbs img").live("click", function(e) {
			$("#artist_gallery_subtitle").fadeOut(500);
			$("#artist_gallery_large").fadeOut(500, function() {
				var picTitle = $(e.target).attr("title")+"<br>"+$(e.target).attr("size")+"<br>"+$(e.target).attr("method");
				$("#artist_gallery_subtitle").html($(e.target).parent().attr("title")+"<br>"+$(e.target).parent().attr("size")+"<br>"+$(e.target).parent().attr("method"));
				$("#artist_gallery_large").html('<img src="'+$(e.target).attr("id")+'_large.jpg" /><br /><div id="artist_gallery_subtitle">'+picTitle+'</div>');
				$("#artist_gallery_large").fadeIn(500);
				$("#artist_gallery_subtitle").fadeIn(500);
			});
		return false;
	
	});

	
	//BEGIN ARTISTS GALLERY AND BIOS
	$("#artist_list a").click(function(e) {
	
		if($(e.target).hasClass("more") == false) {
			
			$(".active").removeClass("active");
			$(e.target).addClass("active");
			
			$("#artist_gallery_title").fadeOut(500);
			$("#artist_gallery_thumbs").fadeOut(500);
			$("#artist_gallery_large").fadeOut(500);
			$("#artist_gallery_subtitle").fadeOut(500);
			$("#artist_bio").fadeOut(500, function() {
			
			newArtist($(e.target).attr("href"));
												
			});//end fade out	
			
		}//end if statement
		
		return false;

	});//END ARTIST GALLERY AND BIOS
	
	function newArtist(startID) {
	if(startID == undefined) {
		var newBio = $(e.target).attr("href");
	} else {
		var newBio = startID;
	}
	var imageName = newBio.substring(1);
	var newBioContent = $(newBio).html();
	$("#artist_bio").html(newBioContent);
	
	$("#artist_gallery_thumbs").html("");
	$("#artist_gallery_title").html("");
	var thumbCounter = 1;
	var thumbPages = 1;
	$(newBio+"_images a").each(function() {

		if(thumbCounter > 5) { thumbCounter = 1; $("#artist_gallery_title").append('<a href="#'+thumbPages+'" class="pagination">'+thumbPages+'</a>'); thumbPages++;};
		$("#artist_gallery_thumbs").append('<img src="images/artists/'+imageName+'/'+$(this).attr("href").substring(1)+'.jpg" border="0" class="'+thumbPages+'" id="images/artists/'+imageName+'/'+$(this).attr("href").substring(1)+'" title="'+$(this).attr("title")+'" size="'+$(this).attr("size")+'" method="'+$(this).attr("method")+'" />');
		thumbCounter++;

	
	});//END EACH
	
	if(thumbPages >= 2) {
		$("#artist_gallery_title").append('<a href="#'+thumbPages+'" class="pagination">'+thumbPages+'</a>');
	}
	
	$("#artist_gallery_title a:first").addClass("active");
	
	var firstImage = $(newBio+"_images a:first").attr("href");
	firstImage = firstImage.substring(1);
	//$("#artist_gallery_subtitle").html($(newBio+"_images a:first").attr("title")+"<br>"+$(newBio+"_images a:first").attr("size")+"<br>"+$(newBio+"_images a:first").attr("method"));
	var picTitle = $(newBio+"_images a:first").attr("title")+"<br>"+$(newBio+"_images a:first").attr("size")+"<br>"+$(newBio+"_images a:first").attr("method");
	$("#artist_gallery_large").html('<img src="images/artists/'+imageName+'/'+firstImage+'_large.jpg" /><br /><div id="artist_gallery_subtitle">'+picTitle+'</div>');


	$("#artist_gallery_large").fadeIn(500);
	$("#artist_gallery_title").fadeIn(500);
	$("#artist_gallery_thumbs").fadeIn(500);
	$("#artist_bio").fadeIn(500);
	$("#artist_gallery_subtitle").fadeIn(500);
						
	}//end new artist

});//END DOCUMENT