// dialog.js
//###########################################################################
//# <LICENSEINFO>
//# Metadot Metadot Portal Server
//# Copyright (C) 2001 Metadot Corporation                                                        
//#                                                                                               
//# For more information go to                                                                    
//# http://www.metadot.com                                                                        
//# or contact us at info@metadot.com                                                             
//#                                                                                               
//#</LICENSEINFO>
//############################################################################
//
// warnAllErrors (s)         Notify user that there are errors s (if any) [vadim]
// warnEmpty (s [,jre])      Notify user that required field theField is empty or (if jre parameter is specified) Just Return Error message. [vadim]
// warnInvalid (s [,jre])    Notify user that contents of field theField are invalid or (if jre parameter is specified) Just Return Error message. [vadim]

// [vadim]
// header for the window with the all errors at once
var headerAllErrors = "_____________________________________________________\n\n" +
                      "This form has not been submitted because of the following error(s).\n" +
	                  "Please correct the error(s) and re-submit.\n" +
	                  "_____________________________________________________\n" ;

// [vadim]
// header for the window in the case of an empty field
var headerEmpty = headerAllErrors ;

// [vadim]
// header for the window in the case of an invalid field
var headerInvalid = headerAllErrors ;

// m is an abbreviation for "missing"
var mPrefix = "You did not enter a value into the " ;
var mSuffix = " field.\nThis is a required field. Please enter it now.\n" ;

// i is an abbreviation for "invalid"
var iPrefix = "You did not enter a correct value into the " ;
var iSuffix = " field.\nPlease enter the correct value now.\n" ;

// Notify user about All Errors
function warnAllErrors (s)
{
    // if no errors - return true
    if (s.length == 0) {
        return true ;
    }
    // on MacOS currently only IE 5 and up can show ALL text in alert dialog,
    // so reduce the amount of text:
    var temp_header = (is_mac && !is_ie5up) ? "" : headerAllErrors ;
    alert(temp_header + s) ;
    return false ;
}

// Notify user that required field is empty.
function warnEmpty (s)
{
    // if only two parameters - regular processing
    if (warnEmpty.arguments.length == 1) {
        // on MacOS currently only IE 5 and up can show ALL text in alert dialog,
        // so reduce the amount of text:
        var temp_header = (is_mac && !is_ie5up) ? "" : headerEmpty+"\n" ;
        alert(temp_header + mPrefix + s + mSuffix) ;
        return false ;
    }
    // otherwise - just return error string
    return ("\n"+ mPrefix + s + mSuffix) ;
}

// Notify user that contents of field are invalid.
function warnInvalid (s)
{
    // if only two parameters - regular processing
    if (warnInvalid.arguments.length == 1) {
        // on MacOS currently only IE 5 and up can show ALL text in alert dialog,
        // so reduce the amount of text:
        var temp_header = (is_mac && !is_ie5up) ? "" : headerInvalid+"\n" ;
        alert(temp_header + iPrefix + s + iSuffix) ;
        return false ;
    }
    // otherwise - just return error string
    return ("\n" + iPrefix + s + iSuffix) ;
}

