﻿function e_move(o, delta, interval)
{
	var offset = o.scrollLeft() + delta;
	o.animate({ scrollLeft: offset }, interval, function()
	{
		if (o.hasClass("animated"))
		{
			e_move(o, delta, interval);
		}
	});
}

$(document).ready(
	function()
	{
		$("a").gaAddon({ trackInternal: true });
	
		$(".left-btn").mousedown(function()
		{
			var gallery = $(this).siblings(".images:first");
			gallery.addClass("animated");
			e_move(gallery, -3, 5);
		}).mouseup(function()
		{
			var gallery = $(this).siblings(".images:first");
			gallery.removeClass("animated");
		}).mouseout(function()
		{
			var gallery = $(this).siblings(".images:first");
			gallery.removeClass("animated");
		}).css({ cursor: 'pointer' });

		$(".right-btn").mousedown(function()
		{
			var gallery = $(this).siblings(".images:first");
			gallery.addClass("animated");
			e_move(gallery, 3, 5);
		}).mouseup(function()
		{
			var gallery = $(this).siblings(".images:first");
			gallery.removeClass("animated");
		}).mouseout(function()
		{
			var gallery = $(this).siblings(".images:first");
			gallery.removeClass("animated");
		}).css({ cursor: 'pointer' });

		$("div#rotator").cycle({
			fx: 'fade',
			timeout: 13000,
			speed: 2000
		});

		$("div#newsletter-signup input.text").focus(function()
		{
			if (this.value == this.defaultValue)
			{
				this.value = "";
			}
		}).blur(function()
		{
			if (this.value.length == 0)
			{
				this.value = this.defaultValue;
			}
		});

		var href = window.location.href;
		if (href.indexOf('/translate_c?') != -1)
		{
			$("li > span").each(
				function()
				{
					if ($(this).attr("onmouseout") != 'undefined')
					{
						$(this).attr("style", "margin:0px;padding:0px;");
					}
				}
			);
			$("span.google-src-text").attr("style", "margin:0px;padding:0px;");
		}
	}
);