﻿function GetRadWindow() {
    var oWindow = null;
    if (window.radWindow) oWindow = window.radWindow;
    else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
    return oWindow;
}

function AdjustRadWidow() {
    var oWindow = GetRadWindow();
    setTimeout(function () { oWindow.autoSize(true); if ($telerik.isChrome || $telerik.isSafari) ChromeSafariFix(oWindow); }, 500);
}


function CloseLoginDialog(oWnd, args) {
    var arg = args.get_argument();
    if (arg) {
        var valid = arg.Valid;
        if (valid == "true") {
            location.href = "HousePrivateZone.aspx";
        }
    }
}

function CloseDialogRefreshUrl() {
    if ($get("LoginButton") != null) {
        $get("LoginButton").click();
    }
}

function CloseDialogEventCancel() {
    //create the argument that will be returned to the parent page
    var oArg = new Object();

    //get a reference to the current RadWindow
    var oWnd = GetRadWindow();

    oWnd.close(oArg);
    return false;
}

function ReturnLoginToParent(status) {
    var oArg = new Object();

    //get a reference to the current RadWindow
    var oWnd = GetRadWindow();

    oArg.Valid = status;
    oWnd.close(oArg);

    return false;
}

function ValidateLogin() {
    var isValid = true;
    var msg;
    
    if ($get("UserNameTextBox").value == "") {
        msg = "שם משתמש - שדה חובה";
        Alert(msg);
        isValid = false;
        return false;
    }
    if ($get("PasswordTextBox").value == "") {
        msg = "סיסמא - שדה חובה";
        Alert(msg);
        isValid = false;
        return false;
    }
    
    if (isValid) {

        if ($get("LoginButton") != null) {
            $get("LoginButton").click();
        }
    }
}
