1 | /********************
|
---|
2 | * EXPANSION SCRIPTS *
|
---|
3 | ********************/
|
---|
4 |
|
---|
5 | var collapseImageURL = gs.imageURLs.collapse;
|
---|
6 | var expandImageURL = gs.imageURLs.expand;
|
---|
7 | var chapterImageURL = gs.imageURLs.chapter;
|
---|
8 | var pageImageURL = gs.imageURLs.page;
|
---|
9 |
|
---|
10 | function toggleSection(sectionID)
|
---|
11 | {
|
---|
12 | var docElem = document.getElementById("doc" + sectionID);
|
---|
13 | var tocElem = document.getElementById("toc" + sectionID);
|
---|
14 |
|
---|
15 | var tocToggleElem = document.getElementById("ttoggle" + sectionID);
|
---|
16 | var docToggleElem = document.getElementById("dtoggle" + sectionID);
|
---|
17 |
|
---|
18 | if(docElem.style.display == "none")
|
---|
19 | {
|
---|
20 | docElem.style.display = "block";
|
---|
21 | docToggleElem.setAttribute("src", collapseImageURL);
|
---|
22 |
|
---|
23 | if(tocToggleElem)
|
---|
24 | {
|
---|
25 | tocToggleElem.setAttribute("src", collapseImageURL);
|
---|
26 | }
|
---|
27 |
|
---|
28 | if(tocElem)
|
---|
29 | {
|
---|
30 | tocElem.style.display = "block";
|
---|
31 | }
|
---|
32 | }
|
---|
33 | else
|
---|
34 | {
|
---|
35 | docElem.style.display = "none";
|
---|
36 |
|
---|
37 | //Use the page image if this is a leaf node and the chapter image if it not
|
---|
38 | docToggleElem.setAttribute("src", expandImageURL);
|
---|
39 |
|
---|
40 | if(tocToggleElem)
|
---|
41 | {
|
---|
42 | tocToggleElem.setAttribute("src", expandImageURL);
|
---|
43 | }
|
---|
44 |
|
---|
45 | if(tocElem)
|
---|
46 | {
|
---|
47 | tocElem.style.display = "none";
|
---|
48 | }
|
---|
49 | }
|
---|
50 | }
|
---|
51 |
|
---|
52 | function isExpanded(sectionID)
|
---|
53 | {
|
---|
54 | var docElem = document.getElementById("doc" + sectionID);
|
---|
55 | if(docElem.style.display == "block")
|
---|
56 | {
|
---|
57 | return true;
|
---|
58 | }
|
---|
59 | return false;
|
---|
60 | }
|
---|
61 |
|
---|
62 | function isParentOf(parent, child)
|
---|
63 | {
|
---|
64 | if(child.indexOf(parent) != -1 && child.length > parent.length && child[parent.length] == '.')
|
---|
65 | {
|
---|
66 | return true;
|
---|
67 | }
|
---|
68 | return false;
|
---|
69 | }
|
---|
70 |
|
---|
71 | function focusSection(sectionID)
|
---|
72 | {
|
---|
73 | var tableOfContentsDiv = document.getElementById("tableOfContents");
|
---|
74 | var images = tableOfContentsDiv.getElementsByTagName("img");
|
---|
75 | var nodeArray = new Array();
|
---|
76 |
|
---|
77 | for(var i = 0; i < images.length; i++)
|
---|
78 | {
|
---|
79 | nodeArray[i] = images[i].getAttribute("id").substring(7);
|
---|
80 | }
|
---|
81 |
|
---|
82 | for(var j = 0; j < nodeArray.length; j++)
|
---|
83 | {
|
---|
84 | //If this is the node that was clicked and it is not expanded then expand it
|
---|
85 | if(nodeArray[j] == sectionID)
|
---|
86 | {
|
---|
87 | if(!isExpanded(nodeArray[j]))
|
---|
88 | {
|
---|
89 | toggleSection(nodeArray[j]);
|
---|
90 | }
|
---|
91 |
|
---|
92 | continue;
|
---|
93 | }
|
---|
94 |
|
---|
95 | //If the node is a parent or child of the node that is clicked and is not expanded then expand it
|
---|
96 | if((isParentOf(nodeArray[j], sectionID) || isParentOf(sectionID, nodeArray[j])) && !isExpanded(nodeArray[j]))
|
---|
97 | {
|
---|
98 | toggleSection(nodeArray[j]);
|
---|
99 | }
|
---|
100 | //If the node is not a parent or child and is expanded then collapse it
|
---|
101 | else if(!(isParentOf(nodeArray[j], sectionID) || isParentOf(sectionID, nodeArray[j])) && isExpanded(nodeArray[j]))
|
---|
102 | {
|
---|
103 | toggleSection(nodeArray[j]);
|
---|
104 | }
|
---|
105 | }
|
---|
106 | }
|
---|
107 |
|
---|
108 | function minimizeSidebar()
|
---|
109 | {
|
---|
110 | var coverImage = document.getElementById("coverImage");
|
---|
111 | var toc = document.getElementById("tableOfContents");
|
---|
112 | var maxLink = document.getElementById("sidebarMaximizeButton");
|
---|
113 | var minLink = document.getElementById("sidebarMinimizeButton");
|
---|
114 |
|
---|
115 | if(coverImage)
|
---|
116 | {
|
---|
117 | coverImage.style.display = "none";
|
---|
118 | }
|
---|
119 |
|
---|
120 | if(toc)
|
---|
121 | {
|
---|
122 | toc.style.display = "none";
|
---|
123 | }
|
---|
124 |
|
---|
125 | maxLink.style.display = "block";
|
---|
126 | minLink.style.display = "none";
|
---|
127 | }
|
---|
128 |
|
---|
129 | function maximizeSidebar()
|
---|
130 | {
|
---|
131 | var coverImage = document.getElementById("coverImage");
|
---|
132 | var toc = document.getElementById("tableOfContents");
|
---|
133 | var maxLink = document.getElementById("sidebarMaximizeButton");
|
---|
134 | var minLink = document.getElementById("sidebarMinimizeButton");
|
---|
135 |
|
---|
136 | if(coverImage)
|
---|
137 | {
|
---|
138 | coverImage.style.display = "block";
|
---|
139 | }
|
---|
140 |
|
---|
141 | if(toc)
|
---|
142 | {
|
---|
143 | toc.style.display = "block";
|
---|
144 | }
|
---|
145 |
|
---|
146 | maxLink.style.display = "none";
|
---|
147 | minLink.style.display = "block";
|
---|
148 | }
|
---|
149 |
|
---|
150 | /***********************
|
---|
151 | * HIGHLIGHTING SCRIPTS *
|
---|
152 | ***********************/
|
---|
153 | function addHighlight()
|
---|
154 | {
|
---|
155 | var spans = document.getElementsByTagName("span");
|
---|
156 | for(var i = 0; i < spans.length; i++)
|
---|
157 | {
|
---|
158 | var currentSpan = spans[i];
|
---|
159 | if(currentSpan.getAttribute("class") == "noTermHighlight")
|
---|
160 | {
|
---|
161 | currentSpan.setAttribute("class", "termHighlight");
|
---|
162 | }
|
---|
163 | }
|
---|
164 |
|
---|
165 | var option = document.getElementById("highlightOption");
|
---|
166 | option.setAttribute("onclick", "removeHighlight();");
|
---|
167 | }
|
---|
168 |
|
---|
169 | function removeHighlight()
|
---|
170 | {
|
---|
171 | var spans = document.getElementsByTagName("span");
|
---|
172 | for(var i = 0; i < spans.length; i++)
|
---|
173 | {
|
---|
174 | var currentSpan = spans[i];
|
---|
175 | if(currentSpan.getAttribute("class") == "termHighlight")
|
---|
176 | {
|
---|
177 | currentSpan.setAttribute("class", "noTermHighlight");
|
---|
178 | }
|
---|
179 | }
|
---|
180 |
|
---|
181 | var option = document.getElementById("highlightOption");
|
---|
182 | option.setAttribute("onclick", "addHighlight();");
|
---|
183 | }
|
---|
184 |
|
---|
185 | /**************************
|
---|
186 | * REALISTIC BOOKS SCRIPTS *
|
---|
187 | **************************/
|
---|
188 |
|
---|
189 | function bookInit()
|
---|
190 | {
|
---|
191 | loadBook();
|
---|
192 | hideText();
|
---|
193 | showBook();
|
---|
194 | swapLinkJavascript(false);
|
---|
195 | }
|
---|
196 |
|
---|
197 | function hideText()
|
---|
198 | {
|
---|
199 | var textDiv = document.getElementById("gs-document-text");
|
---|
200 | textDiv.style.visibility = "hidden";
|
---|
201 | }
|
---|
202 |
|
---|
203 | function showText()
|
---|
204 | {
|
---|
205 | var textDiv = document.getElementById("gs-document-text");
|
---|
206 | textDiv.style.visibility = "visible";
|
---|
207 | }
|
---|
208 |
|
---|
209 | function hideBook()
|
---|
210 | {
|
---|
211 | var bookDiv = document.getElementById("bookdiv");
|
---|
212 | bookDiv.style.visibility = "hidden";
|
---|
213 | bookDiv.style.height = "0px";
|
---|
214 |
|
---|
215 | var bookObject = document.getElementById("bookObject");
|
---|
216 | bookObject.style.visibility = "hidden";
|
---|
217 | bookObject.style.height = "0px";
|
---|
218 |
|
---|
219 | var bookEmbed = document.getElementById("bookEmbed");
|
---|
220 | bookEmbed.style.visibility = "hidden";
|
---|
221 | bookEmbed.style.height = "0px";
|
---|
222 | }
|
---|
223 |
|
---|
224 | function showBook()
|
---|
225 | {
|
---|
226 | var bookDiv = document.getElementById("bookdiv");
|
---|
227 | bookDiv.style.visibility = "visible";
|
---|
228 | bookDiv.style.height = "600px";
|
---|
229 |
|
---|
230 | var bookObject = document.getElementById("bookObject");
|
---|
231 | bookObject.style.visibility = "visible";
|
---|
232 | bookObject.style.height = "600px";
|
---|
233 |
|
---|
234 | var bookEmbed = document.getElementById("bookEmbed");
|
---|
235 | bookEmbed.style.visibility = "visible";
|
---|
236 | bookEmbed.style.height = "600px";
|
---|
237 | }
|
---|
238 |
|
---|
239 | function swapLinkJavascript(rbOn)
|
---|
240 | {
|
---|
241 | var option = document.getElementById("rbOption");
|
---|
242 | if(rbOn)
|
---|
243 | {
|
---|
244 | option.setAttribute("onclick", "hideText(); showBook(); swapLinkJavascript(false);");
|
---|
245 | }
|
---|
246 | else
|
---|
247 | {
|
---|
248 | option.setAttribute("onclick", "hideBook(); showText(); swapLinkJavascript(true);");
|
---|
249 | }
|
---|
250 | }
|
---|
251 |
|
---|
252 | //Helper function to create param elements
|
---|
253 | function createParam(name, value)
|
---|
254 | {
|
---|
255 | var param = document.createElement("PARAM");
|
---|
256 | param.setAttribute("name", name);
|
---|
257 | param.setAttribute("value", value);
|
---|
258 | return param;
|
---|
259 | }
|
---|
260 |
|
---|
261 | function loadBook()
|
---|
262 | {
|
---|
263 | var doc_url = document.URL;
|
---|
264 | doc_url = doc_url.replace(/(&|\?)book=[a-z]+/gi,'');
|
---|
265 | doc_url += '&book=flashxml';
|
---|
266 |
|
---|
267 | var img_cover = gs.collectionMetadata.httpPath + '/index/assoc/' + gs.documentMetadata.assocfilepath + '/cover.jpg';
|
---|
268 |
|
---|
269 | var flash_plug_html = ""
|
---|
270 | flash_plug_html += '<OBJECT align="middle" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" \n';
|
---|
271 | flash_plug_html += ' height="600px" id="bookObject" swLiveConnect="true" \n';
|
---|
272 | flash_plug_html += ' codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" \n';
|
---|
273 | flash_plug_html += ' width="70%">\n';
|
---|
274 | flash_plug_html += ' <PARAM name="allowScriptAccess" value="always" />\n';
|
---|
275 | flash_plug_html += ' <PARAM name="movie" value="Book.swf';
|
---|
276 | flash_plug_html += '?src_image=' + escape(img_cover);
|
---|
277 | flash_plug_html += '&doc_url=' + escape(doc_url)
|
---|
278 | flash_plug_html += '" />\n';
|
---|
279 | flash_plug_html += ' <PARAM name="quality" value="high" />\n';
|
---|
280 | flash_plug_html += ' <PARAM name="bgcolor" value="#FFFFFF" />\n';
|
---|
281 | flash_plug_html += ' <EMBED align="middle" \n';
|
---|
282 | flash_plug_html += ' allowScriptAccess="always" swLiveConnect="true" \n';
|
---|
283 | flash_plug_html += ' bgcolor="#FFFFFF" height="600px" name="Book" \n';
|
---|
284 | flash_plug_html += ' pluginspage="http://www.macromedia.com/go/getflashplayer" \n';
|
---|
285 | flash_plug_html += ' quality="high" id="bookEmbed"\n';
|
---|
286 | flash_plug_html += ' src="Book.swf';
|
---|
287 | flash_plug_html += '?src_image=' + escape(img_cover);
|
---|
288 | flash_plug_html += '&doc_url=' + escape(doc_url);
|
---|
289 | flash_plug_html += '"\n';
|
---|
290 | flash_plug_html += ' type="application/x-shockwave-flash" width="70%" />\n';
|
---|
291 | flash_plug_html += '</OBJECT>\n';
|
---|
292 | var flash_div = document.getElementById("bookdiv");
|
---|
293 | flash_div.innerHTML = flash_plug_html;
|
---|
294 | } |
---|