Art.View = {
		favoriteText: 'Add to Favorites',
		unfavoriteText: 'Favorited',
		favorite: function()
		{
			var val = $.trim($('.favorites a').text());
			var favorited = (val == Art.View.unfavoriteText);
			
			$('.favorites a').text('Sending...');
			
			$.getJSON($('.favorites a').attr('href'), function(){
				if (favorited) {
					$('.favorites a').text(Art.View.favoriteText);
				} else {
					$('.favorites a').text(Art.View.unfavoriteText);
				}
				
				$('.favorites a').click(Art.View.favorite);
			});
			
			$('.favorites a').click(function(){return false;});
			
			return false;
		},
		
		vote: function(vote)
		{		
			$('.promote').hide();
			$('.demote').hide();
			
			var url;
			if (vote == 1) {
				url = $('.promote a').attr('href');
			} else {
				url = $('.demote a').attr('href');
			}
			
			$.getJSON(url);
			
			return false;
		}
};





var animateSpeed = 100;

var artZoomIn = function(){	
	$("#art-prev").animate({ opacity: 0 }, animateSpeed);
	$("#art-next").animate({ opacity: 0 }, animateSpeed);
	$("#user").animate({ opacity: 0 }, animateSpeed);
	$("#art-buttons").animate({ opacity: 0 }, animateSpeed);
	
	$("#art").animate({ 
		width: artWidth,
		height: artHeight
	}, animateSpeed, "linear", function(){
		$("div.art-button-pusher").css('display', 'none');
		$("#art").unbind('click', artZoomIn);
		$("#art").click(artZoomOut);
	});
	return false;
}
var artZoomOut = function(){
	$("div.art-button-pusher").css('display', 'block');
	
	$("#art-prev").animate({ opacity: 1 }, animateSpeed);
	$("#art-next").animate({ opacity: 1 }, animateSpeed);
	$("#user").animate({ opacity: 1 }, animateSpeed);
	$("#art-buttons").animate({ opacity: 1 }, animateSpeed);
	
	
	$("#art").animate({ 
		width: artPreviewWidth,
		height: artPreviewHeight
	}, animateSpeed, "linear", function(){
		$("#art").unbind('click', artZoomOut);
		$("#art").click(artZoomIn);
	});
	return false;
}

$(document).ready(function(){
	$('.favorites a').click(Art.View.favorite);
	$('.promote a').click(function(){return Art.View.vote(1);});
	$('.demote a').click(function(){return Art.View.vote(-1);});
	$("#art").click(artZoomIn);
});