-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshared.js
More file actions
109 lines (96 loc) · 4.32 KB
/
shared.js
File metadata and controls
109 lines (96 loc) · 4.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
function firstFocus() {
// Sets the focus to a designated control object. All templates name the search box,
// but some pages may also have a firstControl object that will override this.
// This function is called from the body onload event.
try{document.getElementById('searchBox').focus();} catch(e) {}
try{document.getElementById('firstControl').focus();} catch(e) {}
}
function FP_jumpMenu(el,frm,sel) {//v1.0
var href=el.options[el.selectedIndex].value; if(sel) el.selectedIndex=0;
if('_new'==frm) open(href); else eval(frm+".location='"+href+"'");
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_validateForm() { //v4.0
var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
} else if (test!='R') { num = parseFloat(val);
if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
} if (errors) alert('The following error(s) occurred:\n'+errors);
document.MM_returnValue = (errors == '');
}
function MM_setTextOfTextfield(objName,x,newText) { //v3.0
var obj = MM_findObj(objName); if (obj) obj.value = newText;
}
//To use the printSpecial function:
// 1. Add a div tag around the printable range of code:
// <div id=printReady> PRINTABLE RANGE </div>
// 2. Add a hyperlink with href="javascript:void(printSpecial())"
function printSpecial()
{
var gAutoPrint = true; // Flag for whether or not to automatically call the print function
var showCustomTitle = true; // Flag for whether or not to print a special title for printable view
if (document.getElementById != null)
{
var html = '<html>\n<head>\n';
if (document.getElementsByTagName != null)
{
var headTags = document.getElementsByTagName("head");
if (headTags.length > 0) html += headTags[0].innerHTML;
}
html += '\n</he' + 'ad>\n<bo' + 'dy>\n';
if (showCustomTitle)
{
html += '<table width=100% height=100% cellpadding=0 cellspacing=0 border=0>\n';
html += ' <tr height=14 valign=top>\n';
html += ' <td align=right><br>\n';
html += ' </td>\n';
html += ' </tr>\n';
html += ' <tr height=* valign=top><td>\n\n';
}
var printReadyElem = document.getElementById('printReady');
if (printReadyElem != null)
{
html += printReadyElem.innerHTML;
}
else
{
alert('Could not find the print ready section on this page.\nPlease use your browser\'s print function instead.');
return;
}
if (showCustomTitle) {
var d = new Date();
var dateString = new String();
dateString = (d.getMonth() * 1 + 1) + '/' + d.getDate() + '/' + d.getFullYear();
html += '</td></tr>\n';
html += '<tr><td class="smalltext">\n';
html += ' <br><hr size=1 style=color:silver>\n';
html += ' <a href="' + document.location + '">' + document.location + '</a><br>\n';
html += 'Print Date: ' + dateString;
html += '</td></tr>\n';
html += '</table>';
}
html += '\n</BO' + 'DY>\n</HT' + 'ML>';
var printWin = window.open('','printSpecial','location=yes, toolbar=yes, status=yes, menubar=yes, resizable=yes, scrollbars=yes, fullscreen=no');
printWin.document.open();
printWin.document.write(html);
printWin.document.close();
if (gAutoPrint) printWin.print();
}
else
{
alert('Sorry, the printable view feature is not available for this browser.\nPlease use your browser\'s print function instead.');
}
}