// SLIDE OBJECT function Slide(objName){ this.obj = objName; this.aNodes = []; this.currentSlide = 0; this.changeOnRefresh = false; }; // ADD NEW SLIDE Slide.prototype.add = function(slideType, slidePath, slideDuration, height, width, hyperlink, target) { this.aNodes[this.aNodes.length] = new Node(this.obj +"_"+ this.aNodes.length, slideType, slidePath, slideDuration, height, width, hyperlink, target); }; // Node object function Node(name, slideType, slidePath, slideDuration, height, width, hyperlink, target) { this.name = name; this.slideType = slideType; this.slidePath = slidePath; this.slideDuration = slideDuration; this.height = height this.width = width; this.hyperlink= hyperlink; this.target= target; }; // Output the slide to page Slide.prototype.toString = function() { var str = ""; var iSlideIndex = 0; if(this.changeOnRefresh == true){ // Read the cookie var SlideName = this.obj; var lastSlideIndex = readCookie(SlideName); if(isNaN(lastSlideIndex) == true || lastSlideIndex == null){ iSlideIndex = 0; }else if(lastSlideIndex == '' || parseInt(lastSlideIndex) >= this.aNodes.length - 1){ iSlideIndex = 0; }else{ iSlideIndex = parseInt(lastSlideIndex) + 1; } // Set the new value createCookie(SlideName,iSlideIndex,7); } for (var iCtr=0; iCtr < this.aNodes.length; iCtr++){ if(this.changeOnRefresh == true && iSlideIndex != iCtr){ continue; } str = str + '\n'; if ( this.aNodes[iCtr].slideType == "FLASH" ){ str = str + ''; str = str + ''; str = str + ''; str = str + ''; if (this.aNodes[iCtr].hyperlink != ""){ str = str + ''; } str = str + ''; str = str + '' str = str + '' }else if ( this.aNodes[iCtr].slideType == "IMAGE" ){ if (this.aNodes[iCtr].hyperlink != ""){ str = str + ''; } str = str + ''; if (this.aNodes[iCtr].hyperlink != ""){ str = str + ''; } } str += ''; } return str; }; // START THE SLIDE ROTATION Slide.prototype.start = function(){ if(this.changeOnRefresh == false){ this.changeSlide(); var thisSlideObj = this.obj; // CURRENT SLIDE IS ALREADY INCREMENTED IN changeslide() FUNCTION setTimeout(thisSlideObj+".start()", this.aNodes[this.currentSlide].slideDuration * 1000); } } // CHANGE SLIDE Slide.prototype.changeSlide = function(){ var thisSlide; var prevSlide = -1; if (this.currentSlide < this.aNodes.length ){ thisSlide = this.currentSlide; if (this.aNodes.length > 1){ if ( thisSlide > 0 ){ prevSlide = thisSlide - 1; }else{ prevSlide = this.aNodes.length-1; } } if (this.currentSlide < this.aNodes.length - 1){ this.currentSlide = this.currentSlide + 1; }else{ this.currentSlide = 0; } } if (prevSlide >= 0){ document.getElementById(this.aNodes[prevSlide].name).className = "slide_hide"; } document.getElementById(this.aNodes[thisSlide].name).className = "slide_show"; } // Following Cookie Code taken from http://www.quirksmode.org function createCookie(name,value,days) { if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); } else var expires = ""; document.cookie = name+"="+value+expires+"; path=/"; } function readCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null; }