// gallery.view.js

$(document).ready(function() {
	var cache = new Object;
	
	$('#facebox .footer a').livequery('click', function(e) {
		var url = $(this).attr('href');
		
		if(url.match(/func/i))
			return true;
		
		if(typeof cache[url] == 'undefined') {
			$.ajax({
				type: 'POST',
				url: url,
				dataType: 'html',
				processData: false,
				success: function(data) {
					cache[url] = $(data).find('#facebox');
					
					swapPhoto(cache[url]);
				}
			});
		} else {
			swapPhoto(cache[url]);
		}
		
		return false;
	});
	
	function swapPhoto(data) {
		//$('#plugin_gallery.gallery .item').html(data.html());
		$('#facebox').html(data.html());
	}
});
