﻿var LoginPopup = null;
var PostponedAction = null;

function cta_PostponeAction(action) {
    PostponedAction = action;

    // show login/reguster popup
    LoginPopup.show();
    
}
function cta_OnPostponedAction() {
    LoginPopup.close();
    // hide login/register popup
    eval(PostponedAction);
}

document.observe('dom:loaded', function() {
    LoginPopup = new RmzPopup("LoginPopup", 450);
    $('LoginPopup').style.display = 'block';
});


function LoginPopupLogin() {
    
    Rmz.Web.WebServices.DataService.Login_Login($F('loginpopup_login'), $F('loginpopup_password'), $F('loginpopup_rememberme') == 'on',
             cta_OnPostponedAction, LoginPopup_Error);
}

function LoginPopup_Error(result) {
    alert(result._message);
}

function LoginPopupRegister() {
    if (!$F('loginpopup_Agreed')) {
        alert('You must accept Terms of Use and Privacy policy first');
        return;
    }
    Rmz.Web.WebServices.DataService.RegisterHomeowner($F('loginpopup_FirstName'), $F('loginpopup_LastName'), $F('loginpopup_Email'), $F('loginpopup_ZipCode'),
             cta_OnPostponedAction, LoginPopup_Error);

}