$(document).ready(
  function()
  {
	$('.pos').hover(
		function()
		{
			$(this).find('>a').addClass('hover');
			$(this).find('>ul').show();
		},
		function()
		{
			$(this).find('>a').removeClass('hover');
			$(this).find('>ul').hide();
		}
	);

	/* Tabs */
	$('.under_menu:first').show();
	FirstTab = $('.vkladki .vkladka').index($('.vkladki .vkladka:first'));
	$('#tabcont_'+FirstTab).show();
	CurTab = $('#tabcont_'+FirstTab);
	$('.vkladki .vkladka:first').addClass('vkladka_act');
	$('.vkladki .vkladka').click(function(){
		$(this).siblings().removeClass('vkladka_act').end().addClass('vkladka_act');
		var index = $('.vkladki .vkladka').index($(this));
		$(CurTab).slideUp(1, function()
			{
				//$('#tabcont_'+index).slideDown(300);
				$('#tabcont_'+index).slideDown(1);
			}
		);
		CurTab = $('#tabcont_'+index);
	});

	/*Promo*/
	indexFirst = $('.points_btn div').index($('.points_btn div:first'));
	$('.points_btn div:first').addClass('active');
	$('#promo'+indexFirst).show();
	curBlock = $('#promo'+indexFirst);
	$('.points_btn div').click(function()
	{
		var index = $('.points_btn div').index($(this));
		$(curBlock).fadeOut(400, function()
			{
				setTimeout(showbl,400);
				function showbl()
				{
					$('#promo'+index).fadeIn(400);
				}
			}
		);
		curBlock = $('#promo'+index);
		$(this).siblings().removeClass('active').end().addClass('active');
	}
	);


	/*accordion*/
	/*curShow = $('.list_events_bl .list_evs_li:first');
	$('.list_events_bl .list_evs_li:first .text_event').show();
	$('.list_events_bl .list_evs_li .tit').hover(
	function()
	{
		thisis=$(this);
		thisparent = $(this).parent();
		$(curShow).find('.text_event').slideUp(500, function(){
			$(thisis).parent().find('.text_event').slideDown(500);
		});
		curShow = $(this).parent();
	}
	);*/

	    curShow = $('.list_events_bl .list_evs_li:first');
	    $('.list_events_bl .list_evs_li:first .text_event').show();
	    $('.list_events_bl .list_evs_li .tit').click(
	    function()
	    {
	        if ($(this).next('.text_event').css('display')=='none') {
	            thisis=$(this);
	            thisparent = $(this).parent();
	            $(curShow).find('.text_event').slideUp(200, function(){
	                $(thisis).parent().find('.text_event').slideDown(200);
	            });
	            curShow = $(this).parent();
	        }
	    }
    );
    
    
    
    /* carusel horizontal */
	try
	{
		$('.carusel_h').jcarousel({scroll: 1});
	}
	catch(e) {;}

	$('.carusel_h').css('overflow','visible');	
	
	$('.jcarousel-next').hover(function(){
		if ($(this).hasClass('jcarousel-next-disabled')) {
		}
		else {
			$(this).addClass('active-jcarousel-next')
		}
	},function(){
		$(this).removeClass('active-jcarousel-next');
	});
	
	$('.jcarousel-prev').hover(function(){
		if ($(this).hasClass('jcarousel-prev-disabled')) {
		}
		else {
			$(this).addClass('active-jcarousel-prev')
		}
	},function(){
		$(this).removeClass('active-jcarousel-prev');
	});
	
	$('.jcarousel-next').click(function(){
			$('.jcarousel-prev').removeClass('active-jcarousel-prev');
	});
	
	$('.jcarousel-prev').click(function(){
			$('.jcarousel-next').removeClass('active-jcarousel-next');
	});
    
    

  }

);
        $(function () 
					{ 
						$(".bpic").click(function() { 							
							var img = new Image(); 
							url = $(this).attr("rel");
							img_title = $(this).attr("m_rel");
							img.src=url;
							
							$("#url_bpic").attr('href',url);
								
							$("#photo_name").html(img_title);


							var tst = $("#url_bpic").attr('href');

							$(img).load(function (){ 
	

								$('#bpic').removeClass('loading').empty().append(this); 
								$("#bpic").fadeOut('fast',function()
								{
									$("#bpic").attr('src',url);
									$("#bpic").fadeIn('fast');
								}); 
								
							});
						});
						
					});	

function ReNewCaptchaById(imageId, captchaKey, captchaHeight)
{	
	// Пытаемся получить скрытый объект для input-а
	var captchaObject = document.getElementById(imageId);

	// Элемента нет, добавим его
	if (null != captchaObject && undefined !== captchaObject)
	{
		var antiCache = Math.floor(Math.random()*100000);
		captchaObject.src = "/captcha.php?get_captcha=" + captchaKey + "&height=" + captchaHeight + "&anc=" + antiCache;
	}
}
