Subversion Repositories DevTools

Rev

Go to most recent revision | 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 confirmDelete(m)
395
{
129 ghuddy 396
   var agree=confirm('Are you sure you want to delete '+m+'?');
397
   if (agree) {
3959 dpurdie 398
      MM_showProgressBar();
129 ghuddy 399
      return true;
400
   } else {
401
      return false;
402
   }
119 ghuddy 403
}
404
 
405
function confirmAction(m)
406
{
129 ghuddy 407
   var agree=confirm(m);
408
   if (agree) {
3959 dpurdie 409
      MM_showProgressBar();
129 ghuddy 410
      return true;
411
   } else {
412
      return false;
413
   }
119 ghuddy 414
}
415
 
416
function DisplaySPAN(show) {
129 ghuddy 417
   if (show) {
418
      MM_findObj("spanHideDetails").style.display = "block";
419
      MM_findObj("spanPkgInfo").style.display = "block";
420
      MM_findObj("spanShowDetails").style.display = "none";
421
   } else {
422
      MM_findObj("spanHideDetails").style.display = "none";
423
      MM_findObj("spanPkgInfo").style.display = "none";
424
      MM_findObj("spanShowDetails").style.display = "block";
425
   }
119 ghuddy 426
}
427
 
428
function ToggleDisplay () {
4388 dpurdie 429
   var i, args, div_name, el
129 ghuddy 430
   args=ToggleDisplay.arguments;
431
   for (i=0; i<(args.length); i+=1) {
432
      div_name=args[i];
4388 dpurdie 433
      el = MM_findObj(div_name);
434
      if (el) { 
435
        if ( el.style.display == 'block' ) {
436
           el.style.display = 'none';
437
        } else {
438
           el.style.display = 'block';
439
        }
440
     }
129 ghuddy 441
   }
119 ghuddy 442
}
443
 
444
function Visible () {
121 hknight 445
 
129 ghuddy 446
   var i, args, div_name, visibility
447
   args=Visible.arguments;
448
   for (i=0; i<(args.length); i+=2) {
449
      div_name=args[i];
450
      visibility=args[i+1]
451
      MM_findObj(div_name).style.display = visibility;
121 hknight 452
 
129 ghuddy 453
   }
119 ghuddy 454
}
455
 
456
function DisplayObjects () {
129 ghuddy 457
   var i, args, div_name
458
   args=DisplayObjects.arguments;
459
   for (i=0; i<(args.length); i+=1) {
460
      div_name=args[i];
461
      MM_findObj(div_name).style.display = 'block';
462
   }
119 ghuddy 463
}
464
 
121 hknight 465
function GetCookieVal (offset) {
129 ghuddy 466
   var endstr = document.cookie.indexOf (";", offset);
467
   if (endstr == -1) { endstr = document.cookie.length; }
468
   return unescape(document.cookie.substring(offset, endstr));
119 ghuddy 469
}
470
 
471
 
121 hknight 472
function GetCookie (name) {
129 ghuddy 473
   var arg = name + "=";
474
   var alen = arg.length;
475
   var clen = document.cookie.length;
476
   var i = 0;
119 ghuddy 477
 
129 ghuddy 478
   while (i < clen) {
479
      var j = i + alen;
480
      if (document.cookie.substring(i, j) == arg) return GetCookieVal (j);
481
      i = document.cookie.indexOf(" ", i) + 1;
482
      if (i == 0) break;
483
   }
119 ghuddy 484
 
129 ghuddy 485
   return null;
119 ghuddy 486
}
487
 
488
function go_submit( formname, actionname )
489
{
129 ghuddy 490
   formname.action.value = actionname;
491
   formname.submit();
119 ghuddy 492
}
493
 
494
function ExpandAll()
495
{
129 ghuddy 496
   var elem
121 hknight 497
 
129 ghuddy 498
   if (document.all)
499
   {
500
      // Run this for IE
501
      elem = document.all;
502
   } else {
503
      // Run this for other browsers
504
      elem = document.getElementsByTagName('div');
505
   }
121 hknight 506
 
129 ghuddy 507
   for (i in elem)
508
   {
509
      if (elem[i].id)
510
      {
511
         if (elem[i].id.indexOf('SHORT_') == 0) elem[i].style.display = 'none';
512
         if (elem[i].id.indexOf('FULL_') == 0) elem[i].style.display = 'block';
513
      }
514
   }
121 hknight 515
 
119 ghuddy 516
}
517
 
518
function CollapseAll()
519
{
129 ghuddy 520
   var elem
121 hknight 521
 
129 ghuddy 522
   if (document.all)
523
   {
524
      // Run this for IE
525
      elem = document.all;
526
   } else {
527
      // Run this for other browsers
528
      elem = document.getElementsByTagName('div');
529
   }
121 hknight 530
 
129 ghuddy 531
   for (i in elem)
532
   {
533
      if (elem[i].id)
534
      {
535
         if (elem[i].id.indexOf('SHORT_') == 0) elem[i].style.display = 'block';
536
         if (elem[i].id.indexOf('FULL_') == 0) elem[i].style.display = 'none';
537
      }
538
   }
121 hknight 539
 
119 ghuddy 540
}
541
 
542
 
543
function height()
121 hknight 544
{
129 ghuddy 545
   if( typeof( window.innerWidth ) == 'number' )
546
   {
547
      h = window.innerHeight;
548
   }
549
   else if(document.documentElement&&(document.documentElement.clientHeight ))
550
   {
551
      h = document.documentElement.clientHeight;
552
   }
553
   else if( document.body &&   ( document.body.clientWidth || document.body.clientHeight ) )
554
   {
555
      h = document.body.clientHeight;
556
   }
121 hknight 557
 
129 ghuddy 558
   var e = document.getElementById("LayerDescription");
121 hknight 559
 
129 ghuddy 560
   if (navigator.userAgent.indexOf('Internet Explorer'))
561
   {
562
      e.style.height = h - 350 + "px";
563
      e.style.overflow = "auto";
564
   }
565
   else
566
   {
567
      // This line shouldn't be run by IE; it doesn't seem to work. It gets run in Firefox, etc.
568
      e.style.minHeight= h - 350 + "px";
569
      e.style.overflow = "auto";
570
   }
119 ghuddy 571
}
572
 
121 hknight 573
//////////////////////////////////////////////////////////////////////////////////////////////////
574
//
3959 dpurdie 575
// MM_ValidateVersion(versionBase, versionExt, isAutobuild isPatch)
576
// Should NOT be used externally. Use MM_validateForm to access this function
121 hknight 577
//
578
//    versionBase   eg 1.2.3
3959 dpurdie 579
//    versionExt    eg .cr
121 hknight 580
//    isAutobuild   true or false
133 ghuddy 581
//    isPatch       true or false
121 hknight 582
//
583
// Returns a non-zero-length error string if version is NOT valid, else returns a zero-length string
584
//
585
//////////////////////////////////////////////////////////////////////////////////////////////////
3959 dpurdie 586
function MM_ValidateVersion(versionBase, versionExt, isAutobuild, isPatch)
121 hknight 587
{
133 ghuddy 588
   var re_std_ver_format   = /^\d+\.\d+\.\d+$/;
589
   var re_patch_ver_format = /^\d+\.\d+\.\d+\.p\d+$/;
590
   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 591
   var re_cots_ver_format_exc1 = /[-_.]+[-_.]+/;   // look for any two adjacent special characters
592
   var re_cots_ver_format_exc2 = /[0-9A-Za-z]+/;   // look for any alphanumeric char
3959 dpurdie 593
   var isCots = versionExt == ".cots" || versionExt == ".tool";
121 hknight 594
 
3959 dpurdie 595
   if (!isAutobuild) {
596
      if ( versionBase.length == 0 ) {
597
         return " is of zero length";
598
      } else if ( !isCots) {
599
         if ( isPatch ) {
600
            if ( !re_patch_ver_format.test(versionBase) ) {
601
               return " is not of form (integer).(integer).(integer).p(integer)";
133 ghuddy 602
            }
3959 dpurdie 603
         } else {
604
            if ( !re_std_ver_format.test(versionBase) ) {
605
               return " is not of form (integer).(integer).(integer)";
133 ghuddy 606
            }
607
         }
3959 dpurdie 608
      } else if (isCots) {
609
         var extName = versionExt.toUpperCase().substr(1);
610
 
611
         if ( !re_cots_ver_format.test(versionBase) ) {
612
            return " " + extName + " package must begin with letter/digit/underscore, cannot contain any whitespace, and only special characters underscore/dash/dot are allowed";
129 ghuddy 613
         }
121 hknight 614
 
3959 dpurdie 615
         if ( re_cots_ver_format_exc1.test(versionBase) ) {
616
            return " " + extName + " package cannot contain two adjacent special characters (underscore/dash/dot)";
129 ghuddy 617
         }
121 hknight 618
 
3959 dpurdie 619
         if ( !re_cots_ver_format_exc2.test(versionBase) ) {
620
            return " " + extName + " package must contain one or more alphanumeric characters";
129 ghuddy 621
         }
622
      }
623
   }
121 hknight 624
 
129 ghuddy 625
   // everything ok - no error
626
   return "";
121 hknight 627
}
628
 
629
 
3959 dpurdie 630
// Manipulate the class list for a given element
631
function hasClass(ele, cls) {
632
    return ele.className.match(new RegExp('(\\s|^)' + cls + '(\\s|$)'));
633
}
121 hknight 634
 
3959 dpurdie 635
function addClass(ele, cls) {
636
    if (!this.hasClass(ele, cls)) ele.className += " " + cls;
637
}
638
 
639
function removeClass(ele, cls) {
640
    if (hasClass(ele, cls)) {
641
        var reg = new RegExp('(\\s|^)' + cls + '(\\s|$)');
642
        ele.className = ele.className.replace(reg, ' ');
643
    }
644
}
645
 
646
function toggleClass(ele, cls1, cls2){
647
    if(hasClass(ele, cls1)){
648
        replaceClass(ele, cls1, cls2);
649
    }else if(hasClass(ele, cls2)){
650
        replaceClass(ele, cls2, cls1);
651
    }else{
652
        addClass(ele, cls1);
653
    }
654
}
655
 
656
// Highlight combobox if selection is zero
657
// Returns true:  None-zero selection
658
// Returns false: Invalid element or item-0 selected
659
function checkSeletion(el)
660
{
661
   if (el ) {
662
     if ( el.selectedIndex == 0) {
663
        addClass(el, 'form_error');
664
     } else {
665
        removeClass(el, 'form_error');
666
        return true;
667
     }
668
   }
669
   return false;
670
}
671
 
672
function getElementsByClassName(classname, node)  {
673
    if(!node) node = document.getElementsByTagName("body")[0];
674
    var a = [];
675
    var re = new RegExp('\\b' + classname + '\\b');
676
    var els = node.getElementsByTagName("*");
677
    for(var i=0,j=els.length; i<j; i++)
678
        if(re.test(els[i].className))a.push(els[i]);
679
    return a;
680
}
681
 
682
function setCookie(c_name,value,exdays)
683
{
684
  var exdate=new Date();
685
  exdate.setDate(exdate.getDate() + exdays);
686
  var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
687
  document.cookie=c_name + "=" + c_value;
688
}
689
 
690
function getCookie(c_name)
691
{
692
  var c_value = document.cookie;
693
  var c_start = c_value.indexOf(" " + c_name + "=");
694
  if (c_start == -1)
695
  {
696
    c_start = c_value.indexOf(c_name + "=");
697
  }
698
  if (c_start == -1)
699
  {
700
    c_value = null;
701
  }
702
  else
703
  {
704
    c_start = c_value.indexOf("=", c_start) + 1;
705
    var c_end = c_value.indexOf(";", c_start);
706
    if (c_end == -1)
707
    {
708
      c_end = c_value.length;
709
    }
710
  c_value = unescape(c_value.substring(c_start,c_end));
711
}
712
return c_value;
713
}
714
 
119 ghuddy 715
//-->