var CUR_GEOIP;
var JS_LIST_COUNTRY_CODE = 'RU';

$(document).ready(function() { 
  showSelectedCountry(CUR_GEOIP);
  ch_link_stoim();
});

function showSelectedCountry(idCountry)
{
  CUR_GEOIP = idCountry;
  var cntr_code = new Array();
  cntr_code = JS_LIST_COUNTRY_CODE.split(',');
  var l = cntr_code.length;
  for (i=0;i<l;i++) { hide(cntr_code[i]); hide('stoimost_'+cntr_code[i]); hide('appendhtml_'+cntr_code[i]); }
  hide('rules-text-div');
  show(idCountry);
  show('stoimost_'+idCountry);
  show('appendhtml_'+idCountry);
  
  /*
  var opt = byID('appendhtml_'+idCountry);
  if (opt)
  {
    var valss = jQuery.trim(opt.innerHTML);
    if (valss != '')
    {
      //alert('"' + valss + '"');
      $('#mts_sel_oper_in').html(valss);
      show('content_sel_oper');
    } else { hide('content_sel_oper'); }
  } else { hide('content_sel_oper'); }
  */
  ch_link_stoim();
  
  var postFieldGeoIP = byID('id-geoipcode');
  if (postFieldGeoIP) { postFieldGeoIP.value = idCountry; }
  check_enable_alt_number();
}

function showEnterDiv()
{
  hide('login-form-div-no');
  show('login-form-div-yes');
}

function showRulesText()
{
  ua_rules();
  hide('total-div');
  show('rules-text-div');
  //sendActionRulesOpen();
}

function acceptRules()
{
  show('total-div');
  showSelectedCountry(CUR_GEOIP);
}

function show_alt_number(e)
{
  if ($('#alt_number_conteiner').length)
  {
    $('.all_alt_num').hide();
    $('.alt_num_for_'+CUR_GEOIP).show();
    $('.alt_num_or_'+CUR_GEOIP).show();
    $('.alt_num_or_'+CUR_GEOIP+':last').hide();
    $('#for_cntr_name').html($('.alt_num_or_'+CUR_GEOIP+':last').attr('cntr_name'));
    
    
    //**
    var pos_x = 0;
    if ($('#alt_number_posx_start').length) { pos_x = parseInt($('#alt_number_posx_start').html()); }
    var pos_y = 0;
    if (byID('link_show_alt_num')) 
    {
      tmp = getAbsolutePosition(byID('link_show_alt_num'));
      pos_x = pos_x + tmp.x ;
      pos_y = pos_y + tmp.y;
    }
    $('#alt_number_conteiner').css({ top: pos_y + 'px', left: pos_x + 'px' });
    //**
    
    $('#alt_number_conteiner').slideDown('fast');
  }
}

function check_enable_alt_number()
{
  if ($('#alt_number_conteiner').length)
  {
    $('#alt_number_conteiner').hide();
    
    if ($('#alt_number_conteiner').find('.alt_num_for_'+CUR_GEOIP+':first').length)
      { $('#link_show_alt_num').show(); }
    else
      { $('#link_show_alt_num').hide(); }
  } else { $('#link_show_alt_num').hide(); }
}

function hide_alt_num()
{
  $('#alt_number_conteiner').hide();
}

