/**
* 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 = 12;//сͼ�߶�
this.autoplayer = 4;//�զ����ż����룩
this.target = "_blank";
this._box = [];
this._curindex = 0;
}
pptbox.prototype =
{
_createmainbox : function (){
var flashboxwidth = this.width * this._box.length + 5;
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" + 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*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;
},
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*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);
}