﻿// requires formhandler.js
/* ------------------------------------------------------------- */
/* ------------------------------------------------------------- */
// receives a string in the form "name=value&name=value..." and assigns the
//  value portion to the HTML element with the id matching the name portion...
function ReceiveServerResponse(rValue) {

    var vArray = new Array();
    vArray = rValue.split('&');
    for (var i = 0; i < vArray.length; i++) {
        eArray = vArray[i].split('=');
        eId = eArray[0];
        eValue = eArray[1];
        e = document.getElementById(eId);
        if (eId == 'AjaxError' | eId == 'AjaxMessage' | eId == 'AjaxWarning') {
            //alert(eId + ' = [' + eValue + ']');
            if (eValue == '') {
                e.style.display = 'none';
            } else {
                //alert('not blank: doing stuff');
                e.style.display = 'block';
                var win = document.getElementById('AjaxResponse');
                win.style.display = 'block';
                var p = document.getElementById('Page');
                win.style.left = getElementPosition(p, 'x') + ((p.offsetWidth - win.offsetWidth) / 2) + 'px';
                win.style.top = (win.offsetHeight / 2) + Geometry.getVerticalScroll() + 'px';
            } 
        }
        try {
            e.value = eValue;
            e.innerHTML = eValue;
        } catch (ex) {
        }
    }
}
/* ------------------------------------------------------------- */
/* ------------------------------------------------------------- */
// function SendClientRequest is created on the server side in WebCore.vb



/* ------------------------------------------------------------- */
/* ------------------------------------------------------------- */
function AjaxErrorHandler(arg) {
    var strErrorIntro = 'Unfortunately, a problem has occurred whilst processing your request.\n\n' +
                        'Please try again, and if the problem continues, please contact us with a screenshot of this information:' +
                        '[' + arg + ']';
    alert(arg);
}
