$(function(){

	$("#update_captcha").live('click',function (e){
        e.preventDefault();
        $("#captcha_img").attr('src','/captcha.php?'+Math.random());
        return false;
    });
	$('.gall-tumbler li.first').bind('click', function(){
		$(document).stopTime();
		$('.gall-tumbler li.last').addClass('active');$('.gall-tumbler li.first').removeClass('active');$('.gall-tumbler .tumbler span').addClass('tumb-left');$('.gall-tumbler .tumbler span').removeClass('tumb-right');
		$("#list_1").show();
		$("#list_2").hide();
		$(".main-foto img").attr('src', $("#list_1 img.item").parent().attr('href'));
		$(document).everyTime(5000, function(){autochoose();});
		return false;
	});
	$('.gall-tumbler li.last').bind('click', function(){
		$(document).stopTime();
		$('.gall-tumbler li.first').addClass('active');$('.gall-tumbler li.last').removeClass('active');$('.gall-tumbler .tumbler span').addClass('tumb-right');$('.gall-tumbler .tumbler span').removeClass('tumb-left');
		$("#list_2").show();
		$("#list_1").hide();
		$(".main-foto img").attr('src', $("#list_2 img.item").parent().attr('href'));
		$(document).everyTime(5000, function(){autochoose();});
		return false;
	});
/*
	$('.list .last a').bind('click',function(){$('.list .item').appendTo($('.list .item').parents('li').next('li').children('a'));return false})
	$('.list .first a').bind('click',function(){$('.list .item').appendTo($('.list .item').parents('li').prev('li').children('a'));return false})
*/	
	
	$('.tel span').bind('click', function(event){
		black_fon=document.createElement('div');
		black_fon.className='black_fon';
		$('body').append(black_fon);
		$('.black_fon').fadeTo(0, 0.4);
		$('.popup').fadeIn('slow');
		$('.popup').css('top',  298.5 + parseFloat($(window ).scrollTop()) + 'px');
	});
	$('.close').bind('click',function(){$('.popup').hide().parents('body').children('.black_fon').remove();})
	
	
			var placeholder = $( ".col_left" );
			var index = $( ".menu" );
			$( window ).bind("scroll resize",function(){
					var placeholderTop = placeholder.offset().top-20;
					var viewTop = $( window ).scrollTop();
					if ((viewTop > placeholderTop) &&!index.is( ".index-fixed" )){
						placeholder.height(placeholder.height());
						index.addClass( "index-fixed" );
					} 
					else if ((viewTop <= placeholderTop)&&index.is( ".index-fixed" )){
						placeholder.css( "height", "auto" );
						index.removeClass( "index-fixed" );
					}
				}
			);
});
