// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

function add_image(image_id) {
	// send ajax request to add image to the current users gallery
	$.post('/gallery/add_image/'+image_id, function(data) {
	  $('#img_icons_'+image_id).html(data);
		update_image_total();
	});
}

function remove_image(image_id) {
	// send ajax request to add image to the current users gallery
	$.post('/gallery/remove_image/'+image_id, function(data) {
	  $('#img_icons_'+image_id).html(data);
		update_image_total();
	});
}

function update_image_total() {
	$.get('/gallery/count_top/', function(data) {
	  $('#gallery-count-top').html(data);
	});
	$.get('/gallery/count_bottom/', function(data) {
	  $('#gallery-count-bottom').html(data);
	});
	$.get('/gallery/bottom_order/', function(data) {
		$('#bottom_order').html(data);
	});
}


