home *** CD-ROM | disk | FTP | other *** search
- // JavaScript Source File -- Created with NetObjects ScriptBuilder
- // Category: Images// Language: All
- // AUTHOR: Joe Hage, http://www.exceptional.com, All Rights Reserved.
- // Feel free to reuse this code provided you include this
- // AUTHOR section in your pages.
- // DESC: Ad banners just with JavaScript. No CGI required.
- // Sample HTML: ADBANNERS.HTML// PLATFORMS: Netscape Navigator 3.0 and higher,
- // Microsoft Internet Explorer 4.0 and higher
- //====================================================================
-
- function com_netobjects_rotatingBannerComponent( params ) {
- this.addToArray = rbAddToArray;
- this.visitAdvertiser = rbVisitAdvertiser;
- this.rotateBanner = rbRotateBanner;
- this.render = rbRender;
-
- this.imagesrc = (params.imagesrc+"" != "undefined" && params.imagesrc != null ? params.imagesrc+"" : "");
- this.rotateTime = (params.rotateTime+"" != "undefined" && params.rotateTime != null ? params.rotateTime : 1);
- this.name = (params.name+"" != "undefined" && params.name+"" != "" && params.name != null ? params.name : "rotatingBannerComponent1");
-
- this.rbAdvertiser = 0;
- this.rbAdvertiserArray = new Array();
- this.rbImageArray = new Array();
-
- function rbAddToArray( url, img ) {
- newIndex = this.rbAdvertiserArray.length;
- this.rbAdvertiserArray[newIndex] = url;
- this.rbImageArray[newIndex] = img;
- }
-
- //Function to navigate to the advertiser's web site
- function rbVisitAdvertiser() {
- var outputString;
- if(this.rbAdvertiserArray[this.rbAdvertiser].substring(0, 4) != "http")
- outputString = "http://" + this.rbAdvertiserArray[this.rbAdvertiser];
- else
- outputString = this.rbAdvertiserArray[this.rbAdvertiser];
- window.location.href = outputString
- }
-
- //Function to render the image for banner
- function rbRender() {
- var output = "<FORM NAME='" + this.imagesrc + "'><IMG NAME='" + this.imagesrc + "'";
- output += " SRC='" + this.rbImageArray[0] + "' onClick='" + this.name + ".visitAdvertiser()'></FORM>";
-
- document.write(output);
- }
-
- //Function to Rotate and Cycle through the images
- function rbRotateBanner() {
- if (this.rbAdvertiser >= this.rbAdvertiserArray.length)
- this.rbAdvertiser = 0;
- if(this.imagesrc != "")
- {
- document.images[this.imagesrc].src = this.rbImageArray[this.rbAdvertiser++];
- if(document.images[this.imagesrc].src+"" == "undefined")
- document.images[this.imagesrc].src = this.rbImageArray[0];
-
- setTimeout(this.name + ".rotateBanner()", this.rotateTime*1000);
- }
- }
- }
-