///
///
///
//#region resizePopUpSize
function resizePopUpSize() {
if (window.top && window.top.utility) {
var $wrapper = $("#reg-c"); //body>div.c:first
var height = $wrapper.outerHeight() + 20;
var width = $wrapper.outerWidth();
var $dialog = window.top.$("#popup");
//alert(height + " " + width);
$dialog.css("height", height);
$dialog.css("width", width);
$dialog.dialog({
position: ['center', 'center'],
autoOpen: false
});
}
//alert($wrapper.height);
}
//#endregion
$(function () {
Placeholder.init(); // Call place holder plugin for contact field
resizePopUpSize();
$("form").attr("id", "CreateMember");
SetContactAreaCode();
SetPromoCode();
//#region Reload Contach No.
$("#CountryCode").change(function () {
SetCurrencyByCountryCode("", $("#CountryCode").val());
SetPromoCode();
});
//#endregion
//#region Reload Country
$("#CurrencyCode").change(function () {
SetCurrencyByCountryCode($("#CurrencyCode").val(), "");
});
//#endregion
//#region Bind Plugin
var maxDate = new Date($("#DateOfBirth").val().replace('-', '/'));
$("#DateOfBirth").datepicker({
dateFormat: "yy/mm/dd",
maxDate: maxDate,
prevText: "",
nextText: "",
changeMonth: true,
changeYear: true,
yearRange: $("#pastYear").val(),
inline: true
});
$("#DateOfBirth").datepicker("option", "yearRange", $("#pastYear").val());
$("#DateOfBirth").datepicker("setDate", "");
//#endregion
//#region Bind Events
$("#btn-close").click(function () {
window.close();
});
$("#captcha").click(function () {
utility.reloadImg($(this));
});
//#endregion
//#region utility.initSubmitForm
utility.initSubmitForm($("form"), $("#btn-submit"),
function (result) {
var btn = {};
btn[l.OK] = function () {
//alert(result.l.pl + " " + gv.lang);
if (result.l.pl != gv.lang) { // if current website language and language selected in registration form is different
window.top.location.href = window.top.location.href.replace("/" + gv.lang + "/", "/" + result.l.pl + "/"); // refresh profile page if change language in profile page
}
else {
var currentUrl = window.top.location.href;
if (currentUrl.substr(currentUrl.length - 11) == "/sportsbook" || currentUrl.substr(currentUrl.length - 12) == "/sportsbook/") {
window.top.location.reload();
}
else {
window.top.dialog.close();
windowSync.setClientdata(result);
window.top.utility.closePopUp();
}
}
};
dialog.info(l.Message, $("#msg").val(), btn);
},
function () {
utility.reloadImg($("#captcha"));
},
null
);
//#endregion
//#region Login name contain Forbidden Keywords?
$("#LoginName").rules("add",
{
remote: {
url: $("#LoginName").data("allowedname-url"),
type: "POST",
data: {
loginName: $("#LoginName").val()
}
},
messages: {
remote: $("#LoginName").data("allowedname-msg")
}
});
//#endregion
//#region Check Password
jQuery.validator.addMethod("passwordContent", function (value, element) {
var loginName = $("#LoginName").val();
if (loginName != null && loginName != "") {
if (value.indexOf(loginName) > -1) {
return false; //contain login name
}
}
return true;
}, $("#Password").attr("msgContent"));
jQuery.validator.addMethod("passwordLength", function (value, element) {
return value.length >= 6 && /\d/.test(value) && /[a-z]/i.test(value);
}, $("#Password").attr("msgLength"));
$("#Password").rules("add", {
passwordLength: true,
passwordContent: true
});
//#endregion
//#region Check Age
jQuery.validator.addMethod("mustCheck", function (value, element) {
return $(element).prop("checked");
}, " ");
$("#ConfirmAges").rules("add", {
mustCheck: true
});
//#endregion
//facebook registration
if (sessionStorage.fbresponse) {
var response = JSON.parse(sessionStorage.fbresponse);
var fullName = "";
if (response.middle_name != undefined) {
fullName = response.first_name + ' ' + response.middle_name + ' ' + response.last_name;
} else {
fullName = response.first_name + ' ' + response.last_name;
}
$('#fullNameTextBox').val(fullName);
$('#emailTextBox,#confirmEmailTextBox').val(response.email).prop('disabled', true);
$('#emailHidden,#confirmEmailHidden').val(response.email);
if (response.gender == 'male') {
$('#g1').prop('checked', true);
} else if (response.gender == 'female') {
$('#g2').prop('checked', true);
}
if (response.timezone) {
var timeZone = Number(response.timezone);
var timeZoneString = "";
if (timeZone > 0) {
if (timeZone >= 10)
timeZoneString = '+' + timeZone + ':00';
else
timeZoneString = '+0' + timeZone + ':00';
}
else if (timeZone < 0) {
if (timeZone > -10)
timeZoneString = '-0' + timeZone + ':00';
else
timeZoneString = '-' + timeZone + ':00';
}
else { timeZoneString = '00:00'; }
$('#timezoneDDL').val(timeZoneString).prop('disabled', true);
$('#timezoneHidden').val(timeZoneString);
}
sessionStorage.fbresponse = null;
}
});
//#region Function
function SetCurrencyByCountryCode(currency, country) {
utility.service('registrationservice/MapCurrencyCountry', { currencyCode: currency, countryCode: country }, function (data) {
var newData = data.split(",");
if (newData[0] != "") {
$("#CurrencyCode").val(newData[0]);
}
if (newData[1] != "") {
$("#CountryCode").val(newData[1]);
}
$("#PreferedLanguage").val();
$("#ContactArea").attr("code", $("#CountryCode").val());
SetContactAreaCode();
});
}
//#endregion
//#region SetContactAreaCode
function SetContactAreaCode() {
if ($("#CountryCode").val() == "MY") {
$("#ContactArea").attr("value", "+60");
}
else if ($("#CountryCode").val() == "KH") {
$("#ContactArea").attr("value", "+855");
}
else if ($("#CountryCode").val() == "TH") {
$("#ContactArea").attr("value", "+66");
}
else if ($("#CountryCode").val() == "ID") {
$("#ContactArea").attr("value", "+62");
}
else {
$("#ContactArea").attr("value", "+84");
}
if (!isNaN($("#ContactNo").val())) {
$("#ContactNo").removeData("previousValue");
$("form").validate().element("#ContactNo");
}
}
//#endregion
//#region SetPromoCode
function SetPromoCode() {
if ($("#CountryCode").val() == "TH") {
$("#PromotionCode").val("");
$("#PromotionCode").attr("disabled", "disabled");
} else {
$("#PromotionCode").removeAttr("disabled", "disabled");
}
}
//#endregion