Ext.ns("com.trs.FocusPic");
/*lky添加注釋*/
(function(){
//定義FocusPic函數
var FocusPic = function(BigPicID,SmallPicsID,TitleID,DescripID,width,height){
//用戶輸入的寬高添加px
width=width+"px";
height=height+"px";
//定義空數組
this.Data=[];
this.ImgLoad=[];
//通過id獲取dom元素
this.findById=function(objName){
if(document.getElementById){
return eval('document.getElementById("'+objName+'")');
}else{
return eval('document.all.'+objName);
}
};
//判斷圖片容器是否為空,不為空設置則它和父容器的寬高
if(BigPicID){
if(this.findById(BigPicID)){
this.findById(BigPicID).style.width=width;
this.findById(BigPicID).style.height=height;
if(this.findById(BigPicID).parentNode){
this.findById(BigPicID).parentNode.style.width=width;
this.findById(BigPicID).parentNode.style.height=height;
}
if(this.findById(BigPicID).parentNode.parentNode){
this.findById(BigPicID).parentNode.parentNode.style.width=width;
this.findById(BigPicID).parentNode.parentNode.style.height=height;
}
}
};
//參數定義
this.TimeOut=5000;
var isIE=navigator.appVersion.indexOf("MSIE")!=-1?true:false;
this.width=width;
this.height=height;
this.adNum=0;
var TimeOutObj;
if(!FocusPic.childs){FocusPic.childs=[]};
this.showTime=null;
this.showSum=10;
this.ID=FocusPic.childs.push(this)-1;
//alert("this.ID1:"+this.ID);
//添加記錄
this.Add=function(BigPic,SmallPic,Title,Url,Descrip){
var ls;
this.Data.push([BigPic,SmallPic,Title,Url,Descrip]);
ls=this.ImgLoad.length;
this.ImgLoad.push(new Image);
this.ImgLoad[ls].src=BigPic;
};
//時間過期後開始
this.TimeOutBegin=function(){
clearInterval(TimeOutObj);
TimeOutObj=setInterval("com.trs.FocusPic.childs["+this.ID+"].next()",this.TimeOut);
};
//時間過期後,清理定時執行
this.TimeOutEnd=function(){
clearInterval(TimeOutObj);
};
//當前選中
this.select=function(num){
if(num>this.Data.length-1){return};
if(num==this.adNum){return};
this.TimeOutBegin();
//添加圖片鏈接
if(BigPicID){
if(this.findById(BigPicID)){
var aObj=this.findById(BigPicID).getElementsByTagName("a")[0];
aObj.href=this.Data[num][2];
if(this.aImgY){
this.aImgY.style.display='none';
this.aImg.style.position="relative";
this.aImg.style.left=0;
this.aImg.style.top=0;
this.aImg.style.zIndex=0;
};
this.aImgY=this.findById('F'+this.ID+'BF'+this.adNum);
this.aImg=this.findById('F'+this.ID+'BF'+num);
clearTimeout(this.showTime);
this.showSum=10;
//alert("this.ID:"+this.ID);
this.showTime=setTimeout("com.trs.FocusPic.childs["+this.ID+"].show()",10);
}
};
//添加標題
if(TitleID){
if(this.findById(TitleID)){
this.findById(TitleID).innerHTML=""+this.Data[num][3]+"";
}
};
//添加描述信息
if(DescripID){
if(this.findById(DescripID)){
this.findById(DescripID).innerHTML=this.Data[num][4];
}
};
//更改小圖片樣式
if(SmallPicsID){
if(this.findById(SmallPicsID)){
var sImg=this.findById(SmallPicsID).getElementsByTagName("span"),i;
for(i=0;i=this.Data.length){temp=0;};
this.select(temp);
};
//上一個
this.pre=function(){
var temp=this.adNum;
temp--;
if(temp<0){ temp=this.Data.length-1;
};
this.select(temp);
};
//鼠标放在图片上图片不切换事件
this.MInStopEvent=function(ObjID){
if(ObjID){
if(this.findById(ObjID)){
if(this.findById(ObjID).attachEvent){
this.findById(ObjID).attachEvent("onmouseover",Function("com.trs.FocusPic.childs["+this.ID+"].TimeOutEnd()"));
this.findById(ObjID).attachEvent("onmouseout",Function("com.trs.FocusPic.childs["+this.ID+"].TimeOutBegin()"));
}else{
this.findById(ObjID).addEventListener("mouseover",Function("com.trs.FocusPic.childs["+this.ID+"].TimeOutEnd()"),false);
this.findById(ObjID).addEventListener("mouseout",Function("com.trs.FocusPic.childs["+this.ID+"].TimeOutBegin()"),false);
}
}
}
};
//开始
this.begin=function(){
this.MInStopEvent(TitleID);
this.MInStopEvent(SmallPicsID);
this.MInStopEvent(DescripID);
this.MInStopEvent(BigPicID);
this.adNum=0;
var i,temp="";
if(BigPicID){
if(this.findById(BigPicID)){
var aObj=this.findById(BigPicID).getElementsByTagName("a")[0];aObj.style.zoom=1;
this.findById(BigPicID).style.position="relative";
for(i=0;i'
};
aObj.innerHTML=temp;
}
};
if(SmallPicsID){
if(this.findById(SmallPicsID)){
temp="";
for(i=0;i";
};
this.findById(SmallPicsID).innerHTML=temp;
}
};
this.TimeOutBegin();
this.findById(BigPicID).getElementsByTagName("a")[0].href=this.Data[0][2];
this.findById(TitleID).innerHTML=""+this.Data[0][3]+"";
if(this.findById(DescripID))this.findById(DescripID).innerHTML=this.Data[0][4];
};
};
com.trs.FocusPic = FocusPic;
})();