| 119 |
ghuddy |
1 |
<!--
|
|
|
2 |
|
|
|
3 |
var xmlHttp;
|
|
|
4 |
var is_ie = (navigator.userAgent.indexOf('MSIE') >= 0) ? 1 : 0;
|
|
|
5 |
var is_ie5 = (navigator.appVersion.indexOf("MSIE 5.5")!=-1) ? 1 : 0;
|
|
|
6 |
var is_opera = ((navigator.userAgent.indexOf("Opera6")!=-1)||(navigator.userAgent.indexOf("Opera/6")!=-1)) ? 1 : 0;
|
|
|
7 |
//netscape, safari, mozilla behave the same???
|
|
|
8 |
var is_netscape = (navigator.userAgent.indexOf('Netscape') >= 0) ? 1 : 0;
|
|
|
9 |
var ajaxdivname;
|
|
|
10 |
|
| 6613 |
dpurdie |
11 |
//
|
|
|
12 |
// Load/Hide/Show an Ajax expander
|
|
|
13 |
// BaseId - Base for IDs to process
|
|
|
14 |
// IMG_BaseId - image to to toggle
|
|
|
15 |
// TGL_BaseId - element to show/hide if found else use BaseId
|
|
|
16 |
// BaseId - Div to load Ajax into
|
|
|
17 |
// url - Url used to load subcontrol
|
|
|
18 |
function ToggleLoadControl(baseId, url)
|
|
|
19 |
{
|
|
|
20 |
var img, dmode;
|
|
|
21 |
var imgel = MM_findObj("IMG_" + baseId);
|
|
|
22 |
var shel = MM_findObj("TGL_" + baseId);
|
|
|
23 |
var divel = MM_findObj(baseId);
|
|
|
24 |
if ( !shel ) {
|
|
|
25 |
shel = divel;
|
|
|
26 |
}
|
|
|
27 |
var showing = imgel.getAttribute("data-show");
|
|
|
28 |
if(showing == 1) {
|
|
|
29 |
img = "images/bt_minus.gif";
|
|
|
30 |
dmode = '';
|
|
|
31 |
showing = 2
|
|
|
32 |
} else if(showing == 2) {
|
|
|
33 |
img = "images/bt_plus.gif";
|
|
|
34 |
dmode = 'none';
|
|
|
35 |
showing = 1;
|
| 6616 |
dpurdie |
36 |
} else if (url == null) {
|
|
|
37 |
img = "images/bt_plus.gif";
|
|
|
38 |
dmode = 'none';
|
|
|
39 |
showing = 1;
|
| 6613 |
dpurdie |
40 |
} else {
|
|
|
41 |
img = "images/bt_minus.gif";
|
|
|
42 |
dmode = '';
|
|
|
43 |
showing = 2;
|
| 119 |
ghuddy |
44 |
|
| 6613 |
dpurdie |
45 |
// Set div name for ajax loading
|
|
|
46 |
ajaxdivname = baseId;
|
| 119 |
ghuddy |
47 |
|
| 6613 |
dpurdie |
48 |
//Create the xmlHttp object to use in the request
|
|
|
49 |
//stateChangeHandler will fire when the state has changed, i.e. data is received back
|
|
|
50 |
// This is non-blocking (asynchronous)
|
|
|
51 |
xmlHttp = GetXmlHttpObject(stateChangeHandler);
|
|
|
52 |
|
|
|
53 |
//Send the xmlHttp get to the specified url
|
|
|
54 |
xmlHttp_Get(xmlHttp, url);
|
|
|
55 |
}
|
| 6616 |
dpurdie |
56 |
|
| 6613 |
dpurdie |
57 |
// Update image and attributes
|
|
|
58 |
imgel.src = img;
|
|
|
59 |
shel.style.display = dmode;
|
|
|
60 |
imgel.setAttribute("data-show", showing);
|
|
|
61 |
}
|
|
|
62 |
|
| 119 |
ghuddy |
63 |
//stateChangeHandler will fire when the state has changed, i.e. data is received back
|
|
|
64 |
// This is non-blocking (asynchronous)
|
|
|
65 |
function stateChangeHandler()
|
|
|
66 |
{
|
|
|
67 |
|
|
|
68 |
//readyState of 4 or 'complete' represents that data has been returned
|
|
|
69 |
if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete'){
|
|
|
70 |
//Gather the results from the callback
|
|
|
71 |
var str = xmlHttp.responseText;
|
|
|
72 |
|
|
|
73 |
//Populate the innerHTML of the div with the results
|
|
|
74 |
MM_findObj( ajaxdivname ).innerHTML = str;
|
|
|
75 |
}
|
|
|
76 |
}
|
|
|
77 |
|
|
|
78 |
|
|
|
79 |
//stateComboChangeHandler will fire when the state has changed, i.e. data is received back
|
|
|
80 |
// This is non-blocking (asynchronous)
|
|
|
81 |
function stateComboChangeHandler()
|
|
|
82 |
{
|
|
|
83 |
//Expected response data: text|-|value|-|selected|+|text2|-|value2|-|selected2
|
|
|
84 |
|
|
|
85 |
//readyState of 4 or 'complete' represents that data has been returned
|
|
|
86 |
if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete'){
|
|
|
87 |
//Gather the results from the callback
|
|
|
88 |
var str = xmlHttp.responseText;
|
|
|
89 |
var combo = ajaxdivname ;
|
|
|
90 |
var lastOption = combo.options.length
|
|
|
91 |
|
|
|
92 |
//Remove current Combo options
|
| 6613 |
dpurdie |
93 |
for (i=0; i<lastOption; i++) {
|
| 119 |
ghuddy |
94 |
combo.options[0] = null;//The combo box re-organizes itself therefore remove the first element
|
|
|
95 |
}
|
|
|
96 |
|
|
|
97 |
//Populate combowith new items
|
|
|
98 |
var optionArray = str.split('|+|');
|
|
|
99 |
|
| 6613 |
dpurdie |
100 |
for (i in optionArray) {
|
| 119 |
ghuddy |
101 |
//alert(optionArray[i]);
|
|
|
102 |
var opt = optionArray[i].split('|-|');
|
|
|
103 |
combo.options[i] = new Option( opt[0], opt[1], opt[2] );
|
|
|
104 |
}
|
|
|
105 |
}
|
|
|
106 |
}
|
|
|
107 |
|
|
|
108 |
// XMLHttp send GET request
|
|
|
109 |
function xmlHttp_Get(xmlhttp, url) {
|
|
|
110 |
xmlhttp.open('GET', url, true);
|
|
|
111 |
xmlhttp.send(null);
|
|
|
112 |
}
|
|
|
113 |
|
| 3959 |
dpurdie |
114 |
// XMLHttp send GET request but wait for return;
|
|
|
115 |
function xmlHttp_Get_Synch(xmlhttp, url) {
|
|
|
116 |
xmlhttp.open('GET', url, false);
|
|
|
117 |
xmlhttp.send(null);
|
|
|
118 |
}
|
|
|
119 |
|
| 119 |
ghuddy |
120 |
function GetXmlHttpObject(handler) {
|
|
|
121 |
var objXmlHttp = null; //Holds the local xmlHTTP object instance
|
|
|
122 |
|
| 3959 |
dpurdie |
123 |
if (typeof(handler) != "function") {
|
|
|
124 |
alert('Internal: GetXmlHttpObject called without a handler');
|
|
|
125 |
return;
|
|
|
126 |
}
|
|
|
127 |
//Depending on the browser, try to create the xmlHttp object
|
| 119 |
ghuddy |
128 |
if (is_ie){
|
|
|
129 |
//The object to create depends on version of IE
|
|
|
130 |
//If it isn't ie5, then default to the Msxml2.XMLHTTP object
|
|
|
131 |
var strObjName = (is_ie5) ? 'Microsoft.XMLHTTP' : 'Msxml2.XMLHTTP';
|
|
|
132 |
|
|
|
133 |
//Attempt to create the object
|
|
|
134 |
try{
|
|
|
135 |
objXmlHttp = new ActiveXObject(strObjName);
|
|
|
136 |
objXmlHttp.onreadystatechange = handler;
|
|
|
137 |
}
|
|
|
138 |
catch(e){
|
|
|
139 |
//Object creation errored
|
|
|
140 |
alert('IE detected, but object could not be created. Verify that active scripting and activeX controls are enabled');
|
|
|
141 |
return;
|
|
|
142 |
}
|
|
|
143 |
}
|
|
|
144 |
else if (is_opera){
|
|
|
145 |
//Opera has some issues with xmlHttp object functionality
|
|
|
146 |
alert('Opera detected. The page may not behave as expected.');
|
|
|
147 |
return;
|
|
|
148 |
}
|
|
|
149 |
else{
|
|
|
150 |
// Mozilla | Netscape | Safari
|
|
|
151 |
objXmlHttp = new XMLHttpRequest();
|
|
|
152 |
objXmlHttp.onload = handler;
|
|
|
153 |
objXmlHttp.onerror = handler;
|
|
|
154 |
}
|
|
|
155 |
|
|
|
156 |
//Return the instantiated object
|
|
|
157 |
return objXmlHttp;
|
|
|
158 |
}
|
|
|
159 |
|
|
|
160 |
//-->
|