﻿// JScript 文件
var magicphoto=new Object;
magicphoto.objinit=function(obj,data,iwidth,iheight)
{
this.srcElement=obj;
this.datasource=data;
if(iwidth==null){this.width=248;}else{var test=/^\d+$/;if(test.test(iwidth)){this.width=iwidth;}else{this.width=248;};};
if(iheight==null){this.height=248;}else{var test=/^\d+$/;if(test.test(iheight)){this.height=iheight;}else{this.height=248;};};
this.srcElement.appendChild(this.objectinit());
this.index=0;
this.scroll();
};
magicphoto.CreateDiv=function(tagname,cssText,id){var E=document.createElement(tagname);E.style.cssText=cssText;if(id!=""||id!=null){E.id=id;};return E;};
magicphoto.objectinit=function(){
var Div=this.CreateDiv("div","width:100%;height:100%");
this.imgdiv=this.CreateImgDiv();Div.appendChild(this.imgdiv);
Div.appendChild(this.CreateList());return Div;};
magicphoto.CreateImgDiv=function()
{
    var Div=this.CreateDiv("div","width:100%; height:100%");
    for(var i=0;i<this.datasource.length;i++)
    {
        var A=i==0?this.CreateDiv("a","display:block;visibility:visible"):this.CreateDiv("a","display:none;visibility:hidden"),Img=this.CreateDiv("img","border:none;width:100%;height:100%"),index=this.datasource[i].split(";");
        A.href=index[1];Img.src=index[0];Img.alt=index[2];Img.title=index[2];
        EventUtil.addEventHandler(Img,"mouseout",this.imgitemmouseout);
        EventUtil.addEventHandler(Img,"mouseover",this.imgitemmouseover);
        A.appendChild(Img);Div.appendChild(A);
    };
    return Div;
};
magicphoto.imgitemmouseout=function(){magicphoto.scroll();};
magicphoto.imgitemmouseover=function(){clearTimeout(magicphoto.itimeout);};

magicphoto.CreateList=function()
{
    var Div=this.CreateDiv("div","-moz-opacity:0.5;width:100%;height:16px;overflow:hidden;position:relative;top:-16px;left:0px;z-index:97");
    if(this.width-18*this.datasource.length-40>0){Div.style.paddingLeft="39px";for(var i=0,A=this.width-18*this.datasource.length-40,B=A/2,C=70/B;i<B;i++){Div.appendChild(this.CreateDiv("div","float:left;width:2px;height:13px;margin-top:3px;background-color:#333333;-moz-opacity:0.5;filter:alpha(opacity="+i*C+");"));}}
    else if(this.width-18*this.datasource.length>0){Div.style.paddingLeft=(this.width-18*this.datasource.length)+"px";};
    this.numlist=this.CreateNumList();
    Div.appendChild(this.numlist);
    return Div;
};
magicphoto.CreateNumList=function()
{
var Div=this.CreateDiv("div","float:left");
for(var i=0,l=this.datasource.length;i<l;i++)
{
    var iDiv=this.CreateDiv("div","cursor:hand;float:left;line-height:13px;margin-top:3px;width:17px;border-left:solid 1px #ffffff;background-color:#333333;text-align:center;color:#fff");
    iDiv.innerText=i+1;
    EventUtil.addEventHandler(iDiv,"mouseout",this.listitemmouseout);
    EventUtil.addEventHandler(iDiv,"mouseover",this.listitemmouseover);
    EventUtil.addEventHandler(iDiv,"click",this.listitemmouseclick);
    Div.appendChild(iDiv);
};
return Div;
};
magicphoto.listitemmouseover=function(){var A=EventUtil.formatEvent(event).target;if(A.style.backgroundColor=="#cc0000"||A.style.backgroundColor=="#ff0000"){return;}else{A.style.backgroundColor="#cc0000";A.style.color="#FFFF00";};};
magicphoto.listitemmouseout=function(){var A=EventUtil.formatEvent(event).target;if(A.style.backgroundColor=="#333333"||A.style.backgroundColor=="#ff0000"){return;}else{A.style.backgroundColor="#333333";A.style.color="#fff";};};
magicphoto.listitemmouseclick=function(){var A=EventUtil.formatEvent(event).target;if(A.style.backgroundColor=="#ff0000"){return;}else{this.index=Number(A.innerText)-1; magicphoto.scroll();};};


magicphoto.imgindex=function(index){return "<div style='height:1px; width:2px; background-color:#ff0000; overflow:hidden;'></div><div style='height:1px; width:6px; background-color:#ff0000; overflow:hidden;'></div><div style='height:1px; width:8px; background-color:#ff0000; overflow:hidden;'></div><div style='height:13px; width:17px; border-left:solid 1px #ffffff; background-color:#ff0000; text-align:center; overflow:hidden;'>"+index+"</div>";};

magicphoto.scroll=function()
{
    var A=this.imgdiv.childNodes,B=this.numlist.childNodes;
    for(var i=0,l=A.length;i<l;i++){if(i==this.index){A[i].style.cssText="display:block;visibility:visible";B[i].style.cssText="float:left;cursor:hand;height:16px;width:18px;text-align:center";B[i].innerHTML=this.imgindex(i+1);}else{A[i].style.cssText="display:none;visibility:hidden";B[i].style.cssText="cursor:hand;float:left;height:13px;line-height:13px;width:17px;border-left:solid 1px #ffffff;background-color:#333333;margin-top:3px;text-align:center;color:#fff";B[i].innerText=i+1;};};
    this.index=this.index==this.datasource.length-1?0:this.index+1;
    this.itimeout=setTimeout(function(){magicphoto.scroll();},6000);
};