comparison presen/ui/school_gfx/slides.js @ 54:a967ee5a0b0f

add presen
author Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
date Sat, 24 Dec 2011 18:53:34 +0900
parents
children
comparison
equal deleted inserted replaced
53:de1f203636d1 54:a967ee5a0b0f
1 // S5 1.3beta7 (18-Apr-2007) advanced version by C. Effenberger
2 // Please see http://s5.netzgesta.de/ for more information
3 // based on S5 v1.2a1 slides.js -- released into the Public Domain
4 // Please see http://www.meyerweb.com/eric/tools/s5/credits.html for information
5 // about all the wonderful and talented contributors to this code!
6 // audio extension: soundmanager2 is NOT Public Domain
7 // Please see http://www.schillmania.com/projects/soundmanager2/ for information
8
9 var undef;
10 var slideCSS = '';
11 var snum = 0;
12 var smax = 1;
13 var incpos = 0;
14 var number = undef;
15 var firstTime = 1;
16 var s5mode = true;
17 var helpmode = false;
18 var defaultView = 'slideshow'; //outline
19 var controlVis = 'visible';
20
21 // scalable images extension
22 var empx = 0;
23 var images = new Array();
24 var canvas = new Array();
25 var medias = new Array();
26 var piecharts = new Array();
27 var barcharts = new Array();
28 var linecharts = new Array();
29 // scalable images extension
30
31 // transition extension
32 var tranSitions = false;
33 var fadeModus = false;
34 var fadeDuration = 500;
35 var incrDuration = 250;
36 var opac = 1;
37 var cid = '';
38 var nid = '';
39 var tid = '';
40 var jl = '';
41 // transition extension
42
43 // autoplay extension
44 var autoMatic = false;
45 var playLoop = false;
46 var playPause = false;
47 var autoRun = false;
48 var playDelay = 5000;
49 var remainDer = 0;
50 var incrDelay = 0;
51 // autoplay extension
52
53 // audio extension
54 var sound = new Array();
55 var audioSupport = false;
56 var audioVolume = 100;
57 var audioError = false;
58 var swfUnloaded = true;
59 var bgSoundItem = 9999;
60 var curSoundID = -1;
61 // audio extension
62
63 // panel extension
64 var imgWidth = 32;
65 var imgHeight = 32;
66 // panel extension
67
68 // canvas chart extension
69 var canvasSupport = false;
70 var ChartData = new Array();
71 var colorSlice = new Array();
72 var font = document.createElement("img");
73 font.setAttribute("src", "ui/graphic_support/numeric.png");
74 signs = {
75 '0': {sx: 0, sy: 0, sw: 48, sh: 64},
76 '1': {sx: 48, sy: 0, sw: 48, sh: 64},
77 '2': {sx: 96, sy: 0, sw: 48, sh: 64},
78 '3': {sx: 144, sy: 0, sw: 48, sh: 64},
79 '4': {sx: 192, sy: 0, sw: 48, sh: 64},
80 '5': {sx: 240, sy: 0, sw: 48, sh: 64},
81 '6': {sx: 288, sy: 0, sw: 48, sh: 64},
82 '7': {sx: 336, sy: 0, sw: 48, sh: 64},
83 '8': {sx: 384, sy: 0, sw: 48, sh: 64},
84 '9': {sx: 432, sy: 0, sw: 48, sh: 64},
85 '%': {sx: 480, sy: 0, sw: 48, sh: 64},
86 '.': {sx: 528, sy: 0, sw: 24, sh: 64}
87 };
88 var colorNames= new Array();
89 colorNames["black"]="#000000"; colorNames["maroon"]="#800000";
90 colorNames["green"]="#008000"; colorNames["olive"]="#808000";
91 colorNames["navy"]="#000080"; colorNames["purple"]="#800080";
92 colorNames["teal"]="#008080"; colorNames["gray"]="#808080";
93 colorNames["silver"]="#C0C0C0"; colorNames["red"]="#FF0000";
94 colorNames["lime"]="#00FF00"; colorNames["yellow"]="#FFFF00";
95 colorNames["blue"]="#0000FF"; colorNames["fuchsia"]="#FF00FF";
96 colorNames["aqua"]="#00FFFF"; colorNames["white"]="#FFFFFF";
97 colorNames["aliceblue"]="#F0F8FF"; colorNames["antiquewhite"]="#FAEBD7";
98 colorNames["aquamarine"]="#7FFFD4"; colorNames["azure"]="#F0FFFF";
99 colorNames["beige"]="#F5F5DC"; colorNames["blueviolet"]="#8A2BE2";
100 colorNames["brown"]="#A52A2A"; colorNames["burlywood"]="#DEB887";
101 colorNames["cadetblue"]="#5F9EA0"; colorNames["chartreuse"]="#7FFF00";
102 colorNames["chocolate"]="#D2691E"; colorNames["coral"]="#FF7F50";
103 colorNames["cornflowerblue"]="#6495ED"; colorNames["cornsilk"]="#FFF8DC";
104 colorNames["crimson"]="#DC143C"; colorNames["darkblue"]="#00008B";
105 colorNames["darkcyan"]="#008B8B"; colorNames["darkgoldenrod"]="#B8860B";
106 colorNames["darkgray"]="#A9A9A9"; colorNames["darkgreen"]="#006400";
107 colorNames["darkkhaki"]="#BDB76B"; colorNames["darkmagenta"]="#8B008B";
108 colorNames["darkolivegreen"]="#556B2F"; colorNames["darkorange"]="#FF8C00";
109 colorNames["darkorchid"]="#9932CC"; colorNames["darkred"]="#8B0000";
110 colorNames["darksalmon"]="#E9967A"; colorNames["darkseagreen"]="#8FBC8F";
111 colorNames["darkslateblue"]="#483D8B"; colorNames["darkslategray"]="#2F4F4F";
112 colorNames["darkturquoise"]="#00CED1"; colorNames["darkviolet"]="#9400D3";
113 colorNames["deeppink"]="#FF1493"; colorNames["deepskyblue"]="#00BFFF";
114 colorNames["dimgray"]="#696969"; colorNames["dodgerblue"]="#1E90FF";
115 colorNames["firebrick"]="#B22222"; colorNames["floralwhite"]="#FFFAF0";
116 colorNames["forestgreen"]="#228B22"; colorNames["gainsboro"]="#DCDCDC";
117 colorNames["ghostwhite"]="#F8F8FF"; colorNames["gold"]="#FFD700";
118 colorNames["goldenrod"]="#DAA520"; colorNames["greenyellow"]="#ADFF2F";
119 colorNames["honeydew"]="#F0FFF0"; colorNames["hotpink"]="#FF69B4";
120 colorNames["indianred"]="#CD5C5C"; colorNames["indigo"]="#4B0082";
121 colorNames["ivory"]="#FFFFF0"; colorNames["khaki"]="#F0E68C";
122 colorNames["lavender"]="#E6E6FA"; colorNames["lavenderblush"]="#FFF0F5";
123 colorNames["lawngreen"]="#7CFC00"; colorNames["lemonchiffon"]="#FFFACD";
124 colorNames["lightblue"]="#ADD8E6"; colorNames["lightcoral"]="#F08080";
125 colorNames["lightcyan"]="#E0FFFF"; colorNames["lightgoldenrodyellow"]="#FAFAD2";
126 colorNames["lightgreen"]="#90EE90"; colorNames["lightgrey"]="#D3D3D3";
127 colorNames["lightpink"]="#FFB6C1"; colorNames["lightsalmon"]="#FFA07A";
128 colorNames["lightseagreen"]="#20B2AA"; colorNames["lightskyblue"]="#87CEFA";
129 colorNames["lightslategray"]="#778899"; colorNames["lightsteelblue"]="#B0C4DE";
130 colorNames["lightyellow"]="#FFFFE0"; colorNames["limegreen"]="#32CD32";
131 colorNames["linen"]="#FAF0E6"; colorNames["mediumaquamarine"]="#66CDAA";
132 colorNames["mediumblue"]="#0000CD"; colorNames["mediumorchid"]="#BA55D3";
133 colorNames["ediumpurple"]="#9370D"; colorNames["mediumseagreen"]="#3CB371";
134 colorNames["mediumslateblue"]="#7B68EE"; colorNames["mediumspringgreen"]="#00FA9A";
135 colorNames["mediumturquoise"]="#48D1CC"; colorNames["mediumvioletred"]="#C71585";
136 colorNames["midnightblue"]="#191970"; colorNames["mintcream"]="#F5FFFA";
137 colorNames["mistyrose"]="#FFE4E1"; colorNames["moccasin"]="#FFE4B5";
138 colorNames["navajowhite"]="#FFDEAD"; colorNames["oldlace"]="#FDF5E6";
139 colorNames["olivedrab"]="#6B8E23"; colorNames["orange"]="#FFA500";
140 colorNames["orangered"]="#FF4500"; colorNames["orchid"]="#DA70D6";
141 colorNames["palegoldenrod"]="#EEE8AA"; colorNames["palegreen"]="#98FB98";
142 colorNames["paleturquoise"]="#AFEEEE"; colorNames["palevioletred"]="#DB7093";
143 colorNames["papayawhip"]="#FFEFD5"; colorNames["peachpuff"]="#FFDAB9";
144 colorNames["peru"]="#CD853F"; colorNames["pink"]="#FFC0CB";
145 colorNames["plum"]="#DDA0DD"; colorNames["powderblue"]="#B0E0E6";
146 colorNames["rosybrown"]="#BC8F8F"; colorNames["royalblue"]="#4169E1";
147 colorNames["saddlebrown"]="#8B4513"; colorNames["salmon"]="#FA8072";
148 colorNames["sandybrown"]="#F4A460"; colorNames["seagreen"]="#2E8B57";
149 colorNames["seashell"]="#FFF5EE"; colorNames["sienna"]="#A0522D";
150 colorNames["skyblue"]="#87CEEB"; colorNames["slateblue"]="#6A5ACD";
151 colorNames["slategray"]="#708090"; colorNames["snow"]="#FFFAFA";
152 colorNames["springgreen"]="#00FF7F"; colorNames["steelblue"]="#4682B4";
153 colorNames["tan"]="#D2B48C"; colorNames["thistle"]="#D8BFD8";
154 colorNames["tomato"]="#FF6347"; colorNames["turquoise"]="#40E0D0";
155 colorNames["violet"]="#EE82EE"; colorNames["wheat"]="#F5DEB3";
156 colorNames["whitesmoke"]="#F5F5F5"; colorNames["yellowgreen"]="#9ACD32";
157 var canvas_bgcolor = "";
158 var canvas_width = 200;
159 var canvas_height = 200;
160 var canvas_noshade = 0;
161 var canvas_nofill = 0;
162 var canvas_noshadow = 0;
163 var canvas_htmltext = 0;
164 var canvas_imgtext = 0;
165 var canvas_notext = 0;
166 // canvas chart extension
167
168 var s5NotesWindow;
169 var s5NotesWindowLoaded = false;
170 var previousSlide = 0;
171 var presentationStart = new Date();
172 var slideStart = new Date();
173
174 var countdown = {
175 timer: 0,
176 state: 'pause',
177 start: new Date(),
178 end: 0,
179 remaining: 0
180 };
181
182 var isIE = navigator.appName == 'Microsoft Internet Explorer' && navigator.userAgent.indexOf('Opera') < 1 ? 1 : 0;
183 if(isIE) var notIE7 = parseInt(navigator.appVersion) < 7 ? 1 : 0;
184 var isOp = navigator.userAgent.indexOf('Opera') > -1 ? 1 : 0;
185 var isGe = navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('Safari') < 1 ? 1 : 0;
186 var isS2 = navigator.userAgent.indexOf('Safari') >= 2 ? 1 : 0;
187
188 function hasClass(object, className) {
189 if (!object.className) return false;
190 return (object.className.search('(^|\\s)' + className + '(\\s|$)') != -1);
191 }
192
193 function hasValue(object, value) {
194 if (!object) return false;
195 return (object.search('(^|\\s)' + value + '(\\s|$)') != -1);
196 }
197
198 function removeClass(object,className) {
199 if (!object || !hasClass(object,className)) return;
200 object.className = object.className.replace(new RegExp('(^|\\s)'+className+'(\\s|$)'), RegExp.$1+RegExp.$2);
201 }
202
203 function addClass(object,className) {
204 if (!object || hasClass(object, className)) return;
205 if (object.className) {
206 object.className += ' '+className;
207 } else {
208 object.className = className;
209 }
210 }
211
212 function changeClass(object,className) {
213 if (!object) return;
214 object.firstChild.className = className;
215 }
216
217 function GetElementsWithClassName(elementName,className) {
218 var allElements = document.getElementsByTagName(elementName);
219 var elemColl = new Array();
220 for (var i = 0; i< allElements.length; i++) {
221 if (hasClass(allElements[i], className)) {
222 elemColl[elemColl.length] = allElements[i];
223 }
224 }
225 return elemColl;
226 }
227
228 function isParentOrSelf(element, id) {
229 if (element == null || element.nodeName=='BODY') return false;
230 else if (element.id == id) return true;
231 else return isParentOrSelf(element.parentNode, id);
232 }
233
234 function nodeValue(node) {
235 var result = "";
236 if (node.nodeType == 1) {
237 var children = node.childNodes;
238 for (var i = 0; i < children.length; ++i) {
239 result += nodeValue(children[i]);
240 }
241 }
242 else if (node.nodeType == 3) {
243 result = node.nodeValue;
244 }
245 return(result);
246 }
247
248 function slideLabel() {
249 var slideColl = GetElementsWithClassName('*','slide');
250 var list = document.getElementById('jumplist');
251 smax = slideColl.length;
252 for (var n = 0; n < smax; n++) {
253 var obj = slideColl[n];
254 var did = 'slide' + n.toString();
255 obj.setAttribute('id',did);
256 var otext = '';
257 var menu = obj.firstChild;
258 if (!menu) continue; // to cope with empty slides
259 while (menu && menu.nodeType == 3) {
260 menu = menu.nextSibling;
261 }
262 if (!menu) continue; // to cope with slides with only text nodes
263 var menunodes = menu.childNodes;
264 for (var o = 0; o < menunodes.length; o++) {
265 otext += nodeValue(menunodes[o]);
266 }
267 list.options[list.length] = new Option(n + ' : ' + otext, n);
268 }
269 }
270
271 function currentSlide() {
272 var cs, at, fd, ss;
273 if (document.getElementById) {
274 cs = document.getElementById('currentSlide');
275 } else {
276 cs = document.currentSlide;
277 }
278 fd = fadeModus?"F":"&ndash;";
279 ss = audioSupport?"S":"&ndash;";
280 at = (autoMatic?(playPause?"||":(playLoop?"&gt;0":"&gt;|")):"&ndash;&ndash;");
281 cs.innerHTML = '<div id="plink" nowrap="nowrap">' +
282 '<span id="csFade">[' + fd + ss + ']<\/span>&nbsp;' +
283 '<span id="csHere"><strong>' + snum + '<\/strong><\/span>' +
284 '<span id="csSep">\/<\/span>' +
285 '<span id="csTotal">' + (smax-1) + '<\/span>&nbsp;' +
286 '<span id="csAuto">[' + at + ']<\/span>' +
287 '<\/div>';
288
289 if (snum == 0) {
290 cs.style.visibility = 'hidden';
291 } else {
292 cs.style.visibility = 'visible';
293 }
294 }
295
296 function go(step) {
297 if (document.getElementById('slideProj').disabled || step == 0) return;
298 jl = document.getElementById('jumplist');
299 cid = 'slide' + snum;
300 var ce = document.getElementById(cid);
301 if (incrementals[snum].length > 0) {
302 for (var i = 0; i < incrementals[snum].length; i++) {
303 removeClass(incrementals[snum][i], 'current');
304 removeClass(incrementals[snum][i], 'incremental');
305 }
306 }
307 if (step != 'j') {
308 snum += step;
309 lmax = smax - 1;
310 if (snum > lmax) snum = lmax;
311 if (snum < 0) snum = 0;
312 }else {
313 snum = parseInt(jl.value);
314 }
315 nid = 'slide' + snum;
316 var ne = document.getElementById(nid);
317 if (!ne) {
318 ne = document.getElementById('slide0');
319 nid = 'slide0';
320 snum = 0;
321 }
322 if (step < 0) {
323 incpos = incrementals[snum].length
324 }else {
325 incpos = 0;
326 }
327 if (incrementals[snum].length > 0 && incpos == 0) {
328 for (var i = 0; i < incrementals[snum].length; i++) {
329 if (hasClass(incrementals[snum][i], 'current')) {
330 incpos = i + 1;
331 }else {
332 addClass(incrementals[snum][i], 'incremental');
333 }
334 }
335 }
336 if (incrementals[snum].length > 0 && incpos > 0) {
337 addClass(incrementals[snum][incpos - 1], 'current');
338 }
339 var guru = document.getElementById('guru');
340 if(guru && snum==0) {
341 guru.style.visibility = 'visible';
342 }else if(guru && snum>0) {
343 guru.style.visibility = 'hidden';
344 }
345 if(tranSitions && s5mode && fadeModus) {
346 if(curSoundID != getSoundID(nid)) {
347 if(curSoundID == bgSoundItem && !sound[getSoundID(nid)]) {
348 }else {fadeoutSound(curSoundID,true); } // audio support
349 }
350 changeOpac(0,nid);
351 changeOpac(100,cid);
352 ce.style.visibility = 'visible';
353 shiftOpacity(cid,fadeDuration);
354 window.setTimeout("changeSlides()",fadeDuration);
355 }else {
356 if(curSoundID != getSoundID(nid)) {
357 if(curSoundID == bgSoundItem && !sound[getSoundID(nid)]) {
358 }else {stopSound(curSoundID); } // audio support
359 }
360 ce.style.visibility = 'hidden';
361 if (isOp) location.hash = nid;
362 ne.style.visibility = 'visible';
363 finishSlides();
364 }
365 }
366
367 function changeSlides() {
368 if(nid != cid) changeOpac(100,cid);
369 document.getElementById(cid).style.visibility = 'hidden';
370 document.getElementById(nid).style.visibility = 'visible';
371 if (isOp) location.hash = nid;
372 shiftOpacity(nid,fadeDuration);
373 window.setTimeout("finishSlides()",fadeDuration);
374 }
375
376 function finishSlides() {
377 jl.selectedIndex = snum;
378 currentSlide();
379 loadNote();
380 permaLink();
381 number = undef;
382 if(sound[getSoundID(nid)]) {
383 playSound(nid); // audio support
384 }else if(sound[bgSoundItem] && curSoundID != bgSoundItem) {
385 playSound(bgSoundItem); // audio support
386 }
387 }
388
389 function goTo(target) {
390 if (target >= smax || target == snum) return;
391 go(target - snum);
392 }
393
394 function subgo(step) {
395 if (step > 0) {
396 removeClass(incrementals[snum][incpos - 1],'current');
397 removeClass(incrementals[snum][incpos], 'incremental');
398 if(tranSitions && s5mode && fadeModus) {
399 if(!incrementals[snum][incpos].id) {
400 var tmp = new Date(); tid = "inc" + String(tmp.getTime());
401 incrementals[snum][incpos].id = tid;
402 }else {
403 tid = incrementals[snum][incpos].id;
404 }
405 if(typeof(incrementals[snum][incpos].src) != "undefined" || incrementals[snum][incpos].getContext) {
406 changeOpac(0,tid);
407 addClass(incrementals[snum][incpos],'current');
408 shiftOpacity(tid,incrDuration);
409 setTimeout("nextInc()",incrDuration);
410 }else {
411 addClass(incrementals[snum][incpos],'current');
412 nextInc();
413 }
414 }else {
415 addClass(incrementals[snum][incpos],'current');
416 nextInc();
417 }
418 } else {
419 incpos--;
420 removeClass(incrementals[snum][incpos],'current');
421 addClass(incrementals[snum][incpos], 'incremental');
422 addClass(incrementals[snum][incpos - 1],'current');
423 loadNote();
424 }
425 }
426
427 function nextInc() {
428 incpos++;
429 loadNote();
430 }
431
432 function toggle() {
433 var slideColl = GetElementsWithClassName('*','slide');
434 var slides = document.getElementById('slideProj');
435 var outline = document.getElementById('outlineStyle');
436 var guru = document.getElementById('guru');
437 if (!slides.disabled) {
438 stopPlay();
439 if(audioSupport && !swfUnloaded) stopAllSounds();
440 slides.disabled = true;
441 outline.disabled = false;
442 s5mode = false;
443 fontSize(1,'em');
444 for (var n = 0; n < smax; n++) {
445 var slide = slideColl[n];
446 slide.style.visibility = 'visible';
447 }
448 if(guru) guru.style.visibility = 'hidden';
449 } else {
450 slides.disabled = false;
451 outline.disabled = true;
452 s5mode = true;
453 fontScale();
454 for (var n = 0; n < smax; n++) {
455 var slide = slideColl[n];
456 slide.style.visibility = 'hidden';
457 }
458 slideColl[snum].style.visibility = 'visible';
459 if(guru && snum==0) guru.style.visibility = 'visible';
460 }
461 }
462
463 function showHide(action) {
464 var obj = GetElementsWithClassName('*','hideme')[0];
465 switch (action) {
466 case 's':
467 obj.style.visibility = 'visible';
468 break;
469 case 'h':
470 obj.style.visibility = 'hidden';
471 break;
472 case 'k':
473 if (obj.style.visibility != 'visible') {
474 obj.style.visibility = 'visible';
475 } else {
476 obj.style.visibility = 'hidden';
477 }
478 break;
479 }
480 }
481
482 function keys(key) {
483 if (!key) {
484 key = event;
485 key.which = key.keyCode;
486 }
487 if (helpmode) {
488 dumpHelpReq();
489 return;
490 }
491 if (key.which == 84 && !isOp) {
492 toggle();
493 return;
494 }
495 if (s5mode) {
496 if (autoMatic) {
497 switch (key.which) {
498 case 70: // f/ading on/off
499 switchFade();
500 break;
501 case 83: // s/ound on/off
502 toggleSounds();
503 break;
504 case 67: // c
505 showHide('k');
506 break;
507 case 65: // a/utoplay on/off
508 stopPlay();
509 break;
510 case 76: // l/ooping on/off
511 switchLoop();
512 break;
513 case 80: // p/ause
514 case 32: // spacebar
515 pausePlay();
516 break;
517 }
518 }else {
519 switch (key.which) {
520 case 8: // backspace = HELP
521 createHelpReq();
522 break;
523 case 10: // return
524 case 13: // enter
525 if (window.event && isParentOrSelf(window.event.srcElement, 'controls')) return;
526 if (key.target && isParentOrSelf(key.target, 'controls')) return;
527 if(number != undef) {
528 goTo(number);
529 break;
530 }
531 case 32: // spacebar
532 case 34: // page down
533 case 39: // rightkey
534 case 40: // downkey
535 if(number != undef) {
536 go(number);
537 } else if (!incrementals[snum] || incpos >= incrementals[snum].length) {
538 go(1);
539 } else {
540 subgo(1);
541 }
542 break;
543 case 33: // page up
544 case 37: // leftkey
545 case 38: // upkey
546 if(number != undef) {
547 go(-1 * number);
548 } else if (!incrementals[snum] || incpos <= 0) {
549 go(-1);
550 } else {
551 subgo(-1);
552 }
553 break;
554 case 65: // a/utoplay
555 startPlay();
556 break;
557 case 72: // h
558 case 36: // home
559 goTo(0);
560 break;
561 case 69: // e
562 case 35: // end
563 goTo(smax-1);
564 break;
565 case 70: // f/ade transitions on/off
566 switchFade();
567 break;
568 case 76: // l/ooping on/off
569 switchLoop();
570 break;
571 case 83: // s/ound support on/off
572 toggleSounds();
573 break;
574 case 27: // escape
575 case 81: // q
576 if(!isOp) byby();
577 break;
578 case 67: // c
579 showHide('k');
580 break;
581 case 78: // n
582 createNotesWindow();
583 break;
584 }
585 if (key.which < 48 || key.which > 57) {
586 number = undef;
587 } else {
588 if (window.event && isParentOrSelf(window.event.srcElement, 'controls')) return;
589 if (key.target && isParentOrSelf(key.target, 'controls')) return;
590 number = (((number != undef) ? number : 0) * 10) + (key.which - 48);
591 }
592 }
593 }
594 return false;
595 }
596
597 function clicker(e) {
598 number = undef;
599 var target;
600 if (window.event) {
601 target = window.event.srcElement;
602 e = window.event;
603 } else {
604 target = e.target;
605 }
606 if (target.href != null || hasValue(target.rel, 'external') || isParentOrSelf(target, 'controls') || isParentOrSelf(target,'embed') || isParentOrSelf(target,'object')) return true;
607 if (!helpmode) {
608 if (!e.which || e.which == 1) {
609 if (!incrementals[snum] || incpos >= incrementals[snum].length) {
610 go(1);
611 } else {
612 subgo(1);
613 }
614 }
615 } else {
616 dumpHelpReq();
617 }
618 }
619
620 function findSlide(hash) {
621 var target = null;
622 var slides = GetElementsWithClassName('*','slide');
623 for (var i = 0; i < slides.length; i++) {
624 var targetSlide = slides[i];
625 if ( (targetSlide.name && targetSlide.name == hash)
626 || (targetSlide.id && targetSlide.id == hash) ) {
627 target = targetSlide;
628 break;
629 }
630 }
631 while(target != null && target.nodeName != 'BODY') {
632 if (hasClass(target, 'slide')) {
633 return parseInt(target.id.slice(5));
634 }
635 target = target.parentNode;
636 }
637 return null;
638 }
639
640 function slideJump() {
641 if (window.location.hash == null) return;
642 var sregex = /^#slide(\d+)$/;
643 var matches = sregex.exec(window.location.hash);
644 var dest = null;
645 if (matches != null) {
646 dest = parseInt(matches[1]);
647 } else {
648 dest = findSlide(window.location.hash.slice(1));
649 }
650 if (dest != null)
651 go(dest - snum);
652 }
653
654 function fixLinks() {
655 var thisUri = window.location.href;
656 thisUri = thisUri.slice(0, thisUri.length - window.location.hash.length);
657 var aelements = document.getElementsByTagName('A');
658 for (var i = 0; i < aelements.length; i++) {
659 var a = aelements[i].href;
660 var slideID = a.match('\#slide[0-9]{1,2}');
661 if ((slideID) && (slideID[0].slice(0,1) == '#')) {
662 var dest = findSlide(slideID[0].slice(1));
663 if (dest != null) {
664 if (aelements[i].addEventListener) {
665 aelements[i].addEventListener("click", new Function("e",
666 "if (document.getElementById('slideProj').disabled) return;" +
667 "go("+dest+" - snum); " +
668 "if (e.preventDefault) e.preventDefault();"), true);
669 } else if (aelements[i].attachEvent) {
670 aelements[i].attachEvent("onclick", new Function("",
671 "if (document.getElementById('slideProj').disabled) return;" +
672 "go("+dest+" - snum); " +
673 "event.returnValue = false;"));
674 }
675 }
676 }
677 }
678 }
679
680 function externalLinks() {
681 if (!document.getElementsByTagName) return;
682 var anchors = document.getElementsByTagName('a');
683 for (var i=0; i<anchors.length; i++) {
684 var anchor = anchors[i];
685 if (anchor.getAttribute('href') && hasValue(anchor.rel, 'external')) {
686 anchor.target = '_blank';
687 addClass(anchor,'external');
688 }
689 }
690 }
691
692 function permaLink() {
693 document.getElementById('plink').href = window.location.pathname + '#slide' + snum;
694 }
695
696 function createControls() {
697 var controlsDiv = document.getElementById("controls");
698 if (!controlsDiv) return;
699 var hider = ' onmouseover="showHide(\'s\');" onmouseout="showHide(\'h\');"';
700 var hideDiv, hideList = '';
701 if (controlVis == 'hidden') {
702 hideDiv = hider;
703 } else {
704 hideList = hider;
705 }
706 if(isOp) {
707 var str = '';
708 }else {
709 var str = '<a accesskey="t" id="sheet" title="toggle CSS" href="javascript:toggle();">&plusmn;<\/a>';
710 }
711 if(isIE) {
712 var tmp = "move around&xA0;until the color&xA0;change to red!";
713 }else if(isS2) {
714 var tmp = "move around\r\nuntil the color\r\nchange to red!";
715 }else {
716 var tmp = "move around until color change to red!";
717 }
718 if(isIE) {
719 controlsDiv.innerHTML = str +
720 '<form action="#" id="controlForm"' + hideDiv + '>' +
721 '<div id="navLinks" title="press [backspace] for keyboard help!"><ul>' +
722 '<li id="show-notes"><a href="javascript:createNotesWindow();" accesskey="n" title="show Notes"><\/a><\/li>' +
723 '<li id="toggle"><a href="javascript:toggle();" accesskey="t" title="toggle CSS"><\/a><\/li>' +
724 '<li id="zero"><a href="javascript:goTo(0);" accesskey="h" title="goto Start Slide"><\/a><\/li>' +
725 '<li id="prev"><a href="javascript:go(-1);" accesskey="y" title="previous Slide"><\/a><\/li>' +
726 '<li id="next"><a href="javascript:go(1);" accesskey="x" title="next Slide"><\/a><\/li>' +
727 '<li id="last"><a href="javascript:goTo(smax-1);" accesskey="e" title="goto Last Slide"><\/a><\/li>' +
728 '<li id="lst" style="vertical-align: middle; width: 160px;"><select style="cursor: auto; width: 160px; height: auto;" id="jumplist" title="select named Slide" onchange="go(\'j\');"><\/select><\/li>' +
729 '<li id="auto"><a class="isoff" href="javascript:togglePlay();" accesskey="a" title="Auto Play"><\/a><\/li>' +
730 '<li id="pause"><a class="isoff" href="javascript:pausePlay();" accesskey="p" title="Pause"><\/a><\/li>' +
731 '<li id="loop"><a class="isoff" href="javascript:switchLoop();" accesskey="l" title="Loop"><\/a><\/li>' +
732 '<li id="del" style="vertical-align: middle; width: 52px;"><select style="cursor: auto; width: 52px; height: auto;" id="delaylist" title="select Delay" onchange="setDelay();"><option value="90">90<\/option><option value="75">75<\/option><option value="60">60<\/option><option value="45">45<\/option><option value="30">30<\/option><option value="20">20<\/option><option value="15">15<\/option><option value="10">10<\/option><option value="5">5<\/option><\/select><\/li>' +
733 '<\/ul><\/div><\/form>';
734 }else {
735 controlsDiv.innerHTML = str +
736 '<form action="#" id="controlForm"' + hideDiv + '>' +
737 '<div id="navLinks" title="press [backspace] or double click this area for keyboard help!" ondblclick="createHelpReq();"><ul>' +
738 '<li id="exit"><a href="javascript:byby();" accesskey="q" title="exit Show"><\/a><\/li>' +
739 '<li id="show-notes"><a href="javascript:createNotesWindow();" accesskey="n" title="show Notes"><\/a><\/li>' +
740 '<li id="toggle"><a href="javascript:toggle();" accesskey="t" title="toggle CSS"><\/a><\/li>' +
741 '<li class="vr"><\/li>' +
742 '<li id="zero"><a href="javascript:goTo(0);" accesskey="h" title="goto Start Slide"><\/a><\/li>' +
743 '<li id="prev"><a href="javascript:go(-1);" accesskey="y" title="previous Slide"><\/a><\/li>' +
744 '<li id="next"><a href="javascript:go(1);" accesskey="x" title="next Slide"><\/a><\/li>' +
745 '<li id="last"><a href="javascript:goTo(smax-1);" accesskey="e" title="goto Last Slide"><\/a><\/li>' +
746 '<li id="lst"><a id="list" style="cursor:wait;" title="' + tmp + '"><\/a><select id="jumplist" title="select named Slide" onchange="go(\'j\');"><\/select><\/li>' +
747 '<li id="fadeLinks" class="vr"><\/li>' +
748 '<li id="fade"><a class="isoff" href="javascript:switchFade();" accesskey="f" title="Transions"><\/a><\/li>' +
749 '<li id="audioLinks" class="vr"><\/li>' +
750 '<li id="audio"><a class="isoff" href="javascript:toggleSounds();" accesskey="s" title="Sounds" ><\/a><\/li>' +
751 '<li id="vol"><a id="volume" style="cursor:wait;" title="' + tmp + '"><\/a><select id="volumelist" title="select Volume" onchange="setVolume();"><option value="100">100<\/option><option value="90">90<\/option><option value="80">80<\/option><option value="70">70<\/option><option value="60">60<\/option><option value="50">50<\/option><option value="40">40<\/option><option value="30">30<\/option><option value="20">20<\/option><option value="10">10<\/option><option value="0">0<\/option><\/select><\/li>' +
752 '<li id="autoLinks" class="vr"><\/li>' +
753 '<li id="auto"><a class="isoff" href="javascript:togglePlay();" accesskey="a" title="Auto Play"><\/a><\/li>' +
754 '<li id="pause"><a class="isoff" href="javascript:pausePlay();" accesskey="p" title="Pause"><\/a><\/li>' +
755 '<li id="loop"><a class="isoff" href="javascript:switchLoop();" accesskey="l" title="Loop"><\/a><\/li>' +
756 '<li id="del"><a id="delay" style="cursor:wait;" title="' + tmp + '"><\/a><select id="delaylist" title="select Delay" onchange="setDelay();"><option value="90">90<\/option><option value="75">75<\/option><option value="60">60<\/option><option value="45">45<\/option><option value="30">30<\/option><option value="20">20<\/option><option value="15">15<\/option><option value="10">10<\/option><option value="5">5<\/option><\/select><\/li>' +
757 '<\/ul>' +
758 '<a href="http://s5.netzgesta.de" target="_blank" title="S5 Reloaded"><img style="position: absolute; right: 0; bottom: 0;" src="data:image/png;charset=utf-8;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAgCAYAAAASYli2AAAABGdBTUEAANbY1E9YMgAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAYpSURBVHjaYvz//z8DOYCRkZEZRAEx0Ij/f2HiAAHEgqYIpACkkB1J7g8Q/wLRIJ1QNSB5fiDmAOLvQKHPQPoHSB4ggFiQDGMCUnxALAPECkAsBLIdiD8A8SMgfghU8wlqkTgQK1ZVVWldv3792fr16y8D+c9AhgMEECPIy1DDRIDYAojdzMzMWNXV1UG2/v/y5Qvzw4cPP587d24/kH8Gar/uwoULQ+/cufNFXFyciZmZ+UVmZuZKoFmvAQII5kJOIDbi4uKK2Llz53EbG5vP6GGWn5+vMWnSpJtA5jcg5v327Rtnc3PzfSD79+rVq2WBNBtIHUAAwQzkAWKzBQsWnIUZFhISovXmzZsfkpKSDD09PY8kJCR+QtWCguGvrKwsz7Rp07Q4ODh+srCwgILiH0gSIIBgBrICsUBoaCgorBiANgqvXbtWDMg8AcQf9+7d+x0o9xbI/gJV/3fVqlUvmJiY/gIdcaWhoYETahEDQADBDPwNxO9h3gNpBiq6f/HiRbWjR4+yvnr16grQNbeh6kCWsxkYGIhClT8yNDQUgyYhBoAAYoIKfgXi06mpqUowQ+vr6x+uW7fu0suXL8+uWbOGS0BAwB7kC6jXvqmoqLDIyclxzZo1S4udnR2WtBgAAggWyyCXSgOxZUxMjGpWVtY7S0vLr8iRsnnzZl4/P7/DQCYoYtSA2DApKUkVGNNPDh06dBrIvwU06xNAAMEM5AIKqAOxCjQsmHl5eXWdnJx4N2zYcB4prd4CUpfwJRuAAGJCimULoGYpbm5uZ5DBnz9/5tq4caPWkSNHeJEc+g0aTFzfv3/nACabjzk5OW8FBQVloLmHASCAYJECUiTg7+//HJiQTzY2NsrfvXv3n7m5+T5YMgJGEkjDS2gY/pKRkeHt7Ow0Bsb0v9+/fz+HxTJAAMG8DHKFLTC9aRUXF79BT9Qgw4CWHAAy70FdYgjEDgkJCTpWVlYMQBfeAaaMPqBZbwECCGYgMzQGQSleCehS0X///jEDvf9lxYoVoOTyAIjfANX+BqrlBrL1gLFf09vb+0FaWvoHMBctA6USUKQABBAjrPiCliKg7AOKIG5ougLlju9Ipc1foDJWqMWGhYWFtsBg4RISEnrg5uY2BWQgQACxIBkGMkQKijmRfPwXWuI8ASp7DQ1vEP4DDO8PwBzzDJheT0CLPQaAAEJOh0o8zAzeihwMiv+gGZ0B4sz/bIwM797/YTh1/wfDIWj5qAfMmtFnzpz5ICIiwqKoqPgjKChoOtCs5wABhJyXpUCGzddgOIethJ71jEFi1nNwgQrKz8zv37//097eDop15qVLl0pAzWAACCAWhEMYOJFdduELA++b3wxsTIwMfzmYGH6xMDG8gYYpKAg+cnJy/gB6VwuYZFiA7E+wvAwQQCy46ozexwzG17+BYx6UVE4B8Vmo68CRFR0dDQo3UAHBBUwJ4lCLGAACCNnAv4zQxAkCxbIMZ0EuBIYb98EPDFo3voGTzjOogVzArGf969cvNmC2+wssHD7BDAQIIBakmHwPDPy3MAMNeBhgpfbbVEkGhqQbDJaXvjI8BPJB4jz79u37DcwlP+fPn38NuTwECCBkA1+8+8Nwtusxg+STHwwcP/8z8EuwMXA1KjBcBSlwEmRgBhrID/U2O7QMBIEHxsbGkrAwBAggmIGgNMT64AfDWyB+By0EQMVZlC0/wwsXQYa38hzgCGGBWv5ZU1OT4c+fP8yLFi1SA3r5Haw8BAggmIGg5KBpJ8BgeOYTg8S3f2DN/OxMDNwgw0AKnv0EJ+avsITu7u6+EZqzQEHwHFqaMwAEEAtShS/pLcTwrU+Z4QwsyQANOwIL06tfGV5BqwmQWoGKigoLYJnJvWPHjhstLS169vb2M0DqAAIIVh6CXHT/9ndIawEUITCXgUDrQwbGbe8YjkJdAzZQVVVV/t69e8LAgtUYaNgxWKQABBByacMHzfTK9gIMYkBZpj//GT4c+8gAKm1AsfseqPYPtHTXAtaEacBqlgHoyq+srKw3XV1dFwHlvwEEECNyYwmp3cIJjbUf0DbLP7RGEg+0bcMCjQxQzH8BWQgQQIzktr5wAYAAYmKgMgAIMAAp8Fx3osz1lgAAAABJRU5ErkJggg==" width="20" height="32" alt="S5" \/><\/a>' +
759 '<\/div><\/form>';
760 }
761 if (controlVis == 'hidden') {
762 var hidden = document.getElementById('navLinks');
763 } else {
764 var hidden = document.getElementById('jumplist');
765 }
766 addClass(hidden,'hideme');
767 }
768
769 function fontScale() { // causes layout problems in FireFox that get fixed if browser's Reload is used; same may be true of other Gecko-based browsers
770 if (!s5mode && !isOp) return false;
771 var hScreen = screen.width; var vScreen = screen.height;
772 var vWindow = window.outerHeight; var hWindow = window.outerWidth;
773 if (isOp && s5mode && defaultView=='slideshow' && ((hScreen != hWindow) || (vScreen != vWindow))) {
774 toggle();
775 return false;
776 }
777 if (isOp && !s5mode && ((hScreen != hWindow) || (vScreen != vWindow))) return false;
778 if (isOp && !s5mode && (hScreen == hWindow) && (vScreen == vWindow)) toggle();
779 var vScale = 48; // both yield 16 (the usual browser default) at 1024x768
780 var hScale = 64; // perhaps should auto-calculate based on theme's declared value?
781 if (window.innerHeight) {
782 var vSize = window.innerHeight;
783 var hSize = window.innerWidth;
784 } else if (document.documentElement.clientHeight) {
785 var vSize = document.documentElement.clientHeight;
786 var hSize = document.documentElement.clientWidth;
787 } else if (document.body.clientHeight) {
788 var vSize = document.body.clientHeight;
789 var hSize = document.body.clientWidth;
790 } else {
791 var vSize = 700; // assuming 1024x768, minus chrome and such equals 8:5
792 var hSize = 1024; // these do not account for kiosk mode or Opera Show
793 }
794 var newSize = Math.min(Math.round(vSize/vScale),Math.round(hSize/hScale));
795 extendImgSizes(newSize); // scalable images extension
796 extendCanSizes(newSize); // scalable canvas extension
797 extendObjSizes(newSize); // scalable object extension
798 fontSize(newSize,"px");
799 if(!isS2 || firstTime==0) {
800 generateCanvas(); // dynamic canvas extension
801 }
802 if (isGe) { // hack to counter incremental reflow bugs
803 var obj = document.getElementsByTagName('body')[0];
804 obj.style.visibility = 'hidden';
805 obj.style.display = 'none';
806 obj.style.display = 'block';
807 obj.style.visibility = 'visible';
808 changeOpac(100,'slide' + snum);
809 shiftOpacity('slide' + snum,10);
810 window.setTimeout("fixReflow()",10);
811 }else {
812 setListPos(); // invisible select extension
813 }
814 }
815
816 function fixReflow() {
817 shiftOpacity('slide' + snum,10);
818 window.setTimeout("finishReflow()",10);
819 }
820 function finishReflow() {
821 setListPos(); // invisible select extension
822 }
823
824 function fontSize(val,fmt) {
825 var value = val + fmt;
826 if (!(s5ss = document.getElementById('s5ss'))) {
827 if (!document.createStyleSheet) {
828 document.getElementsByTagName('head')[0].appendChild(s5ss = document.createElement('style'));
829 s5ss.setAttribute('media','screen, projection');
830 s5ss.setAttribute('id','s5ss');
831 } else {
832 document.createStyleSheet();
833 document.s5ss = document.styleSheets[document.styleSheets.length - 1];
834 }
835 }
836 if (!(document.s5ss && document.s5ss.addRule)) {
837 while (s5ss.lastChild) s5ss.removeChild(s5ss.lastChild);
838 s5ss.appendChild(document.createTextNode('html {font-size: ' + value + ' !important;}'));
839 } else {
840 document.s5ss.addRule('html','font-size: ' + value + ' !important;');
841 }
842 }
843
844 function windowChange() {
845 fontScale();
846 }
847
848 function notOperaFix() {
849 slideCSS = document.getElementById('slideProj').href;
850 var slides = document.getElementById('slideProj');
851 var outline = document.getElementById('outlineStyle');
852 slides.setAttribute('media','screen');
853 outline.disabled = true;
854 if (isGe) {
855 slides.setAttribute('href','null'); // Gecko fix
856 slides.setAttribute('href',slideCSS); // Gecko fix
857 }
858 if ((isIE && notIE7) && document.styleSheets && document.styleSheets[0]) {
859 document.styleSheets[0].addRule('img', 'behavior: url(ui/graphic_support/iepngfix.htc)');
860 document.styleSheets[0].addRule('div', 'behavior: url(ui/graphic_support/iepngfix.htc)');
861 document.styleSheets[0].addRule('.slide', 'behavior: url(ui/graphic_support/iepngfix.htc)');
862 }
863 }
864
865 function getIncrementals(obj) {
866 var incrementals = new Array();
867 if (!obj)
868 return incrementals;
869 var children = obj.childNodes;
870 for (var i = 0; i < children.length; i++) {
871 var child = children[i];
872 if (hasClass(child, 'incremental')) {
873 if (child.nodeName == 'OL' || child.nodeName == 'UL') {
874 removeClass(child, 'incremental');
875 for (var j = 0; j < child.childNodes.length; j++) {
876 if (child.childNodes[j].nodeType == 1) {
877 addClass(child.childNodes[j], 'incremental');
878 }
879 }
880 } else {
881 incrementals[incrementals.length] = child;
882 removeClass(child,'incremental');
883 }
884 }
885 if (hasClass(child, 'show-first')) {
886 if (child.nodeName == 'OL' || child.nodeName == 'UL') {
887 removeClass(child, 'show-first');
888 if (child.childNodes[isGe].nodeType == 1) {
889 removeClass(child.childNodes[isGe], 'incremental');
890 }
891 } else {
892 incrementals[incrementals.length] = child;
893 }
894 }
895 incrementals = incrementals.concat(getIncrementals(child));
896 }
897 return incrementals;
898 }
899
900 function createIncrementals() {
901 var incrementals = new Array();
902 for (var i = 0; i < smax; i++) {
903 incrementals[i] = getIncrementals(document.getElementById('slide'+i));
904 }
905 return incrementals;
906 }
907
908 function trap(e) {
909 if (!e) {
910 e = event;
911 e.which = e.keyCode;
912 }
913 try {
914 modifierKey = e.ctrlKey || e.altKey || e.metaKey;
915 }
916 catch(e) {
917 modifierKey = false;
918 }
919 return modifierKey || e.which == 0;
920 }
921
922 // notes extension
923 function noteLabel() { // Gives notes id's to match parent slides
924 var notes = GetElementsWithClassName('div','notes');
925 for (var i = 0; i < notes.length; i++) {
926 var note = notes[i];
927 var id = 'note' + note.parentNode.id.substring(5);
928 note.setAttribute('id',id);
929 }
930 resetElapsedSlide();
931 resetRemainingTime();
932 window.setInterval('updateElaspedTime()', 1000);
933 }
934
935 function createNotesWindow() { // creates a window for our notes
936 if (!s5NotesWindow || s5NotesWindow.closed) { // Create the window if it doesn't exist
937 s5NotesWindowLoaded = false;
938 // Note: Safari has a tendency to ignore window options preferring to default to the settings of the parent window, grr.
939 s5NotesWindow = window.open('ui/s5-notes.html', 's5NotesWindow', 'top=0,left=0');
940 }
941 if (s5NotesWindowLoaded) { // Load the current note if the Note HTML has loaded
942 loadNote();
943 } else { // Keep trying...
944 window.setTimeout('createNotesWindow()', 50);
945 }
946 }
947
948 function loadNote() {
949 // Loads a note into the note window
950 var notes = nextNotes = '<em class="disclaimer">There are no notes for this slide.</em>';
951 if (document.getElementById('note' + snum)) {
952 notes = document.getElementById('note' + snum).innerHTML;
953 }
954 if (document.getElementById('note' + (snum + 1))) {
955 nextNotes = document.getElementById('note' + (snum + 1)).innerHTML;
956 }
957
958 var jl = document.getElementById('jumplist');
959 var slideTitle = jl.options[jl.selectedIndex].text.replace(/^\d+\s+:\s+/, '') + ((jl.selectedIndex) ? ' (' + jl.selectedIndex + '/' + (smax - 1) + ')' : '');
960 if (incrementals[snum].length > 0) {
961 slideTitle += ' <small>[' + incpos + '/' + incrementals[snum].length + ']</small>';
962 }
963 if (jl.selectedIndex < smax - 1) {
964 var nextTitle = jl.options[jl.selectedIndex + 1].text.replace(/^\d+\s+:\s+/, '') + ((jl.selectedIndex + 1) ? ' (' + (jl.selectedIndex + 1) + '/' + (smax - 1) + ')' : '');
965 } else {
966 var nextTitle = '[end of slide show]';
967 }
968
969 if (s5NotesWindow && !s5NotesWindow.closed && s5NotesWindow.document) {
970 s5NotesWindow.document.getElementById('slide').innerHTML = slideTitle;
971 s5NotesWindow.document.getElementById('notes').innerHTML = notes;
972 s5NotesWindow.document.getElementById('next').innerHTML = nextTitle;
973 s5NotesWindow.document.getElementById('nextnotes').innerHTML = nextNotes;
974 }
975 resetElapsedSlide();
976 }
977
978 function minimizeTimer(id) {
979 var obj = s5NotesWindow.document.getElementById(id);
980 if (hasClass(obj,'collapsed')) {
981 removeClass(obj,'collapsed');
982 } else {
983 addClass(obj,'collapsed');
984 }
985 }
986
987 function resetElapsedTime() {
988 presentationStart = new Date();
989 slideStart = new Date();
990 updateElaspedTime();
991 }
992
993 function resetElapsedSlide() {
994 if (snum != previousSlide) {
995 slideStart = new Date();
996 previousSlide = snum;
997 updateElaspedTime();
998 }
999 }
1000
1001 function updateElaspedTime() {
1002 if (!s5NotesWindowLoaded || !s5NotesWindow || s5NotesWindow.closed) return;
1003 var now = new Date();
1004 var ep = s5NotesWindow.document.getElementById('elapsed-presentation');
1005 var es = s5NotesWindow.document.getElementById('elapsed-slide');
1006 ep.innerHTML = formatTime(now.valueOf() - presentationStart.valueOf());
1007 es.innerHTML = formatTime(now.valueOf() - slideStart.valueOf());
1008 }
1009
1010 function resetRemainingTime() {
1011 if (!s5NotesWindowLoaded || !s5NotesWindow || s5NotesWindow.closed) return;
1012 var startField = s5NotesWindow.document.getElementById('startFrom');
1013 startFrom = readTime(startField.value);
1014 countdown.remaining = startFrom * 60000; // convert to msecs
1015 countdown.start = new Date().valueOf();
1016 countdown.end = countdown.start + countdown.remaining;
1017 var tl = s5NotesWindow.document.getElementById('timeLeft');
1018 var timeLeft = formatTime(countdown.remaining);
1019 tl.innerHTML = timeLeft;
1020 }
1021
1022 function updateRemainingTime() {
1023 if (!s5NotesWindowLoaded || !s5NotesWindow || s5NotesWindow.closed) return;
1024 var tl = s5NotesWindow.document.getElementById('timeLeft');
1025 var now = new Date();
1026 if (countdown.state == 'run') {
1027 countdown.remaining = countdown.end - now;
1028 }
1029 tl.style.color = '';
1030 tl.style.backgroundColor = '';
1031 if (countdown.remaining >= 0) {
1032 var timeLeft = formatTime(countdown.remaining);
1033 removeClass(tl,'overtime');
1034 if (countdown.remaining < 300000) {
1035 tl.style.color = 'rgb(' + (255-Math.round(countdown.remaining/2000)) + ',0,0)';
1036 tl.style.backgroundColor = 'rgb(255,255,' + (Math.round(countdown.remaining/2000)) + ')';
1037 }
1038 } else {
1039 var timeLeft = '-' + formatTime(-countdown.remaining);
1040 addClass(tl,'overtime');
1041 }
1042 tl.innerHTML = timeLeft;
1043 }
1044
1045 function toggleRemainingTime() {
1046 if (countdown.state == 'pause') countdown.state = 'run'; else countdown.state = 'pause';
1047 if (countdown.state == 'pause') {
1048 window.clearInterval(countdown.timer);
1049 }
1050 if (countdown.state == 'run') {
1051 countdown.start = new Date().valueOf();
1052 countdown.end = countdown.start + countdown.remaining;
1053 countdown.timer = window.setInterval('updateRemainingTime()', 1000);
1054 }
1055 }
1056
1057 function alterRemainingTime(amt) {
1058 var change = amt * 60000; // convert to msecs
1059 countdown.end += change;
1060 countdown.remaining += change;
1061 updateRemainingTime();
1062 }
1063
1064 function formatTime(msecs) {
1065 var time = new Date(msecs);
1066
1067 var hrs = time.getUTCHours() + ((time.getUTCDate() -1) * 24); // I doubt anyone will spend more than 24 hours on a presentation or single slide but just in case...
1068 hrs = (hrs < 10) ? '0'+hrs : hrs;
1069 if (hrs == 'NaN' || isNaN(hrs)) hrs = '--';
1070
1071 var min = time.getUTCMinutes();
1072 min = (min < 10) ? '0'+min : min;
1073 if (min == 'NaN' || isNaN(min)) min = '--';
1074
1075 var sec = time.getUTCSeconds();
1076 sec = (sec < 10) ? '0'+sec : sec;
1077 if (sec == 'NaN' || isNaN(sec)) sec = '--';
1078
1079 return hrs + ':' + min + ':' + sec;
1080 }
1081
1082 function readTime(val) {
1083 var sregex = /:/;
1084 var matches = sregex.exec(val);
1085 if (matches == null) {
1086 return val;
1087 } else {
1088 var times = val.split(':');
1089 var hours = parseInt(times[0]);
1090 var mins = parseInt(times[1]);
1091 var total = (hours * 60) + mins;
1092 return total;
1093 }
1094 }
1095 // notes extension
1096
1097 // startup process
1098 function createSlideShow() {
1099 defaultCheck();
1100 if(!isIE) createDetector(); // (degrade IE) scalable images extension
1101 if(opac!=0 || isIE) { // &&!isIE (degrade IE)
1102 tranSitions = false;
1103 fadeModus = false;
1104 }
1105 if(tranSitions && document.getElementById && document.createElement){
1106 createProgress();
1107 var nop=document.getElementById('StartupControl');
1108 nop.onload = dumpProgress;
1109 }else {
1110 startup();
1111 showAll();
1112 setListPos(true); // invisible select extension
1113 panelSetup();
1114 audioSetup(); // audio extension
1115 if(isS2 && firstTime>=1) {
1116 generateCanvas(); // dynamic canvas extension
1117 } firstTime = 0;
1118 }
1119 }
1120
1121 function defaultCheck() {
1122 var allMetas = document.getElementsByTagName('meta');
1123 for (var i = 0; i< allMetas.length; i++) {
1124 if (allMetas[i].name == 'defaultView') {
1125 defaultView = allMetas[i].content;
1126 }
1127 if (allMetas[i].name == 'controlVis') {
1128 controlVis = allMetas[i].content;
1129 }
1130 if (allMetas[i].name == 'tranSitions') {
1131 tranSitions = (allMetas[i].content == "true") ? true : false;
1132 fadeModus = (tranSitions == true) ? true : false;
1133 }
1134 if (allMetas[i].name == 'fadeDuration') {
1135 var tmp = parseInt(allMetas[i].content);
1136 fadeDuration = Math.max(200,Math.min(tmp,2000));
1137 }
1138 if (allMetas[i].name == 'incrDuration') {
1139 var tmp = parseInt(allMetas[i].content);
1140 incrDuration = Math.max(50,Math.min(tmp,500));
1141 }
1142 if (allMetas[i].name == 'autoMatic') {
1143 autoMatic = (allMetas[i].content == "true") ? true : false;
1144 }
1145 if (allMetas[i].name == 'playLoop') {
1146 playLoop = (allMetas[i].content == "true") ? true : false;
1147 }
1148 if (allMetas[i].name == 'playDelay') {
1149 var tmp = parseInt(allMetas[i].content);
1150 playDelay = Math.max(5,Math.min(tmp,90))*1000;
1151 playDelay = (fadeModus == true) ? (playDelay+(2*fadeDuration)) : playDelay;
1152 }
1153 if (allMetas[i].name == 'audioSupport') {
1154 audioSupport = (allMetas[i].content == "true") ? true : false;
1155 }
1156 if (allMetas[i].name == 'audioVolume') {
1157 var tmp = parseInt(allMetas[i].content);
1158 audioVolume = Math.max(0,Math.min(tmp,100));
1159 }
1160 if (allMetas[i].name == 'audioError') {
1161 audioError = (allMetas[i].content == "true") ? true : false;
1162 }
1163 }
1164 }
1165
1166 function createProgress() {
1167 var obj = document.getElementsByTagName("body")[0].firstChild;
1168 var pg = document.createElement('div');
1169 pg.id = "StartupProgress";
1170 pg.style.position = 'absolute';
1171 pg.style.left = 0 + 'px';
1172 pg.style.top = 0 + 'px';
1173 pg.style.width = 100 + '%';
1174 pg.style.height = 100 + '%';
1175 pg.style.margin = 0 + 'px';
1176 pg.style.padding = 0 + 'px';
1177 if (isIE) {
1178 pg.style.filter = "alpha(opacity=100)";
1179 }else {
1180 pg.style.opacity = 1.0;
1181 }
1182 pg.style.zIndex = 9999;
1183 pg.style.backgroundColor="rgb(255, 255, 255)";
1184 pg.style.textAlign = "center";
1185 pg.style.verticalAlign = "middle";
1186 pg.style.backgroundPosition="center center";
1187 pg.style.backgroundRepeat="no-repeat";
1188 pg.style.backgroundImage="url(ui/graphic_support/progress.gif)";
1189 document.getElementsByTagName("body")[0].insertBefore(pg,obj);
1190
1191 var im = document.createElement('img');
1192 im.id = "StartupControl";
1193 im.src = "ui/graphic_support/blank.gif?" + new Date().valueOf();
1194 document.getElementsByTagName("body")[0].appendChild(im);
1195 }
1196
1197 function startup() {
1198 createControls(); // hallvord
1199 slideLabel();
1200 incrementals = createIncrementals();
1201 noteLabel(); // [SI:060104] must follow slideLabel()
1202 loadNote();
1203 fixLinks();
1204 externalLinks();
1205 fontScale();
1206 if (!isOp) {
1207 if(isIE) {
1208 document.getElementById('lst').style.backgroundImage = 'none';
1209 document.getElementById('del').style.backgroundImage = 'none';
1210 }else {
1211 document.getElementById('audio').style.backgroundImage = 'none';
1212 }
1213 notOperaFix();
1214 }else if(isOp) {
1215 var obj = document.getElementById('exit');
1216 obj.firstChild.style.visibility = 'hidden';
1217 document.getElementById('exit').style.opacity = 0.5;
1218 obj = document.getElementById('toggle');
1219 obj.firstChild.style.visibility = 'hidden';
1220 document.getElementById('toggle').style.opacity = 0.5;
1221 document.getElementById('jumplist').style.visibility = 'hidden';
1222 document.getElementById('list').style.visibility = 'hidden';
1223 document.getElementById('lst').style.opacity = 0.5;
1224 obj = document.getElementById('audio');
1225 obj.firstChild.style.visibility = 'hidden';
1226 document.getElementById('audio').style.opacity = 0.5;
1227 document.getElementById('volumelist').style.visibility = 'hidden';
1228 document.getElementById('volume').style.visibility = 'hidden';
1229 document.getElementById('vol').style.opacity = 0.5;
1230 document.getElementById('delaylist').style.visibility = 'hidden';
1231 document.getElementById('delay').style.visibility = 'hidden';
1232 document.getElementById('del').style.opacity = 0.5;
1233 }
1234 slideJump();
1235 if (defaultView == 'outline') toggle();
1236 document.onkeyup = keys;
1237 document.onkeypress = trap;
1238 document.onclick = clicker;
1239 }
1240
1241 function preloadImgages() {
1242 var temp = '';
1243 var objects = document.getElementsByTagName('img');
1244 for (var i=0; i < objects.length; i++) {
1245 if(objects[i].src != '') {
1246 temp = new Image();
1247 temp.src = objects[i].src;
1248 }
1249 }
1250 }
1251
1252 function showAll() {
1253 var obj1 = GetElementsWithClassName('div','presentation')[0];
1254 if(!obj1) var obj1 = GetElementsWithClassName('ol','presentation')[0];
1255 var obj2 = GetElementsWithClassName('div','layout')[0];
1256 if(!obj1){}else {obj1.style.display = 'block'};
1257 if(!obj2){}else {obj2.style.display = 'block'};
1258 }
1259
1260 function dumpProgress() {
1261 document.body.removeChild(document.getElementById('StartupControl'));
1262 startup();
1263 preloadImgages();
1264 showAll();
1265 createSoundManagerScript();
1266 shiftOpacity('StartupProgress',1000);
1267 window.setTimeout("removeProgress()",1000);
1268 }
1269
1270 function removeProgress() {
1271 document.body.removeChild(document.getElementById('StartupProgress'));
1272 setListPos(true); // invisible select extension
1273 panelSetup();
1274 audioSetup(); // audio extension
1275 if(isS2 && firstTime>=1) {
1276 generateCanvas(); // dynamic canvas extension
1277 } firstTime = 0;
1278 }
1279 function panelSetup() {
1280 if(playPause) {
1281 var obj = document.getElementById('pause'); changeClass(obj,'ison');
1282 }
1283 if(playLoop) {
1284 var obj = document.getElementById('loop'); changeClass(obj,'ison');
1285 }
1286 if(audioSupport && !isIE && !isOp) {
1287 var obj = document.getElementById('audio'); changeClass(obj,'ison');
1288 }
1289 if(fadeModus && !isIE) {
1290 var obj = document.getElementById('fade'); changeClass(obj,'ison');
1291 }
1292 if(autoMatic) {
1293 var obj = document.getElementById('auto'); changeClass(obj,'ison');
1294 startPlay();
1295 }
1296 if(audioVolume && !isIE && !isOp) {
1297 var idx = 0;
1298 if(audioVolume >= 95 && audioVolume <= 100) {idx = 0;}
1299 else if(audioVolume >= 85 && audioVolume < 95) {idx = 1;}
1300 else if(audioVolume >= 75 && audioVolume < 85) {idx = 2;}
1301 else if(audioVolume >= 65 && audioVolume < 75) {idx = 3;}
1302 else if(audioVolume >= 55 && audioVolume < 65) {idx = 4;}
1303 else if(audioVolume >= 45 && audioVolume < 55) {idx = 5;}
1304 else if(audioVolume >= 35 && audioVolume < 45) {idx = 6;}
1305 else if(audioVolume >= 25 && audioVolume < 35) {idx = 7;}
1306 else if(audioVolume >= 15 && audioVolume < 25) {idx = 8;}
1307 else if(audioVolume >= 5 && audioVolume < 15) {idx = 9;}
1308 else {idx = 10;}
1309 document.getElementById('volumelist').selectedIndex = idx;
1310 }
1311 if(playDelay && !isOp) {
1312 var idx = 0; var vol = parseInt(playDelay/1000);
1313 if(vol >= 83 && vol <= 90) {idx = 0;}
1314 else if(vol >= 68 && vol < 83) {idx = 1;}
1315 else if(vol >= 53 && vol < 68) {idx = 2;}
1316 else if(vol >= 38 && vol < 53) {idx = 3;}
1317 else if(vol >= 25 && vol < 38) {idx = 4;}
1318 else if(vol >= 18 && vol < 25) {idx = 5;}
1319 else if(vol >= 13 && vol < 18) {idx = 6;}
1320 else if(vol >= 8 && vol < 13) {idx = 7;}
1321 else {idx = 8;}
1322 document.getElementById('delaylist').selectedIndex = idx;
1323 }
1324 }
1325 // startup process
1326
1327 // shutdown process
1328 function byby() {
1329 stopPlay();
1330 if(tranSitions && fadeModus && s5mode && !isOp) {
1331 fadeoutSound(curSoundID,true); // audio support
1332 var pg = document.createElement('div');
1333 pg.id = "GoodBy";
1334 pg.style.position = 'absolute';
1335 pg.style.left = 0 + 'px';
1336 pg.style.top = 0 + 'px';
1337 pg.style.width = 100 + '%';
1338 pg.style.height = 100 + '%';
1339 pg.style.margin = 0 + 'px';
1340 pg.style.padding = 0 + 'px';
1341 if (isIE) {
1342 pg.style.filter = "alpha(opacity=0)";
1343 }else {
1344 pg.style.opacity = 0.0;
1345 }
1346 pg.style.zIndex = 9999;
1347 pg.style.backgroundColor="rgb(255, 255, 255)";
1348 pg.style.textAlign = "center";
1349 pg.style.verticalAlign = "middle";
1350 pg.style.backgroundPosition="center center";
1351 pg.style.backgroundRepeat="no-repeat";
1352 pg.style.backgroundImage="url(ui/graphic_support/finish.gif)";
1353 document.getElementsByTagName("body")[0].appendChild(pg);
1354 shiftOpacity('GoodBy',1000);
1355 window.setTimeout("history.back()",1000);
1356 }else {
1357 stopSound(curSoundID);
1358 history.back();
1359 }
1360 }
1361 // shutdown process
1362
1363 // scalable images extension
1364 function createDetector() {
1365 var em = document.createElement('div');
1366 em.id='EMSizeControl'; em.style.position="absolute"; em.style.left="-999px";
1367 em.style.width="1em"; em.style.height="1em"; em.style.opacity=0.0;
1368 document.getElementsByTagName("body")[0].appendChild(em);
1369 var nop=document.getElementById('EMSizeControl');
1370 if(!nop||findPosX(nop)!=-999) {}else {
1371 opac=document.getElementById('EMSizeControl').style.opacity;
1372 empx=document.getElementById('EMSizeControl').offsetHeight;
1373 document.body.removeChild(document.getElementById('EMSizeControl'));
1374 var objects = document.getElementsByTagName('img');
1375 var j = 0; var i = 0; var k = 0; var d; var obj;
1376 for (i=0; i < objects.length; i++) {
1377 if(objects[i].className.match(/^scale/i)) {
1378 images[j] = objects[i];
1379 ++j;
1380 }
1381 }
1382 var objects = document.getElementsByTagName('canvas'); j = 0;
1383 for (i=0; i < objects.length; i++) {
1384 if(objects[i].className.match(/^scale/i)) {
1385 canvas[objects[i].id] = objects[i];
1386 if(j==0) {
1387 if(objects[i].getContext) {
1388 canvasSupport = true;
1389 }
1390 ++j;
1391 }
1392 }
1393 }
1394 if(canvasSupport!=true) {
1395 for (d in canvas) {
1396 canvas[d].setAttribute("width",1);
1397 canvas[d].setAttribute("height",1);
1398 }
1399 }
1400 var objects = document.getElementsByTagName('table');
1401 j = 0; k = 0; l = 0; var w; var h; var tmp; var cnt;
1402 for (i=0; i < objects.length; i++) {
1403 if(objects[i].className.match(/^piechart/i)) {
1404 tmp = objects[i].id;
1405 cnt = tmp.split("_");
1406 obj = cnt[0] + "_canvas";
1407 if(canvas[obj]) {
1408 w = canvas[obj].getAttribute("width");
1409 h = canvas[obj].getAttribute("height");
1410 if(w>0&&h>0) {
1411 piecharts[j] = objects[i];
1412 em = piecharts[j].getAttribute("summary");
1413 if(em != "") em = "," + em;
1414 piecharts[j].setAttribute("summary", w + "," + h + em);
1415 ++j;
1416 }
1417 }
1418 }
1419 if(objects[i].className.match(/^barchart/i)) {
1420 tmp = objects[i].id;
1421 cnt = tmp.split("_");
1422 obj = cnt[0] + "_canvas";
1423 if(canvas[obj]) {
1424 w = canvas[obj].getAttribute("width");
1425 h = canvas[obj].getAttribute("height");
1426 if(w>0&&h>0) {
1427 barcharts[k] = objects[i];
1428 em = barcharts[k].getAttribute("summary");
1429 if(em != "") em = "," + em;
1430 barcharts[k].setAttribute("summary", w + "," + h + em);
1431 ++k;
1432 }
1433 }
1434 }
1435 if(objects[i].className.match(/^linechart/i)) {
1436 tmp = objects[i].id;
1437 cnt = tmp.split("_");
1438 obj = cnt[0] + "_canvas";
1439 if(canvas[obj]) {
1440 w = canvas[obj].getAttribute("width");
1441 h = canvas[obj].getAttribute("height");
1442 if(w>0&&h>0) {
1443 linecharts[l] = objects[i];
1444 em = linecharts[l].getAttribute("summary");
1445 if(em != "") em = "," + em;
1446 linecharts[l].setAttribute("summary", w + "," + h + em);
1447 ++l;
1448 }
1449 }
1450 }
1451 }
1452 objects = document.getElementsByTagName('object'); j = 0; i = 0;
1453 for (i=0; i < objects.length; i++) {
1454 if(objects[i].className.match(/^scale/i)) {
1455 medias[j] = objects[i]; ++j;
1456 if(!isIE) {
1457 if(objects[i].getAttributeNode("classid")) objects[i].removeAttributeNode(objects[i].getAttributeNode("classid"));
1458 if(objects[i].getAttributeNode("codebase")) objects[i].removeAttributeNode(objects[i].getAttributeNode("codebase"));
1459 }
1460 }
1461 }
1462 }
1463 }
1464 function extendImgSizes(f) {
1465 if(empx>0) {
1466 var q = (f/empx); var w = 0; var h = 0;
1467 for(var i=0; i < images.length; i++) {
1468 w=images[i].getAttribute("width",0);
1469 h=images[i].getAttribute("height",0);
1470 if(w>0&&h>0) {
1471 images[i].style.width=Math.floor(w*q)+"px";
1472 images[i].style.height=Math.floor(h*q)+"px";
1473 }
1474 }
1475 }
1476 }
1477
1478 function extendCanSizes(f) {
1479 if(empx>0 && canvasSupport) {
1480 var q = (f/empx); var w = 0; var h = 0; var tmp = ""; var cnt; var obj;
1481 for(var i=0; i < piecharts.length; i++) {
1482 if(piecharts[i].getAttribute("summary")) {
1483 tmp = piecharts[i].getAttribute("summary");
1484 cnt = tmp.split(",");
1485 if(cnt[0].match(/^[1-9][0-9]+/)) w = parseInt(cnt[0]);
1486 if(cnt[1].match(/^[1-9][0-9]+/)) h = parseInt(cnt[1]);
1487 if(w>0&&h>0) {
1488 tmp = piecharts[i].id;
1489 cnt = tmp.split("_");
1490 obj = cnt[0] + "_canvas";
1491 canvas[obj].setAttribute("width",Math.floor(w*q));
1492 canvas[obj].setAttribute("height",Math.floor(h*q));
1493 canvas[obj].style.width=Math.floor(w*q)+"px";
1494 canvas[obj].style.height=Math.floor(h*q)+"px";
1495 }
1496 }
1497 }
1498 for(var i=0; i < barcharts.length; i++) {
1499 if(barcharts[i].getAttribute("summary")) {
1500 tmp = barcharts[i].getAttribute("summary");
1501 cnt = tmp.split(",");
1502 if(cnt[0].match(/^[1-9][0-9]+/)) w = parseInt(cnt[0]);
1503 if(cnt[1].match(/^[1-9][0-9]+/)) h = parseInt(cnt[1]);
1504 if(w>0&&h>0) {
1505 tmp = barcharts[i].id;
1506 cnt = tmp.split("_");
1507 obj = cnt[0] + "_canvas";
1508 canvas[obj].setAttribute("width",Math.floor(w*q));
1509 canvas[obj].setAttribute("height",Math.floor(h*q));
1510 canvas[obj].style.width=Math.floor(w*q)+"px";
1511 canvas[obj].style.height=Math.floor(h*q)+"px";
1512 }
1513 }
1514 }
1515 for(var i=0; i < linecharts.length; i++) {
1516 if(linecharts[i].getAttribute("summary")) {
1517 tmp = linecharts[i].getAttribute("summary");
1518 cnt = tmp.split(",");
1519 if(cnt[0].match(/^[1-9][0-9]+/)) w = parseInt(cnt[0]);
1520 if(cnt[1].match(/^[1-9][0-9]+/)) h = parseInt(cnt[1]);
1521 if(w>0&&h>0) {
1522 tmp = linecharts[i].id;
1523 cnt = tmp.split("_");
1524 obj = cnt[0] + "_canvas";
1525 canvas[obj].setAttribute("width",Math.floor(w*q));
1526 canvas[obj].setAttribute("height",Math.floor(h*q));
1527 canvas[obj].style.width=Math.floor(w*q)+"px";
1528 canvas[obj].style.height=Math.floor(h*q)+"px";
1529 }
1530 }
1531 }
1532 }
1533 }
1534 function extendObjSizes(f) {
1535 if(empx>0) {
1536 var q = (f/empx); var w = 0; var h = 0;
1537 for(var i=0; i < medias.length; i++) {
1538 w=medias[i].getAttribute("width",0);
1539 h=medias[i].getAttribute("height",0);
1540 if(w>0&&h>0) {
1541 medias[i].style.width=Math.floor(w*q)+"px";
1542 medias[i].style.height=Math.floor(h*q)+"px";
1543 }
1544 }
1545 }
1546 }
1547 function findPosX(obj) {
1548 var posLeft = 0;
1549 while (obj.offsetParent) {
1550 posLeft += obj.offsetLeft;
1551 obj = obj.offsetParent;
1552 }
1553 return posLeft;
1554 }
1555 function findPosY(obj) {
1556 var posTop = 0;
1557 while (obj.offsetParent) {
1558 posTop += obj.offsetTop;
1559 obj = obj.offsetParent;
1560 }
1561 return posTop;
1562 }
1563 // scalable images extension
1564
1565 // canvas chart extension
1566 function deg2rad(degrees) {
1567 return Math.PI *degrees/180;
1568 }
1569 function rad2deg(radians) {
1570 return 180.0 *radians/Math.PI;
1571 }
1572 function circle_point_x(radians, diameter) {
1573 var x = Math.cos(radians)*(diameter/2);
1574 return x;
1575 }
1576 function circle_point_y(radians, diameter) {
1577 var y = Math.sin(radians)*(diameter/2);
1578 return y;
1579 }
1580 function roundTo(val,dig) {
1581 var num = val;
1582 if (val > 8191 && val < 10485) {
1583 val = val-5000;
1584 num = Math.round(val*Math.pow(10,dig))/Math.pow(10,dig);
1585 num = num+5000;
1586 } else {
1587 num = Math.round(val*Math.pow(10,dig))/Math.pow(10,dig);
1588 }
1589 return num;
1590 }
1591 function searchColor(value) {
1592 for (var dat in colorNames) {
1593 if(dat==value) return colorNames[dat];
1594 }
1595 return false;
1596 }
1597 function scanColor(value) {
1598 if(value.match(/^#[0-9a-f][0-9a-f][0-9a-f]$/i)) {
1599 var val1 = value.substr(1,1).toLowerCase();
1600 var val2 = value.substr(2,1).toLowerCase();
1601 var val3 = value.substr(3,1).toLowerCase();
1602 value = '#' + val1 + val1 + val2 + val2 + val3 + val3;
1603 }
1604 if(!value.match(/^#[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]$/i)) {
1605 var tmp = searchColor(value.toLowerCase());
1606 if(!tmp) {}else{value = tmp;}
1607 }
1608 if(!value.match(/^#[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]$/i)) {
1609 value = '#000000';
1610 }
1611 return value.toLowerCase();
1612 }
1613 function hex2rgb(val,trans) {
1614 if(val.length==7) {
1615 var tp1 = Math.max(0,Math.min(parseInt(val.substr(1,2),16),255));
1616 var tp2 = Math.max(0,Math.min(parseInt(val.substr(3,2),16),255));
1617 var tp3 = Math.max(0,Math.min(parseInt(val.substr(5,2),16),255));
1618 return 'rgba(' + tp1 + ',' + tp2 + ',' + tp3 + ',' + trans + ')';
1619 }
1620 }
1621 function trim(str) {
1622 return (str.replace(/\s+$/,"").replace(/^\s+/,""));
1623 }
1624 function roundedRect(ctx,x,y,width,height,radius){
1625 ctx.beginPath();
1626 ctx.moveTo(x,y+radius);
1627 ctx.lineTo(x,y+height-radius);
1628 ctx.quadraticCurveTo(x,y+height,x+radius,y+height);
1629 ctx.lineTo(x+width-radius,y+height);
1630 ctx.quadraticCurveTo(x+width,y+height,x+width,y+height-radius);
1631 ctx.lineTo(x+width,y+radius);
1632 ctx.quadraticCurveTo(x+width,y,x+width-radius,y);
1633 ctx.lineTo(x+radius,y);
1634 ctx.quadraticCurveTo(x,y,x,y+radius);
1635 ctx.closePath();
1636 }
1637 function drawString(ctx, text, fc, tx, ty) {
1638 var xp = 0; var c = "";
1639 ctx.beginPath();
1640 for (var i = 0; i < text.length; i++) {
1641 c = text[i];
1642 ctx.drawImage(font, signs[c].sx, signs[c].sy, signs[c].sw, signs[c].sh, tx+xp, ty, signs[c].sw*fc, signs[c].sh*fc);
1643 xp += (signs[c].sw*fc);
1644 }
1645 ctx.closePath();
1646 }
1647 function strokeString(ctx, txt, col, fh, tx, ty) {
1648 var fw = fh*0.666666; var lw = fh*0.125;
1649 var ls = lw/2; var cr = lw; var xp = 0;
1650 ctx.lineCap = "round"; ctx.lineJoin = "round"
1651 ctx.lineWidth = lw; ctx.strokeStyle = col;
1652 for (var i = 0; i < txt.length; i++) {
1653 strokeSymbol(ctx, txt[i], ls, tx+xp, ty, fw, fh);
1654 xp += (txt[i]!="."?fw+cr:(fw/2)+cr);
1655 }
1656 }
1657 function strokeSymbol(ctx, symbol, fc, cx, cy, cw, ch) {
1658 ctx.beginPath();
1659 switch (symbol) {
1660 case "0":
1661 ctx.moveTo(cx+fc,cy+(ch*0.333333));
1662 ctx.arc(cx+(cw/2),cy+(cw/2),(cw/2)-fc,deg2rad(180),0, false);
1663 ctx.arc(cx+(cw/2),(cy+ch)-(cw/2),(cw/2)-fc,0,deg2rad(180), false);
1664 ctx.closePath();
1665 break;
1666 case "1":
1667 ctx.moveTo(cx+(cw*0.1)+fc,cy+ch-fc);
1668 ctx.lineTo(cx+cw-fc,cy+ch-fc);
1669 ctx.moveTo(cx+(cw*0.666666),cy+ch-fc);
1670 ctx.lineTo(cx+(cw*0.666666),cy+fc);
1671 ctx.lineTo(cx+(cw*0.25),cy+(ch*0.25));
1672 break;
1673 case "2":
1674 ctx.moveTo(cx+cw-fc,cy+(ch*0.8));
1675 ctx.lineTo(cx+cw-fc,cy+ch-fc);
1676 ctx.lineTo(cx+fc,cy+ch-fc);
1677 ctx.arc(cx+(cw/2),cy+(cw*0.425),(cw*0.425)-fc,deg2rad(45),deg2rad(-180), true);
1678 break;
1679 case "3":
1680 ctx.moveTo(cx+(cw*0.1)+fc,cy+fc);
1681 ctx.lineTo(cx+(cw*0.9)-fc,cy+fc);
1682 ctx.arc(cx+(cw/2),cy+ch-(cw*0.5),(cw*0.5)-fc,deg2rad(-90),deg2rad(180), false);
1683 break;
1684 case "4":
1685 ctx.moveTo(cx+(cw*0.75),cy+ch-fc);
1686 ctx.lineTo(cx+(cw*0.75),cy+fc);
1687 ctx.moveTo(cx+cw-fc,cy+(ch*0.666666));
1688 ctx.lineTo(cx+fc,cy+(ch*0.666666));
1689 ctx.lineTo(cx+(cw*0.75),cy+fc);
1690 ctx.moveTo(cx+cw-fc,cy+ch-fc);
1691 ctx.lineTo(cx+(cw*0.5),cy+ch-fc);
1692 break;
1693 case "5":
1694 ctx.moveTo(cx+(cw*0.9)-fc,cy+fc);
1695 ctx.lineTo(cx+(cw*0.1)+fc,cy+fc);
1696 ctx.lineTo(cx+(cw*0.1)+fc,cy+(ch*0.333333));
1697 ctx.arc(cx+(cw/2),cy+ch-(cw*0.5),(cw*0.5)-fc,deg2rad(-80),deg2rad(180), false);
1698 break;
1699 case "6":
1700 ctx.moveTo(cx+fc,cy+ch-(cw*0.5)-fc);
1701 ctx.arc(cx+(cw/2),cy+ch-(cw*0.5),(cw*0.5)-fc,deg2rad(-180),deg2rad(180), false);
1702 ctx.bezierCurveTo(cx+fc,cy+fc,cx+fc,cy+fc,cx+(cw*0.9)-fc,cy+fc);
1703 ctx.moveTo(cx+(cw*0.9)-fc,cy+fc);
1704 break;
1705 case "7":
1706 ctx.moveTo(cx+(cw*0.5),cy+ch-fc);
1707 ctx.lineTo(cx+cw-fc,cy+fc);
1708 ctx.lineTo(cx+(cw*0.1)+fc,cy+fc);
1709 ctx.lineTo(cx+(cw*0.1)+fc,cy+(ch*0.25)-fc);
1710 break;
1711 case "8":
1712 ctx.moveTo(cx+(cw*0.92)-fc,cy+(cw*0.59));
1713 ctx.arc(cx+(cw/2),cy+(cw*0.45),(cw*0.45)-fc,deg2rad(25),deg2rad(-205), true);
1714 ctx.arc(cx+(cw/2),cy+ch-(cw*0.5),(cw*0.5)-fc,deg2rad(-135),deg2rad(-45), true);
1715 ctx.closePath();
1716 ctx.moveTo(cx+(cw*0.79),cy+(ch*0.47));
1717 ctx.lineTo(cx+(cw*0.21),cy+(ch*0.47));
1718 break;
1719 case "9":
1720 ctx.moveTo(cx+cw-fc,cy+(cw*0.5));
1721 ctx.arc(cx+(cw/2),cy+(cw*0.5),(cw*0.5)-fc,deg2rad(0),deg2rad(360), false);
1722 ctx.bezierCurveTo(cx+cw-fc,cy+ch-fc,cx+cw-fc,cy+ch-fc,cx+(cw*0.1)+fc,cy+ch-fc);
1723 break;
1724 case "%":
1725 ctx.moveTo(cx+fc,cy+(ch*0.75));
1726 ctx.lineTo(cx+cw-fc,cy+(ch*0.25));
1727 ctx.moveTo(cx+(cw*0.505),cy+(cw*0.3));
1728 ctx.arc(cx+(cw*0.3),cy+(cw*0.3),(cw*0.3)-fc,deg2rad(0),deg2rad(360), false);
1729 ctx.moveTo(cx+(cw*0.905),cy+ch-(cw*0.3));
1730 ctx.arc(cx+(cw*0.7),cy+ch-(cw*0.3),(cw*0.3)-fc,deg2rad(0),deg2rad(360), false);
1731 break;
1732 case ".":
1733 ctx.moveTo(cx+(cw*0.25),cy+ch-fc-fc);
1734 ctx.arc(cx+(cw*0.25),cy+ch-fc-fc,fc,deg2rad(0),deg2rad(360), false);
1735 ctx.closePath();
1736 break;
1737 default:
1738 break;
1739 }
1740 ctx.stroke();
1741 }
1742 function drawBar(ctx,x,y,width,height,color,value,textdiv){
1743 var rw = width/2; var rh = rw/2;
1744 height = Math.max(height,rw);
1745 var dh = Math.max(height-(2*rh),0.1); var S2L;
1746 var xx = rw/8; var yy = rh/4;
1747 var yo = rh/2; y = y - yy;
1748 if(canvas_noshadow <= 0 && canvas_noshade <= 0) {
1749 ctx.save();
1750 S2L = ctx.createRadialGradient(x+rw+rh,y+height-rw+yy+rh,0,x+rw,y+height-rw+yy,rw);
1751 S2L.addColorStop(0, 'rgba(0,0,0,0.5)');
1752 S2L.addColorStop(0.7, 'rgba(0,0,0,0.25)');
1753 S2L.addColorStop(0.9, 'rgba(0,0,0,0.1)');
1754 S2L.addColorStop(1, 'rgba(0,0,0,0)');
1755 ctx.fillStyle = S2L;
1756 ctx.scale(1,0.5);
1757 ctx.translate(xx,y+height+yy);
1758 if(isOp){
1759 ctx.fillRect(x,y+yy+height-width,width,width);
1760 }else {
1761 ctx.arc(x+rw,y+yy+height-width,width,0,deg2rad(360), false);
1762 ctx.fill();
1763 }
1764 ctx.restore();
1765 }else if(canvas_noshadow <= 0 && canvas_noshade >= 1) {
1766 ctx.fillStyle = 'rgba(0,0,0,0.2)';
1767 ctx.fillRect(x+yo,y+rh+yo+yo,width,dh);
1768 }
1769
1770 if(canvas_noshade <= 0) {
1771 ctx.beginPath();
1772 ctx.moveTo(x,y+rh);
1773 ctx.lineTo(x,y+rh+dh);
1774 ctx.bezierCurveTo(x,y+height,x+width,y+height,x+width,y+rh+dh)
1775 ctx.lineTo(x+width,y+rh);
1776 ctx.bezierCurveTo(x+width,y,x,y,x,y+rh)
1777 ctx.closePath();
1778 ctx.fillStyle = color;
1779 ctx.fill();
1780 S2L = ctx.createLinearGradient(x,y+(height/2),x+width,y+(height/2));
1781 S2L.addColorStop(0, 'rgba(255,255,255,0.75)');
1782 S2L.addColorStop(0.2, 'rgba(255,255,255,0)');
1783 S2L.addColorStop(0.3, 'rgba(0,0,0,0)');
1784 S2L.addColorStop(0.5, 'rgba(0,0,0,0.1)');
1785 S2L.addColorStop(0.9, 'rgba(0,0,0,0.35)');
1786 S2L.addColorStop(1, 'rgba(0,0,0,0.3)');
1787 ctx.beginPath();
1788 ctx.moveTo(x,y+rh);
1789 ctx.lineTo(x,y+rh+dh);
1790 ctx.bezierCurveTo(x,y+height,x+width,y+height,x+width,y+rh+dh)
1791 ctx.lineTo(x+width,y+rh);
1792 ctx.bezierCurveTo(x+width,y,x,y,x,y+rh)
1793 ctx.closePath();
1794 ctx.fillStyle = S2L;
1795 ctx.fill();
1796 ctx.beginPath();
1797 ctx.moveTo(x+width,y+rh);
1798 ctx.bezierCurveTo(x+width,y,x,y,x,y+rh)
1799 ctx.bezierCurveTo(x,y+(rh*2),x+width,y+(rh*2),x+width,y+rh)
1800 ctx.closePath();
1801 ctx.fillStyle = color;
1802 ctx.fill();
1803 S2L = ctx.createLinearGradient(x+rw-(width*0.15),y-2,x+rw+(width*0.15),y+(2.1*rh));
1804 S2L.addColorStop(0, 'rgba(255,255,255,0.9)');
1805 S2L.addColorStop(0.5, 'rgba(255,255,255,0)');
1806 S2L.addColorStop(0.6, 'rgba(0,0,0,0)');
1807 S2L.addColorStop(1, 'rgba(0,0,0,0.3)');
1808 ctx.beginPath();
1809 ctx.moveTo(x+width,y+rh);
1810 ctx.bezierCurveTo(x+width,y,x,y,x,y+rh)
1811 ctx.bezierCurveTo(x,y+(rh*2),x+width,y+(rh*2),x+width,y+rh)
1812 ctx.closePath();
1813 ctx.fillStyle = S2L;
1814 ctx.fill();
1815 S2L = ctx.createLinearGradient(x+rw-(width*0.15),y-2,x+rw+(width*0.15),y+(2.1*rh));
1816 S2L.addColorStop(0, 'rgba(255,255,255,0.9)');
1817 S2L.addColorStop(0.5, 'rgba(255,255,255,0)');
1818 S2L.addColorStop(0.6, 'rgba(0,0,0,0)');
1819 S2L.addColorStop(1, 'rgba(0,0,0,0.1)');
1820 ctx.beginPath();
1821 ctx.moveTo(x+width,y+rh);
1822 ctx.bezierCurveTo(x+width,y,x,y,x,y+rh)
1823 ctx.bezierCurveTo(x,y+(rh*2),x+width,y+(rh*2),x+width,y+rh)
1824 ctx.closePath();
1825 ctx.strokeStyle = S2L;
1826 ctx.stroke();
1827 }else {
1828 ctx.fillStyle = color;
1829 ctx.fillRect(x,y+rh+yo,width,dh);
1830 }
1831 ctx.lineCap = "butt";
1832 ctx.lineWidth = 1;
1833 ctx.fillStyle = 'rgba(255,255,255,0.5)';
1834 var bw = width; var bh = bw/4;
1835 var th = roundTo(bh*0.75,0); var tf = bh/80;
1836 var c; var w;
1837 if(canvas_notext <= 0) {
1838 if(canvas_htmltext <= 0) {
1839 w = '"' + per + '"';
1840 if(w.indexOf(".")!=-1) {
1841 c = w.length+0.5;
1842 w = parseFloat(c-2)*parseFloat(48*tf);
1843 bw = parseFloat(c-1)*parseFloat(48*tf);
1844 }else {
1845 c = w.length;
1846 w = parseFloat(c-1)*parseFloat(48*tf);
1847 bw = parseFloat(c)*parseFloat(48*tf);
1848 }
1849 roundedRect(ctx,x+(width/2)-(bw/2),y,bw,bh,bh/4);
1850 ctx.fill();
1851 if(canvas_imgtext <= 0) {
1852 strokeString(ctx, value + "%","rgba(48,48,48,1)", th, x+(width/2)-(w/2), y+((bh-th)/2));
1853 }else {
1854 drawString(ctx, value + "%", tf, x+(width/2)-(w/2), y+((bh-th)/2.2));
1855 }
1856 }else {
1857 var bh = bw/3; var th = roundTo(bh*0.75,0);
1858 roundedRect(ctx,x,y,bw,bh,bh/4);
1859 ctx.fill();
1860 var obj = document.createElement('div');
1861 obj.style.position = "absolute";
1862 obj.style.overflow = "hidden";
1863 obj.style.textAlign = "center";
1864 obj.style.width = bw + "px";
1865 obj.style.left = x + "px";
1866 obj.style.top = y+((bh-th)/2.2) + "px";
1867 obj.appendChild(document.createTextNode(per + "%"));
1868 textdiv.appendChild(obj);
1869 }
1870
1871 }
1872 }
1873 function drawLine(ctx,x,y,width,height,dist,array,factor,color,fill){
1874 if(fill <= 0){
1875 var style = hex2rgb(color,0.5);
1876 ctx.lineJoin = "miter";
1877 ctx.beginPath();
1878 ctx.moveTo(x,y+height);
1879 for (var i = 0; i < array.length; i++) {
1880 ctx.lineTo(x+(i*dist),y+height-(array[i]*factor));
1881 }
1882 ctx.lineTo(x+width,y+height);
1883 ctx.lineTo(x,y+height);
1884 ctx.closePath();
1885 ctx.fillStyle = style;
1886 ctx.fill();
1887 }
1888 ctx.lineJoin = "round";
1889 ctx.beginPath();
1890 ctx.moveTo(x,y+height-(array[0]*factor));
1891 for (var i = 0; i < array.length; i++) {
1892 ctx.lineTo(x+(i*dist),y+height-(array[i]*factor));
1893 }
1894 ctx.strokeStyle = color;
1895 ctx.stroke();
1896 }
1897 function setDataURL(cid) {
1898 if(cid.toDataURL) {
1899 var obj = document.getElementById(cid.id + "_link");
1900 if(obj) {
1901 obj.setAttribute("title", "To Data URL");
1902 obj.setAttribute("target", "_blank");
1903 obj.setAttribute("href", cid.toDataURL());
1904 }
1905 }
1906 }
1907 function get_input(dataobj,canvasobj,linechart) {
1908 var table = document.getElementById(dataobj);
1909 var canvas = document.getElementById(canvasobj);
1910 var row; var clm; var cnt = 0; var val = 0; var nme = ""; var col = "";
1911 if(canvas.getContext) {
1912 canvas_width = parseInt(canvas.style.width);
1913 canvas_height = parseInt(canvas.style.height);
1914 if(canvas_width >= 16 && canvas_height >= 16) {
1915 var tmp = table.getAttribute("summary");
1916 canvas_noshade = 0; canvas_noshadow = 0;
1917 canvas_notext = 0; canvas_imgtext = 0;
1918 canvas_htmltext = 0; canvas_nofill = 0;
1919 if(tmp.search(/noshadow/) != -1) canvas_noshadow = 1;
1920 if(tmp.search(/noshade/) != -1) canvas_noshade = 1;
1921 if(tmp.search(/nofill/) != -1) canvas_nofill = 1;
1922 if(tmp.search(/notext/) != -1) canvas_notext = 1;
1923 if(tmp.search(/htmltext/) != -1) canvas_htmltext = 1;
1924 if(tmp.search(/imgtext/) != -1) canvas_imgtext = 1;
1925 if(table.getAttribute("bgcolor")) {
1926 canvas_bgcolor = scanColor(table.getAttribute("bgcolor"));
1927 }
1928 ChartData = new Array(); colorSlice = new Array();
1929 if(table.getElementsByTagName("tr")[0].getElementsByTagName("th")[0]) cnt = 1;
1930 for(var r = cnt; r < table.getElementsByTagName("tr").length; r++) {
1931 row = table.getElementsByTagName("tr")[r];
1932 clm = row.getElementsByTagName("td").length;
1933 if(row.getElementsByTagName("td")[0].getAttribute("bgcolor")) {
1934 col = scanColor(row.getElementsByTagName("td")[0].getAttribute("bgcolor")); val = 0;
1935 nme = trim(row.getElementsByTagName("td")[1].innerHTML.replace(/<[^>]+>/g,""));
1936 if(!linechart) {
1937 if(clm > 3) {
1938 for(var z = 2; z < clm; z++) {
1939 val += parseFloat(row.getElementsByTagName("td")[z].innerHTML.replace(/<[^>]+>/g,""));
1940 }
1941 }else {
1942 val = parseFloat(row.getElementsByTagName("td")[2].innerHTML.replace(/<[^>]+>/g,""));
1943 }
1944 if(!isNaN(val) && val > 0 && nme != '') {
1945 colorSlice[r-cnt] = col; ChartData[nme] = Math.abs(val);
1946 }else {
1947 break;
1948 }
1949 }else {
1950 val = 0; i = 0;
1951 if(clm > 3 && nme != '') {
1952 ChartData[r-cnt] = new Array();
1953 colorSlice[r-cnt] = col;
1954 for(var z = 2; z < clm; z++) {
1955 val = Math.abs(parseFloat(row.getElementsByTagName("td")[z].innerHTML.replace(/<[^>]+>/g,"")));
1956 if(!isNaN(val) && val >= 0) {
1957 ChartData[r-cnt][i] = val; i++;
1958 }else {
1959 ChartData[r-cnt][i] = 0; i++;
1960 }
1961 }
1962 }else {
1963 break;
1964 }
1965 }
1966 }else {
1967 break;
1968 }
1969 }
1970 }
1971 }
1972 }
1973 function setPieChart(canvasobj,textobj) {
1974 var cd = (Math.min(canvas_width,canvas_height)/110)*100;
1975 var cp = cd*0.1; var cr = cd/2;
1976 var sr = cr*0.93; var cw = cd+cp; var ch = cw;
1977 var cx = (cd/2)+(cp/2); var cy = cx; var ct = 0;
1978 for (var data in ChartData) {
1979 ct += ChartData[data];
1980 }
1981 var poc = ct/100;
1982 var canvas = document.getElementById(canvasobj);
1983 if(canvas_htmltext >= 1) {
1984 if(document.getElementById(textobj)) {
1985 canvas.parentNode.removeChild(canvas.parentNode.lastChild);
1986 }
1987 }
1988 if(canvas.getContext) {
1989 var ctx = canvas.getContext('2d');
1990 if(canvas_bgcolor != "") {
1991 ctx.fillStyle = canvas_bgcolor;
1992 ctx.fillRect(0,0,cw,ch);
1993 }else {
1994 ctx.clearRect(0,0,cw,ch);
1995 }
1996 if(canvas_noshadow <= 0) {
1997 if(!isOp) {
1998 ctx.beginPath();
1999 var B2B = ctx.createRadialGradient(cx+(cr*0.1),cy+(cr*0.1),cr,cx+(cr*0.1),cy+(cr*0.1),sr*0.9);
2000 B2B.addColorStop(0, 'rgba(0,0,0,0)');
2001 B2B.addColorStop(1, 'rgba(0,0,0,0.5)');
2002 ctx.arc(cx+(cr*0.1),cy+(cr*0.1),cr,0,deg2rad(360), false);
2003 ctx.closePath();
2004 ctx.fillStyle = B2B;
2005 ctx.fill();
2006 }else {
2007 var B2B = ctx.createRadialGradient(cx+(cr*0.1),cy+(cr*0.1),0,cx+(cr*0.1),cy+(cr*0.1),cr);
2008 B2B.addColorStop(0, 'rgba(0,0,0,0.5)');
2009 B2B.addColorStop(0.87, 'rgba(0,0,0,0.5)');
2010 B2B.addColorStop(1, 'rgba(0,0,0,0)');
2011 ctx.fillStyle = B2B;
2012 ctx.fillRect(0,0,cw,ch);
2013 }
2014 }
2015 var val = 0; var deg = 0; var idx = 0; var data;
2016 for (data in ChartData) {
2017 val = ChartData[data]; sdeg = deg;
2018 deg += (val/ct)*deg2rad(360); edeg = deg;
2019 ctx.beginPath();
2020 ctx.moveTo(cx,cy);
2021 ctx.arc(cx,cy,cr,sdeg,edeg, false);
2022 ctx.lineTo(cx,cy);
2023 ctx.closePath();
2024 ctx.fillStyle = colorSlice[(idx++)];
2025 ctx.fill();
2026 }
2027 if(canvas_noshade <= 0) {
2028 ctx.beginPath();
2029 var W2T = ctx.createLinearGradient(cp*2,cp*2,cx,cy);
2030 W2T.addColorStop(0, 'rgba(255,255,255,0.8)');
2031 W2T.addColorStop(1, 'rgba(255,255,255,0)');
2032 ctx.moveTo(cx,cy);
2033 ctx.arc(cx,cy,sr,deg2rad(135),deg2rad(315), false);
2034 ctx.closePath();
2035 ctx.fillStyle = W2T;
2036 ctx.fill();
2037 ctx.beginPath();
2038 var T2B = ctx.createLinearGradient(cx,cy,cw-(cp*2),ch-(cp*2));
2039 T2B.addColorStop(0, 'rgba(0,0,0,0)');
2040 T2B.addColorStop(1, 'rgba(0,0,0,0.5)');
2041 ctx.moveTo(cx,cy);
2042 ctx.arc(cx,cy,sr,deg2rad(-45),deg2rad(135), false);
2043 ctx.closePath();
2044 ctx.fillStyle = T2B;
2045 ctx.fill();
2046 ctx.beginPath();
2047 var B2T = ctx.createLinearGradient(cx,cy,cw-(cp*1.9),ch-(cp*1.9));
2048 B2T.addColorStop(0, 'rgba(0,0,0,0)');
2049 B2T.addColorStop(1, 'rgba(0,0,0,0.6)');
2050 ctx.lineWidth = cr*0.07;
2051 ctx.lineCap = "round";
2052 ctx.moveTo(cx,cy);
2053 ctx.arc(cx,cy,cr*0.965,deg2rad(-45),deg2rad(135), false);
2054 ctx.closePath();
2055 ctx.strokeStyle = B2T;
2056 ctx.stroke();
2057 ctx.beginPath();
2058 var T2W = ctx.createLinearGradient(cx,cy,(cp*1.9),(cp*1.9));
2059 T2W.addColorStop(0, 'rgba(255,255,255,0)');
2060 T2W.addColorStop(1, 'rgba(255,255,255,0.6)');
2061 ctx.lineWidth = cr*0.07;
2062 ctx.lineCap = "round";
2063 ctx.moveTo(cx,cy);
2064 ctx.arc(cx,cy,cr*0.965,deg2rad(135),deg2rad(315), false);
2065 ctx.closePath();
2066 ctx.strokeStyle = T2W;
2067 ctx.stroke();
2068 }
2069 ctx.lineCap = "butt";
2070 ctx.lineWidth = 1;
2071 ctx.fillStyle = 'rgba(255,255,255,0.5)';
2072 var mpos = 0; var per = 0; var gx = 0;
2073 var gy = 0; var tx = 0; var ty = 0;
2074 var obj = ""; var w = 0; var c = 0;
2075 var bw = cr*0.45; var bh = cr*0.125;
2076 var th = roundTo(bh*0.75,0); var tf = bh/80;
2077 if(canvas_notext <= 0) {
2078 if(canvas_htmltext >= 1) {
2079 bw = (cr*0.365);
2080 canvas.parentNode.style.position = "relative";
2081 if(!document.getElementById(textobj)) {
2082 obj = document.createElement('div');
2083 obj.id = textobj;
2084 obj.style.color = "rgb(0,0,0)";
2085 obj.style.fontFamily = "Arial,sans-serif";
2086 obj.style.fontSize = th + "px";
2087 obj.style.zIndex = 11;
2088 canvas.parentNode.appendChild(obj);
2089 }
2090 var textdiv = document.getElementById(obj.id);
2091 }
2092 for (data in ChartData) {
2093 val = ChartData[data];
2094 sdeg = deg; mpos = deg+(((val/2)/ct)*deg2rad(360));
2095 deg += (val/ct)*deg2rad(360); edeg = deg;
2096 per = roundTo(val/poc,2);
2097 gx = circle_point_x(mpos, cd);
2098 gy = circle_point_y(mpos, cd);
2099 tx = parseFloat((cx+(2*Math.floor(cx + gx)))/3);
2100 ty = (cy+(2*Math.floor(cy + gy)))/3;
2101 if(canvas_htmltext <= 0) {
2102 w = '"' + per + '"';
2103 if(w.indexOf(".")!=-1) {
2104 c = w.length+0.5;
2105 w = parseFloat(c-2)*parseFloat(48*tf);
2106 bw = parseFloat(c-1)*parseFloat(48*tf);
2107 }else {
2108 c = w.length;
2109 w = parseFloat(c-1)*parseFloat(48*tf);
2110 bw = parseFloat(c)*parseFloat(48*tf);
2111 }
2112 roundedRect(ctx,(tx-(bw/2)),ty-(bh/2),bw,bh,bh/4);
2113 ctx.fill();
2114 if(canvas_imgtext >= 1) {
2115 drawString(ctx, per + "%", tf, tx-(w/2), ty-(th/1.8));
2116 }else {
2117 strokeString(ctx, per + "%","rgba(48,48,48,1)", th, tx-(w/2), ty-(th/2));
2118 }
2119 }else {
2120 roundedRect(ctx,(tx-(bw/2)),ty-(bh/2),bw,bh,bh/4);
2121 ctx.fill();
2122 obj = document.createElement('div');
2123 obj.style.position = "absolute";
2124 obj.style.overflow = "hidden";
2125 obj.style.textAlign = "center";
2126 obj.style.width = bw + "px";
2127 obj.style.left = (tx-(bw/2)) + "px";
2128 obj.style.top = ty-(th/1.8) + "px";
2129 obj.appendChild(document.createTextNode(per + "%"));
2130 textdiv.appendChild(obj);
2131 }
2132 }
2133 }
2134 }
2135 }
2136 function setBarChart(canvasobj,textobj) {
2137 var iw = canvas_width*0.9; var ih = canvas_height*0.9;
2138 var pw = canvas_width*0.05; var ph = canvas_height*0.05;
2139 var cm = 0; var ct = 0;
2140 for (var data in ChartData) {
2141 cm = Math.max(cm,ChartData[data]);
2142 ct += ChartData[data];
2143 }
2144 var hf = ih/cm; var bs = colorSlice.length;
2145 var bw = iw/(bs*1.1); var poc = ct/100;
2146 var th = roundTo((bw/3)*0.75,0);
2147 var canvas = document.getElementById(canvasobj);
2148 if(canvas.getContext) {
2149 var ctx = canvas.getContext('2d');
2150 if(canvas_bgcolor != "") {
2151 ctx.fillStyle = canvas_bgcolor;
2152 ctx.fillRect(0,0,canvas_width,canvas_height);
2153 }else {
2154 ctx.clearRect(0,0,canvas_width,canvas_height);
2155 }
2156 if(canvas_htmltext >= 1) {
2157 if(document.getElementById(textobj)) {
2158 canvas.parentNode.removeChild(canvas.parentNode.lastChild);
2159 }
2160 canvas.parentNode.style.position = "relative";
2161 if(!document.getElementById(textobj)) {
2162 var obj = document.createElement('div');
2163 obj.id = textobj;
2164 obj.style.color = "rgb(0,0,0)";
2165 obj.style.fontFamily = "Arial,sans-serif";
2166 obj.style.fontSize = th + "px";
2167 obj.style.zIndex = 11;
2168 canvas.parentNode.appendChild(obj);
2169 }
2170 var textdiv = document.getElementById(obj.id);
2171 }
2172 var cc = ""; var bh = 0; var idx = 0; var t = 0; per = 0;
2173 for (var data in ChartData) {
2174 per = roundTo(ChartData[data]/poc,2);
2175 bh = ChartData[data]*hf;
2176 drawBar(ctx,pw+(t*(bw*1.1)),ph+ih-bh,bw,bh,colorSlice[(idx++)],per,textdiv);
2177 t++;
2178 }
2179 }
2180 }
2181 function setLineChart(canvasobj,textobj) {
2182 var iw = canvas_width*0.9;
2183 var ih = canvas_height*0.9;
2184 var pw = canvas_width*0.05;
2185 var ph = canvas_height*0.05;
2186 var cm = 0;
2187 for (var i = 0; i < ChartData.length; i++) {
2188 for (var j = 0; j < ChartData[i].length; j++) {
2189 cm = Math.max(cm,ChartData[i][j]);
2190 }
2191 }
2192 var hf = (ih*0.95)/cm; var bw = iw;
2193 var dw = iw/(ChartData[0].length-1)
2194 var dh = ih/(ChartData[0].length-1)
2195 var ps = Math.min(pw,ph); lw = ps/4;
2196 var B2T;
2197 var canvas = document.getElementById(canvasobj);
2198 if(canvas.getContext) {
2199 var ctx = canvas.getContext('2d');
2200 if(canvas_bgcolor != "") {
2201 ctx.fillStyle = canvas_bgcolor;
2202 ctx.fillRect(0,0,canvas_width,canvas_height);
2203 }else {
2204 ctx.clearRect(0,0,canvas_width,canvas_height);
2205 }
2206 if(canvas_noshadow <= 0) {
2207 B2T = ctx.createLinearGradient(pw+ps,ph+ih+1,pw+ps+ps,ph+ih+1);
2208 B2T.addColorStop(0, 'rgba(0,0,0,0.0)');
2209 B2T.addColorStop(1, 'rgba(0,0,0,0.5)');
2210 ctx.fillStyle = B2T;
2211 ctx.beginPath();
2212 ctx.moveTo(pw+ps,ph+ih);
2213 ctx.lineTo(pw+ps,ph+ih+ps);
2214 ctx.lineTo(pw+ps+ps,ph+ih);
2215 ctx.closePath();
2216 ctx.fill();
2217 B2T = ctx.createLinearGradient(pw+ps+ps,ph+ih,pw+ps+ps,ph+ih+ps);
2218 B2T.addColorStop(0, 'rgba(0,0,0,0.5)');
2219 B2T.addColorStop(1, 'rgba(0,0,0,0.0)');
2220 ctx.fillStyle = B2T;
2221 ctx.beginPath();
2222 ctx.moveTo(pw+ps+ps,ph+ih);
2223 ctx.lineTo(pw+iw,ph+ih);
2224 ctx.lineTo(pw+ps+iw,ph+ih+ps);
2225 ctx.lineTo(pw+ps,ph+ih+ps);
2226 ctx.closePath();
2227 ctx.fill();
2228 var B2T = ctx.createLinearGradient(pw+iw+1,ph+ps,pw+iw+1,ph+ps+ps);
2229 B2T.addColorStop(0, 'rgba(0,0,0,0.0)');
2230 B2T.addColorStop(1, 'rgba(0,0,0,0.35)');
2231 ctx.fillStyle = B2T;
2232 ctx.beginPath();
2233 ctx.moveTo(pw+iw,ph+ps);
2234 ctx.lineTo(pw+iw,ph+ps+ps);
2235 ctx.lineTo(pw+iw+ps,ph+ps);
2236 ctx.closePath();
2237 ctx.fill();
2238 B2T = ctx.createLinearGradient(pw+iw,ph+ps+ps,pw+iw+ps,ph+ps+ps);
2239 B2T.addColorStop(0, 'rgba(0,0,0,0.35)');
2240 B2T.addColorStop(1, 'rgba(0,0,0,0.0)');
2241 ctx.fillStyle = B2T;
2242 ctx.beginPath();
2243 ctx.moveTo(pw+iw,ph+ps+ps);
2244 ctx.lineTo(pw+iw,ph+ih);
2245 ctx.lineTo(pw+iw+ps,ph+ih+ps);
2246 ctx.lineTo(pw+iw+ps,ph+ps);
2247 ctx.closePath();
2248 ctx.fill();
2249 }
2250 ctx.lineCap = "butt";
2251 ctx.lineWidth = lw/2;
2252 ctx.strokeStyle = "rgba(255,255,255,0.25)";
2253 if(canvas_nofill <= 0) {
2254 ctx.fillStyle = "rgba(240,240,240,0.8)";
2255 ctx.strokeStyle = "rgba(255,255,255,1)";
2256 ctx.fillRect(pw,ph,iw,ih);
2257 }
2258 for (var i = 0; i < ChartData[0].length-1; i++) {
2259 ctx.beginPath();
2260 ctx.moveTo(pw+(i*dw),ph);
2261 ctx.lineTo(pw+(i*dw),ph+ih);
2262 ctx.stroke();
2263 }
2264 for (var i = 1; i < ChartData[0].length; i++) {
2265 ctx.beginPath();
2266 ctx.moveTo(pw,ph+(i*dh));
2267 ctx.lineTo(pw+iw,ph+(i*dh));
2268 ctx.stroke();
2269 }
2270 ctx.lineWidth = lw;
2271 var cc = ""; var bh = 0; var idx = 0; var t = 0;
2272 for (var i = 0; i < ChartData.length; i++) {
2273 for (var j = 0; j < ChartData[i].length; j++) {
2274 t = Math.max(t,ChartData[i][j]);
2275 }
2276 bh = t*hf; cc = colorSlice[(idx++)];
2277 drawLine(ctx,pw,ph+ih-bh,bw,bh,dw,ChartData[i],hf,cc,canvas_nofill);
2278 }
2279 ctx.beginPath();
2280 ctx.moveTo(pw,ph);
2281 ctx.lineTo(pw,ph+ih);
2282 ctx.lineTo(pw+iw+(lw/2),ph+ih);
2283 ctx.strokeStyle = "rgba(48,48,48,1)";
2284 ctx.stroke();
2285 ctx.lineWidth = lw/2;
2286 B2T = ctx.createLinearGradient(pw,ph+ih,pw,ph+ih+ps);
2287 B2T.addColorStop(0, 'rgba(0,0,0,1)');
2288 B2T.addColorStop(0.5, 'rgba(0,0,0,1)');
2289 B2T.addColorStop(1, 'rgba(0,0,0,0)');
2290 ctx.strokeStyle = B2T;
2291 for (var i = 0; i < ChartData[0].length; i++) {
2292 ctx.beginPath();
2293 ctx.moveTo(pw+(i*dw),ph+ih);
2294 ctx.lineTo(pw+(i*dw),ph+ih+ps);
2295 ctx.stroke();
2296 }
2297 B2T = ctx.createLinearGradient(pw-ps,ph,pw,ph);
2298 B2T.addColorStop(0, 'rgba(0,0,0,0)');
2299 B2T.addColorStop(0.5, 'rgba(0,0,0,1)');
2300 B2T.addColorStop(1, 'rgba(0,0,0,1)');
2301 ctx.strokeStyle = B2T;
2302 for (var i = 1; i < ChartData[0].length; i++) {
2303 ctx.beginPath();
2304 ctx.moveTo(pw-ps,ph+(i*dh));
2305 ctx.lineTo(pw,ph+(i*dh));
2306 ctx.stroke();
2307 }
2308 }
2309 }
2310 function generateCanvas() {
2311 if(canvasSupport) {
2312 var canvasID; var tdataID; var textID;
2313 var tmp; var dat; var i; var j;
2314 for(i=0; i < piecharts.length; i++) {
2315 tmp = piecharts[i].id.split("_");
2316 tdataID = piecharts[i].id;
2317 canvasID = tmp[0] + "_canvas";
2318 textID = tmp[0] + "_text";
2319 if(document.getElementById(tdataID)) {
2320 get_input(tdataID,canvasID);
2321 if(colorSlice.length > 0) {
2322 j = 0; dat = ""; for(dat in ChartData) {j++; }
2323 if(j > 0 && j == colorSlice.length) {
2324 setPieChart(canvasID,textID);
2325 }
2326 }
2327 }
2328 }
2329 for(i=0; i < barcharts.length; i++) {
2330 tmp = barcharts[i].id.split("_");
2331 tdataID = barcharts[i].id;
2332 canvasID = tmp[0] + "_canvas";
2333 textID = tmp[0] + "_text";
2334 if(document.getElementById(tdataID)) {
2335 get_input(tdataID,canvasID);
2336 if(colorSlice.length > 0) {
2337 j = 0; dat = ""; for(dat in ChartData) {j++; }
2338 if(j > 0 && j == colorSlice.length) {
2339 setBarChart(canvasID,textID);
2340 }
2341 }
2342 }
2343 }
2344 for(i=0; i < linecharts.length; i++) {
2345 tmp = linecharts[i].id.split("_");
2346 tdataID = linecharts[i].id;
2347 canvasID = tmp[0] + "_canvas";
2348 textID = tmp[0] + "_text";
2349 if(document.getElementById(tdataID)) {
2350 get_input(tdataID,canvasID,true);
2351 if(colorSlice.length > 0) {
2352 if(ChartData.length == colorSlice.length) {
2353 setLineChart(canvasID,textID);
2354 }
2355 }
2356 }
2357 }
2358 }
2359 }
2360 // canvas chart extension
2361
2362 // invisible select extension
2363 function setListPos(opt) {
2364 if(!isIE) { //(degrade IE)
2365 var ref = document.getElementById('list');
2366 var x = findPosX(ref); var y = findPosY(ref);
2367 var obj = document.getElementById('jumplist');
2368 obj.style.position = 'fixed'; obj.style.left = x + 'px'; obj.style.top = y + 'px';
2369 var vol = document.getElementById('volumelist');
2370 ref = document.getElementById('volume');
2371 x = findPosX(ref); if(isOp) {y = window.innerHeight-imgHeight; }else {y = findPosY(ref);}
2372 vol.style.position = 'fixed'; vol.style.left = x + 'px'; vol.style.top = y + 'px';
2373 var del = document.getElementById('delaylist');
2374 ref = document.getElementById('delay');
2375 x = findPosX(ref); if(isOp) {y = window.innerHeight-imgHeight; }else {y = findPosY(ref);}
2376 del.style.position = 'fixed'; del.style.left = x + 'px'; del.style.top = y + 'px';
2377 var pnl = document.getElementById('navLinks');
2378 }
2379 if(opt) {
2380 if(isIE) {
2381 //(degrade IE)
2382 //pnl.style.filter = "alpha(opacity=80)";
2383 }else {
2384 obj.style.opacity = 0.0;
2385 vol.style.opacity = 0.0;
2386 del.style.opacity = 0.0;
2387 pnl.style.opacity = 0.8;
2388 }
2389 }
2390 }
2391 // invisible select extension
2392
2393 // transition extension
2394 function switchFade() {
2395 if(tranSitions && s5mode && fadeModus) {
2396 fadeModus = false;
2397 playDelay = playDelay-(2*fadeDuration);
2398 var obj = document.getElementById('fade'); changeClass(obj,'isoff');
2399 }else if(tranSitions && s5mode && !fadeModus) {
2400 fadeModus = true;
2401 playDelay = playDelay+(2*fadeDuration);
2402 var obj = document.getElementById('fade'); changeClass(obj,'ison');
2403 }
2404 currentSlide();
2405 }
2406 function opacity(ids, opacStart, opacEnd, millisec) {
2407 var speed = Math.round(millisec / 100);
2408 var timer = 0;
2409 if(opacStart > opacEnd) {
2410 for(var i = opacStart; i >= opacEnd; i--) {
2411 window.setTimeout("changeOpac(" + i + ",'" + ids + "')",(timer * speed));
2412 timer++;
2413 }
2414 } else if(opacStart < opacEnd) {
2415 for(var i = opacStart; i <= opacEnd; i++) {
2416 window.setTimeout("changeOpac(" + i + ",'" + ids + "')",(timer * speed));
2417 timer++;
2418 }
2419 }
2420 }
2421 function changeOpac(opacity, ids) {
2422 var obj = document.getElementById(ids);
2423 if (isIE) {
2424 obj.style.filter = "alpha(opacity=" + opacity + ")";
2425 } else {
2426 obj.style.opacity = (opacity / 100);
2427 }
2428 }
2429 function shiftOpacity(ids, millisec) {
2430 if(document.getElementById(ids).style.opacity != '') {
2431 var currentOpac = document.getElementById(ids).style.opacity * 100;
2432 } else {
2433 var currentOpac = 0;
2434 }
2435 if(currentOpac == 0) {
2436 opacity(ids, currentOpac, 100, millisec);
2437 } else if(currentOpac > 0) {
2438 opacity(ids, currentOpac, 0, millisec);
2439 }
2440 }
2441 // transition extension
2442
2443 // autoplay extension
2444 function autoPlay() {
2445 if (s5mode && autoMatic && !playPause) {
2446 if ((snum >= (smax-1)) && playLoop) {
2447 goTo(0);
2448 autoRun = setTimeout('autoPlay();',playDelay);
2449 }else if ((snum >= (smax-1)) && !playLoop) {
2450 stopPlay();
2451 }else {
2452 if (!incrementals[snum] || incpos >= incrementals[snum].length) {
2453 go(1);
2454 if (incrementals[snum].length >0) {
2455 clearTimeout(autoRun); autoRun = null;
2456 incrDelay = parseInt(playDelay/(incrementals[snum].length+1));
2457 remainDer = parseInt(playDelay-(incrDelay*incrementals[snum].length));
2458 autoRun = setTimeout('autoPlayIncr()',incrDelay);
2459 }
2460 } else {
2461 clearTimeout(autoRun); autoRun = null;
2462 incrDelay = incrDuration;
2463 remainDer = parseInt(playDelay-(incrementals[snum].length*incrDuration));
2464 autoRun = setTimeout('autoPlayIncr()',incrDelay);
2465 }
2466 autoRun = setTimeout('autoPlay();',playDelay);
2467 }
2468 }
2469 }
2470 function autoPlayIncr() {
2471 if (incpos < incrementals[snum].length) {
2472 subgo(1);
2473 autoRun = setTimeout('autoPlayIncr();',incrDelay);
2474 }else {
2475 autoRun = setTimeout('nop();',remainDer);
2476 }
2477 }
2478 function nop() {
2479 // no operation dummy
2480 }
2481 function togglePlay() {
2482 if (autoRun && s5mode) {
2483 stopPlay();
2484 }else if (!autoRun && s5mode) {
2485 startPlay();
2486 }
2487 }
2488 function stopPlay() {
2489 if (autoRun && s5mode) {
2490 clearTimeout(autoRun); autoRun = null;
2491 autoMatic = false; playPause = false; var obj = '';
2492 obj = document.getElementById('auto'); changeClass(obj,'isoff');
2493 obj = document.getElementById('pause'); changeClass(obj,'isoff');
2494 currentSlide();
2495 }
2496 }
2497 function startPlay() {
2498 if (!autoRun && s5mode) {
2499 playPause = false; autoMatic = true; var obj = '';
2500 obj = document.getElementById('auto'); changeClass(obj,'ison');
2501 obj = document.getElementById('pause'); changeClass(obj,'isoff');
2502 autoRun = setTimeout('autoPlay();',playDelay);
2503 currentSlide();
2504 }
2505 }
2506 function pausePlay() {
2507 if (s5mode && autoMatic) {
2508 if (playPause) {
2509 playPause = false; autoRun = setTimeout('autoPlay();',playDelay);
2510 var obj = document.getElementById('pause'); changeClass(obj,'isoff');
2511 }else {
2512 if (autoRun){
2513 clearTimeout(autoRun); autoRun = null; playPause = true;
2514 var obj = document.getElementById('pause'); changeClass(obj,'ison');
2515 }
2516 }
2517 currentSlide();
2518 }
2519 }
2520 function switchLoop() {
2521 if(s5mode) {
2522 if (playLoop) {
2523 playLoop = false;
2524 var obj = document.getElementById('loop'); changeClass(obj,'isoff');
2525 }else {
2526 playLoop = true;
2527 var obj = document.getElementById('loop'); changeClass(obj,'ison');
2528 }
2529 }
2530 currentSlide();
2531 }
2532 function setDelay() {
2533 var val = document.getElementById('delaylist');
2534 if(s5mode) {
2535 var delay = Math.max(5,Math.min(parseInt(val.value),300));
2536 playDelay = (fadeModus == true) ? ((delay*1000)+(2*fadeDuration)) : (delay*1000);
2537 }
2538 }
2539 // autoplay extension
2540
2541 // audio extension
2542 function createSoundManagerScript() {
2543 if(typeof soundManager=="undefined") {
2544 onerrorSM2();
2545 }else {
2546 var script=document.createElement('SCRIPT');
2547 var tx=document.createTextNode("soundManager.createMovie();");
2548 script.appendChild(tx);
2549 document.getElementsByTagName("body")[0].appendChild(script);
2550 }
2551 }
2552 //soundManager.onload = function() {
2553 function onloadSM2() {
2554 if(!isIE) { //(degrade IE)
2555 swfUnloaded = false;
2556 preloadSounds();
2557 }
2558 }
2559 //soundManager.onerror = function() {
2560 function onerrorSM2() {
2561 if(typeof soundManager!="undefined") {
2562 soundManager.destruct;
2563 delete soundManager;
2564 }
2565 audioSupport = false; swfUnloaded = true;
2566 if(audioError && !isIE && !isOp) {
2567 var dv = document.createElement('div'); dv.id = "guru";
2568 var d2=document.createElement('div'); dv.appendChild(d2);
2569 var tx=document.createTextNode('Guru Meditation - SoundManager failed to load/initialize!');
2570 d2.appendChild(tx); document.getElementById('slide0').appendChild(dv);
2571 }
2572 }
2573 function audioSetup() {
2574 if(sound[0]) {
2575 playSound(0);
2576 }else if(sound[bgSoundItem] && !sound[0]) {
2577 playSound(bgSoundItem);
2578 }
2579 }
2580 function fadeoutSound(ids, option) {
2581 if(curSoundID >= 0 && !swfUnloaded) {
2582 if(isNaN(ids)) {
2583 if(ids == "bgSound") {
2584 var cnum = parseInt(bgSoundItem);
2585 }else {
2586 for (var i = 0; i < (sound.length-1); i++) {
2587 if(sound[i] && ids == sound[i]["id"]) {
2588 var cnum = i;
2589 break;
2590 }
2591 }
2592 }
2593 }else {
2594 var cnum = ids;
2595 ids = sound[cnum]["id"];
2596 }
2597 var vol = getMaxVolume(sound[cnum]["volume"]);
2598 var millisec = fadeDuration;
2599 var speed = Math.round(millisec / vol);
2600 var timer = 0;
2601 for(var i = vol; i > 0; i--) {
2602 setTimeout("fadeout(" + i + ",'" + ids + "')",(timer * speed));
2603 timer++;
2604 }
2605 if(option) setTimeout("stopSound('"+ids+"')",millisec);
2606 }
2607 }
2608 function fadeout(volume, id) {
2609 soundManager.setVolume(id,volume);
2610 }
2611 function stopSound(ids) {
2612 var sid;
2613 if(isNaN(ids)) {
2614 sid = ids;
2615 }else if(sound[ids]) {
2616 sid = sound[ids]["id"];
2617 }
2618 if(sid!='' && curSoundID >= 0) {
2619 soundManager.stop(sid);
2620 curSoundID = -1;
2621 }
2622 }
2623 function toggleSounds() {
2624 if(audioSupport && !swfUnloaded) {
2625 stopAllSounds();
2626 }else if (!audioSupport && !swfUnloaded) {
2627 allowSounds();
2628 }
2629 }
2630 function allowSounds() {
2631 if(!swfUnloaded) {
2632 audioSupport = true;
2633 var obj = document.getElementById('audio'); changeClass(obj,'ison');
2634 currentSlide();
2635 }
2636 }
2637 function stopAllSounds() {
2638 if(curSoundID >= 0) {
2639 stopSound(curSoundID);
2640 }else {
2641 soundManager.stopAll();
2642 curSoundID = -1;
2643 }
2644 audioSupport = false;
2645 var obj = document.getElementById('audio'); changeClass(obj,'isoff');
2646 currentSlide();
2647 }
2648 function playSound(id) {
2649 if(audioSupport && !swfUnloaded) {
2650 var url, sid, vol, lps, cnum;
2651 if(isNaN(id)) {
2652 sid = id;
2653 if(sid == "bgSound") {
2654 cnum = parseInt(bgSoundItem);
2655 }else {
2656 cnum = getSoundID(id);
2657 }
2658 }else {
2659 cnum = parseInt(id);
2660 if(sound[cnum]) sid = sound[cnum]["id"];
2661 }
2662 if(sound[cnum] && sound[cnum]["url"]!='' && sid!=''){
2663 url = sound[cnum]["url"];
2664 vol = (sound[cnum]["volume"]!='')?getMaxVolume(sound[cnum]["volume"]):getMaxVolume(100);
2665 lps = (sound[cnum]["loops"])?true:false;
2666 if(lps) {
2667 soundManager.play(sid,{volume:vol,onplay:function(){curSoundID=cnum;},onfinish:function(){soundManager.play(sid,{volume:getMaxVolume(sound[cnum]["volume"])});}});
2668 }else {
2669 soundManager.play(sid,{volume:vol,onplay:function(){curSoundID=cnum;},onfinish:function(){curSoundID=-1;}});
2670 }
2671 }
2672 }
2673 }
2674 function getSoundID(str) {
2675 for (var i = 0; i < (sound.length-1); i++) {
2676 if(sound[i] && str == sound[i]["id"]) {
2677 var id = i;
2678 break;
2679 }
2680 }
2681 return id;
2682 }
2683 function setVolume() {
2684 var vol = document.getElementById('volumelist');
2685 if(audioSupport && !swfUnloaded) {
2686 audioVolume = parseInt(vol.value);
2687 if(curSoundID >= 0) {
2688 if(sound[curSoundID]) {
2689 var sid = sound[curSoundID]["id"];
2690 var vid = getMaxVolume(sound[curSoundID]["volume"]);
2691 soundManager.setVolume(sid,vid);
2692 }
2693 }
2694 }
2695 }
2696 function getMaxVolume(value) {
2697 if(audioVolume>0) {var factor = audioVolume/100;}else {var factor = 0;}
2698 return Math.max(0,Math.min(parseInt(value*factor),audioVolume));
2699 }
2700 function preloadSounds() {
2701 var temp = ''; var parm = ''; var t = ''; var cl = '';
2702 var objects = document.getElementsByTagName('object');
2703 for (var i=0; i < objects.length; i++) {
2704 if(objects[i].type.toLowerCase() == 'audio/mp3' && objects[i].data != '') {
2705 objects[i].width = 0; objects[i].height = 0;
2706 if(objects[i].parentNode.tagName == 'DIV') {
2707 cl = objects[i].parentNode.className.toLowerCase();
2708 if(cl == 'presentation' || cl == 'slide') {
2709 if(cl == 'presentation') {
2710 t = parseInt(bgSoundItem);
2711 }else {
2712 t = parseInt(objects[i].parentNode.id.slice(5, objects[i].parentNode.id.length));
2713 }
2714 sound[t] = new Object();
2715 if(t < bgSoundItem) {
2716 sound[t]["id"] = objects[i].parentNode.id;
2717 }else {
2718 sound[t]["id"] = "bgSound";
2719 }
2720 sound[t]["url"] = objects[i].data;
2721 sound[t]["volume"] = 100; sound[t]["loops"] = false;
2722 if(objects[i].archive != '') {
2723 parm = objects[i].archive.toLowerCase().split(',');
2724 for (var j=0; j < parm.length; j++) {
2725 if(parm[j] == 'loop') sound[t]["loops"] = true;
2726 if(parm[j].search(/^volume/) != -1) {
2727 var tmp = parm[j].split(':');
2728 sound[t]["volume"] = parseInt(tmp[1]);
2729 }
2730 }
2731 }
2732 soundManager.createSound(sound[t]["id"],sound[t]["url"]);
2733 }
2734 }
2735 }
2736 }
2737 }
2738 // audio extension
2739
2740 // help extension
2741 function createHelpReq() {
2742 if(!document.getElementById("HelpReq")) {
2743 var obj = document.getElementsByTagName("body")[0].firstChild;
2744 var pg = document.createElement('div');
2745 pg.id = "HelpReq";
2746 if (pg.addEventListener) {
2747 pg.addEventListener("onclick",dumpHelpReq,false);
2748 } else if (pg.attachEvent) {
2749 pg.attachEvent("onclick",dumpHelpReq);
2750 }
2751 pg.style.position = 'absolute';
2752 pg.style.left = 0 + 'px';
2753 pg.style.top = 0 + 'px';
2754 pg.style.width = 100 + '%';
2755 pg.style.height = 100 + '%';
2756 pg.style.margin = 0 + 'px';
2757 pg.style.padding = 0 + 'px';
2758 if (isIE) {
2759 pg.style.filter = "alpha(opacity=90)";
2760 }else {
2761 pg.style.opacity = 0.9;
2762 }
2763 pg.style.zIndex = 9999;
2764 pg.style.backgroundColor="rgb(64,64,64)";
2765 pg.style.textAlign = "center";
2766 pg.style.verticalAlign = "middle";
2767 pg.style.backgroundPosition="center center";
2768 pg.style.backgroundRepeat="no-repeat";
2769 pg.style.backgroundImage="url(ui/graphic_support/help.jpg)";
2770 document.getElementsByTagName("body")[0].insertBefore(pg,obj);
2771 if(document.getElementById("HelpReq")) {
2772 helpmode = true;
2773 }
2774 }
2775 }
2776 function dumpHelpReq() {
2777 if(document.getElementById("HelpReq")) {
2778 document.body.removeChild(document.getElementById('HelpReq'));
2779 helpmode = false;
2780 }
2781 }
2782 // help extension
2783
2784 //DEBUG
2785 function ConsoleLog(value) {
2786 if(window.console) {
2787 window.console.log(value);
2788 }
2789 }
2790 //DEBUG
2791
2792 document.write('<style type="text/css" media="screen" id="blockStyle">.presentation, .layout {display: none; }</style>');
2793
2794 if(!isIE && !isOp) {
2795 document.write('<script type="text/javascript" src="ui/audio_support/soundmanager2.js"></script>');
2796 if(typeof soundManager!="undefined") {
2797 var allMetas = document.getElementsByTagName('meta');
2798 for (var i = 0; i< allMetas.length; i++) {
2799 if (allMetas[i].name == 'audioDebug') {
2800 var audioDebug = (allMetas[i].content == "true") ? true : false;
2801 soundManager.defaultOptions.debugMode = audioDebug;
2802 }
2803 }
2804 }
2805 }
2806
2807 window.onload = createSlideShow;
2808 window.onresize = function(){setTimeout('windowChange()',5);}