﻿// JScript File
function ClearAndRelocate(destinationpage){
    if (window.confirm('Are you sure to abandon the current booking?') == true){
        Samples.AspNet.SimpleWebService.ClearSession(Relocate, Stay, destinationpage);
    }
}
function Relocate(result, userContext, methodName){
    window.location = userContext;
}
function Stay(error, userContext, methodName){
    alert(error);
}
function ClearPrefix(fld){
    if (fld.value.substring(0,7) == 'Please ') fld.select();
}

// alternative to alert() © Ax :-)
var _alertwindow_maxcnt = 10;
var _alertwindow_timer = 50;
var _alertwindow_msg = '';
var _alertwindow_w = null;
var _alertwindow_cnt = 0;

function alertwindow(msg)
{
    _alertwindow_w = window.open('/common/js/x.html','xx');
    _alertwindow_msg = msg;
    _alertwindowwait(1);
}

function _alertwindowwait(init)
{
    if (init) _alertwindow_cnt = 0;
    var ok = false;
    if (_alertwindow_w != null)
    {
        var w = _alertwindow_w;
        if (w.document) {
            if (w.document.getElementById('blah')) {
                w.document.getElementById('blah').innerHTML = '<xmp>' + _alertwindow_msg + '</xmp>';
                w.focus();
                ok = true;
            }
        }
    }
    if (ok == false) {
        if (++_alertwindowcnt == _alertwindowmaxcnt) {
            if (_alertwindow_w != null) _alertwindow_w.close();
        }
        else {
            setTimeout('_alertwindowwait()', _alertwindow_timer);
        }
    }
}
