//=== THE CODE STARTS HERE - no need to change anything below === //=== global variables ==== theImages = new Array(); normal_delay = 300; delay = normal_delay; //delay between frames in 1/100 seconds delay_step = 10; delay_max = 4000; delay_min = 10; current_image = first_image; //number of the current image timeID = null; status = 1; // 0-stopped, 1-playing play_mode = 1; // 0-loop, 1-normal, 2-swing size_valid = 0; //===> makes sure the first image number is not bigger than the last image number if (first_image > last_image) { var help = last_image; last_image = first_image; first_image = help; }; //===> preload the images - gets executed first, while downloading the page for (var i = first_image; i <= last_image; i++) { theImages[i] = new Image(); //theImages[i].onerror = my_alert("\nError loading ",image_name,i,image_type,"!"); //theImages[i].onabort = my_alert("\nLoading of ",image_name,i,image_type," aborted!"); theImages[i].src = image_name + i + "." + image_type; }; //===> displays image depending on the play mode in forward direction function animate_fwd() { current_image++; if(current_image > last_image) { if (play_mode == 1) { current_image = last_image; status=0; return; }; //NORMAL if (play_mode == 0) { current_image = first_image; //LOOP }; if (play_mode == 2) { current_image = last_image; animate_rev(); return; }; }; document.animation.src = theImages[current_image].src; document.control_form.frame_nr.value = current_image; timeID = setTimeout("animate_fwd()", delay); } //===> displays image depending on the play mode in reverse direction function animate_rev() { current_image--; if(current_image < first_image) { if (play_mode == 1) { current_image = first_image; status=0; return; }; //NORMAL if (play_mode == 0) { current_image = last_image; //LOOP }; if (play_mode == 2) { current_image = first_image; animate_fwd(); return; }; }; document.animation.src = theImages[current_image].src; document.control_form.frame_nr.value = current_image; timeID = setTimeout("animate_rev()", delay); } //===> changes playing speed by adding to or substracting from the delay between frames function change_speed(dv) { delay+=dv; if(delay > delay_max) delay = delay_max; if(delay < delay_min) delay = delay_min; } //===> stop the movie function stop() { if (status == 1) clearTimeout (timeID); status = 0; } //===> "play forward" function fwd() { stop(); status = 1; animate_fwd(); } //===> jumps to a given image number function go2image(number) { stop(); if (number > last_image) number = last_image; if (number < first_image) number = first_image; current_image = number; document.animation.src = theImages[current_image].src; document.control_form.frame_nr.value = current_image; } //===> "play reverse" function rev() { stop(); status = 1; animate_rev(); } //===> changes play mode (normal, loop, swing) function change_mode(mode) { play_mode = mode; } //===> sets everything once the whole page and the images are loaded (onLoad handler in ) function launch() { stop(); current_image = first_image; document.animation.src = theImages[current_image].src; document.control_form.frame_nr.value = current_image; // this is trying to set the text (Value property) on the START and END buttons // to S(first_image number), E(last_image number). It's supposed (according to // JavaScrtipt Authoring Guide) to be a read only value but for some reason // it works on win3.11 (on IRIX it doesn't). document.control_form.start_but.value = " S(" + first_image + ") "; document.control_form.end_but.value = " E(" + last_image + ") "; // this needs to be done to set the right mode when the page is manualy reloaded change_mode (document.control_form.play_mode_selection.selectedIndex); status=1; // fwd(); } //===> writes the interface into the code where you want it function animation() { document.write("
");