var ue = false;
var ce = '';
var freeUser = false;
//function test() {
// var requestOptions = {
// method: 'GET',
// };
// debugger;
// fetch("https://api.geoapify.com/v1/ipinfo?&apiKey=bf43301638684301ab9f905f5f31a5f6", requestOptions)
// .then(response => response.json())
// .then(result => console.log(result))
// .catch(error => console.log('error', error));
//}
$(document).ready(function () {
var url = window.location.search;
if (url.includes("type=update")) {
freeUser = true;
$("#divPassword").hide();
$("#divConfirmPassword").hide();
}
if (window.matchMedia) {
//var mql = new Object();// matchMedia("(max-width: 500px), (max-height: 500px)");
if (/Android|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
}
else {
normalizeHeight($('#left'), $('#right'));
}
} else {
normalizeHeight($('#left'), $('#right'));
}
$("#txtFirstName").focus();
$("#btnContinue").click(function () {
var error = false;
var control;
var firstName = $.trim($("#txtFirstName").val());
var lastName = $.trim($("#txtLastName").val());
var email = $.trim($("#txtEmail").val());
var password = $("#txtPassword").val();
var confirmPassword = $("#txtConfirmPassword").val();
var address = $("#txtAddress").val();
var postalCode = $("#txtPostalCode").val();
var city = $("#txtCity").val();
var country = $("#ddCountry").val();
var agree = $("#chkAgree").prop("checked");
if (firstName == "") {
error = true;
control = $("#divFirstName");
}
else if (lastName == "") {
error = true;
$("#divFirstName").removeClass("has-error");
control = $("#divLastName");
}
else if (!freeUser && email == "") {
error = true;
$("#divFirstName").removeClass("has-error");
$("#divLastName").removeClass("has-error");
control = $("#divEmail");
}
else if (!validateEmail(email)) {
error = true;
$("#divFirstName").removeClass("has-error");
$("#divLastName").removeClass("has-error");
control = $("#divEmail");
}
else if (!freeUser && ue == null) {
error = true;
control = $("#divEmail");
alert(ReturnUser_Exists());
}
else if (ue == true) {
error = true;
control = $("#divEmail");
alert(ReturnUser_Exists());
}
else if (!freeUser && password == "") {
error = true;
$("#divFirstName").removeClass("has-error");
$("#divLastName").removeClass("has-error");
$("#divEmail").removeClass("has-error");
control = $("#divPassword");
}
else if (!freeUser && (password.length < 6 || password.length > 15)) {
error = true;
control = $("#divPassword");
alert(ReturnPasswordMinMaxLength());
}
else if (!freeUser && confirmPassword == "") {
error = true;
$("#divFirstName").removeClass("has-error");
$("#divLastName").removeClass("has-error");
$("#divEmail").removeClass("has-error");
$("#divPassword").removeClass("has-error");
control = $("#divConfirmPassword");
}
else if (!freeUser && password !=confirmPassword) {
error = true;
$("#divFirstName").removeClass("has-error");
$("#divLastName").removeClass("has-error");
$("#divEmail").removeClass("has-error");
control = $("#divPassword");
alert(ReturnPasswordAndConfirmMismatch());
}
else if (address == "") {
error = true;
$("#divFirstName").removeClass("has-error");
$("#divLastName").removeClass("has-error");
$("#divEmail").removeClass("has-error");
$("#divPassword").removeClass("has-error");
$("#divConfirmPassword").removeClass("has-error");
control = $("#divAddress");
}
else if (postalCode == "") {
error = true;
$("#divFirstName").removeClass("has-error");
$("#divLastName").removeClass("has-error");
$("#divEmail").removeClass("has-error");
$("#divPassword").removeClass("has-error");
$("#divAddress").removeClass("has-error");
control = $("#divPostalCode");
}
else if (city == "") {
error = true;
$("#divFirstName").removeClass("has-error");
$("#divLastName").removeClass("has-error");
$("#divEmail").removeClass("has-error");
$("#divPassword").removeClass("has-error");
$("#divAddress").removeClass("has-error");
$("#divPostalCode").removeClass("has-error");
control = $("#divCity");
}
else if (country == 0) {
error = true;
$("#divFirstName").removeClass("has-error");
$("#divLastName").removeClass("has-error");
$("#divEmail").removeClass("has-error");
$("#divPassword").removeClass("has-error");
$("#divAddress").removeClass("has-error");
$("#divPostalCode").removeClass("has-error");
$("#divCity").removeClass("has-error");
control = $("#divCountry");
}
else if (!agree) {
error = true;
$("#divFirstName").removeClass("has-error");
$("#divLastName").removeClass("has-error");
$("#divEmail").removeClass("has-error");
$("#divPassword").removeClass("has-error");
$("#divAddress").removeClass("has-error");
$("#divPostalCode").removeClass("has-error");
$("#divCity").removeClass("has-error");
$("#divCountry").removeClass("has-error");
$("#divAgree").addClass("checkbox-inline");
control = $("#divAgree");
}
if (error) {
if (control != "") {
control.addClass("has-error");
}
return false;
}
else {
setTimeout(function () { ShowProgress(); return true; }, 200);
}
});
$("#txtEmail").blur(function (event) {
event.preventDefault();
var msg = '';
if ($(this).val().trim() != '' && validateEmail($(this).val().trim())) {
if (ce == '' || ce != $(this).val().trim() || !ue) {
ce = $(this).val().trim();
var url = "../api/oauth/checkuser/" + encodeURI($(this).val().trim());
var response = MakeSyncWebCall(url, "", "get");
if (response == "true") {
ue = true;
msg = ReturnUser_Exists();
}
else if (response == "false") {
ue = false;
}
else {
ue = null;
try {
msg = response;
}
catch (ex1) {
msg = response;
}
}
}
}
if (msg != '') {
$($(this).attr('id')).focus();
alert(msg);
}
});
//$("input[type=radio]").click(function () {
// if($(this).val()=="1"){
// $("#divPriceAndSymbol").html(ReturnMonthlyString());
// }
// else {
// $("#divPriceAndSymbol").html(ReturnYearlyString());
// }
//});
});
function normalizeHeight($left, $right) {
// get the max height of the two divs
var $maxHeight = Math.max($left.height(), $right.height())
// get the lower div
var $lowerpanel = $left
if ($lowerpanel.height() > $right.height())
$lowerpanel = $right
// set the height of the lower panel
$lowerpanel.height($maxHeight)
}
function ShowProgress() {
$("#loader").show();
$(".loaderbg").show();
}
//function SetBillingMethod(obj, billingmethodid)
//{
// $('#hdn_billingmethod').val(billingmethodid);
// $('.nav-tabs li').removeClass('active');
// $(obj).addClass('active');
//}
function changePrice() {
if ($("#ddCountry").val() != 0) {
var currency = $("#ddCountry").find(':selected').attr('currency');
$("#hdCurrency").val(currency);
var subscriptiontypeid = $("#hdUpgradeTo").val();
var url = "../api/Subscription/subscription/details?subscriptiontypeid=" + subscriptiontypeid + "¤cy=" + currency;
var liproducts = MakeSyncWebCall(url, "", "get");
if (liproducts.length > 0) {
var priceandSymbol = "";
if (liproducts[0].symbolposition == 0) {
priceandSymbol = "" + liproducts[0].symbol;
priceandSymbol += liproducts[0].Price + "/ " + liproducts[0].intervalname + "";
}
else {
priceandSymbol = "";
priceandSymbol += liproducts[0].Price + " " + liproducts[0].symbol + "/ " + liproducts[0].intervalname + "";
}
$("#divPriceAndSymbol").html(priceandSymbol);
}
}
}