// BANNER OBJECT function Banner(objName){ this.obj = objName; this.aNodes = []; this.currentBanner = 0; }; // ADD NEW BANNER Banner.prototype.add = function(bannerType, bannerPath, bannerDuration, height, width, hyperlink) { this.aNodes[this.aNodes.length] = new Node(this.obj +"_"+ this.aNodes.length, bannerType, bannerPath, bannerDuration, height, width, hyperlink); }; // Node object function Node(name, bannerType, bannerPath, bannerDuration, height, width, hyperlink) { this.name = name; this.bannerType = bannerType; this.bannerPath = bannerPath; this.bannerDuration = bannerDuration; this.height = height this.width = width; this.hyperlink= hyperlink; // alert (name +"|" + bannerType +"|" + bannerPath +"|" + bannerDuration +"|" + height +"|" + width + "|" + hyperlink); }; // Outputs the banner to the page Banner.prototype.toString = function() { var str = "" for (var iCtr=0; iCtr < this.aNodes.length; iCtr++){ str = str + '\n'; if (this.aNodes[iCtr].hyperlink != ""){ str = str + ''; } if ( this.aNodes[iCtr].bannerType == "FLASH" ){ str = str + '' str = str + '' str = str + '' str = str + '' str = str + '' str = str + '' str = str + '' }else if ( this.aNodes[iCtr].bannerType == "IMAGE" ){ str = str + ''; } if (this.aNodes[iCtr].hyperlink != ""){ str = str + ''; } str += ''; } return str; }; // START THE BANNER ROTATION Banner.prototype.start = function(){ this.changeBanner(); var thisBannerObj = this.obj; // CURRENT BANNER IS ALREADY INCREMENTED IN cahngeBanner() FUNCTION setTimeout(thisBannerObj+".start()", this.aNodes[this.currentBanner].bannerDuration * 2000); } // CHANGE BANNER Banner.prototype.changeBanner = function(){ var thisBanner; var prevBanner = -1; if (this.currentBanner < this.aNodes.length ){ thisBanner = this.currentBanner; if (this.aNodes.length > 1){ if ( thisBanner > 0 ){ prevBanner = thisBanner - 1; }else{ prevBanner = this.aNodes.length-1; } } if (this.currentBanner < this.aNodes.length - 1){ this.currentBanner = this.currentBanner + 1; }else{ this.currentBanner = 0; } } if (prevBanner >= 0){ document.getElementById(this.aNodes[prevBanner].name).className = "m_banner_hide"; } document.getElementById(this.aNodes[thisBanner].name).className = "m_banner_show"; }