/** * ppt ���� * ������ 2012-05-17 */ function pptbox() { this.uid = pptboxhelper.getid(); pptboxhelper.instance[this.uid] = this; this._$ = function(id){return document.getelementbyid(id);}; this.width = 400;//��� this.height = 300;//�߶� this.picwidth = 15;//сͼ��� this.picheight = 9;//сͼ�߶� this.autoplayer = 4;//�զ����ż����룩 this.target = "_blank"; this._box = []; this._curindex = 0; this.showbtn = true;//�ƿ���ʾͼƭ�ϵ����ҷ���ť } pptbox.prototype = { _createmainbox : function (){ var btntop = this.height/2 - 69/2; var flashboxwidth = this.width * this._box.length + 5; var eventstr = "pptboxhelper.instance[\""+this.uid+"\"]"; var html="
"; if(this.showbtn){ html += ""; html += ""; } html += "
"; html += "
"; html += "
"; html += "
"; document.write(html); if(this.showbtn){ var box=this._$(this.uid+"_mainbox"); var self=this; box.onmouseover = function(e){ if( !e ) e = window.event; var reltg = e.relatedtarget ? e.relatedtarget : e.fromelement; while( reltg && reltg != this ) reltg = reltg.parentnode; if( reltg != this ){ self._$(self.uid+"_mainbox_btn_left").style.display=""; self._$(self.uid+"_mainbox_btn_right").style.display=""; } } box.onmouseout = function(e){ if( !e ) e = window.event; var reltg = e.relatedtarget ? e.relatedtarget : e.toelement; while( reltg && reltg != this ) reltg = reltg.parentnode; if( reltg != this ){ self._$(self.uid+"_mainbox_btn_left").style.display="none"; self._$(self.uid+"_mainbox_btn_right").style.display="none"; } } } }, _init : function (){ var picstyle= ""; var eventstr = "pptboxhelper.instance['"+this.uid+"']"; var imagehtml=""; var flashbox = ""; for(var i=0;i" + imagehtml; } var tw = this.width - (this._box.length*26); var alink = (this._box.length>0) ? (""+this._box[0].title+"") :''; imagehtml+="
"+alink+"
" 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*1000); }, 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; }, next : function(){ var idx = this._curindex+1; if(idx>=this._box.length){idx=0} this.mouseoverpic(idx); }, up : function(idx){ var idx = this._curindex-1; if(idx<0){idx=this._box.length-1;} this.mouseoverpic(idx); }, 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"; var tw = this.width - (this._box.length*26); this._$(this.uid+"_textbox").innerhtml = ""+this._box[idx].title+""; 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*1000); } }, clickpic:function(idx){ var parame = this._box[idx]; if(parame.href&¶me.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*1000); } } } 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); }