home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 November / Chip_2004-11_cd1.bin / zkuste / jalbum / ukazka / res / js / slideshow.js < prev    next >
Text File  |  2004-05-03  |  3KB  |  116 lines

  1. //// Slideshow section...
  2.  
  3. // Variables from setup.js: seconds, timerID, exp, pauseIconUrl, playIconUrl
  4.  
  5. // START/STOP Slideshow
  6. function toggleSlideShow(exp) 
  7. {
  8.     var on = getCookie('slideShowOn');
  9.     if( on!=null )
  10.         dontSlides(exp);
  11.     else
  12.         doSlides(exp);
  13.     
  14.     // For JS keyboard support
  15.     takenAction = false;
  16. }
  17.  
  18. function setSlideShowStatus(status) 
  19. {
  20.     var url = status ? pauseIconUrl : playIconUrl;
  21.     
  22.     if (document.getElementById)    // IE5+ & Gecko
  23.     {
  24.         if( document.getElementById("slide_show1")!=null )
  25.             document.getElementById("slide_show1").src=url;
  26.  
  27.         if( document.getElementById("slide_show2")!=null )
  28.             document.getElementById("slide_show2").src=url;
  29.     }
  30.     else if (document.all)    // IE4
  31.     {
  32.         if( document.all["slide_show1"]!=null )
  33.             document.all["slide_show1"].src=url;
  34.  
  35.         if( document.all["slide_show2"]!=null )
  36.             document.all["slide_show2"].src=url;
  37.     }
  38.     else // Netscape 4
  39.     {
  40.         if( document.images["slide_show1"]!=null )
  41.             document.images["slide_show1"].src=url;
  42.  
  43.         if( document.images["slide_show2"]!=null )
  44.             document.images["slide_show2"].src=url;
  45.     }
  46. }
  47.  
  48. //start slideshow
  49. function doSlides(exp) 
  50. {
  51.     setCookie("slideShowOn", "on", exp);
  52.     setSlideShowStatus(true);
  53.     timerID = setTimeout('nextPage()', seconds * 1000);
  54. }
  55.  
  56. //stop slideshow
  57. function dontSlides(exp) 
  58. {
  59.     deleteCookie("slideShowOn");
  60.     setSlideShowStatus(false);
  61.     clearTimeout(timerID);
  62. }
  63.  
  64. function getCookieVal(offset) 
  65. {
  66.     var endstr = document.cookie.indexOf (";", offset);
  67.     if (endstr == -1)
  68.         endstr = document.cookie.length;
  69.     return unescape(document.cookie.substring(offset, endstr));
  70. }
  71.  
  72. function getCookie(name) 
  73. {
  74.     var arg = name + "=";
  75.     var alen = arg.length;
  76.     var clen = document.cookie.length;
  77.     var i = 0;
  78.  
  79.     while (i < clen) 
  80.     {
  81.         var j = i + alen;
  82.         
  83.         if (document.cookie.substring(i, j) == arg) 
  84.             return getCookieVal (j);
  85.         i = document.cookie.indexOf(" ", i) + 1;
  86.         if (i == 0) 
  87.             break;
  88.     }
  89.     return null;
  90. }
  91.  
  92. function setCookie(name, value) 
  93. {
  94.     var argv = setCookie.arguments;
  95.     var argc = setCookie.arguments.length;
  96.     var expires = (argc > 2) ? argv[2] : null;
  97.     var path = (argc > 3) ? argv[3] : null;
  98.     var domain = (argc > 4) ? argv[4] : null;
  99.     var secure = (argc > 5) ? argv[5] : false;
  100.  
  101.     document.cookie = name + "=" + escape (value) +
  102.         ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
  103.         ((path == null) ? "" : ("; path=" + path)) +
  104.         ((domain == null) ? "" : ("; domain=" + domain)) +
  105.         ((secure == true) ? "; secure" : "");
  106. }
  107.  
  108. function deleteCookie(name) 
  109. {
  110.     var exp = new Date();
  111.     exp.setTime(exp.getTime() - 1);
  112.     var cval = getCookie(name);
  113.  
  114.     document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
  115. }
  116.