$(document).ready(function(){

	$(".tags .tag-artwork-cover").hover(
		function () {
			$(this).find('.tag-cover-rec').stop().animate({ top : "-8px" }, 'fast');  
		},
		function () {
			$(this).find('.tag-cover-rec').stop().animate({ top : "0px" }, 'fast');  
		}
	);
	
	$(".tags li").stop().hover(
		function () {
			$(this).find('.popup').stop(true,true).fadeIn('fast').animate({ top : "-4px" }, 'fast');  
		},
		function () {
			$(this).find('.popup').stop(true,true).fadeOut('fast').animate({ top : "0px" }, 'fast');  
		}
	);
	
	$('.thumb-gallery ul li a.click').click(function() {
		var image_id = $(this).attr('id');
		$(this).parents('.gallery').find('.loader').fadeIn('fast');
		setTimeout("swapMainImage('"+image_id+"')",500);
		return false;
	});
	
	// get artist images for posts
	if ( $('.artist-container').length > 0 ) {
		$('.artist-container').each(function() {
			var artist_name = $(this).find('.artist-name').html();
			var file = '/wp-content/themes/blank/artist_img.php?name='+escape(artist_name);
			var img = '';
			var artist_link = this;
			$.get(file, function(data){
				$(artist_link).find('.artist-img').css('background', 'url('+data+') no-repeat 50% 50%');
			});
		});
	}
	
});

function swapMainImage(image_id) {
	var img = $('#'+image_id).attr('href');
	$('#'+image_id).parents('.gallery').find('.main-image').css('background-image','url("'+img+'")');
	$('#gallery-loader').attr('src', img).load(function() {  
		$('#'+image_id).parents('.gallery').find('.loader').fadeOut('fast');
	});  
}
