﻿// JScript 文件
function getAbsolutePosX(obj) {
var l = obj.offsetLeft;
while(obj = obj.offsetParent)
l += obj.offsetLeft;
return l;
}

function getAbsolutePosY(obj) {
var t = obj.offsetTop;
while(obj = obj.offsetParent)
t += obj.offsetTop;
return t;
}

function genPannel(){
    oImgDiv=document.getElementById("imgL");
    oDiv=document.createElement("DIV");
    oDiv.id="oPanelLayer";
    oDiv.name="oPanelLayer";
    var leftPos;
    var topPos;
    var oHeight=15;
    var oWidth=100;
    leftPos=getAbsolutePosX(oImgDiv);
    topPos=getAbsolutePosY(oImgDiv);
    oDiv.style.cssText = "background-color:black;filter:alpha(opacity=95);position:absolute;left:"+leftPos+"px;top:"+topPos+"px;width:"+oWidth+"px;height:"+oHeight+"px";
    document.body.appendChild(oDiv);
}

function genPannelContent(){
    oDiv=document.getElementById("oPanelLayer");
    if(oDiv==null)return;
    str="<table align='left' cellspacing='0'><tr>";
    for(i=1;i<=count;i++){
        str+="<td onclick='setImg("+i+")' id='cell"+i+"' align='center' width='15px' style='border-right:1px solid white;color:white;font-weight:bold;font-size:9pt;cursor:hand'>";
        str+=i;
        str+="</td>";
    }
    str+="</tr></table>";
    oDiv.innerHTML=str;
}
function changeImg(){
    for(i=1;i<=count;i++){
        oTd=document.getElementById("cell"+i);
        if(i==lp){
            oTd.style.backgroundColor='red'; 
            oTd.style.color='white';
        }else{
            oTd.style.backgroundColor='transparent'; 
            oTd.style.color='white';
        }
    }
    oImg=document.getElementById("img");
    oImg.src=imgArr[lp-1].url;
    oImg.alt=imgArr[lp-1].desc;
    try{
    oImg.filters.revealTrans.Transition=23;
    oImg.filters.revealTrans.apply();
    oImg.filters.revealTrans.play();
    }catch(e){
    }
    lp++;
    if(lp>count)lp=1;
}
function setImg(indx){
    lp=indx;
    changeImg();    
}
function openWin(){
    if(lp-2==-1){
        window.open(imgArr[count-1].linkAddress);    
    }else{
        window.open(imgArr[lp-2].linkAddress);    
    }
}
function imgObj(oUrl,oLinkAddress,oDesc){
    this.url=oUrl;
    this.linkAddress=oLinkAddress;
    this.desc=oDesc;
}
