﻿function findLoan(refcode) {
    var code = "";
    if (refcode != null) { code = refcode; }
    
    var amount = document.getElementById('loan_amount').value.replace("$", "").replace(",", "");
    var type = document.getElementById('loan_type').value;

    if (isNaN(amount) || amount.replace(" ", "").length == 0) {
        alert("Please enter a valid dollar amount.");
        document.getElementById('loan_amount').focus();
        return false;
    }
    else {
        var url = "http://www.simpletuition.com/thinkfinancial/partner_landing?amt=" + amount + "&borrowerType=" + type + code;
        window.location.href = url;
    }
}
function findLoanModal(refcode) {
    var code = "";
    if (refcode != null) { code = refcode; }

    var amount = document.getElementById('loan_amount_modal').value.replace("$", "").replace(",", "");
    var type = document.getElementById('loan_type_modal').value;

    if (isNaN(amount) || amount.replace(" ", "").length == 0) {
        alert("Please enter a valid dollar amount.");
        document.getElementById('loan_amount_modal').focus();
        return false;
    }
    else {
        var url = "http://www.simpletuition.com/thinkfinancial/partner_landing?amt=" + amount + "&borrowerType=" + type + code;
        window.location.href = url;
    }
}

//Submits the tweet wager text area when the enter key is pressed
function loanModalEnter(e) {
    var keycode;
    if (window.event) { keycode = window.event.keyCode; }
    else if (e) { keycode = e.which; }
    else return true;
    if (keycode == 13) {
        findLoanModal();
        return false;
    }
    else { return true; }
}