$(document).ready(
		function() {
			$("a[rel=obraz]").fancybox(
					{
						'transitionIn' : 'none',
						'transitionOut' : 'none',
						'titlePosition' : 'over',
						'titleFormat' : function(title, currentArray,
								currentIndex, currentOpts) {
							return '<span id="fancybox-title-over"><strong>'
									+ (currentIndex + 1) + '/'
									+ currentArray.length + '</strong> '
									+ title + '</span>';
						},
						'onComplete' : function() {
							$("#fancybox-wrap").hover(function() {
								$("#fancybox-title").show();
							}, function() {
								$("#fancybox-title").hide();
							});
						}
					});
			$("#tresc .opis a img, #tresc .tresc a img, #tresc .wstep a img, #zdjecia-prawa a img").parent().fancybox(
					{
						'transitionIn' : 'none',
						'transitionOut' : 'none',
						'titlePosition' : 'over',
						'titleFormat' : function(title, currentArray,
								currentIndex, currentOpts) {
							return '<span id="fancybox-title-over"><strong>'
									+ (currentIndex + 1) + '/'
									+ currentArray.length + '</strong> '
									+ title + '</span>';
						},
						'onComplete' : function() {
							$("#fancybox-wrap").hover(function() {
								$("#fancybox-title").show();
							}, function() {
								$("#fancybox-title").hide();
							});
						}
					});
			$("a[rel=film]").click(
					function() {
						$.fancybox( {
							'padding' : 0,
							'autoScale' : false,
							'transitionIn' : 'none',
							'transitionOut' : 'none',
							'title' : this.title,
							'width' : 680,
							'height' : 495,
							'href' : this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
							'type' : 'swf',
							'swf' : {
								'wmode' : 'transparent',
								'allowfullscreen' : 'true'
							}
						});

						return false;
					});

		});

function galeria_obraz_usun(obj, id, hash) {
	$.ajax( {
		async : false,
		url : '/galerie_obrazy/usun/' + id + '/' + hash + '/layout:ajax',
		cache : false,
		success : function(data) {
			if (data == 'ok') {
				obj.parentNode.removeChild(obj);
			}
		},
		error : function(request, textStatus, error) {
			alert('AJAX error');
		}
	});
}

function galeria_obraz_przesun(dol, obj, id, hash) {

	$.ajax( {
		async : false,
		url : '/galerie_obrazy/przesun/' + (dol ? 'dol' : 'gora') + '/'
				+ id + '/' + hash + '/layout:ajax',
		cache : false,
		success : function(data) {
			if (data == 'ok') {
				rodzic = obj.parentNode;
				if (dol && rodzic.lastChild != obj) {
					drugi = obj.nextSibling;
					rodzic.replaceChild(drugi, obj);
					rodzic.insertBefore(obj, drugi.nextSibling);
				} else if (!dol && rodzic.firstChild != obj) {
					drugi = obj.previousSibling;
					rodzic.replaceChild(obj, drugi);
					rodzic.insertBefore(drugi, obj.nextSibling);
				}
			}
		},
		error : function(request, textStatus, error) {
			alert('AJAX error');
		}
	});
}

