$(document).ready( function (){

	$(document).pngFix();
  $('.avatar-download').change(function()
	{
		$('.avatar-download-text').val($(this).val());
	});

  $('.main-slider').MainSlider();
   $('.blog-slider').MainBlogSlider();
  
	$('#auth-popup-open').click(function(){
		$('.auth-popup').fadeIn('slow');
		$('.popup-content').show();
		return false;
	});
  
	$('.close-auth-popup').click(function(){
		$('.auth-popup').hide();
		$('.popup-content').hide();
		return false;
	});

	$('.search-input').val('Поиск по сайту');
	$('.search-input').mouseover(function()
	{
		if($('.search-input').val() == 'Поиск по сайту')
		{
			$('.search-input').val('');
		}
	});
	$('.search-input').mouseleave(function(){
		if($('.search-input').val() == '')
		{
			$('.search-input').val('Поиск по сайту');
		}
	});
	$('#search-button').hover(function(){
		if($('.search-input').val() == 'Поиск по сайту')
		{
			$('.search-input').val('');
		}
	}, function(){
		if($('.search-input').val() == '')
		{
			$('.search-input').val('Поиск по сайту');
		}
	});
	$('#menu ul li').hover(function()
	{
		if( $(this).attr('class') != 'step' )
		{
			$(this).css('background-color', '#4490b6');
		}
	},function()
	{
		if( $(this).attr('class') != 'step' )
		{
			$(this).css('background-color', '#4ea4d0');
		}
	});

	$('.program-show').live('click',function()
	{
		$(this).parent().css({height: 'auto', border: '1px solid'});
		$(this).hide();
		$(this).parent().find('.program-hide').show();
	});
	$('.program-hide').live('click',function()
	{
		$(this).parent().css({height: '10px', border: 'none'});
		$(this).hide();
		$(this).parent().find('.program-show').show();
	});

  $('.speaker .show').live('click',function()
	{
		$(this).parent('li').css({ height: 'auto', overflow: 'visible' });
    $(this).parent('li').find('.hide').show();
    $(this).parent('li').find('.data').show();
    $(this).hide();
	});
	$('.speaker .hide').live('click',function()
	{
		$(this).parent('li').css({ height: '130px' });
		$(this).hide();
    $(this).parent('li').find('.data').hide();
		$(this).parent('li').find('.show').show();
	});

	$('.full-screen').click(function()
	{
		full_screen_program();
	});
	$('.small-screen').live('click', function()
	{
		remove_full_screen();
	});
});


function initialize(a, id)
{
	$('.reply-comment a').not($(a)).removeClass('a-open');
	$('.reply-comment a').not($(a)).text('Ответить');
	$('.fake_edit').remove();
	var fake = $('<div class="fake_edit" style="height: 320px;">&nbsp;</div>');
	if(!$(a).hasClass('a-open'))
	{
		$('#c'+id).append(fake);
		$(a).addClass('a-open');
		$(a).text('Отмена');
		var parent = $('.post-info');
		$('.reply-form').css({ 'top': fake.offset().top-parent.offset().top+180, 'left': 50, 'position': 'absolute', 'display': 'block' });
		$('#pid').val(id);
	}
	else
	{
		$('.reply-form').hide();
		$(a).removeClass('a-open');
		$(a).text('Ответить');
	}


	return false;
}

function add_rating(a, url, statement_id)
{
	
	$.post(url, { my_statement_id: statement_id },  function(response){
		var parent = $(a).parent();
		$(parent).empty();
		$(parent).append("Рейтинг:" +response);
	});
}

function full_screen_program()
{
	$('.big-program').css('width', $(document).width());
	$('.big-program').css('height', '100%');
	$('.big-program').show();
	var program = $('.mini-program').clone();
	$(program).css({ width: 'auto', overflow: 'visible', height: 'auto'});
	$(program).find('.small-screen').css('display', 'block');
	$('.big-program').append(program);
}
function remove_full_screen()
{
	$('.big-program').html('');
	$('.big-program').hide();
}
