function proverka(input) { 
    input.value = input.value.replace(/[^\d,]/g, '');
};

$(document).ready(function(){




$(".startup_icon h2").mouseover(function(){
       
    $(".startupblock").show("fade", {}, 500);
});

$(".startup_icon h2").mouseout(function(){
    $(".startupblock").hide("fade", {}, 500);

});

$(".investor_icon h2").mouseover(function(){
       
    $(".investorblock").show("fade", {}, 500);
});

$(".investor_icon h2").mouseout(function(){
    $(".investorblock").hide("fade", {}, 500);
        
    
});

$(".creditor_icon h2").mouseover(function(){
       
    $(".creditblock").show("fade", {}, 500);
});

$(".creditor_icon h2").mouseout(function(){
    $(".creditblock").hide("fade", {}, 500);
        
    
});


$("#post_button").live('mousedown', function() {
    $(this).attr('src', '/images/public_down.png');
    return true;
    
});
$("#post_button").live('mouseup', function() {
    $(this).attr('src', '/images/public.png');
    return true;
    
});  

    
$("#identify_button").live('mousedown', function() {
    $(this).attr('src', '/images/go_down.png');
    return true;
    
});
$("#identify_button").live('mouseup', function() {
    $(this).attr('src', '/images/go.png');
    return true;
    
});  

$("#identify_button").live('mousedown', function() {
    $(this).attr('src', '/images/go_down.png');
    return true;
    
});
$("#identify_button").live('mouseup', function() {
    $(this).attr('src', '/images/go.png');
    return true;
    
});  


$(".reg-button").live('mousedown', function() {
    $(this).attr('src', '/images/reg_down.png');
    return true;
    
});
$(".reg-button").live('mouseup', function() {
    $(this).attr('src', '/images/reg.png');
    return true;
    
});  


$("#profile_save_button").live('mousedown', function() {
    $(this).attr('src', '/images/save_down.png');
    return true;
    
});
$("#profile_save_button").live('mouseup', function() {    
    $(this).attr('src', '/images/save.png');
    return true;
    
});  

$(".pedit").live('mousedown', function() {
    $(this).css('backgroundImage', 'url(/images/pedit_down.png)');

    return true;
    
});
$(".pedit").live('mouseup', function() {
    $(this).css('backgroundImage', 'url(/images/pedit.png)');
    return true;
    
});  


$(".postadd").live('mousedown', function() {
    $(this).css('backgroundImage', 'url(/images/postadd_down.png)');

    return true;
    
});
$(".postadd").live('mouseup', function() {
    $(this).css('backgroundImage', 'url(/images/postadd.png)');
    return true;
    
});  

$(".proaddb").live('mousedown', function() {
    $(this).css('backgroundImage', 'url(/images/proadd_down.png)');

    return true;
    
});
$(".proaddb").live('mouseup', function() {
    $(this).css('backgroundImage', 'url(/images/proadd.png)');
    return true;
    
});  

$(".startupadd").live('mousedown', function() {
    $(this).css('backgroundImage', 'url(/images/startupadd_down.png)');

    return true;
    
});
$(".startupadd").live('mouseup', function() {
    $(this).css('backgroundImage', 'url(/images/startupadd.png)');
    return true;
    
});  

$("#enter").live('mousedown', function() {
    $(this).attr('src', '/images/public_down.png');
    return true;
    
});
$("#enter").live('mouseup', function() {
    $(this).attr('src', '/images/public.png');
    return true;
    
});  

$(".send_author a").mousedown(function() {
    $(this).css('backgroundImage','url(/images/send_author_down.png)');   

    
});
$(".send_author a").mouseup(function() {
    $(this).css('backgroundImage','url(/images/send_author.png)');
    
    
});

$("#enter").mousedown(function() {
    $(this).attr('src', '/images/public_down.png');
    
});
$("#enter").mouseup(function() {
    $(this).attr('src', '/images/public.png');
    
});           


// спрятать #back-top в начале
	$("#back-top").hide();
 
	// показать #back-top
	$(function () {
		$(window).scroll(function () {
			if ($(this).scrollTop() > 100) {
				$('#back-top').fadeIn();
			} else {
				$('#back-top').fadeOut();
			}
		});
 
		// прокрутить плавно тело документа к 0px при нажатии
		$('#back-top a').click(function () {
			$('body,html').animate({
				scrollTop: 0
			}, 800);
			return false;
		});
	});


//Мигалка
//setInterval(function () {$("#disc_link").toggleClass('redlink');},1000);
$("#balans-closer").click(function(){

     $.ajax({
       type: "POST",
       url: "/ajax/balans_info.php",
       
       success: function(){
          $('.robo-error').hide();        
       }
     });
     
    
    
});

$("#register-button a").mousedown(function() {
    $(this).css('box-shadow','-1px 2px 4px -1px #434343 inset'); 
    
    return true;
});
$("#register-button a").mouseup(function() {
    $(this).css('box-shadow','none');
});



$("#login_new input[type='submit']").mousedown(function() {
    $(this).css('box-shadow','0px 2px 5px 0px #434343 inset'); 
    
    return true;
});
$("#login_new input[type='submit']").mouseup(function() {
    
    $(this).css('box-shadow','1px 1px 1px 0 #9E9E9E');
});
/*
$("#login_new input[type='text']").mouseover(function (){
    
    $(this).css('background','#e8e8e8');    
});  


$("#login_new input[type='password']").mouseover(function (){
    
    $(this).css('background','#e8e8e8');    
});    


$("#login_new input[type='password']").mouseout(function (){

    $(this).css('background','#DFDFDF');    
});
*/ 

$('.karma-plus').click(function(){

  comment_id = $(this).parent();
  comment_id = comment_id.attr("id");
  obj = $(this);
     $.ajax({
       type: "POST",
       url: "/ajax/karma.php",
       data: "comment_id="+comment_id+"&value=1",
       success: function(msg){
          if (parseInt(msg) > 0) {
  
          obj.parent().css("color","#52b51a");
          obj.parent().html('+'+msg);
          }
                    
          if (parseInt(msg) < 0) {
  
          obj.parent().css("color","#ff0000");
          obj.parent().html(msg);
          }
          if (parseInt(msg) = 0) {
  
          obj.parent().css("color","#2a2a2a");
          obj.parent().html(msg);
          }            

          
       }
     });
     $(this).hide();
     $(this).next($('.karma-minus')).hide();
     
    
    
});


$('.karma-minus').click(function(){
    
  comment_id = $(this).parent();
  comment_id = comment_id.attr("id");
   obj = $(this);
     $.ajax({
       type: "POST",
       url: "/ajax/karma.php",
       data: "comment_id="+comment_id+"&value=-1",
       success: function(msg){
          if (parseInt(msg) > 0) {
  
          obj.parent().css("color","#52b51a");
          obj.parent().html('+'+msg);
          }
                    
          if (parseInt(msg) < 0) {
  
          obj.parent().css("color","#ff0000");
          obj.parent().html(msg);
          }
          if (parseInt(msg) = 0) {
  
          obj.parent().css("color","#2a2a2a");
          obj.parent().html(msg);
          }     
       }
     });
     $(this).hide();
     $(this).prev($('.karma-plus')).hide();    
    
});

    
//Запоминанаем открыт или закрыт фильтр

$('#exp-plus').click(function() {$.cookie('filter',null);});
$('#exp-plus-text').click(function() {$.cookie('filter',null);});
$('#exp-minus').click(function() {$.cookie('filter','hide');});
$('#exp-minus-text').click(function() {$.cookie('filter','hide');});

var proc=$('#user_id').innerhtml;
var proc=$('#user_id').html();
if (proc=='') {
    $(".comn").css("display","none");
}
//Hide (Collapse) the toggle containers on load
	

	//Switch the "Open" and "Close" state per click then slide up/down (depending on open/close state)
$(".filter-exp").click(function(){
		$('#filter-block').slideToggle("fast");
        $('#exp-plus').toggle();
        $('#exp-minus').toggle();
        $('#exp-plus-text').toggle();
        $('#exp-minus-text').toggle();
		return false; 
});

$("#filter-sel").change(function(){
     var filter = $(this).val();
    
    if (filter=='1') {
    $("#filter-startup").show();
    $("#filter-investment").hide();
    $("#filter-creditor").hide();

    } 
     
    if (filter=='2') {
    $("#filter-startup").hide();
    $("#filter-investment").show();
    $("#filter-creditor").hide();
        
    } 
    if (filter=='3') {
    $("#filter-startup").hide();
    $("#filter-investment").hide();
    $("#filter-creditor").show();
        
    }
    
    
});

 
/*
	при загрузке страницы проверям заполненность полей (на слуяай если запоминалка паролей вставила уже значения)
	если значения вставлены, удаляем текст у label для логина и пароля
 
*/
if($("#loginEnterToSite").val()!='')
{
	$("#loginEnterToSite").prev().text('');
	$("#passwordEnterToSite").prev().text('');
}
 
 
/*
	тут привзяно одно событие на получение фокуса полю в форме
	
*/
 
$("div > input").focus(
function(e)
{
	var clicked = $(e.target),
		clickedId = clicked.attr("id");
	
	/*
		если поле логин получило фокус, удаляем текст в label для логин
	*/
	if(clickedId=="loginEnterToSite")
	{
		clicked.prev().text('');
        clicked.parent().css('background-image','url("/images/input.gif")');
        clicked.css('border-color','#FFFFFF');
        clicked.css('background','none');
       
	}
	
	/*
		если поле пароль получило фокус, удаляем текст в label для пароль
	*/
	else if(clickedId=="passwordEnterToSite")
	{
		clicked.prev().text('');
                clicked.parent().css('background-image','url("/images/input.gif")');
        clicked.css('border-color','#FFFFFF');
        clicked.css('background','none');

	}
 
});
 
$("div > input").blur(
function(e)
{
	var clicked = $(e.target),
		clickedId = clicked.attr("id");
 
	/*
		если ушли из поля логин и его значение пусто, добавляем текст в label для логин
	*/
	if(clickedId=="loginEnterToSite")
	{
		if(clicked.val()=='') clicked.prev().text('E-mail');
         clicked.parent().css('background-image','url("/images/input.png")');
         clicked.css('background','#f5f5f5');
         clicked.css('border-color','#f5f5f5');
	}
	/*
		если ушли из поля пароль и его значение пусто, добавляем текст в label для пароль
	*/
	else if(clickedId=="passwordEnterToSite")
	{
		if(clicked.val()=='')
		{
		
			clicked.prev().text('Пароль');
         clicked.parent().css('background-image','url("/images/input.png")');
         clicked.css('background','#f5f5f5');
         clicked.css('border-color','#f5f5f5');            
            
		}
	}
 
});


$(".menu-expand").hover(  function() {

            $('.submenu').stop(true, true); // останавливаем всю текущую анимацию

            $('.submenu').slideDown();

        },

        function() {

          

            $('.submenu').slideUp('slow');

        }

    );
$(".submenu").hover(  function() {

            $('.submenu').stop(true, true); // останавливаем всю текущую анимацию

            $('.submenu').slideDown();

        },

        function() {

          

            $('.submenu').slideUp('slow');

        }

    );  

  $('#identify-phone-radio').click(function () {
    $("#identify-phone").slideUp("fast");
    $("#identify-passport").slideDown("fast");
    
    });
  $('#identify-passport-radio').click(function () {
    $("#identify-passport").slideUp("fast");
    $("#identify-phone").slideDown("fast");
  
    });

    $('#link-add-blog').click(function(){
        
      $('.new-blog-item').toggle('slow', function() {
    // Animation complete.
  });
    });
    

//Работа со страницей доп-акка
$('#dop_money_select').change(function() {

  $('.dop_month_pay').html($('#dop_money_select :selected').val())+'&nbsp'; 
    
});


$(".count_textarea").keyup(function() {
    var max_lenght = 500;
    if ($(this).val().length > max_lenght) {
        
        $(this).val($(this).val().slice(0, max_lenght));    
    }
    
    $(".count_output > span").html(max_lenght - $(this).val().length);
    
});

$(".mes_send_sending input").mousedown(function() {
    $(this).attr("src","/images/messages/mes_sending_down.png");
    return false;
});

$(".mes_send_sending input").mouseup(function() {
    $(this).attr("src","/images/messages/mes_sending_up.png");
    return false;
});

});


