Subversion Repositories DevTools

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
119 ghuddy 1
/*
129 ghuddy 2
 *    COMMON JAVASCRIPTS
119 ghuddy 3
 */
4
 
5
<!--
6
var clickedButton = false;
7
function check() {
129 ghuddy 8
   if (clickedButton) {
9
       clickedButton = false;
119 ghuddy 10
        return true;
11
    } else {
129 ghuddy 12
       return false;
13
   }
119 ghuddy 14
}
15
 
16
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
17
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
18
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
19
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
20
}
21
MM_reloadPage(true);
22
 
23
function MM_preloadImages() { //v3.0
24
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
25
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
26
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
27
}
28
 
29
function MM_swapImgRestore() { //v3.0
30
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
31
}
32
 
33
function MM_findObj(n, d) { //v4.0
121 hknight 34
  var p,i,x;
35
  if(!d) d=document;
119 ghuddy 36
  if((p=n.indexOf("?"))>0&&parent.frames.length) {
129 ghuddy 37
     d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
119 ghuddy 38
  }
121 hknight 39
  if(!(x=d[n])&&d.all) x=d.all[n];
119 ghuddy 40
  for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
41
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
121 hknight 42
  if(!x && document.getElementById) x=document.getElementById(n);
119 ghuddy 43
  return x;
44
}
45
 
46
function MM_swapImage() { //v3.0
47
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
48
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
49
}
50
 
51
function MM_openBrWindow(theURL,winName,features) { //v2.0
2735 dpurdie 52
  window.open(theURL,winName,'left=20,top=20,'+features);
119 ghuddy 53
}
54
 
55
function MM_jumpMenu(targ,selObj,restore){ //v3.1
56
  if (selObj.options[selObj.selectedIndex].value) {
129 ghuddy 57
     eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
58
     if (restore) selObj.selectedIndex=0;
119 ghuddy 59
  }
60
}
61
 
62
function Cascaded_Menu(targ,url,selObj,restore){ //v3.1
63
  if (selObj.options[selObj.selectedIndex].value) {
129 ghuddy 64
     eval(targ+".location='"+url+selObj.options[selObj.selectedIndex].value+"'");
65
     if (restore) selObj.selectedIndex=0;
119 ghuddy 66
  }
67
}
68
 
3959 dpurdie 69
//
70
//  Validate Forms
71
//  Arguments:
72
//    --Silent          - Optional. Supresses alert
73
//    Triplets          - Zero or more triplets.
74
//                        Eg: 'FRpkgName','Package Name','RisPackage'
75
//      FormObject      - Form Object ID
76
//      TextPrefix      - Error message Prefix
77
//      TestType        - Type of test to perfom.
78
//                        First letter may be R - Required.
79
//
80
function MM_validateForm() {
1376 dpurdie 81
   var ii,p,pl,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
129 ghuddy 82
   var REresults;
83
   var pass,passc;
3959 dpurdie 84
   var showAlert = true;
121 hknight 85
 
129 ghuddy 86
   // Other general validations
87
   var cleanStrRE = /^[0-9a-z_\.\(\)\-]+$/i;
88
   var pkgRE = /^[a-z][a-z0-9_-]*[a-z0-9]$/i;
89
   var versionRE = /^[0-9a-z_\.\(\)\-]+$/i;
145 ghuddy 90
   var re_patch_ver_format = /^\d+\.\d+\.\d+\.p\d+\.[a-zA-Z0-9]+$/;
129 ghuddy 91
   var urlRE = "^https?://[a-z1-9]";
92
   //character range disallowed
93
   var HTMLchr = /[\<\>\'\"]+/i;
171 brianf 94
   var alphanumRE = /^[a-z0-9]+$/i;
121 hknight 95
 
3959 dpurdie 96
   // Options are first
97
   for (ii=0; ii<(args.length-2) && typeof(args[ii]) === 'string' && args[ii].indexOf('--') == 0; ii++) {
98
    switch(args[ii].toLowerCase()) {
99
      case "--silent" :
100
        showAlert = false;
101
        break;
102
    }
103
  }
104
 
105
  // Iterate over arguments
106
  // These are in triplets
107
  //    Name of form object - Value is extracted for user as 'val'
108
  //    Text Prefix for error - 'nm'
109
  //    Type of Test to Perform -'test'
110
   for (; ii<(args.length-2); ii+=3) {
111
      nm=args[ii+1];
1376 dpurdie 112
      test=args[ii+2];
3959 dpurdie 113
      if ( typeof(args[ii]) === 'string' ) {
114
        val=MM_findObj(args[ii]);
115
        if (val) {
116
           val=val.value;
121 hknight 117
 
3959 dpurdie 118
           if (val!="") {
119
              if (test.indexOf('isEmail')!=-1) {
120
                 p=val.indexOf('@');
121
                 if (p<1 || p==(val.length-1) || test.charAt(0) == '@') errors+='- '+nm+' must contain an e-mail address.\n';
122
              }
121 hknight 123
 
3959 dpurdie 124
              if (test.indexOf('isDate') != -1) {
125
                 if (val.indexOf("/") != -1) {
126
                    tmpARR = val.split("/");
127
                    if (tmpARR.length == 3) {
128
                       if (!(tmpARR[0]>0  && tmpARR[0]<32  && tmpARR[1]>0 && tmpARR[1]<13 && tmpARR[2]>1900 && tmpARR[2]<9999)) {
129
                          errors += '- '+nm+' must be in DD/MM/YYYY format.\n';
130
                       }
131
                    } else {
132
                       errors += '- '+nm+' must be in DD/MM/YYYY format.\n';
133
                    }
134
                 } else {
135
                    errors += '- '+nm+' must be in DD/MM/YYYY format.\n';
136
                 }
137
              }
121 hknight 138
 
3959 dpurdie 139
              if (test.indexOf('isPackage')!=-1) {
140
                 REresults = val.search(pkgRE);
141
                 if (REresults < 0) errors += val + ' - '+nm+' is not valid. Valid characters are A-Z a-z 0-9 - _\n'
142
                          + 'Names must start with a letter and cannot contain spaces or symbols other than - and _\n';
143
              }
121 hknight 144
 
3959 dpurdie 145
              if (test.indexOf('isCleanStr')!=-1) {
146
                 REresults = val.search(cleanStrRE);
147
                 if (REresults < 0) errors += val + '- '+nm+' uses invalid character. Allowed characters are A-Z a-z 0-9 . - _\n';
148
              }
121 hknight 149
 
3959 dpurdie 150
              if (test.indexOf('isVersionStr')!=-1) {
151
                 REresults = val.search(versionRE);
152
                 if (REresults < 0) errors += val + '- '+nm+' uses invalid character. Allowed characters are A-Z a-z 0-9 . - _\n';
153
              }
121 hknight 154
 
3959 dpurdie 155
              if (test.indexOf('isPatchVersionStr')!=-1) {
156
                 if ( !re_patch_ver_format.test(val) ) {
157
                    errors += val + '- '+nm+' is not of form (integer).(integer).(integer).p(integer).(extension)\n';
158
                 }
159
              }
121 hknight 160
 
3959 dpurdie 161
              if (test.indexOf('isCCPath')!=-1) {
162
                 var CCPathRE = /^\\|\/[a-z]+[0-9a-z_\.\-\\\/ ]+$/i;
121 hknight 163
 
3959 dpurdie 164
                 REresults = val.search(/^(\\|\/)/);
165
                 if (REresults < 0) errors += val + '- '+nm+' must begin with \\ or /\n';
2365 dpurdie 166
 
3959 dpurdie 167
                 REresults = val.search(CCPathRE);
168
                 if (REresults < 0) errors += val + '- '+nm+' uses invalid character.\nAllowed characters are \\ / A-Z a-z 0-9 . - _ SPACE\n';
169
              }
121 hknight 170
 
3959 dpurdie 171
              if (test.indexOf('isCCLabel')!=-1) {
172
                 var CCLabelRE = /^[0-9a-z_\.\-]+$/i;
121 hknight 173
 
3959 dpurdie 174
                 REresults = val.search(CCLabelRE);
175
                 if (REresults < 0) errors += val + '- '+nm+' uses invalid character.\nAllowed characters are A-Z a-z 0-9 . - _\n';
176
              }
121 hknight 177
 
3959 dpurdie 178
              if (test.indexOf('isSVNTag')!=-1) {
179
                  // Subversion Tag validation
180
                  var SVNTagValidPeg = /^@?\d+$/;
181
                  var SVNTagRE = /^[0-9a-z_\.\-]+$/i;
1376 dpurdie 182
 
3959 dpurdie 183
                 if ( val.search(SVNTagValidPeg) < 0) {
1376 dpurdie 184
 
3959 dpurdie 185
                      var stripped;
186
                      stripped = val.replace (/@\d+$/,"");
187
                      if (stripped.search(SVNTagRE) < 0)
188
                          errors += val + '- '+nm+' uses invalid character. Allowed characters are A-Z a-z 0-9 . - _\n';
189
                 }
190
              }
1376 dpurdie 191
 
3959 dpurdie 192
              if (test.indexOf('isSVNPegTag')!=-1 && ! errors) {
193
                  // Subversion Tag has peg - Must have done valid check first
194
                  var SVNTagPegged = /@?\d+$/;
1376 dpurdie 195
 
3959 dpurdie 196
                  if ( val.search(SVNTagPegged) < 0) {
197
                      errors += val + '- '+nm+' Must be pegged for Manually Versioned Package. ie:tag@pegNumber\n';
198
                 }
199
              }
1376 dpurdie 200
 
3959 dpurdie 201
              if (test.indexOf('isSVNPath')!=-1) {
202
                 // Subversion Base Path validation
203
                 var SVNTagValidCharsRE = /^[0-9a-z_\.\-\/]+$/i;
204
                 var SVNTagInValidSlashAtBOL = /^\/.*$/i;
205
                 var SVNTagInValidSlashAtEOL = /\/$/i;
206
                 var SVNTagInValidSlash = /^.*\/\/.*$/i;
207
                 var SVNTagInValidTrunkAnywhereRE = /\/trunk\//i;
208
                 var SVNTagValidTagAnywhereRE = /^.*\/tags\/.*$/i;
4525 dpurdie 209
                 var SVNTagValidTagBranchPathRE = /^.*\/branches\/.*\/.*$/i;
121 hknight 210
 
3959 dpurdie 211
                 if (val.search(SVNTagValidCharsRE) < 0)
212
                    errors += val + ' - '+nm+' uses invalid character. Allowed characters are / A-Z a-z 0-9 . - _\n';
213
                 else if (val.search(SVNTagInValidSlashAtBOL) >= 0)
214
                    errors += val + ' - '+nm+' begins with a /. This is not allowed.\n';
215
                 else if (val.search(SVNTagInValidSlashAtEOL) >= 0)
216
                    errors += val + ' - '+nm+' ends with a /. This is not allowed.\n';
217
                 else if (val.search(SVNTagInValidSlash) >= 0)
218
                    errors += val + ' - '+nm+' uses //. This is not allowed.\n';
219
                 else if (val.search(SVNTagValidTagAnywhereRE) >= 0)
220
                       errors += val + ' - '+nm+' contains /tags/. This is not allowed.\n';
221
                 else if (val.search(SVNTagInValidTrunkAnywhereRE) >= 0)
222
                       errors += val + ' - '+nm+' contains /trunk/. This is not allowed.\n';
4525 dpurdie 223
                 else if (val.search(SVNTagValidTagBranchPathRE) >= 0)
224
                       errors += val + ' - '+nm+' contains branch with multiple sub directories. This is not allowed.\n';
3959 dpurdie 225
                 else {
226
                          var bits = val.split("/");
227
                          if ( bits.length < 4 )
228
                              errors += val + ' - Must contain at least 4 path items.\n';
1376 dpurdie 229
 
3959 dpurdie 230
                          var ttbcount = 0;
231
                          var i
232
                          for (i=0; i < bits.length; i++ )
233
                          {
234
                              var el = bits[i];
235
                              if ( el == 'tags') ttbcount++;
236
                              if ( el == 'trunk') ttbcount++;
237
                              if ( el == 'branches') ttbcount++;
238
                          }
239
                          if ( ttbcount != 1 )
240
                              errors += val + ' - '+nm+' must contain exactly one of tags, trunk or branches. It contains '+ttbcount+'.\n';
1376 dpurdie 241
 
3959 dpurdie 242
                          if ( bits.pop() == 'branches' )    
243
                              errors += val + ' - '+nm+' must not end in branches.\n';
1376 dpurdie 244
 
3959 dpurdie 245
                       }
246
              }
129 ghuddy 247
 
3959 dpurdie 248
              // No longer used in this simple form
249
              if (test.indexOf('isVersionNumber')!=-1) {
250
                 REresults = -1;
251
                 if (REresults < 0) errors += val + ' - '+nm+' isVersionNumber is no longer supported in this form';
252
              }
129 ghuddy 253
 
3959 dpurdie 254
              if (test.indexOf('isURL')!=-1) {
255
                 REresults = val.match(urlRE);
256
                 if (REresults == null) errors += '"'+val+'" is not a valid URL.\n';
257
              }
129 ghuddy 258
 
3959 dpurdie 259
              if (test.indexOf('isAlphaNum')!=-1) {
260
                 REresults = val.match(alphanumRE);
261
                 if (REresults == null) errors += '"'+nm+'" must be an alphanumeric value.\n';
262
              }
171 brianf 263
 
3959 dpurdie 264
              if (test.indexOf('isChangePassword')!=-1) {
265
                 pass=MM_findObj('FRpassword');
266
                 passc=MM_findObj('FRpasswordc');
267
                 if (pass.value!=passc.value) errors+='- Password confirmation does not match.\n';
268
              }
129 ghuddy 269
 
3959 dpurdie 270
              if (test.indexOf('maxLength')!=-1) {
271
                 p=test.indexOf(':');
272
                 max=test.substring(p+1);
273
                 if (val.length>max) errors+='- '+nm+' can be maximum '+max+' characters long.\n';
274
              }
129 ghuddy 275
 
4025 dpurdie 276
              if (test.indexOf('minLength')!=-1) {
277
                 p=test.indexOf(':');
278
                 max=test.substring(p+1);
279
                 if (val.length<max) errors+='- '+nm+' must be minimum '+max+' characters long.\n';
280
              }
281
 
3959 dpurdie 282
              if (test.indexOf('notHTML')!=-1) {
283
                 if (val.match(HTMLchr)) errors+='- '+nm+' has invalid characters like \'< > quotes\'\n';
284
              }
129 ghuddy 285
 
3959 dpurdie 286
              if (test.charAt(0)=='R') {
129 ghuddy 287
 
3959 dpurdie 288
                 if (test.indexOf('isNumber') != -1) {
289
                    if (isNaN(val)) errors+='- '+nm+' must be a number.\n';
290
                 }
129 ghuddy 291
 
3959 dpurdie 292
                 if (test.indexOf('inRange') != -1) {
293
                    p=test.indexOf(':');
294
                    min=test.substring(8,p);
295
                    max=test.substring(p+1);
296
                    if (val<min || max<val) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
297
                 }
129 ghuddy 298
 
3959 dpurdie 299
                 if (test.indexOf('inLength')!=-1) {
300
                     pl=test.indexOf('inLength')
301
                    p=test.indexOf(':');
302
                        min=test.substring(pl+8,p);
303
                        if (val.length<min) errors+='- '+nm+' must be at least '+min+' characters long.\n';
304
                  }
305
              }
306
           } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n';
129 ghuddy 307
 
308
 
3959 dpurdie 309
           if (test.indexOf('isPassword')!=-1) {
310
              pass=MM_findObj('FRpassword');
311
              passc=MM_findObj('FRpasswordc');
312
              if (!MM_findObj('FRdomainauth').checked) {
313
                 if (test.indexOf('inLength')!=-1) {
314
                     pl=test.indexOf('inLength')
315
                    p=test.indexOf(':');
316
                        min=test.substring(pl+8,p);
317
                        if (val.length<min) errors+='- '+nm+' must be at least '+min+' characters long.\n';
318
                  }
319
                 if (pass.value!=passc.value) errors+='- Password confirmation does not match.\n';
320
              } else {
321
                 if (MM_findObj('FRdomain_name').value=="") errors += '- Domain Name is required.\n';
322
              }
323
           }
129 ghuddy 324
 
3959 dpurdie 325
           if (test.indexOf('isDomainName')!=-1) {
326
              if (MM_findObj('FRdomainauth').checked) {
327
                 if (MM_findObj('FRdomain_name').value=="") errors += '- Domain Name is required.\n';
328
              }
329
           }
330
        }
331
      }
332
      else {
333
        // Alternate form. First item is an object
334
        // Contents are test specific
335
        var valp = args[ii];
129 ghuddy 336
 
3959 dpurdie 337
          // Expects object with data to examine
338
        if (test.indexOf('isVersionNumber')!=-1) {
339
          var rv = MM_ValidateVersion(valp.vBase, valp.vExt, valp.isAuto || false, valp.isPatch || false);
340
          if ( rv )
341
            errors += '- ' +nm+rv;
342
        }
129 ghuddy 343
      }
344
   }
345
 
346
   if (errors) {
3959 dpurdie 347
      if ( showAlert )
348
        alert('The following error(s) occurred:\n\n'+errors);
129 ghuddy 349
      clickedButton=false;
350
   } else {
351
      clickedButton=true;
352
   }
353
   document.MM_returnValue = (errors == '');
3959 dpurdie 354
   document.MM_error = errors;
129 ghuddy 355
 
3959 dpurdie 356
  if (document.MM_returnValue && showAlert)
357
    MM_showProgressBar();
119 ghuddy 358
}
359
 
3959 dpurdie 360
function MM_showProgressBar() {
361
  var pb = MM_findObj('ProgressBar');
362
  if ( pb )
363
    pb.style.visibility='visible';
364
}
365
 
366
function MM_hideProgressBar() {
367
  var pb = MM_findObj('ProgressBar');
368
  if ( pb )
369
    pb.style.visibility='hidden';
370
}
371
 
119 ghuddy 372
function isChecked(boxName, buttonId) {
373
  var formButton = document.getElementById(buttonId);
374
  var boxes = document.getElementsByName(boxName);
375
  var btnChecked = false;
376
  if (formButton) {
377
    for (var i = 0; i < boxes.length; i++) {
378
      if (boxes[i].checked) {
379
        btnChecked = true;
380
      }
381
    }
121 hknight 382
 
119 ghuddy 383
    if (btnChecked) {
384
      formButton.disabled = false;
385
      formButton.style.color="";
386
    }
387
    else {
388
      formButton.disabled = true;
389
      formButton.style.color="silver";
390
    }
391
  }
392
}
393
 
394
function DisplaySPAN(show) {
129 ghuddy 395
   if (show) {
396
      MM_findObj("spanHideDetails").style.display = "block";
397
      MM_findObj("spanPkgInfo").style.display = "block";
398
      MM_findObj("spanShowDetails").style.display = "none";
399
   } else {
400
      MM_findObj("spanHideDetails").style.display = "none";
401
      MM_findObj("spanPkgInfo").style.display = "none";
402
      MM_findObj("spanShowDetails").style.display = "block";
403
   }
119 ghuddy 404
}
405
 
406
function ToggleDisplay () {
4388 dpurdie 407
   var i, args, div_name, el
129 ghuddy 408
   args=ToggleDisplay.arguments;
409
   for (i=0; i<(args.length); i+=1) {
410
      div_name=args[i];
4388 dpurdie 411
      el = MM_findObj(div_name);
412
      if (el) { 
413
        if ( el.style.display == 'block' ) {
414
           el.style.display = 'none';
415
        } else {
416
           el.style.display = 'block';
417
        }
418
     }
129 ghuddy 419
   }
119 ghuddy 420
}
421
 
422
function Visible () {
121 hknight 423
 
129 ghuddy 424
   var i, args, div_name, visibility
425
   args=Visible.arguments;
426
   for (i=0; i<(args.length); i+=2) {
427
      div_name=args[i];
428
      visibility=args[i+1]
429
      MM_findObj(div_name).style.display = visibility;
121 hknight 430
 
129 ghuddy 431
   }
119 ghuddy 432
}
433
 
434
function DisplayObjects () {
129 ghuddy 435
   var i, args, div_name
436
   args=DisplayObjects.arguments;
437
   for (i=0; i<(args.length); i+=1) {
438
      div_name=args[i];
439
      MM_findObj(div_name).style.display = 'block';
440
   }
119 ghuddy 441
}
442
 
121 hknight 443
function GetCookieVal (offset) {
129 ghuddy 444
   var endstr = document.cookie.indexOf (";", offset);
445
   if (endstr == -1) { endstr = document.cookie.length; }
446
   return unescape(document.cookie.substring(offset, endstr));
119 ghuddy 447
}
448
 
449
 
121 hknight 450
function GetCookie (name) {
129 ghuddy 451
   var arg = name + "=";
452
   var alen = arg.length;
453
   var clen = document.cookie.length;
454
   var i = 0;
119 ghuddy 455
 
129 ghuddy 456
   while (i < clen) {
457
      var j = i + alen;
458
      if (document.cookie.substring(i, j) == arg) return GetCookieVal (j);
459
      i = document.cookie.indexOf(" ", i) + 1;
460
      if (i == 0) break;
461
   }
119 ghuddy 462
 
129 ghuddy 463
   return null;
119 ghuddy 464
}
465
 
466
function go_submit( formname, actionname )
467
{
129 ghuddy 468
   formname.action.value = actionname;
469
   formname.submit();
119 ghuddy 470
}
471
 
472
function ExpandAll()
473
{
129 ghuddy 474
   var elem
121 hknight 475
 
129 ghuddy 476
   if (document.all)
477
   {
478
      // Run this for IE
479
      elem = document.all;
480
   } else {
481
      // Run this for other browsers
482
      elem = document.getElementsByTagName('div');
483
   }
121 hknight 484
 
129 ghuddy 485
   for (i in elem)
486
   {
487
      if (elem[i].id)
488
      {
489
         if (elem[i].id.indexOf('SHORT_') == 0) elem[i].style.display = 'none';
490
         if (elem[i].id.indexOf('FULL_') == 0) elem[i].style.display = 'block';
491
      }
492
   }
121 hknight 493
 
119 ghuddy 494
}
495
 
496
function CollapseAll()
497
{
129 ghuddy 498
   var elem
121 hknight 499
 
129 ghuddy 500
   if (document.all)
501
   {
502
      // Run this for IE
503
      elem = document.all;
504
   } else {
505
      // Run this for other browsers
506
      elem = document.getElementsByTagName('div');
507
   }
121 hknight 508
 
129 ghuddy 509
   for (i in elem)
510
   {
511
      if (elem[i].id)
512
      {
513
         if (elem[i].id.indexOf('SHORT_') == 0) elem[i].style.display = 'block';
514
         if (elem[i].id.indexOf('FULL_') == 0) elem[i].style.display = 'none';
515
      }
516
   }
121 hknight 517
 
119 ghuddy 518
}
519
 
520
 
521
function height()
121 hknight 522
{
129 ghuddy 523
   if( typeof( window.innerWidth ) == 'number' )
524
   {
525
      h = window.innerHeight;
526
   }
527
   else if(document.documentElement&&(document.documentElement.clientHeight ))
528
   {
529
      h = document.documentElement.clientHeight;
530
   }
531
   else if( document.body &&   ( document.body.clientWidth || document.body.clientHeight ) )
532
   {
533
      h = document.body.clientHeight;
534
   }
121 hknight 535
 
129 ghuddy 536
   var e = document.getElementById("LayerDescription");
121 hknight 537
 
129 ghuddy 538
   if (navigator.userAgent.indexOf('Internet Explorer'))
539
   {
540
      e.style.height = h - 350 + "px";
541
      e.style.overflow = "auto";
542
   }
543
   else
544
   {
545
      // This line shouldn't be run by IE; it doesn't seem to work. It gets run in Firefox, etc.
546
      e.style.minHeight= h - 350 + "px";
547
      e.style.overflow = "auto";
548
   }
119 ghuddy 549
}
550
 
121 hknight 551
//////////////////////////////////////////////////////////////////////////////////////////////////
552
//
3959 dpurdie 553
// MM_ValidateVersion(versionBase, versionExt, isAutobuild isPatch)
554
// Should NOT be used externally. Use MM_validateForm to access this function
121 hknight 555
//
556
//    versionBase   eg 1.2.3
3959 dpurdie 557
//    versionExt    eg .cr
121 hknight 558
//    isAutobuild   true or false
133 ghuddy 559
//    isPatch       true or false
121 hknight 560
//
561
// Returns a non-zero-length error string if version is NOT valid, else returns a zero-length string
562
//
563
//////////////////////////////////////////////////////////////////////////////////////////////////
3959 dpurdie 564
function MM_ValidateVersion(versionBase, versionExt, isAutobuild, isPatch)
121 hknight 565
{
133 ghuddy 566
   var re_std_ver_format   = /^\d+\.\d+\.\d+$/;
567
   var re_patch_ver_format = /^\d+\.\d+\.\d+\.p\d+$/;
568
   var re_cots_ver_format  = /^[\w]+[\w\.\-]*$/;   // starts with letter or digit or underscore, subsequent chars can be letters or digits or _ or . or -
129 ghuddy 569
   var re_cots_ver_format_exc1 = /[-_.]+[-_.]+/;   // look for any two adjacent special characters
570
   var re_cots_ver_format_exc2 = /[0-9A-Za-z]+/;   // look for any alphanumeric char
3959 dpurdie 571
   var isCots = versionExt == ".cots" || versionExt == ".tool";
121 hknight 572
 
3959 dpurdie 573
   if (!isAutobuild) {
574
      if ( versionBase.length == 0 ) {
575
         return " is of zero length";
576
      } else if ( !isCots) {
577
         if ( isPatch ) {
578
            if ( !re_patch_ver_format.test(versionBase) ) {
579
               return " is not of form (integer).(integer).(integer).p(integer)";
133 ghuddy 580
            }
3959 dpurdie 581
         } else {
582
            if ( !re_std_ver_format.test(versionBase) ) {
583
               return " is not of form (integer).(integer).(integer)";
133 ghuddy 584
            }
585
         }
3959 dpurdie 586
      } else if (isCots) {
587
         var extName = versionExt.toUpperCase().substr(1);
588
 
589
         if ( !re_cots_ver_format.test(versionBase) ) {
590
            return " " + extName + " package must begin with letter/digit/underscore, cannot contain any whitespace, and only special characters underscore/dash/dot are allowed";
129 ghuddy 591
         }
121 hknight 592
 
3959 dpurdie 593
         if ( re_cots_ver_format_exc1.test(versionBase) ) {
594
            return " " + extName + " package cannot contain two adjacent special characters (underscore/dash/dot)";
129 ghuddy 595
         }
121 hknight 596
 
3959 dpurdie 597
         if ( !re_cots_ver_format_exc2.test(versionBase) ) {
598
            return " " + extName + " package must contain one or more alphanumeric characters";
129 ghuddy 599
         }
600
      }
601
   }
121 hknight 602
 
129 ghuddy 603
   // everything ok - no error
604
   return "";
121 hknight 605
}
606
 
607
 
3959 dpurdie 608
// Manipulate the class list for a given element
609
function hasClass(ele, cls) {
610
    return ele.className.match(new RegExp('(\\s|^)' + cls + '(\\s|$)'));
611
}
121 hknight 612
 
3959 dpurdie 613
function addClass(ele, cls) {
614
    if (!this.hasClass(ele, cls)) ele.className += " " + cls;
615
}
616
 
617
function removeClass(ele, cls) {
618
    if (hasClass(ele, cls)) {
619
        var reg = new RegExp('(\\s|^)' + cls + '(\\s|$)');
620
        ele.className = ele.className.replace(reg, ' ');
621
    }
622
}
623
 
624
function toggleClass(ele, cls1, cls2){
625
    if(hasClass(ele, cls1)){
626
        replaceClass(ele, cls1, cls2);
627
    }else if(hasClass(ele, cls2)){
628
        replaceClass(ele, cls2, cls1);
629
    }else{
630
        addClass(ele, cls1);
631
    }
632
}
633
 
634
// Highlight combobox if selection is zero
635
// Returns true:  None-zero selection
636
// Returns false: Invalid element or item-0 selected
637
function checkSeletion(el)
638
{
639
   if (el ) {
640
     if ( el.selectedIndex == 0) {
641
        addClass(el, 'form_error');
642
     } else {
643
        removeClass(el, 'form_error');
644
        return true;
645
     }
646
   }
647
   return false;
648
}
649
 
650
function getElementsByClassName(classname, node)  {
651
    if(!node) node = document.getElementsByTagName("body")[0];
652
    var a = [];
653
    var re = new RegExp('\\b' + classname + '\\b');
654
    var els = node.getElementsByTagName("*");
655
    for(var i=0,j=els.length; i<j; i++)
656
        if(re.test(els[i].className))a.push(els[i]);
657
    return a;
658
}
659
 
660
function setCookie(c_name,value,exdays)
661
{
662
  var exdate=new Date();
663
  exdate.setDate(exdate.getDate() + exdays);
664
  var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
665
  document.cookie=c_name + "=" + c_value;
666
}
667
 
668
function getCookie(c_name)
669
{
670
  var c_value = document.cookie;
671
  var c_start = c_value.indexOf(" " + c_name + "=");
672
  if (c_start == -1)
673
  {
674
    c_start = c_value.indexOf(c_name + "=");
675
  }
676
  if (c_start == -1)
677
  {
678
    c_value = null;
679
  }
680
  else
681
  {
682
    c_start = c_value.indexOf("=", c_start) + 1;
683
    var c_end = c_value.indexOf(";", c_start);
684
    if (c_end == -1)
685
    {
686
      c_end = c_value.length;
687
    }
688
  c_value = unescape(c_value.substring(c_start,c_end));
689
}
690
return c_value;
691
}
692
 
119 ghuddy 693
//-->