$(document).ready(function(){
	show_curr = function(){
		$('.hidden').hide();
		$(this).parent().next().show();
		$('.block_close').bind('click', hide_curr);
	}
	hide_curr = function(){
		$('.hidden').hide();
	}
	$('.hover').bind('click', show_curr);

//listalko
	var wVopr = $('#list_body').width();
	wVoprNew = (wVopr - 40) / 5;
	
	$('#list_items > .block').css('width', wVoprNew+'px');
	wVoprNew += 15;
	
	var cardCounter = $('#list_items > .block').length;
	var position = 1;
	
	backFunc = function() {
		$('#list_right').unbind('click');
		$('#list_left').unbind('click');
		if (position > 1) {
			position--;
			$('#list_items').animate({
				left: '+='+wVoprNew
			},500);
		}
		if (position == 1) {
			$('#list_left').unbind('click');
			$('#list_left').attr('src', '/images/strelka_left.jpg');
		}
		
		if (position < cardCounter - 4) {
			$('#list_right').attr('src', '/images/strelka_right_active.jpg');
			$('#list_right').bind('click', nextFunc);	
		}
		
		if (position > 1) {
			$('#list_left').bind('click', backFunc);
			$('#list_left').attr('src', '/images/strelka_left_active.jpg');			
		}
		
	}
	
	nextFunc = function() {
		$('#list_right').unbind('click');
		$('#list_left').unbind('click');
		
		if (position < cardCounter - 4) {
			position++;
			$('#list_items').animate({
				left: '-='+wVoprNew
			},500);
		}
		if (position == cardCounter - 4) {
			$('#list_right').unbind('click');
			$('#list_right').attr('src', '/images/strelka_right.jpg');			
		}
		if (position > 1) {
			$('#list_left').attr('src', '/images/strelka_left_active.jpg');
			$('#list_left').bind('click', backFunc);
		}
		if (position < cardCounter - 4) {
			$('#list_right').bind('click', nextFunc);
			$('#list_right').attr('src', '/images/strelka_right_active.jpg');			
		}
	}
	
	if (position < cardCounter - 4) {
		$('#list_right').attr('src', '/images/strelka_right_active.jpg');
		$('#list_right').bind('click', nextFunc);
	} else {
		$('#list_right').attr('src', '/images/strelka_right.jpg');
	}
	
	var curent_height = 0;
	$('#list_items > .block').each(function() {
		if (curent_height < $(this).height()) {
			curent_height = $(this).height();
		}
	});
	$('#top, #list_body, #list_items, #list_body').css('height', curent_height+'px');
	
	$(window).resize(function() {
		var curent_height = 0;
		$('#list_items > .block').each(function() {
			if (curent_height < $(this).height()) {
				curent_height = $(this).height();
			}
		});
		$('#top, #list_body, #list_items, #list_body').css('height', curent_height+'px');

		var wVopr = $('#list_body').width();
		wVoprNew = (wVopr - 40) / 5;
		$('#list_items > .block').css('width', wVoprNew+'px');
		wVoprNew += 15;
	});
	
});
