jQuery(document).ready(function($)
{
	var IMG_WIDTH = 211;
	var SPACER = 12;
	var SLIDE_WIDTH = IMG_WIDTH + SPACER;
	var PREVIEW_PATH = '/files/styles/gallery-block/public/';
	
	var block = $('#block-screenshots');
	
	if (block.length > 0)
	{
		var gallery = $('.fancybox-gallery', block);
		var wrapper = $('.wrapper', gallery);
		
		var prev = $('<a class="arrow arrow-prev" href="#"></a>');
		var next = $('<a class="arrow arrow-next" href="#"></a>');
		
		gallery.after(prev).after(next);
		
		var cnt = 0;
		var firstImage = null;
		var lastImage = null;
		
		$('a', wrapper).each(function(index, element)
		{
			cnt ++;
			
			if (index > 0)
			{
				element = $(element);
				var img = $('<img/>').attr('src', element.attr('href').replace('/files/', PREVIEW_PATH));
				element.append(img);
				
				lastImage = img.clone();
			}
			else
			{
				firstImage = $('img', element).clone();
			}			
		});
		
		wrapper.prepend($("<a></a>").append(lastImage));
		wrapper.append($("<a></a>").append(firstImage));
		
		$('img', wrapper).css('margin', '0 ' + SPACER + 'px 0 0');
		
		wrapper.css({'width': (cnt + 2) * SLIDE_WIDTH + 'px', 'left': -SLIDE_WIDTH + 'px'});
		
		var index = 1;
		var lastIndex = cnt + 1;
		var sliding = false;
		
		next.click(function()
		{
			if (!sliding)
			{
				sliding = true;
				
				index++;
				
				wrapper.animate({'left': - index * SLIDE_WIDTH}, 'fast', 'swing', function()
				{
					if (index == lastIndex)
					{
						index = 1;
						wrapper.css({'left': - index * SLIDE_WIDTH});
					}
					
					sliding = false;
				});
			}
			
			return false;
		});
		
		prev.click(function()
		{
			if (!sliding)
			{
				sliding = true;
				
				index--;

				wrapper.animate({'left': - index * SLIDE_WIDTH}, 'fast', 'swing', function()
				{
					if (index == 0)
					{
						index = lastIndex - 1;
						wrapper.css({'left': - index * SLIDE_WIDTH});
					}
					
					sliding = false;
				});
			}
			
			return false;
		});		
	}
});;
jQuery(document).ready(function($)
{
	function isBlank(str) { return (!str || /^\s*$/.test(str)); }
	function hasFocus(elem) { return elem === document.activeElement && (elem.type || elem.href); }
	
	var emptyEmail = 'e-mail';
	
	var emailField = $('#edit-subscribe-email');
	
	emailField.val(emptyEmail);

	emailField.focus(function()
	{
		if (emailField.attr('value') == emptyEmail)
			emailField.attr('value', '');
	});
	
	emailField.blur(function()
	{
		if (isBlank(emailField.attr('value')))
			emailField.attr('value', emptyEmail);
	});
	
	$('#mod-rq-subscribe-form .form-submit').hover
	(
		function()
		{
			if (emailField.attr('value') == emptyEmail)
				emailField.attr('value', '');
		},
		function()
		{
			if (!hasFocus(emailField.get(0)) && isBlank(emailField.attr('value')))
				emailField.attr('value', emptyEmail);
		}		
	);	
});;

