$(function() {
	$('div#nav_header div').css('cursor', 'pointer');
	var changePanel = function() {
		$('div#nav_header div').removeClass('current');
		$('ul#panels li.panel').stop().hide().each(
				function() {
					var $this = $(this);
					var zIndex = parseInt($this.css('z-index'));
					zIndex = zIndex === 3 ? 1 : zIndex + 1;
					$this.css('z-index', zIndex);
					if (zIndex === 3) {
						$this.stop().fadeIn(800);
						$('div#nav_header div.' + $this.attr('id')).addClass(
								'current');
					}
				});
	};

	var interval = setInterval(changePanel, 10000);

	$('div#nav_header div').click(function() {
		$thisNav = $(this);
		if (!$thisNav.hasClass('current')) {
			clearInterval(interval);
			$('div#nav_header div').removeClass('current');

			var panelToShow = $thisNav.attr('class').match(/panel_\d/)[0];

			$('ul#panels li.panel').hide().each(function() {
				var $this = $(this);
				if ($this.attr('id') === panelToShow) {
					$this.css('z-index', 3);
					var index = 2;
					$this.nextAll('li').each(function() {
						$(this).css('z-index', index);
						index--;
					})
					index = 1;
					$this.prevAll('li').each(function() {
						$(this).css('z-index', index);
						index++;
					})
					$this.stop().fadeIn(800);
				}
			});
			$thisNav.addClass('current')
			interval = setInterval(changePanel, 10000);
		}
	});

	$('input[type="text"], input[type="password"], textarea, select').focus(function() {
		$(this).addClass('input_focus');
	}).blur(function() {
		$(this).removeClass('input_focus');
	});

    //change lang;
   // $('a#change-to-PL').hide();
    $('a#change-country').parent().hover(function() {
        if ($(this).prev($('img[USA]'))) {
            $('a#change-to-PL').show();
        }
    }, function() {
        $('a#change-to-PL').hide();
    });
})
