// ++ WM-PAY *******************
function showPay(type)
{
  if ((type !== null) && ((type == 'WebMoney') || (type == 'SMS'))) { setCookie('paytype',type); }
  if (type == null)
  {
    tmp = getCookie('paytype');
    if ((tmp == 'WebMoney') || (tmp == 'SMS')) { type = tmp; } else { type = 'SMS' }
  }
  if (type == 'WebMoney')
  {
    $('#bt_pay_by_WebMoney').hide();
    $('#bt_pay_by_SMS').show();
    $('#pay_by_SMS').hide();
    $('#pay_by_WebMoney').show();
    getWmStep();
  }
  else
  {
    $('#bt_pay_by_SMS').hide();
    $('#bt_pay_by_WebMoney').show();
    $('#pay_by_WebMoney').hide();
    $('#pay_by_SMS').show();
  }
}

function enterWmEmail()
{
  var email_val = $('#id_wm_email').val();
  if (checkCorrectEmail(email_val))
  {
    url = HTTP_FULL_PATH + '/callback/cb_wmpay.php?email='+encodeURIComponent(email_val);
    //alert(url);
    ajaxChainLoaderGet(url,getWmStep_callback);
  }
  else
  {
    alert('Плохой E-mail!');
    return false;
  }
}

function chWmType()
{
  $('#link_wm_pay').hide();
  url = HTTP_FULL_PATH + '/callback/cb_wmpay.php?wm_type='+$('#wm_type').val();
  //alert(url);
  ajaxChainLoaderGet(url,getWmStep_callback);
}

function getWmStep()
{
  $('#wm_step_1').hide();
  $('#wm_step_2').hide();
  url = HTTP_FULL_PATH + '/callback/cb_wmpay.php';
  ajaxChainLoaderGet(url,getWmStep_callback);
}

function getWmStep_callback()
{
  var nl = null;
  if (this.req.responseXML) { nl = this.req.responseXML.getElementsByTagName('wmpay'); }
  if (nl)
  {
    var nli = nl.item(0);
    var step_wm = parseInt(nli.getAttribute('step'));
    if (step_wm == 2)
    {
      var href_link_wmk = nli.getAttribute('link_wmk');
      var href_link_https  =nli.getAttribute('link_https');
      var user_k_pair = nli.getAttribute('k_pair');
      var user_email = nli.getAttribute('email');
      
      $('#is_link_wmk').attr('href',href_link_wmk);
      $('#is_link_https').attr('href',href_link_https);
      $('#for_k_pair').html(user_k_pair);
      
      $('#link_wm_pay').show();
      $('#wm_step_1').hide();
      $('#wm_step_2').show();
      
      if ($('#kpairenter_check').html() == user_k_pair)
      {
        $('#select_wm_type').hide();
        $('#link_wm_pay').hide();
      }
    }
    else
    {
      $('#link_wm_pay').hide();
      $('#wm_step_2').hide();
      $('#wm_step_1').show();
    }
  }
}
// -- WM-PAY *******************

