jQuery(document).ready(function() {

	$('.in_gallery a').lightBox({fixedNavigation:false,
          imageLoading:			'http://billiard-league.ru/templates/images/lb/lightbox-ico-loading.gif',		// (string) Path and the name of the loading icon
			imageBtnPrev:			'http://billiard-league.ru/templates/images/lb/lightbox-btn-prev.gif',			// (string) Path and the name of the prev button image
			imageBtnNext:			'http://billiard-league.ru/templates/images/lb/lightbox-btn-next.gif',			// (string) Path and the name of the next button image
			imageBtnClose:			'http://billiard-league.ru/templates/images/lb/lightbox-btn-close.gif',		// (string) Path and the name of the close btn
			imageBlank:				'http://billiard-league.ru/templates/images/lb/lightbox-blank.gif',			// (string) Path and the name of a blank image (one pixel)
			txtImage:				'Изображение',	// (string) Specify text "Image"
			txtOf:					'из'		// (string) Specify text "of"

});
	
	 $(".news_multi img").each(function(n) {
        var src = $(this).attr('src');//.replace('img_T','img_L');
        var a = $('<a class="lightbox" rel="lightbox'+n+'"></a>').attr('href', src);
        $(this).wrap(a);
        $(this).parent().lightBox({fixedNavigation:false,
          imageLoading:			'http://billiard-league.ru/templates/images/lb/lightbox-ico-loading.gif',		// (string) Path and the name of the loading icon
			imageBtnPrev:			'http://billiard-league.ru/templates/images/lb/lightbox-btn-prev.gif',			// (string) Path and the name of the prev button image
			imageBtnNext:			'http://billiard-league.ru/templates/images/lb/lightbox-btn-next.gif',			// (string) Path and the name of the next button image
			imageBtnClose:			'http://billiard-league.ru/templates/images/lb/lightbox-btn-close.gif',		// (string) Path and the name of the close btn
			imageBlank:				'http://billiard-league.ru/templates/images/lb/lightbox-blank.gif',			// (string) Path and the name of a blank image (one pixel)
			txtImage:				'Изображение',	// (string) Specify text "Image"
			txtOf:					'из'		// (string) Specify text "of"

});
    }); 
    
    


$('#users a').mouseover(
        function()
        {
          $(this).parents('div.user').addClass('hover');
	
        }); 

$('#users a').mouseout(
        function()
        {
//          alert('qq1');
          $(this).parents('div.user').removeClass('hover');

        }); 

			
  
  $('.feedback .send_msg').click(function()
 {
    //alert('qq');
    if ('' == $('#f_Name').val())
    {
      alert('Укажите, пожалуйста, Ваше имя');
      return false;
    }
      
    if ('' == $('#f_Phone').val())
    {
      alert('Укажите, пожалуйста, Ваш телефон');
      return false;
    }

    if ('' == $('#f_Email').val())
    {
      alert('Укажите, пожалуйста, Ваш e-mail');
      return false;
    }

    if (!check_email($('#f_Email').val()))
    {
      alert('Проверьте, пожалуйста, правильность написания e-mail');
      return false;
    }

      
    if ('' == $('#f_MsgText').val())
    {
      alert('Укажите, пожалуйста, вопрос');
      return false;
    }

    return true;
  });
  
  
  function check_email(email)
  {
     reg = new RegExp(/^\w+([\.-]?\w+)*@(((([a-z0-9]{2,})|([a-z0-9][-][a-z0-9]+))[\.][a-z0-9])|([a-z0-9]+[-]?))+[a-z0-9]+\.([a-z]{2}|(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum))$/i) ;
   
      return reg.test(email); 
  }
  
  function check_login(login)
  {
     reg = new RegExp(/[0-9a-z_]+/i) ;
   
      return reg.test(login); 
  }

  
  /*$('#keystring').keypress(function()
    {
    var keystring = $('#keystring').val();
    
    $.post('/kcaptcha/check_captcha.php', 
              {keystring:keystring},
                function(data)
                {
                  alert(data);
                }
              ); 
    
    });*/
  
  $('#register').submit(function() {
 
    //alert('qq');
    if ('' == $('#username').val())
    {
      alert('Укажите, пожалуйста, логин');
      return false;
    }
    
    if (3 > $('#username').val().length)
    {
      alert('Укажите, пожалуйста, логин длиной не менее трех символов');
      return false;
    }

    if (! check_login($('#username').val()))
    {
      alert('Укажите, пожалуйста, логин только из цифр и латинских букв');
      return false;
    }

      
    if ('' == $('#pf_name').val())
    {
      alert('Укажите, пожалуйста, Ваше имя');
      return false;
    }

    if ('' == $('#pf_surname').val())
    {
      alert('Укажите, пожалуйста, Вашу фамилию');
      return false;
    }

    
    var fill_game = false;
    
    $('input[name=pf_game]').each(
      function()
      {
        if (($(this).attr('checked')))
          fill_game = true; 
      }
      );
    
    
    if (!fill_game)
    {
      alert('Выберите, пожалуйста, дисциплину');
      return false;
    }


    if ('' == $('#new_password').val())
    {
      alert('Укажите, пожалуйста, пароль');
      return false;
    }

    if (6 > $('#new_password').val().length)
    {
      alert('Укажите, пожалуйста, пароль длиной не менее шести символов');
      return false;
    }

    if ($('#new_password').val() != $('#password_confirm').val())
    {
      alert('Пароль и подтверждение пароля не совпадают');
      return false;
    }

    if ('' == $('#email').val())
    {
      alert('Укажите, пожалуйста, Ваш e-mail');
      return false;
    }

    if (!check_email($('#email').val()))
    {
      alert('Проверьте, пожалуйста, правильность написания e-mail');
      return false;
    }
    
    if ($('#new_password').val() != $('#password_confirm').val())
    {
      alert('E-mail и подтверждение e-mail не совпадают');
      return false;
    }
    
    //alert($('#ok1').attr("checked"));
    //alert($('#ok2').attr("checked"));
    if ((true != $('#ok1').attr("checked")) 
            || (true != $('#ok2').attr("checked"))
            || (true != $('#ok3').attr("checked")))
    {
      alert('Отметьте, пожалуйста, согласие со всеми условиями по правилами');
      return false;
    }
    
  
    

    
    return true;


      
  });

  
  });
  

