function validateRequiredField(target, message) { Sys.UI.DomElement.removeCssClass(target, 'validatorCalloutHighlight'); if (_popupBehavior) { _popupBehavior.dispose(); _popupBehavior = null; } if ($(target + "_popupTable") != null) { Element.remove($(target + "_popupTable")); } if (target.value == "") { CreateValidator(target.id, message); Sys.UI.DomElement.addCssClass((target), 'validatorCalloutHighlight'); return false; } return true; }
function validateRegExField(target, regexStatement, message) { Sys.UI.DomElement.removeCssClass(target, 'validatorCalloutHighlight'); if (_popupBehavior) { _popupBehavior.dispose(); _popupBehavior = null; } if ($(target + "_popupTable") != null) { Element.remove($(target + "_popupTable")); } var value = target.value; var re = new RegExp(regexStatement); if (value.match(re)) { return true; } else { CreateValidator(target.id, message); Sys.UI.DomElement.addCssClass((target), 'validatorCalloutHighlight'); return false; } return true; }
function ShowValidator(target, message) { Sys.UI.DomElement.removeCssClass(target, 'validatorCalloutHighlight'); if (_popupBehavior) { _popupBehavior.dispose(); _popupBehavior = null; } CreateValidator(target.id, message); Sys.UI.DomElement.addCssClass((target), 'validatorCalloutHighlight'); return false; }
function AddValidatorCallout(target, message) { Sys.UI.DomElement.removeCssClass($(target), 'validatorCalloutHighlight'); if (_popupBehavior) { _popupBehavior.dispose(); _popupBehavior = null; } CreateValidator(target, message); Sys.UI.DomElement.addCssClass($(target), 'validatorCalloutHighlight'); return false; }

function closeClickHandler(e) {
    var targ; if (!e) var e = window.event; if (e.target) targ = e.target; else if (e.srcElement) targ = e.srcElement; var ind = targ.id.indexOf('_close'); var name = targ.id.substring(0, ind);
    Element.remove($(name));
    var indName = name.indexOf("_popupTable");
    var originalElement = name.substr(0, indName);
    try {
        $(originalElement).focus();
    }
    catch (err) {
    }
} var _popupBehavior;
function CreateValidator(target, errorMessage) {
    var elementToValidate = this._elementToValidate = $(target); var popupTableBody = document.createElement("tbody"); var popupTableRow = document.createElement("tr"); var calloutCell = document.createElement("td"); var calloutTable = document.createElement("table"); var calloutTableBody = document.createElement("tbody"); var calloutTableRow = document.createElement("tr"); var iconCell = document.createElement("td"); var closeCell = document.createElement("td"); var popupTable = this._popupTable = document.createElement("table"); var calloutArrowCell = this._calloutArrowCell = document.createElement("td"); var warningIconImage = this._warningIconImage = document.createElement("img"); var closeImage = this._closeImage = document.createElement("img"); var errorMessageCell = this._errorMessageCell = document.createElement("td"); if ($(target + "_popupTable") == null) {
        popupTable.id = target + "_popupTable"; popupTable.cellPadding = 0; popupTable.cellSpacing = 0; popupTable.border = 0;
        popupTable.width = '185px';  popupTable.style.position = "absolute"; popupTableRow.vAlign = 'top'; popupTableRow.style.height = "100%"; calloutCell.width = 20; calloutCell.align = "right"; calloutCell.style.height = "100%"; calloutCell.style.verticalAlign = "top"; calloutTable.cellPadding = 0; calloutTable.cellSpacing = 0; calloutTable.border = 0; calloutTable.style.height = "100%"; calloutArrowCell.align = "right"; calloutArrowCell.vAlign = "top"; calloutArrowCell.style.fontSize = "1px"; calloutArrowCell.style.paddingTop = "8px"; iconCell.width = 20; iconCell.style.borderTop = "1px solid black"; iconCell.style.borderLeft = "1px solid black"; iconCell.style.borderBottom = "1px solid black"; iconCell.style.padding = "5px"; iconCell.style.backgroundColor = "#E5F0F5"; warningIconImage.border = 0; warningIconImage.src = "../../images/alert-large.gif";errorMessageCell.style.textAlign = 'left';  errorMessageCell.style.backgroundColor = "#E5F0F5"; errorMessageCell.style.fontFamily = 'verdana'; errorMessageCell.style.fontSize = '10px'; errorMessageCell.style.padding = "5px"; errorMessageCell.style.borderTop = "1px solid black"; errorMessageCell.style.borderBottom = "1px solid black"; errorMessageCell.width = '100%'; errorMessageCell.innerHTML = errorMessage; closeCell.style.borderTop = "1px solid black"; closeCell.style.borderRight = "1px solid black"; closeCell.style.borderBottom = "1px solid black"; closeCell.style.backgroundColor = "#E5F0F5"; closeCell.style.verticalAlign = 'top'; closeCell.style.textAlign = 'right'; closeCell.style.padding = '2px'; closeImage.src = "../../images/close.gif"; closeImage.style.cursor = 'pointer'; closeImage.id = popupTable.id + "_close"; $addHandler(closeImage, "click", closeClickHandler); $(target).parentNode.appendChild(popupTable); popupTable.appendChild(popupTableBody); popupTableBody.appendChild(popupTableRow); popupTableRow.appendChild(calloutCell); calloutCell.appendChild(calloutTable); calloutTable.appendChild(calloutTableBody); calloutTableBody.appendChild(calloutTableRow); calloutTableRow.appendChild(calloutArrowCell); popupTableRow.appendChild(iconCell); iconCell.appendChild(warningIconImage); popupTableRow.appendChild(errorMessageCell); popupTableRow.appendChild(closeCell); closeCell.appendChild(closeImage); var div = document.createElement("div"); div.style.fontSize = "1px"; div.style.position = "relative"; div.style.left = "1px"; div.style.borderTop = "1px solid black"; div.style.width = "15px"; calloutArrowCell.appendChild(div); for (var i = 14; i > 0; i--) { var line = document.createElement("div"); line.style.width = i.toString() + "px"; line.style.height = "1px"; line.style.overflow = "hidden"; line.style.backgroundColor = "#E5F0F5"; line.style.borderLeft = "1px solid black"; div.appendChild(line); } 
    } else { popupTable = $(target + "_popupTable"); } _popupBehavior = $create(AjaxControlToolkit.PopupBehavior, { id: target.id + 'PopupBehavior', positioningMode: AjaxControlToolkit.PositioningMode.Absolute, parentElement: $(target) }, null, null, popupTable); _popupBehavior.set_x($common.getSize($(target)).width); _popupBehavior.show(); if (_popupBehavior) { _popupBehavior.onShow(); }
}
function AddValidatorCalloutMiddle(target, message) { Sys.UI.DomElement.removeCssClass($(target), 'validatorCalloutHighlight'); if (_popupBehavior) { _popupBehavior.dispose(); _popupBehavior = null; } CreateValidatorMiddleOfField(target, message); Sys.UI.DomElement.addCssClass($(target), 'validatorCalloutHighlight'); return false; }
function CreateValidatorMiddleOfField(target, errorMessage) {
    var elementToValidate = this._elementToValidate = $(target);
    var popupTableBody = document.createElement("tbody");
    var popupTableRow = document.createElement("tr");
    var calloutCell = document.createElement("td");
    var calloutTable = document.createElement("table");
    var calloutTableBody = document.createElement("tbody");
    var calloutTableRow = document.createElement("tr");
    var iconCell = document.createElement("td");
    var closeCell = document.createElement("td");
    var popupTable = this._popupTable = document.createElement("table");
    var calloutArrowCell = this._calloutArrowCell = document.createElement("td");
    var warningIconImage = this._warningIconImage = document.createElement("img");
    var closeImage = this._closeImage = document.createElement("img");
    var errorMessageCell = this._errorMessageCell = document.createElement("td");
    if ($(target + "_popupTable") == null) {
        popupTable.id = target + "_popupTable";
        popupTable.cellPadding = 0;
        popupTable.cellSpacing = 0;
        popupTable.border = 0;
        popupTable.width = '185px';
        popupTable.style.position = "absolute";
        popupTableRow.vAlign = 'top';
        popupTableRow.style.height = "100%";
        calloutCell.width = 20;
        calloutCell.align = "right";
        calloutCell.style.height = "100%";
        calloutCell.style.verticalAlign = "top";
        calloutTable.cellPadding = 0;
        calloutTable.cellSpacing = 0;
        calloutTable.border = 0;
        calloutTable.style.height = "100%";
        calloutArrowCell.align = "right";
        calloutArrowCell.vAlign = "top";
        calloutArrowCell.style.fontSize = "1px";
        calloutArrowCell.style.paddingTop = "8px";
        iconCell.width = 20;
        iconCell.style.borderTop = "1px solid black";
        iconCell.style.borderLeft = "1px solid black";
        iconCell.style.borderBottom = "1px solid black";
        iconCell.style.padding = "5px";
        iconCell.style.backgroundColor = "#E5F0F5";
        warningIconImage.border = 0;
        warningIconImage.src = "../../images/alert-large.gif";
        errorMessageCell.style.textAlign = 'left';
        errorMessageCell.style.backgroundColor = "#E5F0F5";
        errorMessageCell.style.fontFamily = 'verdana';
        errorMessageCell.style.fontSize = '10px';
        errorMessageCell.style.padding = "5px";
        errorMessageCell.style.borderTop = "1px solid black";
        errorMessageCell.style.borderBottom = "1px solid black";
        errorMessageCell.width = '100%';
        errorMessageCell.innerHTML = errorMessage;
        closeCell.style.borderTop = "1px solid black";
        closeCell.style.borderRight = "1px solid black";
        closeCell.style.borderBottom = "1px solid black";
        closeCell.style.backgroundColor = "#E5F0F5";
        closeCell.style.verticalAlign = 'top';
        closeCell.style.textAlign = 'right';
        closeCell.style.padding = '2px';
        closeImage.src = "../../images/close.gif";
        closeImage.style.cursor = 'pointer';
        closeImage.id = popupTable.id + "_close";
        $addHandler(closeImage, "click", closeClickHandler);
        $(target).parentNode.appendChild(popupTable);
        popupTable.appendChild(popupTableBody);
        popupTableBody.appendChild(popupTableRow);
        popupTableRow.appendChild(calloutCell);
        calloutCell.appendChild(calloutTable);
        calloutTable.appendChild(calloutTableBody);
        calloutTableBody.appendChild(calloutTableRow);
        calloutTableRow.appendChild(calloutArrowCell);
        popupTableRow.appendChild(iconCell);
        iconCell.appendChild(warningIconImage);
        popupTableRow.appendChild(errorMessageCell);
        popupTableRow.appendChild(closeCell);
        closeCell.appendChild(closeImage);
        var div = document.createElement("div");
        div.style.fontSize = "1px";
        div.style.position = "relative";
        div.style.left = "1px";
        div.style.borderTop = "1px solid black";
        div.style.width = "15px";
        calloutArrowCell.appendChild(div);
        for (var i = 14; i > 0; i--) {
            var line = document.createElement("div");
            line.style.width = i.toString() + "px";
            line.style.height = "1px";
            line.style.overflow = "hidden";
            line.style.backgroundColor = "#E5F0F5";
            line.style.borderLeft = "1px solid black";
            div.appendChild(line);
        }
    }
    else {
        popupTable = $(target + "_popupTable");
    }
    _popupBehavior = $create(AjaxControlToolkit.PopupBehavior, {
        id: target.id + 'PopupBehavior',
        positioningMode: AjaxControlToolkit.PositioningMode.Absolute,
        parentElement: $(target)
    }, null, null, popupTable);
    _popupBehavior.set_x($common.getSize($(target)).width / 4);
    _popupBehavior.show();
    if (_popupBehavior) {
        _popupBehavior.onShow();
    }
}

