Subversion Repositories DevTools

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
13 rsolanki 1
/*
2
 *
3
 *			Common Java Scripts
4
 *
5
 */
29 jtweddle 6
 
13 rsolanki 7
<!--
29 jtweddle 8
var clickedButton = false;
9
function check() {
10
	if (clickedButton) {
11
    	clickedButton = false;
12
        return true;
13
    } else {
14
    	return false;
15
	}
13 rsolanki 16
}
17
 
18
function MM_preloadImages() { //v3.0
19
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
20
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
21
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
22
}
23
 
24
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
25
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
26
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
27
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
28
}
29
MM_reloadPage(true);
30
 
31
 
29 jtweddle 32
function MM_swapImgRestore() { //v3.0
33
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
34
}
35
 
13 rsolanki 36
function MM_findObj(n, d) { //v4.0
37
  var p,i,x;  
38
  if(!d) d=document; 
39
  if((p=n.indexOf("?"))>0&&parent.frames.length) {
40
  	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
41
  }
42
  if(!(x=d[n])&&d.all) x=d.all[n]; 
43
  for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
44
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
45
  if(!x && document.getElementById) x=document.getElementById(n); 
46
  return x;
47
}
48
 
29 jtweddle 49
function MM_swapImage() { //v3.0
50
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
51
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
52
}
13 rsolanki 53
 
54
function MM_openBrWindow(theURL,winName,features) { //v2.0
55
  window.open(theURL,winName,features);
56
}
57
 
29 jtweddle 58
function MM_jumpMenu(targ,selObj,restore){ //v3.1
59
  if (selObj.options[selObj.selectedIndex].value) {
60
	  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
61
	  if (restore) selObj.selectedIndex=0;
62
  }
63
}
13 rsolanki 64
 
29 jtweddle 65
function Cascaded_Menu(targ,url,selObj,restore){ //v3.1
66
  if (selObj.options[selObj.selectedIndex].value) {
67
	  eval(targ+".location='"+url+selObj.options[selObj.selectedIndex].value+"'");
68
	  if (restore) selObj.selectedIndex=0;
69
  }
70
}
71
 
72
function MM_validateForm() { //v5.0
73
	var i,p,pl,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
74
	var myRE,REresults,HTMLchr;
75
	var pass,passc;
76
	//character range allowed
77
	myRE = /[^A-Za-z0-9\.\!\$\_\-\(\)]+/i;
78
	HTMLchr = /[\<\>\'\"]+/i;
79
 
80
 
81
	for (i=0; i<(args.length-2); i+=3) { 
82
		test=args[i+2]; 
83
		val=MM_findObj(args[i]);
84
 
85
		if (val) { 
86
			nm=args[i+1];
87
			val=val.value;
88
 
89
 
90
 
91
			if (val!="") {
92
				if (test.indexOf('isEmail')!=-1) { 
93
					p=val.indexOf('@');
94
					if (p<1 || p==(val.length-1) || test.charAt(0) == '@') errors+='- '+nm+' must contain an e-mail address.\n';
95
				} 
96
 
97
				if (test.indexOf('isDate') != -1) {
98
					if (val.indexOf("/") != -1) { 
99
						tmpARR = val.split("/");
100
						if (tmpARR.length == 3) {
101
							if (!(tmpARR[0]>0  && tmpARR[0]<32  && tmpARR[1]>0 && tmpARR[1]<13 && tmpARR[2]>1900 && tmpARR[2]<9999)) {
102
								errors += '- '+name+' must be in DD/MM/YYYY format.\n';
103
							}
104
						} else {
105
							errors += '- '+name+' must be in DD/MM/YYYY format.\n';
106
						}
107
					} else {
108
						errors += '- '+name+' must be in DD/MM/YYYY format.\n';
109
					}
110
				}
111
 
112
				if (test.indexOf('isPackage')!=-1) {
113
					REresults = val.match(myRE);
114
					if (REresults) errors += '- '+nm+' uses invalid character. Allowed characters are A-Z a-z 0-9 . ! $ - _\n'; 
115
				}
116
 
117
				if (test.indexOf('isChangePassword')!=-1) {
118
					pass=MM_findObj('FRpassword');
119
					passc=MM_findObj('FRpasswordc');
120
					if (pass.value!=passc.value) errors+='- Password confirmation does not match.\n';
121
				}
122
 
123
				if (test.indexOf('maxLength')!=-1) {
124
					p=test.indexOf(':');
125
					max=test.substring(p+1);
126
					if (val.length>max) errors+='- '+nm+' can be maximum '+max+' characters long.\n';
127
				}
128
 
129
				if (test.indexOf('notHTML')!=-1) {
130
					if (val.match(HTMLchr)) errors+='- '+nm+' has invalid characters like \'< > quotes\'\n';
131
				}
132
 
133
				if (test.charAt(0)=='R') {
134
 
135
					if (test.indexOf('isNumber') != -1) { 
136
						if (isNaN(val)) errors+='- '+nm+' must be a number.\n';
137
					}
138
 
139
					if (test.indexOf('inRange') != -1) { 
140
						p=test.indexOf(':');
141
						min=test.substring(8,p); 
142
						max=test.substring(p+1);
143
						if (val<min || max<val) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
144
					} 
145
 
146
					if (test.indexOf('inLength')!=-1) {
147
					    pl=test.indexOf('inLength')
148
						p=test.indexOf(':');
149
		          		min=test.substring(pl+8,p); 
150
		          		if (val.length<min) errors+='- '+nm+' must be at least '+min+' characters long.\n';
151
			    	}	
152
				} 
153
			} else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n';    
154
 
155
 
156
			if (test.indexOf('isPassword')!=-1) {
157
				pass=MM_findObj('FRpassword');
158
				passc=MM_findObj('FRpasswordc');
159
				if (!MM_findObj('FRdomainauth').checked) {
160
					if (test.indexOf('inLength')!=-1) {
161
					    pl=test.indexOf('inLength')
162
						p=test.indexOf(':');
163
		          		min=test.substring(pl+8,p); 
164
		          		if (val.length<min) errors+='- '+nm+' must be at least '+min+' characters long.\n';
165
			    	}	
166
					if (pass.value!=passc.value) errors+='- Password confirmation does not match.\n';
167
				} else {
168
					if (MM_findObj('FRdomain_name').value=="") errors += '- Domain Name is required.\n';   
169
				}
170
			} 
171
 
172
			if (test.indexOf('isDomainName')!=-1) {
173
				if (MM_findObj('FRdomainauth').checked) {
174
					if (MM_findObj('FRdomain_name').value=="") errors += '- Domain Name is required.\n';  
175
				}
176
			}
177
 
178
		}
179
	} 
180
 
181
	if (errors) {
182
		alert('The following error(s) occurred:\n\n'+errors);
183
		clickedButton=false;
184
	} else {
185
		clickedButton=true;
186
	}
187
	document.MM_returnValue = (errors == '');
188
 
189
	if (MM_findObj('ProgressBar') && document.MM_returnValue) MM_findObj('ProgressBar').style.visibility='visible';
190
}
191
 
192
function confirmDelete(m)
193
{
194
	var agree=confirm('Are you sure you want to delete '+m+'?');
195
	if (agree) {
196
		if (MM_findObj('ProgressBar')) MM_findObj('ProgressBar').style.visibility='visible';
197
		return true;
198
	} else {
199
		return false;
200
	}	
201
}
202
 
203
function confirmAction(m)
204
{
205
	var agree=confirm(m);
206
	if (agree) {
207
		ShowProgress();
208
		return true;
209
	} else {
210
		return false;
211
	}	
212
}
213
 
214
function ShowProgress ()
215
{
216
	if (MM_findObj('ProgressBar')) MM_findObj('ProgressBar').style.visibility='visible';
217
	if (MM_findObj('divProgressBar')) MM_findObj('divProgressBar').style.visibility='visible';
218
}
219
 
220
function DisplaySPAN(show) {
221
	if (show) {
222
		MM_findObj("spanHideDetails").style.display = "block";
223
		MM_findObj("spanPkgInfo").style.display = "block";
224
		MM_findObj("spanShowDetails").style.display = "none";
225
	} else {
226
		MM_findObj("spanHideDetails").style.display = "none";
227
		MM_findObj("spanPkgInfo").style.display = "none";
228
		MM_findObj("spanShowDetails").style.display = "block";
229
	}
230
}
231
 
13 rsolanki 232
function ToggleDisplay () {
233
	var i, args, div_name, visibility
234
	args=ToggleDisplay.arguments;
235
	for (i=0; i<(args.length); i+=1) {
236
		div_name=args[i];
237
		if ( MM_findObj(div_name).style.display == 'block' ) {
238
			MM_findObj(div_name).style.display = 'none';
239
		} else {
240
			MM_findObj(div_name).style.display = 'block';
241
		}
242
 
243
	}
244
}
245
 
29 jtweddle 246
function Visible () {
247
	var i, args, div_name, visibility
248
	args=Visible.arguments;
249
	for (i=0; i<(args.length); i+=2) {
250
		div_name=args[i];
251
		visibility=args[i+1]
252
		MM_findObj(div_name).style.display = visibility;
253
 
254
	}
255
}
256
 
13 rsolanki 257
function DisplayArea() {
258
	var i, args, row_name, visibility, persist;
259
 
260
	args=DisplayArea.arguments;
261
	for (i=0; i<(args.length); i+=3) { 
262
		row_name=args[i]; 
263
		visibility=args[i+1];
264
		persist=args[i+2];
265
		MM_findObj(row_name).style.display = visibility;
266
		if (persist) {
267
			document.cookie = "DM_"+ row_name +"="+ visibility +";";
268
		}
269
	}
270
}
271
 
29 jtweddle 272
function DisplayObjects () {
273
	var i, args, div_name
274
	args=DisplayObjects.arguments;
275
	for (i=0; i<(args.length); i+=1) {
276
		div_name=args[i];
277
		MM_findObj(div_name).style.display = 'block';
278
	}
13 rsolanki 279
}
280
 
281
function go_submit( formname, actionname )
282
{
283
	formname.action.value = actionname;
284
	formname.submit();
285
}
286
 
287
function ExpandAll()
288
{
289
	var elem
290
 
291
	if (document.all)
292
	{
293
		// Run this for IE
294
		elem = document.all;
295
	} else {
296
		// Run this for other browsers
297
		elem = document.getElementsByTagName('div');
298
	}
299
 
300
	for (i in elem)
301
	{
302
		if (elem[i].id)
303
		{	
304
			if (elem[i].id.indexOf('SHORT_') == 0) elem[i].style.display = 'none';
305
			if (elem[i].id.indexOf('LONG_') == 0) elem[i].style.display = 'block';
306
		}
307
	}
308
 
309
}
310
 
311
function CollapseAll()
312
{
313
	var elem
314
 
315
	if (document.all)
316
	{
317
		// Run this for IE
318
		elem = document.all;
319
	} else {
320
		// Run this for other browsers
321
		elem = document.getElementsByTagName('div');
322
	}
323
 
324
	for (i in elem)
325
	{
326
		if (elem[i].id)
327
		{	
328
			if (elem[i].id.indexOf('SHORT_') == 0) elem[i].style.display = 'block';
329
			if (elem[i].id.indexOf('LONG_') == 0) elem[i].style.display = 'none';
330
		}
331
	}
332
 
333
}
334
 
29 jtweddle 335
function getWindowHeight()
336
{
337
	var h;
338
	if( typeof( window.innerHeight ) == 'number' ) 
339
	{
340
		h = window.innerHeight;
13 rsolanki 341
	}
29 jtweddle 342
	else if(document.documentElement&&(document.documentElement.clientHeight ))
343
	{
344
		h = document.documentElement.clientHeight;
345
	} 
346
	else if( document.body &&	document.body.clientHeight )
347
	{
348
		h = document.body.clientHeight;
349
	}
350
 
351
	return h;
13 rsolanki 352
}
353
 
29 jtweddle 354
function getWindowWidth()
355
{
356
	var w;
357
	if( typeof( window.innerWidth ) == 'number' ) 
358
	{
359
		w = window.innerWidth;
360
	}
361
	else if(document.documentElement&&(document.documentElement.clientWidth ))
362
	{
363
		w = document.documentElement.clientWidth;
364
	} 
365
	else if( document.body &&	document.body.clientWidth )
366
	{
367
		w = document.body.clientWidth;
368
	}
369
 
370
	return w;
13 rsolanki 371
}
372
 
29 jtweddle 373
/*
13 rsolanki 374
function GetCookie (name) {  
375
	var arg = name + "=";  
376
	var alen = arg.length;  
377
	var clen = document.cookie.length;  
378
	var i = 0;  
379
 
380
	while (i < clen) {    
381
		var j = i + alen;    
382
		if (document.cookie.substring(i, j) == arg) return GetCookieVal (j);    
383
		i = document.cookie.indexOf(" ", i) + 1;    
384
		if (i == 0) break;   
385
	}  
386
 
387
	return null;
388
}
29 jtweddle 389
 
390
 
391
function getPaneStatus() {
392
	var i, args
393
	args=getPaneStatus.arguments;
394
	for (i=0; i<(args.length); i+=1) {
395
		MM_findObj(args[i]).style.display = GetCookie("DM_"+ args[i]);
396
	}
397
}
398
 
399
 
400
function GetCookieVal (offset) {  
401
	var endstr = document.cookie.indexOf (";", offset);  
402
	if (endstr == -1) { endstr = document.cookie.length; }
403
	return unescape(document.cookie.substring(offset, endstr));
404
}
13 rsolanki 405
*/
29 jtweddle 406
 
407
 
408
/*
409
//use browser sniffing to determine if IE or Opera (ugly, but required)
410
var isOpera, isIE = false;
411
if(typeof(window.opera) != 'undefined'){isOpera = true;}
412
if(!isOpera && navigator.userAgent.indexOf('Internet Explorer')){isIE = true;}
413
 
414
//fix both IE and Opera (adjust when they implement this method properly)
415
if(isOpera || isIE)
416
{
417
	document.nativeGetElementById = document.getElementById;
418
	//redefine it!
419
	document.getElementById = function(id)
420
	{
421
		var elem = document.nativeGetElementById(id);
422
		if(elem)
423
		{
424
			//verify it is a valid match!
425
			if(elem.attributes['id'] && elem.attributes['id'].value == id)
426
			{
427
				//valid match!
428
				return elem;
429
			}
430
			else 
431
			{
432
				//not a valid match!
433
				//the non-standard, document.all array has keys for all name'd, and id'd elements
434
				//start at one, because we know the first match, is wrong!
435
				for(var i=1;i<document.all[id].length;i++)
436
				{
437
					if(document.all[id][i].attributes['id'] && document.all[id][i].attributes['id'].value == id)
438
					{
439
						return document.all[id][i];
440
					}
441
				}
442
			}
443
		}
444
		return null;
445
	};
446
}
447
*/
448
 
13 rsolanki 449
//-->