function pptbox() { this.uid = pptboxhelper.getid(); pptboxhelper.instance[this.uid] = this; this._$ = function(id) { return document.getelementbyid(id); }; this.width = 1270; //瀹藉害 this.height = 355; //楂樺害 this.picwidth = 19; //灏忓浘瀹藉害 this.picheight = 19; //灏忓浘楂樺害 this.autoplayer = 4; //鑷姩鎾斁闂撮殧锛堢锛? this.target = "_blank"; this._box = []; this._curindex = 0; } pptbox.prototype = { _createmainbox: function() { var flashboxwidth = this.width * this._box.length + 0; var html = "
"; html += "
"; html += "
"; html += "
"; document.write(html); }, _init: function() { var picstyle = ""; var eventstr = "pptboxhelper.instance['" + this.uid + "']"; var imagehtml = ""; var flashbox = ""; for (var i = 0; i < this._box.length; i++) { var parame = this._box[i]; flashbox += this.flashhtml(parame.url, this.width, this.height, i); imagehtml = "
" + imagehtml; } this._$(this.uid + "_flashbox").innerhtml = flashbox; this._$(this.uid + "_imagebox").innerhtml = imagehtml; }, _play: function() { clearinterval(this._autoplay); var idx = this._curindex + 1; if (idx >= this._box.length) { idx = 0; } this.changeindex(idx); var eventstr = "pptboxhelper.instance['" + this.uid + "']._play()"; this._autoplay = setinterval(eventstr, this.autoplayer * 1270); }, flashhtml: function(url, width, height, idx) { var isflash = url.substring(url.lastindexof('.') + 1).tolowercase() == "swf"; var html = ""; if (isflash) { html = "" + "" + "" + "" + "" + " "; } else { var eventstr = "pptboxhelper.instance['" + this.uid + "']"; var style = ""; if (this._box[idx].href) { style = "cursor:pointer" } html = ""; } return html; }, changeindex: function(idx) { var parame = this._box[idx]; moveelement(this.uid + "_flashbox", -(idx * this.width), 1); var imgs = this._$(this.uid + "_imagebox").getelementsbytagname("div"); imgs[this._box.length - 1 - this._curindex].classname = "bitdiv defimg"; imgs[this._box.length - 1 - idx].classname = "bitdiv curimg"; this._curindex = idx; }, mouseoverpic: function(idx) { this.changeindex(idx); if (this.autoplayer > 0) { clearinterval(this._autoplay); var eventstr = "pptboxhelper.instance['" + this.uid + "']._play()"; this._autoplay = setinterval(eventstr, this.autoplayer * 1270); } }, clickpic: function(idx) { var parame = this._box[idx]; if (parame.href && parame.href != "") { window.open(parame.href, this.target); } }, add: function(imgparam) { this._box[this._box.length] = imgparam; }, show: function() { this._createmainbox(); this._init(); if (this.autoplayer > 0) { var eventstr = "pptboxhelper.instance['" + this.uid + "']._play()"; this._autoplay = setinterval(eventstr, this.autoplayer * 1270); } } } var pptboxhelper = { count: 0, instance: {}, getid: function() { return '_ppt_box-' + (this.count++); } }; function moveelement(elementid, final_x, interval) { if (!document.getelementbyid) return false; if (!document.getelementbyid(elementid)) return false; var elem = document.getelementbyid(elementid); if (elem.movement) { cleartimeout(elem.movement); } if (!elem.style.left) { elem.style.left = "0px"; } var xpos = parseint(elem.style.left); if (xpos == final_x) { return true; } if (xpos < final_x) { var dist = math.ceil((final_x - xpos) / 5); xpos = xpos + dist; } if (xpos > final_x) { var dist = math.ceil((xpos - final_x) / 5); xpos = xpos - dist; } elem.style.left = xpos + "px"; var repeat = "moveelement('" + elementid + "'," + final_x + "," + interval + ")"; elem.movement = settimeout(repeat, interval); }