	$(document).ready(function() {
		fancySetup();
	});


	function fancySetup() {
		$("a.fancy").fancybox({
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'titlePosition' 	: 'over',
			'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
				return '<span id="fancybox-title-over">Image ' +  (currentIndex + 1) + ' / ' + currentArray.length + ' ' + title + '</span>';
			}
		});
		$("a[rel=fancy_group]").fancybox({
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'titlePosition' 	: 'over',
			'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
				return '<span id="fancybox-title-over">Image ' +  (currentIndex + 1) + ' / ' + currentArray.length + ' ' + title + '</span>';
			}
		});
	}


	function reQuery(func){setTimeout(func,1000);}
	function refreshPage(){window.location.href=window.location.href;}
	function ajaxQuery(params) {
		if (typeof(params.query)=='undefined') return false;
		params['rnd'] = Math.random();
		$.getJSON('/ajax.php',params,function(data){
			if (data.status=='waiting'){reQuery(function(){ajaxQuery(params)}); return false;}
			eval('response_'+params.query+'(data,params);');
		});
	}
