Project

General

Profile

metacat / lib / style / skins / default / include_advancedsearch.jsp @ 5810

1
<%@ page     language="java" %>
2
<!--
3
/**
4
  *  '$RCSfile$'
5
  *      Authors:     Duane Costa
6
  *      Copyright:   2005 University of New Mexico and
7
  *                   Regents of the University of California and the
8
  *                   National Center for Ecological Analysis and Synthesis
9
  *      For Details: http://www.nceas.ucsb.edu/
10
  *
11
  *   '$Author: leinfelder $'
12
  *     '$Date: 2010-10-06 14:55:03 -0700 (Wed, 06 Oct 2010) $'
13
  * '$Revision: 5601 $'
14
  * 
15
  * This program is free software; you can redistribute it and/or modify
16
  * it under the terms of the GNU General Public License as published by
17
  * the Free Software Foundation; either version 2 of the License, or
18
  * (at your option) any later version.
19
  *
20
  * This program is distributed in the hope that it will be useful,
21
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
  * GNU General Public License for more details.
24
  *
25
  * You should have received a copy of the GNU General Public License
26
  * along with this program; if not, write to the Free Software
27
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
28
  *
29
  */
30
-->
31
<%@ include file="settings.jsp"%>
32
<%@ include file="session_vars.jsp"%>
33
<!-- *********************** START SEARCHBOX TABLE ************************* -->
34
<html>
35
<head>
36
  <title>Metacat Data Catalog Advanced Search Page</title>
37
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
38
  <link href="<%=STYLE_SKINS_URL%>/default/default.css" rel="stylesheet" type="text/css">
39

    
40
  <script language="javascript" 
41
    type="text/javascript" src="<%=STYLE_SKINS_URL%>/default/default.js">
42
  </script>
43

    
44
  <script language="javascript" type="text/javascript">
45

    
46
      function trim(stringToTrim) {
47
        return stringToTrim.replace(/^\s*/, '').replace(/\s*$/,'');
48
      }
49

    
50
      function submitRequest(form) {
51
        var canSearch = true;
52
        var x_range = document.map.get_x_range();
53
        var y_range = document.map.get_y_range();
54
        var x_index = x_range.indexOf(' ');
55
        var y_index = y_range.indexOf(' ');
56
        var x_length = x_range.length;
57
        var y_length = y_range.length;
58
        var x_lo = x_range.substring(0, x_index);
59
        var x_hi = x_range.substring(x_index + 1, x_length);
60
        var y_lo = y_range.substring(0, y_index);
61
        var y_hi = y_range.substring(y_index + 1, y_length);
62

    
63
        if (trim(form.subjectValue.value) == "" &&
64
            trim(form.creatorSurname.value) == "" &&
65
            trim(form.creatorOrganization.value) == "" &&
66
            trim(form.locationName.value) == "" &&
67
            (x_range == "-180.0 180.0") &&
68
            (y_range == "-90.0 90.0") &&            
69
            trim(form.taxon.value) == "" &&
70
            form.siteValue.value == "ALLSITES"
71
           ) {              
72
          canSearch = 
73
             confirm("Show *all* data in the catalog?\n(This may take some time!)");
74
        }
75

    
76
        if (canSearch) {        
77
          // Re-initialize the hidden form values prior to submitting
78
          form.northBound.value = "";
79
          form.southBound.value = "";
80
          form.eastBound.value = "";
81
          form.westBound.value = "";
82

    
83
          if ((x_range != "-180.0 180.0") || (y_range != "-90.0 90.0")) {     
84
            form.northBound.value = y_hi;
85
            form.southBound.value = y_lo;
86
            form.eastBound.value = x_hi;
87
            form.westBound.value = x_lo;
88
          }
89
          
90
          return(validateAdvancedSearchForm(form));
91
        }
92
        else {
93
          return false;
94
        }
95
      }
96
  </script>
97
</head>
98

    
99
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
100
  <table width="750px" align="center" cellspacing="0" cellpadding="0" class="group group_border">
101
    <tr> 
102
     
103
      <th class="sectionheader">
104
        advanced search 
105
      </th>
106
      
107
    </tr>
108
    <tr> 
109
      <td>
110
        <table width="100%" border="0" cellpadding="0" cellspacing="0" 
111
          class="subpanel">
112
          <tr> 
113
            <td></td>
114
          </tr>
115
          <tr valign="baseline"> 
116
            <td>
117
    <form name="advancedSearchForm"
118
          method="POST"
119
          action="<%=STYLE_SKINS_URL%>/default/advancedsearchforward.jsp"
120
          onsubmit="return submitRequest(this)"
121
          target="_top">
122
      <table width="100%" border="0" cellpadding="0" cellspacing="0" >
123
        <tr>
124
          <th colspan="2">
125
            <h3>Subject</h3>
126
          </th>
127
        </tr>
128
        <tr>
129
          <td>&nbsp;</td>
130
          <td>&nbsp;</td>
131
        </tr>
132
        <tr>
133
          <td align="right" nowrap>
134
            <select name="subjectField">
135
              <option value="ALL">Subject</option>
136
              <option value="TITLE">Title Only</option>
137
              <option value="ABSTRACT">Abtract Only</option>
138
              <option value="KEYWORDS">Keywords Only</option>
139
            </select>
140
          </td>
141
          <td>
142
            <select name="subjectQueryType">
143
              <option value="0" selected="selected">contains</option>
144
              <option value="1">matches exactly</option>
145
              <option value="2">starts with</option>
146
              <option value="3">ends with</option>
147
            </select>
148
            <input type="text" name="subjectValue" value="">
149
            <input type="radio" name="subjectAllAny" value="0" checked="checked">All Terms
150
            <input type="radio" name="subjectAllAny" value="1">Any Term
151
          </td>
152
        </tr>
153
        <tr>
154
          <td>&nbsp;</td>
155
          <td>&nbsp;</td>
156
        </tr>
157
        
158
        <tr>
159
          <th colspan="2">
160
            <h3>Author</h3>
161
          </th>
162
        </tr>
163
        <tr>
164
          <td>&nbsp;</td>
165
          <td>&nbsp;</td>
166
        </tr>
167
        <tr>
168
          <td nowrap align="right">Individual's Last Name:
169
          </td>
170
          <td>
171
            <select name="creatorSurnameQueryType">
172
              <option value="0" selected="selected">contains</option>
173
              <option value="1">matches exactly</option>
174
              <option value="2">starts with</option>
175
              <option value="3">ends with</option></select>
176
            <input type="text" name="creatorSurname" value="">
177
          </td>
178
        </tr>
179
        <tr>
180
          <td>&nbsp;</td>
181
          <td>&nbsp;</td>
182
        </tr>
183
        <tr>
184
          <td align="right" nowrap>Organization:
185
          </td>
186
          <td>
187
            <select name="creatorOrganizationQueryType">
188
              <option value="0" selected="selected">contains</option>
189
              <option value="1">matches exactly</option>
190
              <option value="2">starts with</option>
191
              <option value="3">ends with</option></select>
192
            <input type="text" name="creatorOrganization" value="">
193
          </td>
194
        </tr>
195
        <tr>
196
          <td>&nbsp;</td>
197
          <td>&nbsp;</td>
198
        </tr>
199
        <tr>
200
          <th colspan="2">
201
            <h3>Spatial Criteria</h3>
202
          </th>
203
        </tr>
204
        <tr>
205
          <td>&nbsp;</td>
206
          <td>&nbsp;</td>
207
        </tr>
208
        <tr>
209
          <td align="right">Geographic Boundaries:</td>
210
        </tr>
211
        <tr>
212
          <td>&nbsp;</td>
213
          <td>
214
            <applet
215
              CODEBASE="<%= request.getContextPath() %>/LiveMap_30"
216
              CODE="LiveMap_30.class"
217
              ARCHIVE="LiveMap_30.jar"
218
              NAME="map" 
219
              MAYSCRIPT 
220
              width=500 
221
              height=160>
222
              <param name=base_image value="gifs/java_0_world_20k.jpg">
223
              <param name=img_x_domain value="-180 180">
224
              <param name=img_y_domain value="-90 90">
225
              <param name=toolType value="XY">
226
              <param name=tool_x_range value="-180 180">
227
              <param name=tool_y_range value="-90 90">
228
            </applet>
229
          </td>
230
        </tr>
231
        <tr>
232
          <td>&nbsp;</td>
233
          <td>
234
            <!--
235
             The underlying property value associated with checkbox
236
             should be of type boolean, and any value you specify 
237
             should correspond to one of the strings that indicate a 
238
             true value ("true", "yes", or "on").
239
            -->
240
            <input type="checkbox" name="boundaryContained" value="on">
241
            Dataset must be fully contained within boundaries
242
          </td>
243
        </tr>
244
        <tr>
245
          <td>&nbsp;</td>
246
          <td>&nbsp;</td>
247
        </tr>
248
        <tr>
249
          <td align="right">Geographic Place Name: 
250
          </td>
251
          <td><input type="text" name="locationName" value="">
252
          </td>
253
        </tr>
254
        <tr>
255
          <td>&nbsp;</td>
256
          <td>&nbsp;</td>
257
        </tr>
258
        <!-- Temporal Criteria section is disabled because Metacat is
259
             not able to search date ranges. An enhancement request has
260
             been entered in Bugzilla (see 
261
             http://bugzilla.ecoinformatics.org/show_bug.cgi?id=2084 )
262
        <tr>
263
          <td colspan="2">
264
            <h3>Temporal Criteria</h3>
265
          </td>
266
        </tr>
267
        <tr>
268
          <td>&nbsp;</td>
269
          <td>&nbsp;</td>
270
        </tr>
271
        <tr>
272
          <td align="right">
273
            <select name="dateField">
274
              <option value="ALL">All Dates</option>
275
              <option value="COLLECTION">Collection Date</option>
276
              <option value="PUBLICATION">Publication Date</option>
277
            </select>
278
          </td>
279
          <td colspan="2">
280
            <input type="text" name="startDate" maxlength="10" size="10" value="" style="font-family:monospace;">
281
            to
282
            <input type="text" name="endDate" maxlength="10" size="10" value="" style="font-family:monospace;">
283
          </td>
284
        </tr>
285
        <tr>
286
          <td>&nbsp;</td>
287
          <td>&nbsp;</td>
288
        </tr>
289
        <tr>
290
          <td align="right">Named Timescale:
291
            <select name="namedTimescaleQueryType">
292
              <option value="0" selected="selected">contains</option>
293
              <option value="1">matches exactly</option>
294
              <option value="2">starts with</option>
295
              <option value="3">ends with</option>
296
            </select>
297
          </td>
298
          <td>
299
            <input type="text" name="namedTimescale" value="">
300
          </td>
301
        </tr>
302
        <tr>
303
          <td>&nbsp;</td>
304
          <td>&nbsp;</td>
305
        </tr>
306
        <tr>
307
          <td colspan="2"><hr/></td>
308
        </tr>
309
        -->
310
        <tr>
311
          <th colspan="2">
312
            <h3>Taxonomic Criteria</h3>
313
          </th>
314
        </tr>
315
        <tr>
316
          <td>&nbsp;</td>
317
          <td>&nbsp;</td>
318
        </tr>
319
        <tr>
320
          <td align="right">Taxon:
321
          </td>
322
          <td>
323
            <select name="taxonQueryType">
324
              <option value="0" selected="selected">contains</option>
325
              <option value="1">matches exactly</option>
326
              <option value="2">starts with</option>
327
              <option value="3">ends with</option>
328
            </select>
329
            <input type="text" name="taxon" value="">
330
          </td>
331
        </tr>
332
        <tr>
333
          <td>&nbsp;</td>
334
          <td>&nbsp;
335
            <input type="hidden" name="siteValue" value="ALLSITES"/>
336
          </td>
337
        </tr>
338

    
339
<!--   
340
    Un-comment the following section to include an input box that allows the
341
    user to restrict the search to a specific LTER site. Obviously, this is
342
    probably useful only within LTER. If uncommenting this section, 
343
    be sure to comment-out the hidden siteValue input above.
344
-->
345
       
346
<!--
347
        <tr>
348
          <td colspan="2"><hr/></td>
349
        </tr>
350
        <tr>
351
          <td colspan="2">
352
            <h3>LTER Site</h3>
353
          </td>
354
        </tr>
355
        <tr>
356
          <td>&nbsp;</td>
357
          <td>&nbsp;</td>
358
        </tr>
359
        <tr>
360
          <td align="right">Limit search to LTER site:</td>
361
          <td>
362
            <select name="siteValue">
363
              <option value="ALLSITES">All LTER Sites</option>
364
              <option value="AND">Andrews LTER</option>
365
              <option value="ARC">Arctic LTER</option>
366
              <option value="BES">Baltimore Ecosystem Study</option>
367
              <option value="BNZ">Bonanza Creek LTER</option>
368
              <option value="CAP">Central Arizona - Phoenix Urban LTER</option>
369
              <option value="CCE">California Current Ecosystem</option>
370
              <option value="CDR">Cedar Creek Natural History Area</option>
371
              <option value="CWT">Coweeta LTER</option>
372
              <option value="FCE">Florida Coastal Everglades LTER</option>
373
              <option value="GCE">Georgia Coastal Ecosystems LTER</option>
374
              <option value="HBR">Hubbard Brook LTER</option>
375
              <option value="HFR">Harvard Forest LTER</option>
376
              <option value="JRN">Jornada Basin LTER</option>
377
              <option value="KBS">Kellogg Biological Station LTER</option>
378
              <option value="KNZ">Konza Prairie LTER</option>
379
              <option value="LNO">LTER Network Office</option>
380
              <option value="LUQ">Luquillo LTER</option>
381
              <option value="MCM">McMurdo Dry Valleys LTER</option>
382
              <option value="MCR">Moorea Coral Reef</option>
383
              <option value="NTL">North Temperate Lakes LTER</option>
384
              <option value="NWT">Niwot Ridge LTER</option>
385
              <option value="PAL">Palmer Station LTER</option>
386
              <option value="PIE">Plum Island Ecosystem LTER</option>
387
              <option value="SBC">Santa Barbara Coastal LTER</option>
388
              <option value="SEV">Sevilleta LTER</option>
389
              <option value="SGS">Shortgrass Steppe</option>
390
              <option value="VCR">Virginia Coastal Reserve LTER</option>
391
            </select>
392
          </td>
393
       </tr>
394
        <tr>
395
          <td>&nbsp;</td>
396
          <td>&nbsp;</td>
397
        </tr>
398
-->     
399
        <tr>
400
          <th colspan="2">
401
            <h3>Search Options</h3>
402
          </th>
403
        </tr>
404
        <tr>
405
          <td colspan="2" align="center">
406
            <table>
407
              <tr>
408
                <td>
409
                  <input type="radio" name="formAllAny" value="0" checked="checked">"And" all search items&nbsp;
410
                </td>
411
                <td>
412
                  <input type="radio" name="formAllAny" value="1">"Or" all search items&nbsp;
413
                </td>
414
                <td>
415
                  <input type="checkbox" name="caseSensitive" value="on">Case sensitive
416
                </td>
417
              </tr>
418
            </table>
419
          </td>
420
        </tr>
421
        <tr>
422
          <td>&nbsp;</td>
423
          <td>&nbsp;</td>
424
        </tr>
425
        <tr>
426
          <td colspan="2" align="center">
427
            <input type="submit" value="Search">&nbsp;&nbsp;
428
            <!-- <input type="reset" value="Reset"> -->
429
          </td>
430
        </tr>
431
      </table>
432
      <input type="hidden" name="northBound" value=""/>
433
      <input type="hidden" name="southBound" value=""/>
434
      <input type="hidden" name="eastBound" value=""/>
435
      <input type="hidden" name="westBound" value=""/>
436
    </form>
437
    
438
    <script type="text/javascript" language="Javascript1.1"> 
439

    
440
    <!-- Begin JavaScript input validation checking code.
441
    var bCancel = false; 
442

    
443
    function validateAdvancedSearchForm(form) {                                                                   
444
        if (bCancel) 
445
            return true; 
446
        else 
447
            var formValidationResult;
448
            formValidationResult = validateFloat(form) && validateFloatRange(form); 
449
            return (formValidationResult == 1);
450
    } 
451

    
452
    function advancedSearchForm_FloatValidations () { 
453
      this.a0 = new Array("westBound", "West Boundary must be a number.", new Function ("varName", "this.min='-180.0'; this.max='180.0';  return this[varName];"));
454
      this.a1 = new Array("eastBound", "East Boundary must be a number.", new Function ("varName", "this.min='-180.0'; this.max='180.0';  return this[varName];"));
455
      this.a2 = new Array("northBound", "North Boundary must be a number.", new Function ("varName", "this.min='-90.0'; this.max='90.0';  return this[varName];"));
456
      this.a3 = new Array("southBound", "South Boundary must be a number.", new Function ("varName", "this.min='-90.0'; this.max='90.0';  return this[varName];"));
457
    } 
458

    
459
    function advancedSearchForm_DateValidations () { 
460
      this.a0 = new Array("startDate", "Start Date must be a date (YYYY-MM-DD).", new Function ("varName", "this.datePattern='yyyy-MM-dd';  return this[varName];"));
461
      this.a1 = new Array("endDate", "End Date must be a date (YYYY-MM-DD).", new Function ("varName", "this.datePattern='yyyy-MM-dd';  return this[varName];"));
462
    } 
463

    
464
    function advancedSearchForm_floatRange () { 
465
      this.a0 = new Array("westBound", "West Boundary must be in the range -180.0 through 180.0.", new Function ("varName", "this.min='-180.0'; this.max='180.0';  return this[varName];"));
466
      this.a1 = new Array("eastBound", "East Boundary must be in the range -180.0 through 180.0.", new Function ("varName", "this.min='-180.0'; this.max='180.0';  return this[varName];"));
467
      this.a2 = new Array("northBound", "North Boundary must be in the range -90.0 through 90.0.", new Function ("varName", "this.min='-90.0'; this.max='90.0';  return this[varName];"));
468
      this.a3 = new Array("southBound", "South Boundary must be in the range -90.0 through 90.0.", new Function ("varName", "this.min='-90.0'; this.max='90.0';  return this[varName];"));
469
    } 
470

    
471
    /**
472
    * Check to see if fields are in a valid float range.
473
    * Fields are not checked if they are disabled.
474
    * <p>
475
    * @param form The form validation is taking place on.
476
    */
477
    function validateFloatRange(form) {
478
        var isValid = true;
479
        var focusField = null;
480
        var i = 0;
481
        var fields = new Array();
482
        var formName = form.getAttributeNode("name"); 
483

    
484
        oRange = eval('new ' + formName.value + '_floatRange()');
485
        for (x in oRange) {
486
            var field = form[oRange[x][0]];
487
            
488
            if ((field.type == 'hidden' ||
489
                field.type == 'text' || field.type == 'textarea') &&
490
                (field.value.length > 0)  &&
491
                 field.disabled == false) {
492
        
493
                var fMin = parseFloat(oRange[x][2]("min"));
494
                var fMax = parseFloat(oRange[x][2]("max"));
495
                var fValue = parseFloat(field.value);
496
                if (!(fValue >= fMin && fValue <= fMax)) {
497
                    if (i == 0) {
498
                        focusField = field;
499
                    }
500
                    fields[i++] = oRange[x][1];
501
                    isValid = false;
502
                }
503
            }
504
        }
505
        if (fields.length > 0) {
506
            focusField.focus();
507
            alert(fields.join('\n'));
508
        }
509
        return isValid;
510
    }
511

    
512

    
513
  /**
514
  * This is a place holder for common utilities used across the javascript validation
515
  *
516
  **/
517

    
518

    
519
    /**
520
    * Check to see if fields are a valid byte.
521
    * Fields are not checked if they are disabled.
522
    * <p>
523
    * @param form The form validation is taking place on.
524
    */
525
    function validateByte(form) {
526
        var bValid = true;
527
        var focusField = null;
528
        var i = 0;
529
        var fields = new Array();
530
        var formName = form.getAttributeNode("name"); 
531
        oByte = eval('new ' + formName.value + '_ByteValidations()');
532

    
533
        for (x in oByte) {
534
            var field = form[oByte[x][0]];
535

    
536
            if ((field.type == 'hidden' ||
537
                field.type == 'text' ||
538
                field.type == 'textarea' ||
539
                field.type == 'select-one' ||
540
                field.type == 'radio')  &&
541
                field.disabled == false) {
542

    
543
                var value = '';
544
                // get field's value
545
                if (field.type == "select-one") {
546
                    var si = field.selectedIndex;
547
                    if (si >= 0) {
548
                        value = field.options[si].value;
549
                    }
550
                } else {
551
                    value = field.value;
552
                }
553

    
554
                if (value.length > 0) {
555
                    if (!isAllDigits(value)) {
556
                        bValid = false;
557
                        if (i == 0) {
558
                            focusField = field;
559
                        }
560
                        fields[i++] = oByte[x][1];
561

    
562
                    } else {
563

    
564
                        var iValue = parseInt(value);
565
                        if (isNaN(iValue) || !(iValue >= -128 && iValue <= 127)) {
566
                            if (i == 0) {
567
                                focusField = field;
568
                            }
569
                            fields[i++] = oByte[x][1];
570
                            bValid = false;
571
                        }
572
                    }
573
                }
574

    
575
            }
576
        }
577
        if (fields.length > 0) {
578
           focusField.focus();
579
           alert(fields.join('\n'));
580
        }
581
        return bValid;
582
    }
583

    
584

    
585
    /**
586
    * A field is considered valid if less than the specified maximum.
587
    * Fields are not checked if they are disabled.
588
    * <p>
589
    * <strong>Caution:</strong> Using <code>validateMaxLength</code> on a password field in a 
590
    *  login page gives unnecessary information away to hackers. While it only slightly
591
    *  weakens security, we suggest using it only when modifying a password.</p>
592
    * @param form The form validation is taking place on.
593
    */
594
    function validateMaxLength(form) {
595
        var isValid = true;
596
        var focusField = null;
597
        var i = 0;
598
        var fields = new Array();
599
        var formName = form.getAttributeNode("name"); 
600

    
601
        oMaxLength = eval('new ' + formName.value + '_maxlength()');        
602
        for (x in oMaxLength) {
603
            var field = form[oMaxLength[x][0]];
604

    
605
            if ((field.type == 'hidden' ||
606
                field.type == 'text' ||
607
                field.type == 'password' ||
608
                field.type == 'textarea') &&
609
                field.disabled == false) {
610

    
611
                var iMax = parseInt(oMaxLength[x][2]("maxlength"));
612
                if (field.value.length > iMax) {
613
                    if (i == 0) {
614
                        focusField = field;
615
                    }
616
                    fields[i++] = oMaxLength[x][1];
617
                    isValid = false;
618
                }
619
            }
620
        }
621
        if (fields.length > 0) {
622
           focusField.focus();
623
           alert(fields.join('\n'));
624
        }
625
        return isValid;
626
    }
627

    
628

    
629
    /**
630
    *  Check to see if fields must contain a value.
631
    * Fields are not checked if they are disabled.
632
    * <p>
633
    * @param form The form validation is taking place on.
634
    */
635

    
636
    function validateRequired(form) {
637
        var isValid = true;
638
        var focusField = null;
639
        var i = 0;
640
        var fields = new Array();
641
        var formName = form.getAttributeNode("name");
642

    
643
        oRequired = eval('new ' + formName.value + '_required()');
644

    
645
        for (x in oRequired) {
646
            var field = form[oRequired[x][0]];
647

    
648
            if ((field.type == 'hidden' ||
649
                field.type == 'text' ||
650
                field.type == 'textarea' ||
651
                field.type == 'file' ||
652
                field.type == 'checkbox' ||
653
                field.type == 'select-one' ||
654
                field.type == 'password') &&
655
                field.disabled == false) {
656

    
657
                var value = '';
658
                // get field's value
659
                if (field.type == "select-one") {
660
                    var si = field.selectedIndex;
661
                    if (si >= 0) {
662
                        value = field.options[si].value;
663
                    }
664
                } else if (field.type == 'checkbox') {
665
                    if (field.checked) {
666
                        value = field.value;
667
                    }
668
                } else {
669
                    value = field.value;
670
                }
671

    
672
                if (trim(value).length == 0) {
673

    
674
                    if (i == 0) {
675
                        focusField = field;
676
                    }
677
                    fields[i++] = oRequired[x][1];
678
                    isValid = false;
679
                }
680
            } else if (field.type == "select-multiple") { 
681
                var numOptions = field.options.length;
682
                lastSelected=-1;
683
                for(loop=numOptions-1;loop>=0;loop--) {
684
                    if(field.options[loop].selected) {
685
                        lastSelected = loop;
686
                        value = field.options[loop].value;
687
                        break;
688
                    }
689
                }
690
                if(lastSelected < 0 || trim(value).length == 0) {
691
                    if(i == 0) {
692
                        focusField = field;
693
                    }
694
                    fields[i++] = oRequired[x][1];
695
                    isValid=false;
696
                }
697
            } else if ((field.length > 0) && (field[0].type == 'radio' || field[0].type == 'checkbox')) {
698
                isChecked=-1;
699
                for (loop=0;loop < field.length;loop++) {
700
                    if (field[loop].checked) {
701
                        isChecked=loop;
702
                        break; // only one needs to be checked
703
                    }
704
                }
705
                if (isChecked < 0) {
706
                    if (i == 0) {
707
                        focusField = field[0];
708
                    }
709
                    fields[i++] = oRequired[x][1];
710
                    isValid=false;
711
                }
712
            }
713
        }
714
        if (fields.length > 0) {
715
           focusField.focus();
716
           alert(fields.join('\n'));
717
        }
718
        return isValid;
719
    }
720
    
721
    // Trim whitespace from left and right sides of s.
722
    function trim(s) {
723
        return s.replace( /^\s*/, "" ).replace( /\s*$/, "" );
724
    }
725

    
726

    
727
    /**
728
    * Check to see if fields are a valid integer.
729
    * Fields are not checked if they are disabled.
730
    * <p>
731
    * @param form The form validation is taking place on.
732
    */
733
    function validateInteger(form) {
734
        var bValid = true;
735
        var focusField = null;
736
        var i = 0;
737
        var fields = new Array();
738
        var formName = form.getAttributeNode("name"); 
739

    
740
        oInteger = eval('new ' + formName.value + '_IntegerValidations()');
741
        for (x in oInteger) {
742
            var field = form[oInteger[x][0]];
743

    
744
            if ((field.type == 'hidden' ||
745
                field.type == 'text' ||
746
                field.type == 'textarea' ||
747
                field.type == 'select-one' ||
748
                field.type == 'radio') &&
749
                field.disabled == false) {
750

    
751
                var value = '';
752
                // get field's value
753
                if (field.type == "select-one") {
754
                    var si = field.selectedIndex;
755
                    if (si >= 0) {
756
                        value = field.options[si].value;
757
                    }
758
                } else {
759
                    value = field.value;
760
                }
761

    
762
                if (value.length > 0) {
763

    
764
                    if (!isAllDigits(value)) {
765
                        bValid = false;
766
                        if (i == 0) {
767
                            focusField = field;
768
                        }
769
                        fields[i++] = oInteger[x][1];
770

    
771
                    } else {
772
                        var iValue = parseInt(value);
773
                        if (isNaN(iValue) || !(iValue >= -2147483648 && iValue <= 2147483647)) {
774
                            if (i == 0) {
775
                                focusField = field;
776
                            }
777
                            fields[i++] = oInteger[x][1];
778
                            bValid = false;
779
                       }
780
                   }
781
               }
782
            }
783
        }
784
        if (fields.length > 0) {
785
           focusField.focus();
786
           alert(fields.join('\n'));
787
        }
788
        return bValid;
789
    }
790

    
791
    function isAllDigits(argvalue) {
792
        argvalue = argvalue.toString();
793
        var validChars = "0123456789";
794
        var startFrom = 0;
795
        if (argvalue.substring(0, 2) == "0x") {
796
           validChars = "0123456789abcdefABCDEF";
797
           startFrom = 2;
798
        } else if (argvalue.charAt(0) == "0") {
799
           validChars = "01234567";
800
           startFrom = 1;
801
        } else if (argvalue.charAt(0) == "-") {
802
            startFrom = 1;
803
        }
804

    
805
        for (var n = startFrom; n < argvalue.length; n++) {
806
            if (validChars.indexOf(argvalue.substring(n, n+1)) == -1) return false;
807
        }
808
        return true;
809
    }
810

    
811

    
812
    /**
813
    * Check to see if fields are a valid date.
814
    * Fields are not checked if they are disabled.
815
    * <p>
816
    * @param form The form validation is taking place on.
817
    */
818
    function validateDate(form) {
819
       var bValid = true;
820
       var focusField = null;
821
       var i = 0;
822
       var fields = new Array();
823
       var formName = form.getAttributeNode("name"); 
824

    
825
       oDate = eval('new ' + formName.value + '_DateValidations()');
826

    
827
       for (x in oDate) {
828
           var field = form[oDate[x][0]];
829
           var value = field.value;
830
           var datePattern = oDate[x][2]("datePatternStrict");
831
           // try loose pattern
832
           if (datePattern == null)
833
               datePattern = oDate[x][2]("datePattern");
834
           if ((field.type == 'hidden' ||
835
                field.type == 'text' ||
836
                field.type == 'textarea') &&
837
               (value.length > 0) && (datePattern.length > 0) &&
838
                field.disabled == false) {
839
                 var MONTH = "MM";
840
                 var DAY = "dd";
841
                 var YEAR = "yyyy";
842
                 var orderMonth = datePattern.indexOf(MONTH);
843
                 var orderDay = datePattern.indexOf(DAY);
844
                 var orderYear = datePattern.indexOf(YEAR);
845
                 if ((orderDay < orderYear && orderDay > orderMonth)) {
846
                     var iDelim1 = orderMonth + MONTH.length;
847
                     var iDelim2 = orderDay + DAY.length;
848
                     var delim1 = datePattern.substring(iDelim1, iDelim1 + 1);
849
                     var delim2 = datePattern.substring(iDelim2, iDelim2 + 1);
850
                     if (iDelim1 == orderDay && iDelim2 == orderYear) {
851
                        dateRegexp = new RegExp("^(\\d{2})(\\d{2})(\\d{4})$");
852
                     } else if (iDelim1 == orderDay) {
853
                        dateRegexp = new RegExp("^(\\d{2})(\\d{2})[" + delim2 + "](\\d{4})$");
854
                     } else if (iDelim2 == orderYear) {
855
                        dateRegexp = new RegExp("^(\\d{2})[" + delim1 + "](\\d{2})(\\d{4})$");
856
                     } else {
857
                        dateRegexp = new RegExp("^(\\d{2})[" + delim1 + "](\\d{2})[" + delim2 + "](\\d{4})$");
858
                     }
859
                     var matched = dateRegexp.exec(value);
860
                     if(matched != null) {
861
                        if (!isValidDate(matched[2], matched[1], matched[3])) {
862
                           if (i == 0) {
863
                               focusField = field;
864
                           }
865
                           fields[i++] = oDate[x][1];
866
                           bValid =  false;
867
                        }
868
                     } else {
869
                        if (i == 0) {
870
                            focusField = field;
871
                        }
872
                        fields[i++] = oDate[x][1];
873
                        bValid =  false;
874
                     }
875
                 } else if ((orderMonth < orderYear && orderMonth > orderDay)) {
876
                     var iDelim1 = orderDay + DAY.length;
877
                     var iDelim2 = orderMonth + MONTH.length;
878
                     var delim1 = datePattern.substring(iDelim1, iDelim1 + 1);
879
                     var delim2 = datePattern.substring(iDelim2, iDelim2 + 1);
880
                     if (iDelim1 == orderMonth && iDelim2 == orderYear) {
881
                         dateRegexp = new RegExp("^(\\d{2})(\\d{2})(\\d{4})$");
882
                     } else if (iDelim1 == orderMonth) {
883
                         dateRegexp = new RegExp("^(\\d{2})(\\d{2})[" + delim2 + "](\\d{4})$");
884
                     } else if (iDelim2 == orderYear) {
885
                         dateRegexp = new RegExp("^(\\d{2})[" + delim1 + "](\\d{2})(\\d{4})$");
886
                     } else {
887
                         dateRegexp = new RegExp("^(\\d{2})[" + delim1 + "](\\d{2})[" + delim2 + "](\\d{4})$");
888
                     }
889
                     var matched = dateRegexp.exec(value);
890
                     if(matched != null) {
891
                         if (!isValidDate(matched[1], matched[2], matched[3])) {
892
                             if (i == 0) {
893
                         focusField = field;
894
                             }
895
                             fields[i++] = oDate[x][1];
896
                             bValid =  false;
897
                          }
898
                     } else {
899
                         if (i == 0) {
900
                             focusField = field;
901
                         }
902
                         fields[i++] = oDate[x][1];
903
                         bValid =  false;
904
                     }
905
                 } else if ((orderMonth > orderYear && orderMonth < orderDay)) {
906
                     var iDelim1 = orderYear + YEAR.length;
907
                     var iDelim2 = orderMonth + MONTH.length;
908
                     var delim1 = datePattern.substring(iDelim1, iDelim1 + 1);
909
                     var delim2 = datePattern.substring(iDelim2, iDelim2 + 1);
910
                     if (iDelim1 == orderMonth && iDelim2 == orderDay) {
911
                         dateRegexp = new RegExp("^(\\d{4})(\\d{2})(\\d{2})$");
912
                     } else if (iDelim1 == orderMonth) {
913
                         dateRegexp = new RegExp("^(\\d{4})(\\d{2})[" + delim2 + "](\\d{2})$");
914
                     } else if (iDelim2 == orderDay) {
915
                         dateRegexp = new RegExp("^(\\d{4})[" + delim1 + "](\\d{2})(\\d{2})$");
916
                     } else {
917
                         dateRegexp = new RegExp("^(\\d{4})[" + delim1 + "](\\d{2})[" + delim2 + "](\\d{2})$");
918
                     }
919
                     var matched = dateRegexp.exec(value);
920
                     if(matched != null) {
921
                         if (!isValidDate(matched[3], matched[2], matched[1])) {
922
                             if (i == 0) {
923
                                 focusField = field;
924
                             }
925
                             fields[i++] = oDate[x][1];
926
                             bValid =  false;
927
                         }
928
                     } else {
929
                          if (i == 0) {
930
                              focusField = field;
931
                          }
932
                          fields[i++] = oDate[x][1];
933
                          bValid =  false;
934
                     }
935
                 } else {
936
                     if (i == 0) {
937
                         focusField = field;
938
                     }
939
                     fields[i++] = oDate[x][1];
940
                     bValid =  false;
941
                 }
942
          }
943
       }
944
       if (fields.length > 0) {
945
          focusField.focus();
946
          alert(fields.join('\n'));
947
       }
948
       return bValid;
949
    }
950
    
951
    function isValidDate(day, month, year) {
952
        if (month < 1 || month > 12) {
953
            return false;
954
        }
955
        if (day < 1 || day > 31) {
956
            return false;
957
        }
958
        if ((month == 4 || month == 6 || month == 9 || month == 11) &&
959
            (day == 31)) {
960
            return false;
961
        }
962
        if (month == 2) {
963
            var leap = (year % 4 == 0 &&
964
               (year % 100 != 0 || year % 400 == 0));
965
            if (day>29 || (day == 29 && !leap)) {
966
                return false;
967
            }
968
        }
969
        return true;
970
    }
971

    
972

    
973
    /**
974
    * Check to see if fields are a valid creditcard number based on Luhn checksum.
975
    * Fields are not checked if they are disabled.
976
    * <p>
977
    * @param form The form validation is taking place on.
978
    */
979
    function validateCreditCard(form) {
980
        var bValid = true;
981
        var focusField = null;
982
        var i = 0;
983
        var fields = new Array();
984
        var formName = form.getAttributeNode("name");
985

    
986
        oCreditCard = eval('new ' + formName.value + '_creditCard()');
987

    
988
        for (x in oCreditCard) {
989
            if ((form[oCreditCard[x][0]].type == 'text' ||
990
                 form[oCreditCard[x][0]].type == 'textarea') &&
991
                (form[oCreditCard[x][0]].value.length > 0)  &&
992
                 form[oCreditCard[x][0]].disabled == false) {
993
                if (!luhnCheck(form[oCreditCard[x][0]].value)) {
994
                    if (i == 0) {
995
                        focusField = form[oCreditCard[x][0]];
996
                    }
997
                    fields[i++] = oCreditCard[x][1];
998
                    bValid = false;
999
                }
1000
            }
1001
        }
1002
        if (fields.length > 0) {
1003
            focusField.focus();
1004
            alert(fields.join('\n'));
1005
        }
1006
        return bValid;
1007
    }
1008

    
1009
    /**
1010
     * Checks whether a given credit card number has a valid Luhn checksum.
1011
     * This allows you to spot most randomly made-up or garbled credit card numbers immediately.
1012
     * Reference: http://www.speech.cs.cmu.edu/~sburke/pub/luhn_lib.html
1013
     */
1014
    function luhnCheck(cardNumber) {
1015
        if (isLuhnNum(cardNumber)) {
1016
            var no_digit = cardNumber.length;
1017
            var oddoeven = no_digit & 1;
1018
            var sum = 0;
1019
            for (var count = 0; count < no_digit; count++) {
1020
                var digit = parseInt(cardNumber.charAt(count));
1021
                if (!((count & 1) ^ oddoeven)) {
1022
                    digit *= 2;
1023
                    if (digit > 9) digit -= 9;
1024
                };
1025
                sum += digit;
1026
            };
1027
            if (sum == 0) return false;
1028
            if (sum % 10 == 0) return true;
1029
        };
1030
        return false;
1031
    }
1032

    
1033
    function isLuhnNum(argvalue) {
1034
        argvalue = argvalue.toString();
1035
        if (argvalue.length == 0) {
1036
            return false;
1037
        }
1038
        for (var n = 0; n < argvalue.length; n++) {
1039
            if ((argvalue.substring(n, n+1) < "0") ||
1040
                (argvalue.substring(n,n+1) > "9")) {
1041
                return false;
1042
            }
1043
        }
1044
        return true;
1045
    }
1046

    
1047

    
1048
    /**
1049
    * Check to see if fields is in a valid integer range.
1050
    * Fields are not checked if they are disabled.
1051
    * <p>
1052
    * @param form The form validation is taking place on.
1053
    */
1054
    function validateIntRange(form) {
1055
        var isValid = true;
1056
        var focusField = null;
1057
        var i = 0;
1058
        var fields = new Array();
1059
        var formName = form.getAttributeNode("name"); 
1060

    
1061
        oRange = eval('new ' + formName.value + '_intRange()');        
1062
        for (x in oRange) {
1063
            var field = form[oRange[x][0]];
1064
            if (field.disabled == false)  {
1065
                var value = '';
1066
                if (field.type == 'hidden' ||
1067
                    field.type == 'text' || field.type == 'textarea' ||
1068
                    field.type == 'radio' ) {
1069
                    value = field.value;
1070
                }
1071
                if (field.type == 'select-one') {
1072
                    var si = field.selectedIndex;
1073
                    if (si >= 0) {
1074
                        value = field.options[si].value;
1075
                    }
1076
                }
1077
                if (value.length > 0) {
1078
                    var iMin = parseInt(oRange[x][2]("min"));
1079
                    var iMax = parseInt(oRange[x][2]("max"));
1080
                    var iValue = parseInt(value);
1081
                    if (!(iValue >= iMin && iValue <= iMax)) {
1082
                        if (i == 0) {
1083
                            focusField = field;
1084
                        }
1085
                        fields[i++] = oRange[x][1];
1086
                        isValid = false;
1087
                    }
1088
                }
1089
            }
1090
        }
1091
        if (fields.length > 0) {
1092
            focusField.focus();
1093
            alert(fields.join('\n'));
1094
        }
1095
        return isValid;
1096
    }
1097

    
1098

    
1099
    /**
1100
    *  Check to see if fields are a valid short.
1101
    * Fields are not checked if they are disabled.
1102
    * <p>
1103
    * @param form The form validation is taking place on.
1104
    */
1105
    function validateShort(form) {
1106
        var bValid = true;
1107
        var focusField = null;
1108
        var i = 0;
1109
        var fields = new Array();
1110
        var formName = form.getAttributeNode("name");
1111

    
1112
        oShort = eval('new ' + formName.value + '_ShortValidations()');
1113

    
1114
        for (x in oShort) {
1115
            var field = form[oShort[x][0]];
1116

    
1117
            if ((field.type == 'hidden' ||
1118
                field.type == 'text' ||
1119
                field.type == 'textarea' ||
1120
                field.type == 'select-one' ||
1121
                field.type == 'radio')  &&
1122
                field.disabled == false) {
1123

    
1124
                var value = '';
1125
                // get field's value
1126
                if (field.type == "select-one") {
1127
                    var si = field.selectedIndex;
1128
                    if (si >= 0) {
1129
                        value = field.options[si].value;
1130
                    }
1131
                } else {
1132
                    value = field.value;
1133
                }
1134

    
1135
                if (value.length > 0) {
1136
                    if (!isAllDigits(value)) {
1137
                        bValid = false;
1138
                        if (i == 0) {
1139
                            focusField = field;
1140
                        }
1141
                        fields[i++] = oShort[x][1];
1142

    
1143
                    } else {
1144

    
1145
                        var iValue = parseInt(value);
1146
                        if (isNaN(iValue) || !(iValue >= -32768 && iValue <= 32767)) {
1147
                            if (i == 0) {
1148
                                focusField = field;
1149
                            }
1150
                            fields[i++] = oShort[x][1];
1151
                            bValid = false;
1152
                        }
1153
                   }
1154
               }
1155
            }
1156
        }
1157
        if (fields.length > 0) {
1158
           focusField.focus();
1159
           alert(fields.join('\n'));
1160
        }
1161
        return bValid;
1162
    }
1163

    
1164

    
1165
    /**
1166
    * Check to see if fields are a valid float.
1167
    * Fields are not checked if they are disabled.
1168
    * <p>
1169
    * @param form The form validation is taking place on.
1170
    */
1171
    function validateFloat(form) {
1172
        var bValid = true;
1173
        var focusField = null;
1174
        var i = 0;
1175
        var fields = new Array();
1176
         var formName = form.getAttributeNode("name");
1177

    
1178
        oFloat = eval('new ' + formName.value + '_FloatValidations()');
1179
        for (x in oFloat) {
1180
            var field = form[oFloat[x][0]];
1181
            
1182
            if ((field.type == 'hidden' ||
1183
                field.type == 'text' ||
1184
                field.type == 'textarea' ||
1185
                field.type == 'select-one' ||
1186
                field.type == 'radio') &&
1187
                field.disabled == false) {
1188
        
1189
                var value = '';
1190
                // get field's value
1191
                if (field.type == "select-one") {
1192
                    var si = field.selectedIndex;
1193
                    if (si >= 0) {
1194
                        value = field.options[si].value;
1195
                    }
1196
                } else {
1197
                    value = field.value;
1198
                }
1199
        
1200
                if (value.length > 0) {
1201
                    // remove '.' before checking digits
1202
                    var tempArray = value.split('.');
1203
                    //Strip off leading '0'
1204
                    var zeroIndex = 0;
1205
                    var joinedString= tempArray.join('');
1206
                    while (joinedString.charAt(zeroIndex) == '0') {
1207
                        zeroIndex++;
1208
                    }
1209
                    var noZeroString = joinedString.substring(zeroIndex,joinedString.length);
1210

    
1211
                    if (!isAllDigits(noZeroString)) {
1212
                        bValid = false;
1213
                        if (i == 0) {
1214
                            focusField = field;
1215
                        }
1216
                        fields[i++] = oFloat[x][1];
1217

    
1218
                    } else {
1219
                    var iValue = parseFloat(value);
1220
                    if (isNaN(iValue)) {
1221
                        if (i == 0) {
1222
                            focusField = field;
1223
                        }
1224
                        fields[i++] = oFloat[x][1];
1225
                        bValid = false;
1226
                    }
1227
                    }
1228
                }
1229
            }
1230
        }
1231
        if (fields.length > 0) {
1232
           focusField.focus();
1233
           alert(fields.join('\n'));
1234
        }
1235
        return bValid;
1236
    }
1237

    
1238

    
1239
    /**
1240
    * Check to see if fields are a valid email address.
1241
    * Fields are not checked if they are disabled.
1242
    * <p>
1243
    * @param form The form validation is taking place on.
1244
    */
1245
    function validateEmail(form) {
1246
        var bValid = true;
1247
        var focusField = null;
1248
        var i = 0;
1249
        var fields = new Array();
1250
        var formName = form.getAttributeNode("name");
1251

    
1252

    
1253
        oEmail = eval('new ' + formName.value + '_email()');
1254

    
1255
        for (x in oEmail) {
1256
            var field = form[oEmail[x][0]];
1257
            if ((field.type == 'hidden' || 
1258
                 field.type == 'text' ||
1259
                 field.type == 'textarea') &&
1260
                (field.value.length > 0) &&
1261
                field.disabled == false) {
1262
                if (!checkEmail(field.value)) {
1263
                    if (i == 0) {
1264
                        focusField = field;
1265
                    }
1266
                    fields[i++] = oEmail[x][1];
1267
                    bValid = false;
1268
                }
1269
            }
1270
        }
1271
        if (fields.length > 0) {
1272
            focusField.focus();
1273
            alert(fields.join('\n'));
1274
        }
1275
        return bValid;
1276
    }
1277

    
1278
    /**
1279
     * Reference: Sandeep V. Tamhankar (stamhankar@hotmail.com),
1280
     * http://javascript.internet.com
1281
     */
1282
    function checkEmail(emailStr) {
1283
       if (emailStr.length == 0) {
1284
           return true;
1285
       }
1286
       var emailPat=/^(.+)@(.+)$/;
1287
       var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]";
1288
       var validChars="\[^\\s" + specialChars + "\]";
1289
       var quotedUser="(\"[^\"]*\")";
1290
       var ipDomainPat=/^(\d{1,3})[.](\d{1,3})[.](\d{1,3})[.](\d{1,3})$/;
1291
       var atom=validChars + '+';
1292
       var word="(" + atom + "|" + quotedUser + ")";
1293
       var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
1294
       var domainPat=new RegExp("^" + atom + "(\\." + atom + ")*$");
1295
       var matchArray=emailStr.match(emailPat);
1296
       if (matchArray == null) {
1297
           return false;
1298
       }
1299
       var user=matchArray[1];
1300
       var domain=matchArray[2];
1301
       if (user.match(userPat) == null) {
1302
           return false;
1303
       }
1304
       var IPArray = domain.match(ipDomainPat);
1305
       if (IPArray != null) {
1306
           for (var i = 1; i <= 4; i++) {
1307
              if (IPArray[i] > 255) {
1308
                 return false;
1309
              }
1310
           }
1311
           return true;
1312
       }
1313
       var domainArray=domain.match(domainPat);
1314
       if (domainArray == null) {
1315
           return false;
1316
       }
1317
       var atomPat=new RegExp(atom,"g");
1318
       var domArr=domain.match(atomPat);
1319
       var len=domArr.length;
1320
       if ((domArr[domArr.length-1].length < 2) ||
1321
           (domArr[domArr.length-1].length > 3)) {
1322
           return false;
1323
       }
1324
       if (len < 2) {
1325
           return false;
1326
       }
1327
       return true;
1328
    }
1329

    
1330
  
1331
    /**
1332
    * Check to see if fields are a valid using a regular expression.
1333
    * Fields are not checked if they are disabled.
1334
    * <p>
1335
    * @param form The form validation is taking place on.
1336
    */
1337
    function validateMask(form) {
1338
        var isValid = true;
1339
        var focusField = null;
1340
        var i = 0;
1341
        var fields = new Array();
1342
        var formName = form.getAttributeNode("name"); 
1343

    
1344
        oMasked = eval('new ' + formName.value + '_mask()');      
1345
        for (x in oMasked) {
1346
            var field = form[oMasked[x][0]];
1347

    
1348
            if ((field.type == 'hidden' ||
1349
                field.type == 'text' ||
1350
                 field.type == 'textarea' ||
1351
                 field.type == 'file') &&
1352
                 (field.value.length > 0) &&
1353
                 field.disabled == false) {
1354

    
1355
                if (!matchPattern(field.value, oMasked[x][2]("mask"))) {
1356
                    if (i == 0) {
1357
                        focusField = field;
1358
                    }
1359
                    fields[i++] = oMasked[x][1];
1360
                    isValid = false;
1361
                }
1362
            }
1363
        }
1364

    
1365
        if (fields.length > 0) {
1366
           focusField.focus();
1367
           alert(fields.join('\n'));
1368
        }
1369
        return isValid;
1370
    }
1371

    
1372
    function matchPattern(value, mask) {
1373
       return mask.exec(value);
1374
    }
1375

    
1376

    
1377
    /**
1378
    * A field is considered valid if greater than the specified minimum.
1379
    * Fields are not checked if they are disabled.
1380
    * <p>
1381
    * <strong>Caution:</strong> Using <code>validateMinLength</code> on a password field in a 
1382
    *  login page gives unnecessary information away to hackers. While it only slightly
1383
    *  weakens security, we suggest using it only when modifying a password.</p>
1384
    * @param form The form validation is taking place on.
1385
    */
1386
    function validateMinLength(form) {
1387
        var isValid = true;
1388
        var focusField = null;
1389
        var i = 0;
1390
        var fields = new Array();
1391
        var formName = form.getAttributeNode("name");
1392

    
1393

    
1394
        oMinLength = eval('new ' + formName.value + '_minlength()');
1395

    
1396
        for (x in oMinLength) {
1397
            var field = form[oMinLength[x][0]];
1398

    
1399
            if ((field.type == 'hidden' ||
1400
                field.type == 'text' ||
1401
                field.type == 'password' ||
1402
                field.type == 'textarea') &&
1403
                field.disabled == false) {
1404

    
1405
                var iMin = parseInt(oMinLength[x][2]("minlength"));
1406
                if ((trim(field.value).length > 0) && (field.value.length < iMin)) {
1407
                    if (i == 0) {
1408
                        focusField = field;
1409
                    }
1410
                    fields[i++] = oMinLength[x][1];
1411
                    isValid = false;
1412
                }
1413
            }
1414
        }
1415
        if (fields.length > 0) {
1416
           focusField.focus();
1417
           alert(fields.join('\n'));
1418
        }
1419
        return isValid;
1420
    }
1421

    
1422
    //End  JavaScript input validation checking code. --> 
1423
    </script>
1424
            </td>
1425
          </tr>
1426
          <tr> 
1427
            <td width="375">&nbsp;</td>
1428
            <td width="365">&nbsp;</td>
1429
          </tr>
1430
        </table>
1431
      </td>
1432
    </tr>
1433
  </table>
1434
</body>
1435
<!-- ************************* END SEARCHBOX TABLE ************************* -->