function checkMaxLen(txt,maxLen)
{
    try
    {
        if(txt.value.length > (maxLen-1))
        {
            var cont = txt.value;
            txt.value = cont.substring(0,(maxLen -1));
            return false;
        }
    }
    catch(e)
    {
    }
}

function newWindow(a) {
    a.target = "_blank";
}

function popup(url, name, w, h) {
    var details = "toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes,resizable=yes,status=no,width=" + w + ",height= " + h + " ";
    window.open(url, name, details);
}

function HideContent(d) {
    if (d.length < 1) { return; }
    document.getElementById(d).style.display = "none";
}
function ShowContent(d) {
    if (d.length < 1) { return; }
    var dd = document.getElementById(d);
    dd.style.display = "inline";
}
function ReverseContentDisplay(d) {
    if (d.length < 1) { return; }
    var dd = document.getElementById(d);
    if (dd.style.display == "none") { dd.style.display = "inline"; }
    else { dd.style.display = "none"; }
}
var CheckForChangesFunction = new function() {
    // Internal reference to the class to avoid the "this" pointer issue
    // when dealing with events.
    var _this = this;

    //you can declare this if you want, but I don't see the point.
    //this.globalChange = undefined;

    // Determines whether or not a form is being saved.
    this.saving;

    // Message to display.
    this.navigateAwayMessage = "You have made some changes which will be lost if you leave this page. Do you want to leave this page?";

    // Verify if any changes were made. If there have been changes and the form is not being saved,
    // alert the user that they are about to leave a page where they have made edits.
    this.checkForChanges = function() {
        if (!_this.saving && typeof (_this.globalChange) != "undefined" && _this.globalChange) {
            if (document.all && event)
                event.returnValue = _this.navigateAwayMessage;
            else
                return _this.navigateAwayMessage;
        }
    }
}

// Register the event.
window.onbeforeunload = function() { return CheckForChangesFunction.checkForChanges(); }

function PrintPreview() {
    var OLECMDID = 7;
    /* OLECMDID values:
    * 6 - print
    * 7 - print preview
    * 1 - open window
    * 4 - Save As
    */
    var PROMPT = 1; // 2 DONTPROMPTUSER 
    var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
    document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
    WebBrowser1.ExecWB(OLECMDID, PROMPT);
    WebBrowser1.outerHTML = "";
}