Subversion Repositories DevTools

Rev

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