function fpLoadPreview(view,nid) {
	$.getJSON('/sajax/get/'+view+'/'+nid, function(data) {
		$('#firstbox').html(data.content);
	});
}

$(function() {
	$('#gallery-image-list a').click(function() {
		if($(this).attr('rel') == 'video') {
			$('#gallery-image').hide();
			$('#gallery-video').show();
			$('#gallery-video').attr('src', $(this).attr('href'));
		} else {
			$('#gallery-video').hide();
			$('#gallery-image').show();
			$('#gallery-image img').attr({'src':$(this).attr('href'), 'name':$(this).attr('class')});
		}
		return false;
	});
	
	$('#gallery-image-list .right-scroll').click(function() {
		$('#gallery-image-list .image-previews').cycle({
			fx: 'scrollRight',
			speed: 250
		});
	});
});


$(function(){
	if($('#gallery-image-list img').length < 2) return;
	$('#gallery-image img').attr('name', '-1').after('<div class="prev"></div><div class="next"></div>');
	$('#gallery-image').hover(
		function(){
			$('#gallery-image .next, #gallery-image .prev').fadeIn();
		},
		function(){
			$('#gallery-image .next, #gallery-image .prev').fadeOut();
		}
	);
	$('#gallery-image .next').click(function(){
		var i = Number($('#gallery-image img').attr('name')) + 1;
		var href = $('#gallery-image-list a.'+i).attr('href');
		if(!href){
			var href = $('#gallery-image-list a:first').attr('href');
			i = 0;
		}
		$('#gallery-image img').attr('name', i);
		$('#gallery-video').hide();
		$('#gallery-image').show();
		$('#gallery-image img').attr('src', href);
	});
	$('#gallery-image .prev').click(function(){
		var i = Number($('#gallery-image img').attr('name')) - 1;
		var href = $('#gallery-image-list a.'+i).attr('href');
		if(!href){
			var href = $('#gallery-image-list a:last').attr('href');
			i = $('#gallery-image-list a').index($('#gallery-image-list a:last'));
		}
		$('#gallery-image img').attr('name', i);
		$('#gallery-video').hide();
		$('#gallery-image').show();
		$('#gallery-image img').attr('src', href);
	});
});

$(function(){
	$('#block-block-11 h4').hover(
		function(){
			$(this).next().next().next().next().fadeIn();
		}, 
		function(){
			$(this).next().next().next().next().fadeOut();
		}
	);
	
	$('#block-views-memorial-block_1 a#memorials-link').hover(
		function(){
			$(this).next().next().fadeIn();
		}, 
		function(){
			$(this).next().next().fadeOut();
		}
	);
	
	$('#block-block-16 h2, #block-block-17 h2').hover(
		function(){
			$(this).next().children('.pop_descr').fadeIn();
		}, 
		function(){
			$(this).next().children('.pop_descr').fadeOut();
		}
	);
});

$(function(){
	if($('#edit-holiday-node-form').length < 1) return;
	Drupal.settings.datePopup['edit-field-date-0-value-datepicker-popup-0'].settings.changeYear = false;
	//Drupal.settings.datePopup['edit-field-date-0-value-datepicker-popup-0'].settings.dateFormat = 'dd.mm.yy';
	Drupal.settings.datePopup['edit-field-date-0-value2-datepicker-popup-0'].settings.changeYear = false;
	//Drupal.settings.datePopup['edit-field-date-0-value2-datepicker-popup-0'].settings.dateFormat = 'dd-mm';
});

function init(carousel){
	$(window).focus(function(){
		carousel.startAuto();
	});
	$(window).blur(function(){
		carousel.stopAuto();
	});
	carousel.clip.hover(function() {
		carousel.stopAuto();
	}, function() {
		carousel.startAuto();
	});
	if(!$.browser.safari && !$.browser.opera) return;
	$(window).resize(function(){
		carousel.setup();
	});
};
