var l=null,r=null,pl=true;
function mkL(e){var d=$('#'+e);clearTimeout(l);d.scrollLeft(d.scrollLeft()+1);l=setTimeout('mkL(\''+e+'\')',10);}
function mkR(e){var d=$('#'+e);clearTimeout(r);d.scrollLeft(d.scrollLeft()-1);r=setTimeout('mkR(\''+e+'\')',10);}
function st(){clearTimeout(r);clearTimeout(l);}

$(function(){

	$('script').each(function(){if($(this).attr('src') && $(this).attr('src').match(/\/home.js\?en$/g)) pl=false;});

	$('#pane').jScrollPane({scrollbarWidth:17, scrollbarMargin:10});
	
	$('#pane p').click( function() {
		var input = $(this).find('input');
		if ($(this).attr('class') == 'selected') {
			$(this).removeClass('selected');
			input.val( 0 );
		} else {
			$(this).addClass('selected');
			input.val( 1 );
		}
	});

	$('input[name="q"]').focus(function(){$(this).val('');}).val(pl?'wpisz szukane słowo':'enter search word');
	$('input[name="login"]').focus(function(){$(this).val('');}).val(pl?'wpisz login':'enter login');
	$('input[name="passwd"]').focus(function(){$(this).val('');}).val(pl?'wpisz hasło':'enter password');
	$('input[name="newsletter"]').attr('autocomplete','off').focus(function(){$(this).val('');}).val(pl?'twój adres e-mail':'your e-mail address');
		
	$('div.zdjecia_r').each(function(x){
		$(this).children('div').attr('id','roll_'+x);
		$($(this).children('a')[0]).click(function(){var d=$(this).next().next();d.animate({scrollLeft:d.scrollLeft()-300},200);return false;}).hover(function(){mkR($(this).next().next().attr('id'));},st).click(function(){return false;});
		$($(this).children('a')[1]).click(function(){var d=$(this).next();d.animate({scrollLeft:d.scrollLeft()+300},200);return false;}).hover(function(){mkL($(this).next().attr('id'));},st).click(function(){return false;});
	});
	
	$('.zakl li a').each(function(x){
		$(this).attr('id','_z'+x);
		$($('div.zakl').get(x)).attr('id','_zd'+x);
	}).click(function(){
		var z = $(this).parent().parent();
		var p = z.hasClass('z1') ? '1' : '2';
		var x = z.find('li.sel'+p);
		if(x.length==1)
		{
			x.removeClass('sel'+p);
			$('#'+x.children().get(0).id.replace('_z','_zd')).addClass('hc');
		}
		$('#'+$(this).attr('id').replace('_z','_zd')).removeClass('hc');
		$(this).blur().parent().addClass('sel'+p);
		
		return false;
	});
})
