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