Subversion Repositories DevTools

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
119 ghuddy 1
/*
2
 *	 COMMON JAVASCRIPTS
3
 */
4
 
5
<!--
6
var clickedButton = false;
7
function check() {
8
	if (clickedButton) {
9
    	clickedButton = false;
10
        return true;
11
    } else {
12
    	return false;
13
	}
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
34
  var p,i,x;  
35
  if(!d) d=document; 
36
  if((p=n.indexOf("?"))>0&&parent.frames.length) {
37
  	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
38
  }
39
  if(!(x=d[n])&&d.all) x=d.all[n]; 
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);
42
  if(!x && document.getElementById) x=document.getElementById(n); 
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
52
  window.open(theURL,winName,features);
53
}
54
 
55
function MM_jumpMenu(targ,selObj,restore){ //v3.1
56
  if (selObj.options[selObj.selectedIndex].value) {
57
	  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
58
	  if (restore) selObj.selectedIndex=0;
59
  }
60
}
61
 
62
function Cascaded_Menu(targ,url,selObj,restore){ //v3.1
63
  if (selObj.options[selObj.selectedIndex].value) {
64
	  eval(targ+".location='"+url+selObj.options[selObj.selectedIndex].value+"'");
65
	  if (restore) selObj.selectedIndex=0;
66
  }
67
}
68
 
69
function MM_validateForm() { //v5.0
70
	var i,p,pl,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
71
	var REresults,HTMLchr,urlRE,pkgRE,versionRE,cleanStrRE;
72
	var pass,passc;
73
	//character range allowed
74
	cleanStrRE = /^[0-9a-z_\.\(\)\-]+$/i;
75
	pkgRE = /^[a-z][a-z0-9_-]*[a-z0-9]$/i;
76
	versionRE = /^[0-9a-z_\.\(\)\-]+$/i;
77
	urlRE = "^https?://[a-z1-9]";
78
	//character range disallowed
79
	HTMLchr = /[\<\>\'\"]+/i;
80
 
81
 
82
	for (i=0; i<(args.length-2); i+=3) { 
83
		test=args[i+2]; 
84
		val=MM_findObj(args[i]);
85
 
86
		if (val) { 
87
			nm=args[i+1];
88
			val=val.value;
89
 
90
 
91
 
92
			if (val!="") {
93
				if (test.indexOf('isEmail')!=-1) { 
94
					p=val.indexOf('@');
95
					if (p<1 || p==(val.length-1) || test.charAt(0) == '@') errors+='- '+nm+' must contain an e-mail address.\n';
96
				} 
97
 
98
				if (test.indexOf('isDate') != -1) {
99
					if (val.indexOf("/") != -1) { 
100
						tmpARR = val.split("/");
101
						if (tmpARR.length == 3) {
102
							if (!(tmpARR[0]>0  && tmpARR[0]<32  && tmpARR[1]>0 && tmpARR[1]<13 && tmpARR[2]>1900 && tmpARR[2]<9999)) {
103
								errors += '- '+nm+' must be in DD/MM/YYYY format.\n';
104
							}
105
						} else {
106
							errors += '- '+nm+' must be in DD/MM/YYYY format.\n';
107
						}
108
					} else {
109
						errors += '- '+nm+' must be in DD/MM/YYYY format.\n';
110
					}
111
				}
112
 
113
				if (test.indexOf('isPackage')!=-1) {
114
					REresults = val.search(pkgRE);
115
					if (REresults < 0) errors += val += ' - '+nm+' is not valid. Valid characters are A-Z a-z 0-9 - _\n'
116
								+ 'Names must start with a letter and cannot contain spaces or symbols other than - and _\n';
117
				}
118
 
119
				if (test.indexOf('isCleanStr')!=-1) {
120
					REresults = val.search(cleanStrRE);
121
					if (REresults < 0) errors += val += '- '+nm+' uses invalid character. Allowed characters are A-Z a-z 0-9 . - _\n';
122
				}
123
 
124
				if (test.indexOf('isVersionStr')!=-1) {
125
					REresults = val.search(versionRE);
126
					if (REresults < 0) errors += val += '- '+nm+' uses invalid character. Allowed characters are A-Z a-z 0-9 . - _\n';
127
				}
128
 
129
				if (test.indexOf('isURL')!=-1) {
130
					REresults = val.match(urlRE);
131
					if (REresults == null) errors += '"'+val+'" is not a valid URL.\n';
132
				}
133
 
134
				if (test.indexOf('isChangePassword')!=-1) {
135
					pass=MM_findObj('FRpassword');
136
					passc=MM_findObj('FRpasswordc');
137
					if (pass.value!=passc.value) errors+='- Password confirmation does not match.\n';
138
				}
139
 
140
				if (test.indexOf('maxLength')!=-1) {
141
					p=test.indexOf(':');
142
					max=test.substring(p+1);
143
					if (val.length>max) errors+='- '+nm+' can be maximum '+max+' characters long.\n';
144
				}
145
 
146
				if (test.indexOf('notHTML')!=-1) {
147
					if (val.match(HTMLchr)) errors+='- '+nm+' has invalid characters like \'< > quotes\'\n';
148
				}
149
 
150
				if (test.charAt(0)=='R') {
151
 
152
					if (test.indexOf('isNumber') != -1) { 
153
						if (isNaN(val)) errors+='- '+nm+' must be a number.\n';
154
					}
155
 
156
					if (test.indexOf('inRange') != -1) { 
157
						p=test.indexOf(':');
158
						min=test.substring(8,p); 
159
						max=test.substring(p+1);
160
						if (val<min || max<val) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
161
					} 
162
 
163
					if (test.indexOf('inLength')!=-1) {
164
					    pl=test.indexOf('inLength')
165
						p=test.indexOf(':');
166
		          		min=test.substring(pl+8,p); 
167
		          		if (val.length<min) errors+='- '+nm+' must be at least '+min+' characters long.\n';
168
			    	}	
169
				} 
170
			} else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n';    
171
 
172
 
173
			if (test.indexOf('isPassword')!=-1) {
174
				pass=MM_findObj('FRpassword');
175
				passc=MM_findObj('FRpasswordc');
176
				if (!MM_findObj('FRdomainauth').checked) {
177
					if (test.indexOf('inLength')!=-1) {
178
					    pl=test.indexOf('inLength')
179
						p=test.indexOf(':');
180
		          		min=test.substring(pl+8,p); 
181
		          		if (val.length<min) errors+='- '+nm+' must be at least '+min+' characters long.\n';
182
			    	}	
183
					if (pass.value!=passc.value) errors+='- Password confirmation does not match.\n';
184
				} else {
185
					if (MM_findObj('FRdomain_name').value=="") errors += '- Domain Name is required.\n';   
186
				}
187
			} 
188
 
189
			if (test.indexOf('isDomainName')!=-1) {
190
				if (MM_findObj('FRdomainauth').checked) {
191
					if (MM_findObj('FRdomain_name').value=="") errors += '- Domain Name is required.\n';  
192
				}
193
			}
194
 
195
		}
196
	} 
197
 
198
	if (errors) {
199
		alert('The following error(s) occurred:\n\n'+errors);
200
		clickedButton=false;
201
	} else {
202
		clickedButton=true;
203
	}
204
	document.MM_returnValue = (errors == '');
205
 
206
	if (MM_findObj('ProgressBar') && document.MM_returnValue) MM_findObj('ProgressBar').style.visibility='visible';
207
}
208
 
209
function isChecked(boxName, buttonId) {
210
  var formButton = document.getElementById(buttonId);
211
  var boxes = document.getElementsByName(boxName);
212
  var btnChecked = false;
213
  if (formButton) {
214
    for (var i = 0; i < boxes.length; i++) {
215
      if (boxes[i].checked) {
216
        btnChecked = true;
217
      }
218
    }
219
 
220
    if (btnChecked) {
221
      formButton.disabled = false;
222
      formButton.style.color="";
223
    }
224
    else {
225
      formButton.disabled = true;
226
      formButton.style.color="silver";
227
    }
228
  }
229
}
230
 
231
function confirmDelete(m)
232
{
233
	var agree=confirm('Are you sure you want to delete '+m+'?');
234
	if (agree) {
235
		if (MM_findObj('ProgressBar')) MM_findObj('ProgressBar').style.visibility='visible';
236
		return true;
237
	} else {
238
		return false;
239
	}	
240
}
241
 
242
function confirmAction(m)
243
{
244
	var agree=confirm(m);
245
	if (agree) {
246
		if (MM_findObj('ProgressBar')) MM_findObj('ProgressBar').style.visibility='visible';
247
		return true;
248
	} else {
249
		return false;
250
	}	
251
}
252
 
253
function DisplaySPAN(show) {
254
	if (show) {
255
		MM_findObj("spanHideDetails").style.display = "block";
256
		MM_findObj("spanPkgInfo").style.display = "block";
257
		MM_findObj("spanShowDetails").style.display = "none";
258
	} else {
259
		MM_findObj("spanHideDetails").style.display = "none";
260
		MM_findObj("spanPkgInfo").style.display = "none";
261
		MM_findObj("spanShowDetails").style.display = "block";
262
	}
263
}
264
 
265
function ToggleDisplay () {
266
	var i, args, div_name, visibility
267
	args=ToggleDisplay.arguments;
268
	for (i=0; i<(args.length); i+=1) {
269
		div_name=args[i];
270
		if ( MM_findObj(div_name).style.display == 'block' ) {
271
			MM_findObj(div_name).style.display = 'none';
272
		} else {
273
			MM_findObj(div_name).style.display = 'block';
274
		}
275
 
276
	}
277
}
278
 
279
function Visible () {
280
 
281
	var i, args, div_name, visibility
282
	args=Visible.arguments;
283
	for (i=0; i<(args.length); i+=2) {
284
		div_name=args[i];
285
		visibility=args[i+1]
286
		MM_findObj(div_name).style.display = visibility;
287
 
288
	}
289
}
290
 
291
function DisplayObjects () {
292
	var i, args, div_name
293
	args=DisplayObjects.arguments;
294
	for (i=0; i<(args.length); i+=1) {
295
		div_name=args[i];
296
		MM_findObj(div_name).style.display = 'block';
297
	}
298
}
299
 
300
function GetCookieVal (offset) {  
301
	var endstr = document.cookie.indexOf (";", offset);  
302
	if (endstr == -1) { endstr = document.cookie.length; }
303
	return unescape(document.cookie.substring(offset, endstr));
304
}
305
 
306
 
307
function GetCookie (name) {  
308
	var arg = name + "=";  
309
	var alen = arg.length;  
310
	var clen = document.cookie.length;  
311
	var i = 0;  
312
 
313
	while (i < clen) {    
314
		var j = i + alen;    
315
		if (document.cookie.substring(i, j) == arg) return GetCookieVal (j);    
316
		i = document.cookie.indexOf(" ", i) + 1;    
317
		if (i == 0) break;   
318
	}  
319
 
320
	return null;
321
}
322
 
323
function go_submit( formname, actionname )
324
{
325
	formname.action.value = actionname;
326
	formname.submit();
327
}
328
 
329
function ExpandAll()
330
{
331
	var elem
332
 
333
	if (document.all)
334
	{
335
		// Run this for IE
336
		elem = document.all;
337
	} else {
338
		// Run this for other browsers
339
		elem = document.getElementsByTagName('div');
340
	}
341
 
342
	for (i in elem)
343
	{
344
		if (elem[i].id)
345
		{	
346
			if (elem[i].id.indexOf('SHORT_') == 0) elem[i].style.display = 'none';
347
			if (elem[i].id.indexOf('FULL_') == 0) elem[i].style.display = 'block';
348
		}
349
	}
350
 
351
}
352
 
353
function CollapseAll()
354
{
355
	var elem
356
 
357
	if (document.all)
358
	{
359
		// Run this for IE
360
		elem = document.all;
361
	} else {
362
		// Run this for other browsers
363
		elem = document.getElementsByTagName('div');
364
	}
365
 
366
	for (i in elem)
367
	{
368
		if (elem[i].id)
369
		{	
370
			if (elem[i].id.indexOf('SHORT_') == 0) elem[i].style.display = 'block';
371
			if (elem[i].id.indexOf('FULL_') == 0) elem[i].style.display = 'none';
372
		}
373
	}
374
 
375
}
376
 
377
 
378
function height()
379
{ 
380
	if( typeof( window.innerWidth ) == 'number' ) 
381
	{
382
		h = window.innerHeight;
383
	}
384
	else if(document.documentElement&&(document.documentElement.clientHeight ))
385
	{
386
		h = document.documentElement.clientHeight;
387
	} 
388
	else if( document.body &&	( document.body.clientWidth || document.body.clientHeight ) )
389
	{
390
		h = document.body.clientHeight;
391
	} 
392
 
393
	var e = document.getElementById("LayerDescription");
394
 
395
	if (navigator.userAgent.indexOf('Internet Explorer'))
396
	{
397
		e.style.height = h - 350 + "px";
398
		e.style.overflow = "auto";
399
	}
400
	else
401
	{
402
		// This line shouldn't be run by IE; it doesn't seem to work. It gets run in Firefox, etc.
403
		e.style.minHeight= h - 350 + "px";
404
		e.style.overflow = "auto";
405
	}
406
}
407
 
408
//-->