function rull_acc()
{
  if (byID('id-accept'))
  {
    if (byID('id-accept').checked == false)
    {
      alert('Необходимо ознокомиться и согласиться с правилами!');
      return false;
    }
  }
  return true
}


function getStatusCheckboxAccept()
{
  if (byID('id-accept'))
  {
    if (byID('id-accept').checked == false) 
    {
      //alert('lock');
      if ($('#nochekcked_rules').length) 
      {
        $('.submit_button_accept_dis:first').css('background-color',$('#nochekcked_rules').attr('dobgcolor'));
      }
      $('.submit_button_accept').hide();
      $('.submit_button_accept_dis').attr("disabled","disabled");
      $('#submit_button_accept_id').attr('class','lockpodpbutton');
      $('#submit_button_accept_id').attr("disabled","disabled");
    }
    else
    {
      //alert('unlock');
      if ($('#chekcked_rules').length) 
      {
        $('.submit_button_accept_dis:first').css('background-color',$('#chekcked_rules').attr('dobgcolor'));
      }
      $('.submit_button_accept').show();
      $('.submit_button_accept_dis').removeAttr("disabled");
      $('#submit_button_accept_id').attr('class','unlockpodpbutton');
      $('#submit_button_accept_id').removeAttr("disabled");
    }
  }
}

$(document).ready(function() { 

  getStatusCheckboxAccept()
  
  $('#id-accept').click(function() { 
    getStatusCheckboxAccept();
	}); 
	
	var rul_text = $('#main_rules').val();
	if (rul_text == '') { rul_text = $('#main_rules').html(); }
	
  $('#rules_text_div_cont').html(rul_text);
  
  if ($('#country-list-div').length) { $('#stoimost-podpiska-top').hide(); }
  
  $('.popup_rules').click(function() {
   	$.blockUI({
  		message: $('#popup_rules_div'),
  		fadeIn: 500,
  		fadeOut: 500,
  		showOverlay: false,

  		css: {
  			top:  ($(window).height() - $('#popup_rules_div').height()) /2 + 'px',
  			left: ($(window).width() - $('#popup_rules_div').width()) /2 + 'px'
  		}
  	});
	});

});


$(document).ready(function() {
  
	$('.close_member_dialog').click(function() {
	  setCookie('closed_member_dialog','true');
		$.unblockUI(); 
		return false; 
	});
	
	$('.show_member_dialog').click(function() {
	  showMemberPornDialog(false);
	});
	
	//showMemberPornDialog(true);
  
});

function closeMemberPornDialog()
{
	$.unblockUI(); 
	return true; 
}

function showMemberPornDialog(checkcookie)
{
  if (byID('need_show_member_dialog_'))
  {
    if (!getCookie('nevershowpordialog'))
    {
      if (!getCookie('closed_member_dialog') || !checkcookie)
      {
    		$.blockUI({ 
    	  message: $('#need_show_member_dialog'), 
    	  fadeIn: 500, 
        fadeOut: 500,
        showOverlay: false,
        css: { 
          top:  ($(window).height() - $('#need_show_member_dialog').height()) /2 + 'px', 
          left: ($(window).width() - $('#need_show_member_dialog').width()) /2 + 'px'
          }
    		});
      }
    }
  }
}

function setcountofclick(peiod_click)
{
  peiod_click = parseInt(peiod_click);
  var cntclk = getCookie('cntclkonthumb');
  if (!cntclk) { cntclk = 0; }
  cntclk++;
  if ((cntclk > 0) && (cntclk%peiod_click == 0)) { showMemberPornDialog(false); }
  setCookie('cntclkonthumb',cntclk);
  return true;
}

function setParamOfPornDialog(obj)
{
  if (obj.checked) { setCookie('nevershowpordialog','true'); }
  else { setCookie('nevershowpordialog','',-10); }
}


function noFramesFail() 
{
  //alert(byID('rulesframe_id'));
  //alert(self.parent.frames.length);
  if ( (self.parent.frames.length != 0) && !((self.parent.frames.length == 1) && byID('rulesframe_id')))
  {
    self.parent.location = document.location;
  }
}

function podp_ch_oper()
{
  if ($('#podp_sel_oper').length)
  {
    $('.choperatorclass').show();
    var val_oper = $('#podp_sel_oper').val();
    $('.hideforoperator_'+val_oper).hide();
  }
}

function podp_ch_country()
{
  if ($('#podp_sel_country').length && $('#podp_number_field').length)
  {
    var val_country = $('#podp_sel_country').val();
    var val_number = $('#podp_number_field').val();
    if (val_number.length <= 1)
    {
      if (val_country != 'RU')
        { $('#podp_number_field').val(''); }
      else
        { $('#podp_number_field').val('7'); }
    }
    
    if (val_country == 'RU') 
    {
      $('.podp_NOT_RU').hide(); 
      $('.podp_IS_RU').show();
      if ($('#inp_num_prefix').length) { $('#inp_num_prefix').val('7'); }
    }
    else
    {
      $('.podp_NOT_RU').show();
      $('.podp_IS_RU').hide();
      if ($('#inp_num_prefix').length) { $('#inp_num_prefix').val(''); }
    }
  }
}

$(document).ready(function() {
  podp_ch_country();
  podp_ch_oper();
});

