Project

General

Profile

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: daigle $'
12
  *     '$Date: 2008-07-06 21:25:34 -0700 (Sun, 06 Jul 2008) $'
13
  * '$Revision: 4080 $'
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

    
34
<%
35
  String imageHeight = "3";
36
%>
37

    
38
<!-- *********************** START SEARCHBOX TABLE ************************* -->
39
<html>
40
<head>
41
  <title>Metacat Data Catalog Advanced Search Page</title>
42
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
43
  <link href="<%=STYLE_SKINS_URL%>/lter/lter.css" rel="stylesheet" type="text/css">
44

    
45
  <script language="javascript" 
46
    type="text/javascript" src="<%=STYLE_SKINS_URL%>/lter/lter.js">
47
  </script>
48

    
49
  <script language="javascript" type="text/javascript">
50

    
51
      function trim(stringToTrim) {
52
        return stringToTrim.replace(/^\s*/, '').replace(/\s*$/,'');
53
      }
54

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

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

    
81
        if (canSearch) {        
82
          // Re-initialize the hidden form values prior to submitting
83
          form.northBound.value = "";
84
          form.southBound.value = "";
85
          form.eastBound.value = "";
86
          form.westBound.value = "";
87

    
88
          if ((x_range != "-180.0 180.0") && (y_range != "-90.0 90.0")) {     
89
            form.northBound.value = y_hi;
90
            form.southBound.value = y_lo;
91
            form.eastBound.value = x_hi;
92
            form.westBound.value = x_lo;
93
          }
94
          
95
          return(validateAdvancedSearchForm(form));
96
        }
97
        else {
98
          return false;
99
        }
100
      }
101
  </script>
102
</head>
103

    
104
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
105
  <table width="750px" align="center" cellspacing="0" cellpadding="0">
106
    <tr> 
107
      <td colspan="2"><h2>Advanced Search</h2></td>
108
    </tr>
109
    <tr> 
110
      <td colspan="2">
111
        <table width="100%" border="0" cellpadding="0" cellspacing="0" 
112
          class="subpanel">
113
          <tr> 
114
            <td colspan="2"></td>
115
          </tr>
116
          <tr valign="baseline"> 
117
            <td colspan="2">
118
    <form name="advancedSearchForm"
119
          method="POST"
120
          action="advancedsearchforward.jsp"
121
          onsubmit="return submitRequest(this)"
122
          target="_top">
123
      <table width="100%" border="0" cellpadding="0" cellspacing="0" >
124
        <tr class="searchresultsdivider">
125
          <td colspan="2">
126
            <img height="<%= imageHeight %>" width="1" src="/knb/style/skins/default/images/transparent1x1.gif">
127
          </td>
128
        </tr>        
129
        <tr>
130
          <td>&nbsp;</td>
131
        </tr>
132
        <tr>
133
          <td colspan="2">
134
            <h3>Subject</h3>
135
          </td>
136
        </tr>
137
        <tr>
138
          <td>&nbsp;</td>
139
          <td>&nbsp;</td>
140
        </tr>
141
        <tr>
142
          <td align="right" nowrap>
143
            <select name="subjectField">
144
              <option value="ALL">Subject</option>
145
              <option value="TITLE">Title Only</option>
146
              <option value="ABSTRACT">Abtract Only</option>
147
              <option value="KEYWORDS">Keywords Only</option>
148
            </select>
149
          </td>
150
          <td>
151
            <select name="subjectQueryType">
152
              <option value="0" selected="selected">contains</option>
153
              <option value="1">matches exactly</option>
154
              <option value="2">starts with</option>
155
              <option value="3">ends with</option>
156
            </select>
157
            <input type="text" name="subjectValue" value="">
158
            <input type="radio" name="subjectAllAny" value="0" checked="checked">All Terms
159
            <input type="radio" name="subjectAllAny" value="1">Any Term
160
          </td>
161
        </tr>
162
        <tr>
163
          <td>&nbsp;</td>
164
          <td>&nbsp;</td>
165
        </tr>
166
        <tr class="searchresultsdivider">
167
          <td colspan="2">
168
            <img height="<%= imageHeight %>" width="1" src="/knb/style/skins/default/images/transparent1x1.gif">
169
          </td>
170
        </tr>        
171
        <tr>
172
          <td>&nbsp;</td>
173
        </tr>
174
        <tr>
175
          <td colspan="2">
176
            <h3>Author</h3>
177
          </td>
178
        </tr>
179
        <tr>
180
          <td>&nbsp;</td>
181
          <td>&nbsp;</td>
182
        </tr>
183
        <tr>
184
          <td nowrap align="right">Individual's Last Name:
185
          </td>
186
          <td>
187
            <select name="creatorSurnameQueryType">
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="creatorSurname" value="">
193
          </td>
194
        </tr>
195
        <tr>
196
          <td>&nbsp;</td>
197
          <td>&nbsp;</td>
198
        </tr>
199
        <tr>
200
          <td align="right" nowrap>Organization:
201
          </td>
202
          <td>
203
            <select name="creatorOrganizationQueryType">
204
              <option value="0" selected="selected">contains</option>
205
              <option value="1">matches exactly</option>
206
              <option value="2">starts with</option>
207
              <option value="3">ends with</option></select>
208
            <input type="text" name="creatorOrganization" value="">
209
          </td>
210
        </tr>
211
        <tr>
212
          <td>&nbsp;</td>
213
          <td>&nbsp;</td>
214
        </tr>
215
        <tr class="searchresultsdivider">
216
          <td colspan="2">
217
            <img height="<%= imageHeight %>" width="1" src="/knb/style/skins/default/images/transparent1x1.gif">
218
          </td>
219
        </tr>        
220
        <tr>
221
          <td>&nbsp;</td>
222
        </tr>
223
        <tr>
224
          <td colspan="2">
225
            <h3>Spatial Criteria</h3>
226
          </td>
227
        </tr>
228
        <tr>
229
          <td>&nbsp;</td>
230
          <td>&nbsp;</td>
231
        </tr>
232
        <tr>
233
          <td align="right">Geographic Boundaries:</td>
234
        </tr>
235
        <tr>
236
          <td>&nbsp;</td>
237
          <td>
238
            <applet
239
              CODEBASE="<%=CONTEXT_URL%>/LiveMap_30"
240
              CODE="LiveMap_30.class"
241
              ARCHIVE="LiveMap_30.jar"
242
              NAME="map" 
243
              MAYSCRIPT 
244
              width=500 
245
              height=160>
246
              <param name=base_image value="gifs/java_0_world_20k.jpg">
247
              <param name=img_x_domain value="-180 180">
248
              <param name=img_y_domain value="-90 90">
249
              <param name=toolType value="XY">
250
              <param name=tool_x_range value="-180 180">
251
              <param name=tool_y_range value="-90 90">
252
            </applet>
253
          </td>
254
        </tr>
255
        <tr>
256
          <td>&nbsp;</td>
257
          <td>
258
            <!--
259
             The underlying property value associated with checkbox
260
             should be of type boolean, and any value you specify 
261
             should correspond to one of the strings that indicate a 
262
             true value ("true", "yes", or "on").
263
            -->
264
            <input type="checkbox" name="boundaryContained" value="on">
265
            Dataset must be fully contained within boundaries
266
          </td>
267
        </tr>
268
        <tr>
269
          <td>&nbsp;</td>
270
          <td>&nbsp;</td>
271
        </tr>
272
        <tr>
273
          <td align="right">Geographic Place Name: 
274
          </td>
275
          <td><input type="text" name="locationName" value="">
276
          </td>
277
        </tr>
278
        <tr>
279
          <td>&nbsp;</td>
280
          <td>&nbsp;</td>
281
        </tr>
282
        <tr class="searchresultsdivider">
283
          <td colspan="2">
284
            <img height="<%= imageHeight %>" width="1" src="/knb/style/skins/default/images/transparent1x1.gif">
285
          </td>
286
        </tr>        
287
        <!-- Temporal Criteria section is disabled because Metacat is
288
             not able to search date ranges. An enhancement request has
289
             been entered in Bugzilla (see 
290
             http://bugzilla.ecoinformatics.org/show_bug.cgi?id=2084 )
291
        <tr>
292
          <td>&nbsp;</td>
293
        </tr>
294
        <tr>
295
          <td colspan="2">
296
            <h3>Temporal Criteria</h3>
297
          </td>
298
        </tr>
299
        <tr>
300
          <td>&nbsp;</td>
301
          <td>&nbsp;</td>
302
        </tr>
303
        <tr>
304
          <td align="right">
305
            <select name="dateField">
306
              <option value="ALL">All Dates</option>
307
              <option value="COLLECTION">Collection Date</option>
308
              <option value="PUBLICATION">Publication Date</option>
309
            </select>
310
          </td>
311
          <td colspan="2">
312
            <input type="text" name="startDate" maxlength="10" size="10" value="" style="font-family:monospace;">
313
            to
314
            <input type="text" name="endDate" maxlength="10" size="10" value="" style="font-family:monospace;">
315
          </td>
316
        </tr>
317
        <tr>
318
          <td>&nbsp;</td>
319
          <td>&nbsp;</td>
320
        </tr>
321
        <tr>
322
          <td align="right">Named Timescale:
323
            <select name="namedTimescaleQueryType">
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
          </td>
330
          <td>
331
            <input type="text" name="namedTimescale" value="">
332
          </td>
333
        </tr>
334
        <tr>
335
          <td>&nbsp;</td>
336
          <td>&nbsp;</td>
337
        </tr>
338
        <tr class="searchresultsdivider">
339
          <td colspan="2">
340
            <img height="<%= imageHeight %>" width="1" src="/knb/style/skins/default/images/transparent1x1.gif">
341
          </td>
342
        </tr>        
343
        -->
344
        <tr>
345
          <td>&nbsp;</td>
346
        </tr>
347
        <tr>
348
          <td colspan="2">
349
            <h3>Taxonomic Criteria</h3>
350
          </td>
351
        </tr>
352
        <tr>
353
          <td>&nbsp;</td>
354
          <td>&nbsp;</td>
355
        </tr>
356
        <tr>
357
          <td align="right">Taxon:
358
          </td>
359
          <td>
360
            <select name="taxonQueryType">
361
              <option value="0" selected="selected">contains</option>
362
              <option value="1">matches exactly</option>
363
              <option value="2">starts with</option>
364
              <option value="3">ends with</option>
365
            </select>
366
            <input type="text" name="taxon" value="">
367
          </td>
368
        </tr>
369
<!--
370
    Un-comment this row to ensure that siteValue is always set to "ALLSITES".
371
    If this row is commented-out, then the following section should be 
372
    uncommented, and vice-versa.
373
        <tr>
374
          <td>&nbsp;</td>
375
          <td>&nbsp;
376
            <input type="hidden" name="siteValue" value="ALLSITES"/>
377
          </td>
378
        </tr>
379
-->
380
<!--   
381
    Un-comment this section to include an input box that allows the
382
    user to restrict the search to a specific LTER site. Obviously, this is
383
    probably useful only within LTER. If uncommenting this section, 
384
    be sure to comment-out the hidden siteValue input above.
385
-->
386
        <tr class="searchresultsdivider">
387
          <td colspan="2">
388
            <img height="<%= imageHeight %>" width="1" src="/knb/style/skins/default/images/transparent1x1.gif">
389
          </td>
390
        </tr>        
391
        <tr>
392
          <td>&nbsp;</td>
393
        </tr>
394
        <tr>
395
          <td colspan="2">
396
            <h3>LTER Site</h3>
397
          </td>
398
        </tr>
399
        <tr>
400
          <td>&nbsp;</td>
401
          <td>&nbsp;</td>
402
        </tr>
403
        <tr>
404
          <td align="right">Limit search to LTER site:</td>
405
          <td>
406
            <select name="siteValue">
407
              <option value="ALLSITES">All LTER Sites</option>
408
              <option value="AND">Andrews LTER</option>
409
              <option value="ARC">Arctic LTER</option>
410
              <option value="BES">Baltimore Ecosystem Study</option>
411
              <option value="BNZ">Bonanza Creek LTER</option>
412
              <option value="CAP">Central Arizona - Phoenix Urban LTER</option>
413
              <option value="CCE">California Current Ecosystem</option>
414
              <option value="CDR">Cedar Creek Natural History Area</option>
415
              <option value="CWT">Coweeta LTER</option>
416
              <option value="FCE">Florida Coastal Everglades LTER</option>
417
              <option value="GCE">Georgia Coastal Ecosystems LTER</option>
418
              <option value="HBR">Hubbard Brook LTER</option>
419
              <option value="HFR">Harvard Forest LTER</option>
420
              <option value="JRN">Jornada Basin LTER</option>
421
              <option value="KBS">Kellogg Biological Station LTER</option>
422
              <option value="KNZ">Konza Prairie LTER</option>
423
              <option value="LNO">LTER Network Office</option>
424
              <option value="LUQ">Luquillo LTER</option>
425
              <option value="MCM">McMurdo Dry Valleys LTER</option>
426
              <option value="MCR">Moorea Coral Reef</option>
427
              <option value="NTL">North Temperate Lakes LTER</option>
428
              <option value="NWT">Niwot Ridge LTER</option>
429
              <option value="PAL">Palmer Station LTER</option>
430
              <option value="PIE">Plum Island Ecosystem LTER</option>
431
              <option value="SBC">Santa Barbara Coastal LTER</option>
432
              <option value="SEV">Sevilleta LTER</option>
433
              <option value="SGS">Shortgrass Steppe</option>
434
              <option value="VCR">Virginia Coastal Reserve LTER</option>
435
            </select>
436
          </td>
437
       </tr>
438
        <tr>
439
          <td>&nbsp;</td>
440
          <td>&nbsp;</td>
441
        </tr>
442

    
443
        <tr class="searchresultsdivider">
444
          <td colspan="2">
445
            <img height="<%= imageHeight %>" width="1" src="/knb/style/skins/default/images/transparent1x1.gif">
446
          </td>
447
        </tr>        
448
        <tr>
449
          <td>&nbsp;</td>
450
        </tr>
451
        <tr>
452
          <td colspan="2">
453
            <h3>Search Options</h3>
454
          </td>
455
        </tr>
456
        <tr>
457
          <td colspan="2" align="center">
458
            <table>
459
              <tr>
460
                <td>
461
                  <input type="radio" name="formAllAny" value="0" checked="checked">"And" all search items&nbsp;
462
                </td>
463
                <td>
464
                  <input type="radio" name="formAllAny" value="1">"Or" all search items&nbsp;
465
                </td>
466
                <td>
467
                  <input type="checkbox" name="caseSensitive" value="on">Case sensitive
468
                </td>
469
              </tr>
470
            </table>
471
          </td>
472
        </tr>
473
        <tr>
474
          <td>&nbsp;</td>
475
          <td>&nbsp;</td>
476
        </tr>
477
        <tr class="searchresultsdivider">
478
          <td colspan="2">
479
            <img height="<%= imageHeight %>" width="1" src="/knb/style/skins/default/images/transparent1x1.gif">
480
          </td>
481
        </tr>  
482
        <tr>
483
          <td>&nbsp;</td>
484
        </tr>
485
        <tr>
486
          <td colspan="2" align="center">
487
            <input type="submit" value="Search">&nbsp;&nbsp;
488
            <input type="reset" value="Reset">
489
          </td>
490
        </tr>
491
      </table>
492
      <input type="hidden" name="northBound" value=""/>
493
      <input type="hidden" name="southBound" value=""/>
494
      <input type="hidden" name="eastBound" value=""/>
495
      <input type="hidden" name="westBound" value=""/>
496
    </form>
497
    
498
    <script type="text/javascript" language="Javascript1.1"> 
499

    
500
    <!-- Begin JavaScript input validation checking code.
501
    var bCancel = false; 
502

    
503
    function validateAdvancedSearchForm(form) {                                                                   
504
        if (bCancel) 
505
            return true; 
506
        else 
507
            var formValidationResult;
508
            formValidationResult = validateFloat(form) && validateFloatRange(form); 
509
            return (formValidationResult == 1);
510
    } 
511

    
512
    function advancedSearchForm_FloatValidations () { 
513
      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];"));
514
      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];"));
515
      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];"));
516
      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];"));
517
    } 
518

    
519
    function advancedSearchForm_DateValidations () { 
520
      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];"));
521
      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];"));
522
    } 
523

    
524
    function advancedSearchForm_floatRange () { 
525
      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];"));
526
      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];"));
527
      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];"));
528
      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];"));
529
    } 
530

    
531
    /**
532
    * Check to see if fields are in a valid float range.
533
    * Fields are not checked if they are disabled.
534
    * <p>
535
    * @param form The form validation is taking place on.
536
    */
537
    function validateFloatRange(form) {
538
        var isValid = true;
539
        var focusField = null;
540
        var i = 0;
541
        var fields = new Array();
542
        var formName = form.getAttributeNode("name"); 
543

    
544
        oRange = eval('new ' + formName.value + '_floatRange()');
545
        for (x in oRange) {
546
            var field = form[oRange[x][0]];
547
            
548
            if ((field.type == 'hidden' ||
549
                field.type == 'text' || field.type == 'textarea') &&
550
                (field.value.length > 0)  &&
551
                 field.disabled == false) {
552
        
553
                var fMin = parseFloat(oRange[x][2]("min"));
554
                var fMax = parseFloat(oRange[x][2]("max"));
555
                var fValue = parseFloat(field.value);
556
                if (!(fValue >= fMin && fValue <= fMax)) {
557
                    if (i == 0) {
558
                        focusField = field;
559
                    }
560
                    fields[i++] = oRange[x][1];
561
                    isValid = false;
562
                }
563
            }
564
        }
565
        if (fields.length > 0) {
566
            focusField.focus();
567
            alert(fields.join('\n'));
568
        }
569
        return isValid;
570
    }
571

    
572

    
573
  /**
574
  * This is a place holder for common utilities used across the javascript validation
575
  *
576
  **/
577

    
578

    
579
    /**
580
    * Check to see if fields are a valid byte.
581
    * Fields are not checked if they are disabled.
582
    * <p>
583
    * @param form The form validation is taking place on.
584
    */
585
    function validateByte(form) {
586
        var bValid = true;
587
        var focusField = null;
588
        var i = 0;
589
        var fields = new Array();
590
        var formName = form.getAttributeNode("name"); 
591
        oByte = eval('new ' + formName.value + '_ByteValidations()');
592

    
593
        for (x in oByte) {
594
            var field = form[oByte[x][0]];
595

    
596
            if ((field.type == 'hidden' ||
597
                field.type == 'text' ||
598
                field.type == 'textarea' ||
599
                field.type == 'select-one' ||
600
                field.type == 'radio')  &&
601
                field.disabled == false) {
602

    
603
                var value = '';
604
                // get field's value
605
                if (field.type == "select-one") {
606
                    var si = field.selectedIndex;
607
                    if (si >= 0) {
608
                        value = field.options[si].value;
609
                    }
610
                } else {
611
                    value = field.value;
612
                }
613

    
614
                if (value.length > 0) {
615
                    if (!isAllDigits(value)) {
616
                        bValid = false;
617
                        if (i == 0) {
618
                            focusField = field;
619
                        }
620
                        fields[i++] = oByte[x][1];
621

    
622
                    } else {
623

    
624
                        var iValue = parseInt(value);
625
                        if (isNaN(iValue) || !(iValue >= -128 && iValue <= 127)) {
626
                            if (i == 0) {
627
                                focusField = field;
628
                            }
629
                            fields[i++] = oByte[x][1];
630
                            bValid = false;
631
                        }
632
                    }
633
                }
634

    
635
            }
636
        }
637
        if (fields.length > 0) {
638
           focusField.focus();
639
           alert(fields.join('\n'));
640
        }
641
        return bValid;
642
    }
643

    
644

    
645
    /**
646
    * A field is considered valid if less than the specified maximum.
647
    * Fields are not checked if they are disabled.
648
    * <p>
649
    * <strong>Caution:</strong> Using <code>validateMaxLength</code> on a password field in a 
650
    *  login page gives unnecessary information away to hackers. While it only slightly
651
    *  weakens security, we suggest using it only when modifying a password.</p>
652
    * @param form The form validation is taking place on.
653
    */
654
    function validateMaxLength(form) {
655
        var isValid = true;
656
        var focusField = null;
657
        var i = 0;
658
        var fields = new Array();
659
        var formName = form.getAttributeNode("name"); 
660

    
661
        oMaxLength = eval('new ' + formName.value + '_maxlength()');        
662
        for (x in oMaxLength) {
663
            var field = form[oMaxLength[x][0]];
664

    
665
            if ((field.type == 'hidden' ||
666
                field.type == 'text' ||
667
                field.type == 'password' ||
668
                field.type == 'textarea') &&
669
                field.disabled == false) {
670

    
671
                var iMax = parseInt(oMaxLength[x][2]("maxlength"));
672
                if (field.value.length > iMax) {
673
                    if (i == 0) {
674
                        focusField = field;
675
                    }
676
                    fields[i++] = oMaxLength[x][1];
677
                    isValid = false;
678
                }
679
            }
680
        }
681
        if (fields.length > 0) {
682
           focusField.focus();
683
           alert(fields.join('\n'));
684
        }
685
        return isValid;
686
    }
687

    
688

    
689
    /**
690
    *  Check to see if fields must contain a value.
691
    * Fields are not checked if they are disabled.
692
    * <p>
693
    * @param form The form validation is taking place on.
694
    */
695

    
696
    function validateRequired(form) {
697
        var isValid = true;
698
        var focusField = null;
699
        var i = 0;
700
        var fields = new Array();
701
        var formName = form.getAttributeNode("name");
702

    
703
        oRequired = eval('new ' + formName.value + '_required()');
704

    
705
        for (x in oRequired) {
706
            var field = form[oRequired[x][0]];
707

    
708
            if ((field.type == 'hidden' ||
709
                field.type == 'text' ||
710
                field.type == 'textarea' ||
711
                field.type == 'file' ||
712
                field.type == 'checkbox' ||
713
                field.type == 'select-one' ||
714
                field.type == 'password') &&
715
                field.disabled == false) {
716

    
717
                var value = '';
718
                // get field's value
719
                if (field.type == "select-one") {
720
                    var si = field.selectedIndex;
721
                    if (si >= 0) {
722
                        value = field.options[si].value;
723
                    }
724
                } else if (field.type == 'checkbox') {
725
                    if (field.checked) {
726
                        value = field.value;
727
                    }
728
                } else {
729
                    value = field.value;
730
                }
731

    
732
                if (trim(value).length == 0) {
733

    
734
                    if (i == 0) {
735
                        focusField = field;
736
                    }
737
                    fields[i++] = oRequired[x][1];
738
                    isValid = false;
739
                }
740
            } else if (field.type == "select-multiple") { 
741
                var numOptions = field.options.length;
742
                lastSelected=-1;
743
                for(loop=numOptions-1;loop>=0;loop--) {
744
                    if(field.options[loop].selected) {
745
                        lastSelected = loop;
746
                        value = field.options[loop].value;
747
                        break;
748
                    }
749
                }
750
                if(lastSelected < 0 || trim(value).length == 0) {
751
                    if(i == 0) {
752
                        focusField = field;
753
                    }
754
                    fields[i++] = oRequired[x][1];
755
                    isValid=false;
756
                }
757
            } else if ((field.length > 0) && (field[0].type == 'radio' || field[0].type == 'checkbox')) {
758
                isChecked=-1;
759
                for (loop=0;loop < field.length;loop++) {
760
                    if (field[loop].checked) {
761
                        isChecked=loop;
762
                        break; // only one needs to be checked
763
                    }
764
                }
765
                if (isChecked < 0) {
766
                    if (i == 0) {
767
                        focusField = field[0];
768
                    }
769
                    fields[i++] = oRequired[x][1];
770
                    isValid=false;
771
                }
772
            }
773
        }
774
        if (fields.length > 0) {
775
           focusField.focus();
776
           alert(fields.join('\n'));
777
        }
778
        return isValid;
779
    }
780
    
781
    // Trim whitespace from left and right sides of s.
782
    function trim(s) {
783
        return s.replace( /^\s*/, "" ).replace( /\s*$/, "" );
784
    }
785

    
786

    
787
    /**
788
    * Check to see if fields are a valid integer.
789
    * Fields are not checked if they are disabled.
790
    * <p>
791
    * @param form The form validation is taking place on.
792
    */
793
    function validateInteger(form) {
794
        var bValid = true;
795
        var focusField = null;
796
        var i = 0;
797
        var fields = new Array();
798
        var formName = form.getAttributeNode("name"); 
799

    
800
        oInteger = eval('new ' + formName.value + '_IntegerValidations()');
801
        for (x in oInteger) {
802
            var field = form[oInteger[x][0]];
803

    
804
            if ((field.type == 'hidden' ||
805
                field.type == 'text' ||
806
                field.type == 'textarea' ||
807
                field.type == 'select-one' ||
808
                field.type == 'radio') &&
809
                field.disabled == false) {
810

    
811
                var value = '';
812
                // get field's value
813
                if (field.type == "select-one") {
814
                    var si = field.selectedIndex;
815
                    if (si >= 0) {
816
                        value = field.options[si].value;
817
                    }
818
                } else {
819
                    value = field.value;
820
                }
821

    
822
                if (value.length > 0) {
823

    
824
                    if (!isAllDigits(value)) {
825
                        bValid = false;
826
                        if (i == 0) {
827
                            focusField = field;
828
                        }
829
                        fields[i++] = oInteger[x][1];
830

    
831
                    } else {
832
                        var iValue = parseInt(value);
833
                        if (isNaN(iValue) || !(iValue >= -2147483648 && iValue <= 2147483647)) {
834
                            if (i == 0) {
835
                                focusField = field;
836
                            }
837
                            fields[i++] = oInteger[x][1];
838
                            bValid = false;
839
                       }
840
                   }
841
               }
842
            }
843
        }
844
        if (fields.length > 0) {
845
           focusField.focus();
846
           alert(fields.join('\n'));
847
        }
848
        return bValid;
849
    }
850

    
851
    function isAllDigits(argvalue) {
852
        argvalue = argvalue.toString();
853
        var validChars = "0123456789";
854
        var startFrom = 0;
855
        if (argvalue.substring(0, 2) == "0x") {
856
           validChars = "0123456789abcdefABCDEF";
857
           startFrom = 2;
858
        } else if (argvalue.charAt(0) == "0") {
859
           validChars = "01234567";
860
           startFrom = 1;
861
        } else if (argvalue.charAt(0) == "-") {
862
            startFrom = 1;
863
        }
864

    
865
        for (var n = startFrom; n < argvalue.length; n++) {
866
            if (validChars.indexOf(argvalue.substring(n, n+1)) == -1) return false;
867
        }
868
        return true;
869
    }
870

    
871

    
872
    /**
873
    * Check to see if fields are a valid date.
874
    * Fields are not checked if they are disabled.
875
    * <p>
876
    * @param form The form validation is taking place on.
877
    */
878
    function validateDate(form) {
879
       var bValid = true;
880
       var focusField = null;
881
       var i = 0;
882
       var fields = new Array();
883
       var formName = form.getAttributeNode("name"); 
884

    
885
       oDate = eval('new ' + formName.value + '_DateValidations()');
886

    
887
       for (x in oDate) {
888
           var field = form[oDate[x][0]];
889
           var value = field.value;
890
           var datePattern = oDate[x][2]("datePatternStrict");
891
           // try loose pattern
892
           if (datePattern == null)
893
               datePattern = oDate[x][2]("datePattern");
894
           if ((field.type == 'hidden' ||
895
                field.type == 'text' ||
896
                field.type == 'textarea') &&
897
               (value.length > 0) && (datePattern.length > 0) &&
898
                field.disabled == false) {
899
                 var MONTH = "MM";
900
                 var DAY = "dd";
901
                 var YEAR = "yyyy";
902
                 var orderMonth = datePattern.indexOf(MONTH);
903
                 var orderDay = datePattern.indexOf(DAY);
904
                 var orderYear = datePattern.indexOf(YEAR);
905
                 if ((orderDay < orderYear && orderDay > orderMonth)) {
906
                     var iDelim1 = orderMonth + MONTH.length;
907
                     var iDelim2 = orderDay + DAY.length;
908
                     var delim1 = datePattern.substring(iDelim1, iDelim1 + 1);
909
                     var delim2 = datePattern.substring(iDelim2, iDelim2 + 1);
910
                     if (iDelim1 == orderDay && iDelim2 == orderYear) {
911
                        dateRegexp = new RegExp("^(\\d{2})(\\d{2})(\\d{4})$");
912
                     } else if (iDelim1 == orderDay) {
913
                        dateRegexp = new RegExp("^(\\d{2})(\\d{2})[" + delim2 + "](\\d{4})$");
914
                     } else if (iDelim2 == orderYear) {
915
                        dateRegexp = new RegExp("^(\\d{2})[" + delim1 + "](\\d{2})(\\d{4})$");
916
                     } else {
917
                        dateRegexp = new RegExp("^(\\d{2})[" + delim1 + "](\\d{2})[" + delim2 + "](\\d{4})$");
918
                     }
919
                     var matched = dateRegexp.exec(value);
920
                     if(matched != null) {
921
                        if (!isValidDate(matched[2], matched[1], matched[3])) {
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 if ((orderMonth < orderYear && orderMonth > orderDay)) {
936
                     var iDelim1 = orderDay + DAY.length;
937
                     var iDelim2 = orderMonth + MONTH.length;
938
                     var delim1 = datePattern.substring(iDelim1, iDelim1 + 1);
939
                     var delim2 = datePattern.substring(iDelim2, iDelim2 + 1);
940
                     if (iDelim1 == orderMonth && iDelim2 == orderYear) {
941
                         dateRegexp = new RegExp("^(\\d{2})(\\d{2})(\\d{4})$");
942
                     } else if (iDelim1 == orderMonth) {
943
                         dateRegexp = new RegExp("^(\\d{2})(\\d{2})[" + delim2 + "](\\d{4})$");
944
                     } else if (iDelim2 == orderYear) {
945
                         dateRegexp = new RegExp("^(\\d{2})[" + delim1 + "](\\d{2})(\\d{4})$");
946
                     } else {
947
                         dateRegexp = new RegExp("^(\\d{2})[" + delim1 + "](\\d{2})[" + delim2 + "](\\d{4})$");
948
                     }
949
                     var matched = dateRegexp.exec(value);
950
                     if(matched != null) {
951
                         if (!isValidDate(matched[1], matched[2], matched[3])) {
952
                             if (i == 0) {
953
                         focusField = field;
954
                             }
955
                             fields[i++] = oDate[x][1];
956
                             bValid =  false;
957
                          }
958
                     } else {
959
                         if (i == 0) {
960
                             focusField = field;
961
                         }
962
                         fields[i++] = oDate[x][1];
963
                         bValid =  false;
964
                     }
965
                 } else if ((orderMonth > orderYear && orderMonth < orderDay)) {
966
                     var iDelim1 = orderYear + YEAR.length;
967
                     var iDelim2 = orderMonth + MONTH.length;
968
                     var delim1 = datePattern.substring(iDelim1, iDelim1 + 1);
969
                     var delim2 = datePattern.substring(iDelim2, iDelim2 + 1);
970
                     if (iDelim1 == orderMonth && iDelim2 == orderDay) {
971
                         dateRegexp = new RegExp("^(\\d{4})(\\d{2})(\\d{2})$");
972
                     } else if (iDelim1 == orderMonth) {
973
                         dateRegexp = new RegExp("^(\\d{4})(\\d{2})[" + delim2 + "](\\d{2})$");
974
                     } else if (iDelim2 == orderDay) {
975
                         dateRegexp = new RegExp("^(\\d{4})[" + delim1 + "](\\d{2})(\\d{2})$");
976
                     } else {
977
                         dateRegexp = new RegExp("^(\\d{4})[" + delim1 + "](\\d{2})[" + delim2 + "](\\d{2})$");
978
                     }
979
                     var matched = dateRegexp.exec(value);
980
                     if(matched != null) {
981
                         if (!isValidDate(matched[3], matched[2], matched[1])) {
982
                             if (i == 0) {
983
                                 focusField = field;
984
                             }
985
                             fields[i++] = oDate[x][1];
986
                             bValid =  false;
987
                         }
988
                     } else {
989
                          if (i == 0) {
990
                              focusField = field;
991
                          }
992
                          fields[i++] = oDate[x][1];
993
                          bValid =  false;
994
                     }
995
                 } else {
996
                     if (i == 0) {
997
                         focusField = field;
998
                     }
999
                     fields[i++] = oDate[x][1];
1000
                     bValid =  false;
1001
                 }
1002
          }
1003
       }
1004
       if (fields.length > 0) {
1005
          focusField.focus();
1006
          alert(fields.join('\n'));
1007
       }
1008
       return bValid;
1009
    }
1010
    
1011
    function isValidDate(day, month, year) {
1012
        if (month < 1 || month > 12) {
1013
            return false;
1014
        }
1015
        if (day < 1 || day > 31) {
1016
            return false;
1017
        }
1018
        if ((month == 4 || month == 6 || month == 9 || month == 11) &&
1019
            (day == 31)) {
1020
            return false;
1021
        }
1022
        if (month == 2) {
1023
            var leap = (year % 4 == 0 &&
1024
               (year % 100 != 0 || year % 400 == 0));
1025
            if (day>29 || (day == 29 && !leap)) {
1026
                return false;
1027
            }
1028
        }
1029
        return true;
1030
    }
1031

    
1032

    
1033
    /**
1034
    * Check to see if fields are a valid creditcard number based on Luhn checksum.
1035
    * Fields are not checked if they are disabled.
1036
    * <p>
1037
    * @param form The form validation is taking place on.
1038
    */
1039
    function validateCreditCard(form) {
1040
        var bValid = true;
1041
        var focusField = null;
1042
        var i = 0;
1043
        var fields = new Array();
1044
        var formName = form.getAttributeNode("name");
1045

    
1046
        oCreditCard = eval('new ' + formName.value + '_creditCard()');
1047

    
1048
        for (x in oCreditCard) {
1049
            if ((form[oCreditCard[x][0]].type == 'text' ||
1050
                 form[oCreditCard[x][0]].type == 'textarea') &&
1051
                (form[oCreditCard[x][0]].value.length > 0)  &&
1052
                 form[oCreditCard[x][0]].disabled == false) {
1053
                if (!luhnCheck(form[oCreditCard[x][0]].value)) {
1054
                    if (i == 0) {
1055
                        focusField = form[oCreditCard[x][0]];
1056
                    }
1057
                    fields[i++] = oCreditCard[x][1];
1058
                    bValid = false;
1059
                }
1060
            }
1061
        }
1062
        if (fields.length > 0) {
1063
            focusField.focus();
1064
            alert(fields.join('\n'));
1065
        }
1066
        return bValid;
1067
    }
1068

    
1069
    /**
1070
     * Checks whether a given credit card number has a valid Luhn checksum.
1071
     * This allows you to spot most randomly made-up or garbled credit card numbers immediately.
1072
     * Reference: http://www.speech.cs.cmu.edu/~sburke/pub/luhn_lib.html
1073
     */
1074
    function luhnCheck(cardNumber) {
1075
        if (isLuhnNum(cardNumber)) {
1076
            var no_digit = cardNumber.length;
1077
            var oddoeven = no_digit & 1;
1078
            var sum = 0;
1079
            for (var count = 0; count < no_digit; count++) {
1080
                var digit = parseInt(cardNumber.charAt(count));
1081
                if (!((count & 1) ^ oddoeven)) {
1082
                    digit *= 2;
1083
                    if (digit > 9) digit -= 9;
1084
                };
1085
                sum += digit;
1086
            };
1087
            if (sum == 0) return false;
1088
            if (sum % 10 == 0) return true;
1089
        };
1090
        return false;
1091
    }
1092

    
1093
    function isLuhnNum(argvalue) {
1094
        argvalue = argvalue.toString();
1095
        if (argvalue.length == 0) {
1096
            return false;
1097
        }
1098
        for (var n = 0; n < argvalue.length; n++) {
1099
            if ((argvalue.substring(n, n+1) < "0") ||
1100
                (argvalue.substring(n,n+1) > "9")) {
1101
                return false;
1102
            }
1103
        }
1104
        return true;
1105
    }
1106

    
1107

    
1108
    /**
1109
    * Check to see if fields is in a valid integer range.
1110
    * Fields are not checked if they are disabled.
1111
    * <p>
1112
    * @param form The form validation is taking place on.
1113
    */
1114
    function validateIntRange(form) {
1115
        var isValid = true;
1116
        var focusField = null;
1117
        var i = 0;
1118
        var fields = new Array();
1119
        var formName = form.getAttributeNode("name"); 
1120

    
1121
        oRange = eval('new ' + formName.value + '_intRange()');        
1122
        for (x in oRange) {
1123
            var field = form[oRange[x][0]];
1124
            if (field.disabled == false)  {
1125
                var value = '';
1126
                if (field.type == 'hidden' ||
1127
                    field.type == 'text' || field.type == 'textarea' ||
1128
                    field.type == 'radio' ) {
1129
                    value = field.value;
1130
                }
1131
                if (field.type == 'select-one') {
1132
                    var si = field.selectedIndex;
1133
                    if (si >= 0) {
1134
                        value = field.options[si].value;
1135
                    }
1136
                }
1137
                if (value.length > 0) {
1138
                    var iMin = parseInt(oRange[x][2]("min"));
1139
                    var iMax = parseInt(oRange[x][2]("max"));
1140
                    var iValue = parseInt(value);
1141
                    if (!(iValue >= iMin && iValue <= iMax)) {
1142
                        if (i == 0) {
1143
                            focusField = field;
1144
                        }
1145
                        fields[i++] = oRange[x][1];
1146
                        isValid = false;
1147
                    }
1148
                }
1149
            }
1150
        }
1151
        if (fields.length > 0) {
1152
            focusField.focus();
1153
            alert(fields.join('\n'));
1154
        }
1155
        return isValid;
1156
    }
1157

    
1158

    
1159
    /**
1160
    *  Check to see if fields are a valid short.
1161
    * Fields are not checked if they are disabled.
1162
    * <p>
1163
    * @param form The form validation is taking place on.
1164
    */
1165
    function validateShort(form) {
1166
        var bValid = true;
1167
        var focusField = null;
1168
        var i = 0;
1169
        var fields = new Array();
1170
        var formName = form.getAttributeNode("name");
1171

    
1172
        oShort = eval('new ' + formName.value + '_ShortValidations()');
1173

    
1174
        for (x in oShort) {
1175
            var field = form[oShort[x][0]];
1176

    
1177
            if ((field.type == 'hidden' ||
1178
                field.type == 'text' ||
1179
                field.type == 'textarea' ||
1180
                field.type == 'select-one' ||
1181
                field.type == 'radio')  &&
1182
                field.disabled == false) {
1183

    
1184
                var value = '';
1185
                // get field's value
1186
                if (field.type == "select-one") {
1187
                    var si = field.selectedIndex;
1188
                    if (si >= 0) {
1189
                        value = field.options[si].value;
1190
                    }
1191
                } else {
1192
                    value = field.value;
1193
                }
1194

    
1195
                if (value.length > 0) {
1196
                    if (!isAllDigits(value)) {
1197
                        bValid = false;
1198
                        if (i == 0) {
1199
                            focusField = field;
1200
                        }
1201
                        fields[i++] = oShort[x][1];
1202

    
1203
                    } else {
1204

    
1205
                        var iValue = parseInt(value);
1206
                        if (isNaN(iValue) || !(iValue >= -32768 && iValue <= 32767)) {
1207
                            if (i == 0) {
1208
                                focusField = field;
1209
                            }
1210
                            fields[i++] = oShort[x][1];
1211
                            bValid = false;
1212
                        }
1213
                   }
1214
               }
1215
            }
1216
        }
1217
        if (fields.length > 0) {
1218
           focusField.focus();
1219
           alert(fields.join('\n'));
1220
        }
1221
        return bValid;
1222
    }
1223

    
1224

    
1225
    /**
1226
    * Check to see if fields are a valid float.
1227
    * Fields are not checked if they are disabled.
1228
    * <p>
1229
    * @param form The form validation is taking place on.
1230
    */
1231
    function validateFloat(form) {
1232
        var bValid = true;
1233
        var focusField = null;
1234
        var i = 0;
1235
        var fields = new Array();
1236
         var formName = form.getAttributeNode("name");
1237

    
1238
        oFloat = eval('new ' + formName.value + '_FloatValidations()');
1239
        for (x in oFloat) {
1240
            var field = form[oFloat[x][0]];
1241
            
1242
            if ((field.type == 'hidden' ||
1243
                field.type == 'text' ||
1244
                field.type == 'textarea' ||
1245
                field.type == 'select-one' ||
1246
                field.type == 'radio') &&
1247
                field.disabled == false) {
1248
        
1249
                var value = '';
1250
                // get field's value
1251
                if (field.type == "select-one") {
1252
                    var si = field.selectedIndex;
1253
                    if (si >= 0) {
1254
                        value = field.options[si].value;
1255
                    }
1256
                } else {
1257
                    value = field.value;
1258
                }
1259
        
1260
                if (value.length > 0) {
1261
                    // remove '.' before checking digits
1262
                    var tempArray = value.split('.');
1263
                    //Strip off leading '0'
1264
                    var zeroIndex = 0;
1265
                    var joinedString= tempArray.join('');
1266
                    while (joinedString.charAt(zeroIndex) == '0') {
1267
                        zeroIndex++;
1268
                    }
1269
                    var noZeroString = joinedString.substring(zeroIndex,joinedString.length);
1270

    
1271
                    if (!isAllDigits(noZeroString)) {
1272
                        bValid = false;
1273
                        if (i == 0) {
1274
                            focusField = field;
1275
                        }
1276
                        fields[i++] = oFloat[x][1];
1277

    
1278
                    } else {
1279
                    var iValue = parseFloat(value);
1280
                    if (isNaN(iValue)) {
1281
                        if (i == 0) {
1282
                            focusField = field;
1283
                        }
1284
                        fields[i++] = oFloat[x][1];
1285
                        bValid = false;
1286
                    }
1287
                    }
1288
                }
1289
            }
1290
        }
1291
        if (fields.length > 0) {
1292
           focusField.focus();
1293
           alert(fields.join('\n'));
1294
        }
1295
        return bValid;
1296
    }
1297

    
1298

    
1299
    /**
1300
    * Check to see if fields are a valid email address.
1301
    * Fields are not checked if they are disabled.
1302
    * <p>
1303
    * @param form The form validation is taking place on.
1304
    */
1305
    function validateEmail(form) {
1306
        var bValid = true;
1307
        var focusField = null;
1308
        var i = 0;
1309
        var fields = new Array();
1310
        var formName = form.getAttributeNode("name");
1311

    
1312

    
1313
        oEmail = eval('new ' + formName.value + '_email()');
1314

    
1315
        for (x in oEmail) {
1316
            var field = form[oEmail[x][0]];
1317
            if ((field.type == 'hidden' || 
1318
                 field.type == 'text' ||
1319
                 field.type == 'textarea') &&
1320
                (field.value.length > 0) &&
1321
                field.disabled == false) {
1322
                if (!checkEmail(field.value)) {
1323
                    if (i == 0) {
1324
                        focusField = field;
1325
                    }
1326
                    fields[i++] = oEmail[x][1];
1327
                    bValid = false;
1328
                }
1329
            }
1330
        }
1331
        if (fields.length > 0) {
1332
            focusField.focus();
1333
            alert(fields.join('\n'));
1334
        }
1335
        return bValid;
1336
    }
1337

    
1338
    /**
1339
     * Reference: Sandeep V. Tamhankar (stamhankar@hotmail.com),
1340
     * http://javascript.internet.com
1341
     */
1342
    function checkEmail(emailStr) {
1343
       if (emailStr.length == 0) {
1344
           return true;
1345
       }
1346
       var emailPat=/^(.+)@(.+)$/;
1347
       var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]";
1348
       var validChars="\[^\\s" + specialChars + "\]";
1349
       var quotedUser="(\"[^\"]*\")";
1350
       var ipDomainPat=/^(\d{1,3})[.](\d{1,3})[.](\d{1,3})[.](\d{1,3})$/;
1351
       var atom=validChars + '+';
1352
       var word="(" + atom + "|" + quotedUser + ")";
1353
       var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
1354
       var domainPat=new RegExp("^" + atom + "(\\." + atom + ")*$");
1355
       var matchArray=emailStr.match(emailPat);
1356
       if (matchArray == null) {
1357
           return false;
1358
       }
1359
       var user=matchArray[1];
1360
       var domain=matchArray[2];
1361
       if (user.match(userPat) == null) {
1362
           return false;
1363
       }
1364
       var IPArray = domain.match(ipDomainPat);
1365
       if (IPArray != null) {
1366
           for (var i = 1; i <= 4; i++) {
1367
              if (IPArray[i] > 255) {
1368
                 return false;
1369
              }
1370
           }
1371
           return true;
1372
       }
1373
       var domainArray=domain.match(domainPat);
1374
       if (domainArray == null) {
1375
           return false;
1376
       }
1377
       var atomPat=new RegExp(atom,"g");
1378
       var domArr=domain.match(atomPat);
1379
       var len=domArr.length;
1380
       if ((domArr[domArr.length-1].length < 2) ||
1381
           (domArr[domArr.length-1].length > 3)) {
1382
           return false;
1383
       }
1384
       if (len < 2) {
1385
           return false;
1386
       }
1387
       return true;
1388
    }
1389

    
1390
  
1391
    /**
1392
    * Check to see if fields are a valid using a regular expression.
1393
    * Fields are not checked if they are disabled.
1394
    * <p>
1395
    * @param form The form validation is taking place on.
1396
    */
1397
    function validateMask(form) {
1398
        var isValid = true;
1399
        var focusField = null;
1400
        var i = 0;
1401
        var fields = new Array();
1402
        var formName = form.getAttributeNode("name"); 
1403

    
1404
        oMasked = eval('new ' + formName.value + '_mask()');      
1405
        for (x in oMasked) {
1406
            var field = form[oMasked[x][0]];
1407

    
1408
            if ((field.type == 'hidden' ||
1409
                field.type == 'text' ||
1410
                 field.type == 'textarea' ||
1411
                 field.type == 'file') &&
1412
                 (field.value.length > 0) &&
1413
                 field.disabled == false) {
1414

    
1415
                if (!matchPattern(field.value, oMasked[x][2]("mask"))) {
1416
                    if (i == 0) {
1417
                        focusField = field;
1418
                    }
1419
                    fields[i++] = oMasked[x][1];
1420
                    isValid = false;
1421
                }
1422
            }
1423
        }
1424

    
1425
        if (fields.length > 0) {
1426
           focusField.focus();
1427
           alert(fields.join('\n'));
1428
        }
1429
        return isValid;
1430
    }
1431

    
1432
    function matchPattern(value, mask) {
1433
       return mask.exec(value);
1434
    }
1435

    
1436

    
1437
    /**
1438
    * A field is considered valid if greater than the specified minimum.
1439
    * Fields are not checked if they are disabled.
1440
    * <p>
1441
    * <strong>Caution:</strong> Using <code>validateMinLength</code> on a password field in a 
1442
    *  login page gives unnecessary information away to hackers. While it only slightly
1443
    *  weakens security, we suggest using it only when modifying a password.</p>
1444
    * @param form The form validation is taking place on.
1445
    */
1446
    function validateMinLength(form) {
1447
        var isValid = true;
1448
        var focusField = null;
1449
        var i = 0;
1450
        var fields = new Array();
1451
        var formName = form.getAttributeNode("name");
1452

    
1453

    
1454
        oMinLength = eval('new ' + formName.value + '_minlength()');
1455

    
1456
        for (x in oMinLength) {
1457
            var field = form[oMinLength[x][0]];
1458

    
1459
            if ((field.type == 'hidden' ||
1460
                field.type == 'text' ||
1461
                field.type == 'password' ||
1462
                field.type == 'textarea') &&
1463
                field.disabled == false) {
1464

    
1465
                var iMin = parseInt(oMinLength[x][2]("minlength"));
1466
                if ((trim(field.value).length > 0) && (field.value.length < iMin)) {
1467
                    if (i == 0) {
1468
                        focusField = field;
1469
                    }
1470
                    fields[i++] = oMinLength[x][1];
1471
                    isValid = false;
1472
                }
1473
            }
1474
        }
1475
        if (fields.length > 0) {
1476
           focusField.focus();
1477
           alert(fields.join('\n'));
1478
        }
1479
        return isValid;
1480
    }
1481

    
1482
    //End  JavaScript input validation checking code. --> 
1483
    </script>
1484
            </td>
1485
          </tr>
1486
          <tr> 
1487
            <td width="375">&nbsp;</td>
1488
            <td width="365">&nbsp;</td>
1489
          </tr>
1490
        </table>
1491
      </td>
1492
    </tr>
1493
  </table>
1494
</body>
1495
<!-- ************************* END SEARCHBOX TABLE ************************* -->
(3-3/25)