
$(function() {
  doFocus();
});

function configureLoginPage() {
  var isMerchantChecked = document.getElementById('logintype_m').checked;
  var isResellerChecked = document.getElementById('logintype_r').checked;
  
  if (isMerchantChecked) {
    return true;
  }
  
  else if (isResellerChecked) {
    var mmfLoginUrl = document.getElementById('mmfLoginUrl').value;
    var merchantId = document.getElementById('j_merchantid').value;
    var userName = document.getElementById('j_username').value;
    var password = document.getElementById('j_password').value;
    var loginType = document.getElementById('logintype_r').value;
    
    window.location = mmfLoginUrl + '?merchantId=' + merchantId + '&userName=' + userName + '&password=' + password + '&loginType=' + loginType;
    return false;
  }
}

function doFocus() {
  var jmerchantid = $("#j_merchantid");
  var jusername = $("#j_username");
  var jpassword = $("#j_password");
  
  if (jmerchantid.val() == '') {
    jmerchantid.focus();
  }
  else if (jusername.val() == '') {
    jusername.focus();
  }
  else if (jpassword.val() == '') {
    jpassword.focus();
  }
}

