﻿var curImg = 0;
var timerId = -1;
var intervalf = 1500;
var intervalm = 3000;
var intervals = 5000;
var interval = intervalm;
var imgIsLoaded = false;
var arrPreload = new Array();
var imageSrcArray = new Array();
var imageNameArray = new Array();
var imageDescArray = new Array();
var imageWidthArray = new Array();
var imageHeightArray = new Array();
var imageLinkArray = new Array(); //播放时，图片点击的链接地址
var curImageStyle = "cursor:hand;border:2px solid #FFF;"; // 当前播放图片的样式定义
var _PRELOADRANGE = 5;
var playerState = 0;
var numImgs = 0;
var widthe = 1; //是否是实际大小显示
var _SMALLWIDTH = 128;
var _SMALLHEIGHT = 96;
var _LARGEWIDTH = 540;
var _LARGEHEIGHT = 405;
var pWidth = 0; //强制宽度
var pHeight = 0; //强制高度
var isNeedPicPagination = true; // 是否显示图片分页信息，如：第几张 / 共几张
var noPicHtml = "<center>无可查看相片！</center>"; // 没有图片时的提示信息
var playObj;
var forwardObj;
var rewindObj;
var speedObj;
var stopObj;
var repeatObj;
var addFunc = 0; //是否调用外面附加函数(默认不调用)
var stopNum = 0; //停止切换的数字
var rootPath = ""; //根目录
var htmlCont = "";
var isRepeatPlay = false; //是否循环播放
var isPicOpenInNewWindow = true; // 点击图片链接是否在新窗口中打开

var buttonPicPrefix = "/images/photo"; //按钮图片相对目录
var spaceMark = "/"; //图片地址间隔符
var forwardImages = ["bt_u_fwd.gif", "bt_u_fwd2.gif"];
var rewardImages = ["bt_u_rwd.gif", "bt_u_rwd2.gif"];
var playImages = ["bt_u_play.gif", "bt_u_play2.gif"];
var stopImages = ["bt_u_stop.gif", "bt_u_stop2.gif"];
var repeatImages = ["bt_u_repeat.gif", "bt_u_repeat2.gif"];

var playCallbackFunction; // 图片播放时的，回调函数，参数为curImg

function preloadRange(intPic, intRange) {
    arrPreload[0] = new Image();
    for (var i = intPic; i < intPic + intRange; i++) {
        //arrPreload[i] = new Image();
        arrPreload[0].src = imageSrcArray[i];
        //		if(imageWidthArray[i] == 0){
        //			imageWidthArray[i] = arrPreload[i].width;
        //		}
        //		if(imageHeightArray[i] == 0){
        //			imageHeightArray[i] = arrPreload[i].height;
        //		}
        //		imageWidthArray[i] = arrPreload[i].width;
        //		if(imageWidthArray[i] == 0 )
        //			imageWidthArray[i] = arrPreload[i].width;
        //			
        //		imageHeightArray[i] = arrPreload[i].height;
        //		if(imageHeightArray[i] == 0)
        //			imageHeightArray[i] = arrPreload[i].height;

        //		if(imageHeightArray[i] == 0 || imageWidthArray[i] == 0){
        //			imageDescArray[i] = "（大小：正在读取中…）";
        //		}else{
        //			imageDescArray[i] = "（大小：" + imageWidthArray[i] + "*" + imageHeightArray[i] + "）";
        //		}
    }
    return true;
}

/**
* linqz, 2006-7-20
* 算出按大小限制后的图片大小
*/
function imageP(curImg, type) {
    var sWidth;
    var sHeight;
    if (pWidth != 0 && pHeight != 0) {
        sWidth = pWidth;
        sHeight = pHeight;
    } else {
        if (type == 0) {
            sWidth = _SMALLWIDTH;
            sHeight = _SMALLHEIGHT;
        } else {
            sWidth = _LARGEWIDTH;
            sHeight = _LARGEHEIGHT;
        }
    }
    //	var image = new Image();
    //	image.src = src;
    //	var oWidth = image.width;
    //	var oHeight = image.height;
    //
    //	if (oWidth < sWidth && oHeight < sHeight){
    //		this.height = oHeight;
    //		this.width = oWidth;
    //	}else{
    //		var denominator = (oHeight > oWidth ? oHeight : oWidth);
    //		var numerator = ((oWidth / sWidth) > (oHeight / sHeight) ? sWidth : sHeight);
    //		this.height = Math.round(oHeight * (numerator / denominator));
    //		this.width = Math.round(oWidth * (numerator / denominator));
    //	}
    oWidth = imageWidthArray[curImg];
    oHeight = imageHeightArray[curImg];
    if (oWidth == 0 && oHeight == 0) {
        var image = new Image();
        image.src = imageSrcArray[curImg];
        oWidth = image.width;
        oHeight = image.height;
        if (oWidth == 0 && oHeight == 0) {
            image = new Image();
            image.src = imageSrcArray[curImg];
            oWidth = image.width;
            oHeight = image.height;
        }
        if (oWidth == 0 && oHeight == 0) {
            image = new Image();
            image.src = imageSrcArray[curImg];
            oWidth = image.width;
            oHeight = image.height;
        }
        if (oWidth < sWidth && oHeight < sHeight) {
            this.height = oHeight;
            this.width = oWidth;
        } else {
            //			var denominator = (oHeight > oWidth ? oHeight : oWidth);
            //			var numerator = ((oWidth / sWidth) > (oHeight / sHeight) ? sWidth : sHeight);

            var scale = (sWidth / oWidth) > (sHeight / oHeight) ? (sHeight / oHeight) : (sWidth / oWidth);
            this.height = Math.round(oHeight * scale);
            this.width = Math.round(oWidth * scale);
        }
    }
    else if (oWidth < sWidth && oHeight < sHeight) {
        this.height = oHeight;
        this.width = oWidth;
    }
    else {
        if (oHeight > sHeight || oWidth > sWidth) {
            this.height = sHeight;
            var scale = (sWidth / oWidth) > (sHeight / oHeight) ? (sHeight / oHeight) : (sWidth / oWidth);
            this.height = Math.round(oHeight * scale);
            this.width = Math.round(oWidth * scale);
        }
        else {
            this.height = oHeight;
            this.width = oWidth;
        }

    }
    if (this.width == 0 && this.height == 0) {
        this.width = _LARGEWIDTH;
        this.height = _LARGEHEIGHT;
    }
}

function imgLoadNotify() {
    imgIsLoaded = true;
    if (timerId == -1 && playerState == 1) {
        timerId = setTimeout('forward();timerId = -1', interval);
    }
}

function changeSlide(oncomplete) {
    if (document.getElementById("imgp") == null) {
        // 首页栏目拖动过程中，可能出现相册div不存在的情况，所以这里判断
        return;
    }

    htmlCont = "";
    if (numImgs == 0) {
        curImg = -1;
        htmlCont = noPicHtml;
        setButtonStatus("all_hidden");
    }
    else {
        if (addFunc == 1) {
            addFunction();
        }
        htmlCont = "<table width='100%' height='100%' cellpadding='0' cellspacing='0' >";
        if (!oncomplete) oncomplete = 'imgLoadNotify()';
        //	    var img = new imageP(imageSrcArray[curImg], widthe);
        var img = new imageP(curImg, widthe);
        if (document.getElementById("imgp") != null && numImgs > 1) {
            document.getElementById("imgp").style.filter = "blendTrans(duration=1)";
            try {
                document.getElementById("imgp").filters.blendTrans.Apply();
            }
            catch (e)
	    	{ }
        }
        imgIsLoaded = false;
        if (widthe == 1 && isNeedPicPagination == true) {
            htmlCont += "<tr><td align='center'>第" + (curImg + 1) + "张，共" + numImgs + "张</td></tr>";
        }
        var picLinkUrl = ""; // 播放图片的点击链接地址
        if (curImg < imageLinkArray.length) {
            picLinkUrl = imageLinkArray[curImg];
        }
        else {
            var picName = imageSrcArray[curImg];

            picLinkUrl = picName;
        }
        htmlCont += "<tr><td width='100%' align='center'>";
        htmlCont += "<img class='thumbImage' style='" + curImageStyle + "'  src=\"" + imageSrcArray[curImg] + "\""; //onclick=\"windowOpen('" + picLinkUrl + "');\"

        if (widthe == 1) {
            htmlCont += " alt=\"" + imageNameArray[curImg] + "\"";
        }

        if (img.width > 0 && img.height > 0) {
            htmlCont += "width=" + img.width + " height=" + img.height;
        }
        htmlCont += " border=0 onload=\"" + oncomplete + ";this.width=(this.width>500&&this.width>this.height?500:this.width)\" onerror=\"" + oncomplete + "\" onabort=\"" + oncomplete + "\">";
        htmlCont += "</td>";

        // htmlCont += "<tr><td>&nbsp;</td></tr>";
        if (widthe == 1) {
            htmlCont += "<td align='center'><span>" + imageNameArray[curImg] + "</span></td>";
        }
        htmlCont += "</tr>";
        htmlCont += "</table>";
    }
    // alert(htmlCont);
    if (document.getElementById("imgp") != null) {
        document.getElementById("imgp").innerHTML = htmlCont;
    }
    if (numImgs == 1 || numImgs == 0) {
        setButtonStatus("all_hidden");
    } else {
        try {
            document.getElementById("imgp").filters.blendTrans.Play();
        }
        catch (e)
		{ }

        setButtonStatus();
    }

    if (typeof (playCallbackFunction) == "function") {
        playCallbackFunction.call(this, curImg);
    }

}

function rewind() {
    if (curImg > 0) {
        curImg--;
        changeSlide();
    }
    setButtonStatus();
}

function setButtonStatus(type) {
    if (!type) {
        if (forwardObj != null) {
            if (curImg >= numImgs - 1) {
                //				forwardObj.style.visibility = "hidden";
                forwardObj.src = rootPath + buttonPicPrefix + spaceMark + forwardImages[1];
            } else {
                //				forwardObj.style.visibility = "visible";
                forwardObj.src = rootPath + buttonPicPrefix + spaceMark + forwardImages[0];
            }
        }
        if (rewindObj != null) {
            if (curImg <= 0) {
                //				rewindObj.style.visibility = "hidden";
                rewindObj.src = rootPath + buttonPicPrefix + spaceMark + rewardImages[1];
            } else {
                //				rewindObj.style.visibility = "visible";
                rewindObj.src = rootPath + buttonPicPrefix + spaceMark + rewardImages[0];
            }
        }
    }
    else if (type == "all_hidden") {
        if (forwardObj != null)
            forwardObj.style.visibility = "hidden";
        if (rewindObj != null)
            rewindObj.style.visibility = "hidden";
        if (playObj != null)
            playObj.style.visibility = "hidden";
        if (stopObj != null)
            stopObj.style.visibility = "hidden";
        if (speedObj != null)
            speedObj.style.visibility = "hidden";
        if (repeatObj != null)
            repeatObj.style.visibility = "hidden";
    }
}

function forward() {
    if (curImg >= numImgs - 1) {
        if (isRepeatPlay) {
            curImg = 0;
            changeSlide();
            play();
        }
        else {
            stop();
        }
    } else {
        curImg++;
        changeSlide();
        /* if (stopNum != 0 && curImg > stopNum){
        stop();
        }else{
        pause();
        }*/
    }
    if (typeof (imgAutoPage) == 'function') {
        imgAutoPage(curImg);
    }
    setButtonStatus();
}

function rewindPic() {
    rewind();
    pause();
}

function forwardPic() {
    forward();
    pause();
}


function stopPic() {
    stop();
}

function showPic(num) {
    curImg = num - 1;
    forward();
    window.location = "#PhotoContent";
}

function stop() {
    playerState = 0;
    window.clearInterval(timerId);
    if (timerId != -1) {
        clearTimeout(timerId);
        timerId = -1;
    }
    curImg = 0;
    changeSlide();

    imgIsLoaded = true;
    if (playObj) {
        playObj.src = rootPath + buttonPicPrefix + spaceMark + playImages[0];
        playObj.title = "播放";
        playObj.onclick = function() {
            play();
        }
    }
    if (stopObj) {
        stopObj.src = rootPath + buttonPicPrefix + spaceMark + stopImages[1];
    }
}

function play() {
    playerState = 1;
    if (timerId == -1) {
        timerId = setTimeout('forward();timerId=-1', interval);
    }

    if (playObj) {
        playObj.src = rootPath + buttonPicPrefix + spaceMark + playImages[1];
        playObj.title = "暂停";
        playObj.onclick = function() {
            pause();
        }
    }
    if (stopObj) {
        stopObj.src = rootPath + buttonPicPrefix + spaceMark + stopImages[0];
    }

}

function pause() {
    playerState = 0;
    window.clearInterval(timerId);
    if (timerId != -1) {
        clearTimeout(timerId);
        timerId = -1;
    }
    imgIsLoaded = true;
    if (playObj) {
        playObj.src = rootPath + buttonPicPrefix + spaceMark + playImages[0];
        playObj.title = "播放";
        playObj.onclick = function() {
            play();
        }
    }
}

function playPic() {
    play();
}


function init() {
    playObj = document.getElementById("play");
    forwardObj = document.getElementById("forward");
    rewindObj = document.getElementById("rewind");
    stopObj = document.getElementById("stop");
    speedObj = document.getElementById("speed");
    repeatObj = document.getElementById("repeat");

    numImgs = imageSrcArray.length;
    //preloadRange(0, numImgs);
    changeSlide();
    playerState = 1;
    // play();
    setRepeatPlay(false);
}

/*设置是否循环播放，请在init()方法后设置*/
function setRepeatPlay(bol) {
    if (bol != null) {
        isRepeatPlay = bol;
    }
    else {
        isRepeatPlay = !isRepeatPlay;
    }

    if (isRepeatPlay) {
        if (repeatObj) {
            repeatObj.src = rootPath + buttonPicPrefix + spaceMark + repeatImages[1];
        }
    }
    else {
        if (repeatObj) {
            repeatObj.src = rootPath + buttonPicPrefix + spaceMark + repeatImages[0];
        }
    }
}

/*设置按钮图片相对目录*/
function setButtonPicPrefix(val) {
    buttonPicPrefix = val;
}

function windowOpen(val) {
    if (isPicOpenInNewWindow) {
        window.open(val);
    }
    else {
        location.href = val;
    }
}

// 设置图片链接是否在新窗口中打开
function setPicOpenInNewWindow(val) {
    isPicOpenInNewWindow = val;
}

/**
*图片跑马灯效果
*/
var thumbPerWidth = 0; 			// 每个图片所在的宽度
var thumbPlaySpeedConstant = 30; 	// 缩略图翻页的时间片，单位ms
var thumbPlaySpeed = thumbPlaySpeedConstant;
var thumbInterval = null;
var isThumbPlayAuto = 0; 			// 是否自动滚屏，1为往下滚，-1为往上，0为否
var noPicHtml = "<center>无可查看相片！</center>"; // 没有图片时的提示信息

var thumbPageContentID = "thumbPageContent"; // 需滚动层的id
var thumbPagePreDivID = "thumbPagePreDiv"; 	// 上一页按钮所在div的id
var thumbPageNextDivID = "thumbPageNextDiv"; // 下一页按钮所在div的id

var imageBorder = 2; 	// 图片border宽度
var tableCellSpacing = 2; // 图片所在table的cellspacing
var imageDefaultCount = 4; // 默认图片显示最大数量
var imageMaxWidth = 160; 	// 图片最大宽度，同：<%=Constants.SMALL_IMAGE_WIDTH %>;
var imageMaxHeight = 120; // 图片最大高度，同：<%=Constants.SMALL_IMAGE_HEIGHT %>;
var picThumbSize = 0; // 缩略图每页数量
var picThumbInterval = 1000; // 缩略图自动下一张的时间周期
var picThumbVal = null;
var picThumbForceStop = false; // 强制自动翻页暂停

var _showPicThumbTimerID = null;
var _showPicThumbTimerOut = 500; //mouseover触发，缩略图自动播放的延迟


// 缩略图单个下翻页
function thumbPlayPerNext(need2Pause) {
    var obj = document.getElementById(thumbPageContentID);

    if (thumbInterval) {
        if (isThumbPlayAuto != 0) {
            thumbInterval = window.clearInterval(thumbInterval);
            isThumbPlayAuto = 0;
        }
        else {
            return;
        }
    }
    var startScrollLeft = Math.floor(obj.scrollLeft / thumbPerWidth) * thumbPerWidth;
    thumbInterval = window.setInterval("thumbPlayPerNextAuto(" + startScrollLeft + ");", thumbPlaySpeed);

    if (need2Pause == true) {
        pause();
    }

}

// 缩略图单个下翻页，立即跳到下一张
function thumbPlayPerNextPage() {
    var obj = document.getElementById(thumbPageContentID);

    if (thumbInterval) {
        if (isThumbPlayAuto != 0) {
            thumbInterval = window.clearInterval(thumbInterval);
            isThumbPlayAuto = 0;
        }
    }
    var startScrollLeft = Math.floor(obj.scrollLeft / thumbPerWidth) * thumbPerWidth;
    obj.scrollLeft = startScrollLeft + (picThumbSize - 1) * thumbPerWidth;
    thumbPageButton();

    pause();
}

// 缩略图单个下翻页的interval方法
function thumbPlayPerNextAuto(startScrollLeft) {
    isThumbPlayAuto = 0;
    var obj = document.getElementById(thumbPageContentID);

    if (obj.scrollLeft < startScrollLeft + thumbPerWidth) {
        obj.scrollLeft++;
    }
    else {
        thumbInterval = window.clearInterval(thumbInterval);
    }
    thumbPageButton();
}

// 缩略图单个上翻页方法
function thumbPlayPerPre(need2Pause) {
    var obj = document.getElementById(thumbPageContentID);

    var startScrollLeft = Math.floor(obj.scrollLeft / thumbPerWidth) * thumbPerWidth;
    if (thumbInterval) {
        if (isThumbPlayAuto != 0) {
            thumbInterval = window.clearInterval(thumbInterval);
            isThumbPlayAuto = 0;
            startScrollLeft += thumbPerWidth; // 如果是自动上翻页时，点击单个翻页
        }
        else {
            return;
        }
    }
    thumbInterval = window.setInterval("thumbPlayPerPreAuto(" + startScrollLeft + ");", thumbPlaySpeed);

    if (need2Pause == true) {
        pause();
    }
}

// 缩略图单个上翻页方法，立即跳到上一张
function thumbPlayPerPrePage() {
    var obj = document.getElementById(thumbPageContentID);

    var startScrollLeft = Math.floor(obj.scrollLeft / thumbPerWidth) * thumbPerWidth;
    if (thumbInterval) {
        if (isThumbPlayAuto != 0) {
            thumbInterval = window.clearInterval(thumbInterval);
            isThumbPlayAuto = 0;
            startScrollLeft += thumbPerWidth; // 如果是自动上翻页时，点击单个翻页
        }
    }
    obj.scrollLeft = startScrollLeft - (picThumbSize - 1) * thumbPerWidth;
    thumbPageButton();

    pause();
}

// 缩略图单个上翻页的interval方法
function thumbPlayPerPreAuto(startScrollLeft) {
    isThumbPlayAuto = 0;
    var obj = document.getElementById(thumbPageContentID);
    if (obj.scrollLeft <= 0) {
        thumbInterval = window.clearInterval(thumbInterval);
    }
    else if (obj.scrollLeft > startScrollLeft - thumbPerWidth) {
        obj.scrollLeft--;
    }
    else {
        thumbInterval = window.clearInterval(thumbInterval);
    }
    thumbPageButton();
}

function thumbPlayNextTimeOut() {
    _showPicThumbTimerID = window.setTimeout("thumbPlayNext();", _showPicThumbTimerOut);
}

// 缩略图自动下翻页方法
function thumbPlayNext() {
    if (thumbInterval && isThumbPlayAuto == -1) {
        return;
    }
    else if (thumbInterval) {
        thumbInterval = window.clearInterval(thumbInterval);
    }
    var obj = document.getElementById(thumbPageContentID);
    thumbInterval = window.setInterval("thumbPlayNextAuto();", thumbPlaySpeed);

    pause();
}

// 缩略图自动下翻页inteval方法
function thumbPlayNextAuto() {
    var obj = document.getElementById(thumbPageContentID);
    if (obj.scrollLeft >= obj.scrollWidth - obj.clientWidth) {
        thumbInterval = window.clearInterval(thumbInterval);
        isThumbPlayAuto = 0;
    }
    else {
        isThumbPlayAuto = 1;
        obj.scrollLeft++;
    }
    thumbPageButton();
}

function thumbPlayPreTimeOut() {
    _showPicThumbTimerID = window.setTimeout("thumbPlayPre();", _showPicThumbTimerOut);
}

// 缩略图自动上翻页方法
function thumbPlayPre() {
    if (thumbInterval && isThumbPlayAuto == 1) {
        return;
    }
    else if (thumbInterval) {
        thumbInterval = window.clearInterval(thumbInterval);
    }
    var obj = document.getElementById(thumbPageContentID);
    thumbInterval = window.setInterval("thumbPlayPreAuto();", thumbPlaySpeed);

    pause();
}

// 缩略图自动上翻页interval方法
function thumbPlayPreAuto() {
    var obj = document.getElementById(thumbPageContentID);
    if (obj.scrollLeft <= 0) {
        thumbInterval = window.clearInterval(thumbInterval);
        isThumbPlayAuto = 0;
    }
    else {
        obj.scrollLeft--;
        isThumbPlayAuto = -1;
    }
    thumbPageButton();
}

// 取消缩略图自动滚屏
function clearThumbPlayAuto() {
    if (_showPicThumbTimerOut) {
        window.clearTimeout(_showPicThumbTimerID);
    }

    if (thumbInterval && isThumbPlayAuto != 0) {
        thumbInterval = window.clearInterval(thumbInterval);

        var obj = document.getElementById(thumbPageContentID);
        var startScrollLeft = Math.floor(obj.scrollLeft / thumbPerWidth) * thumbPerWidth;
        if (isThumbPlayAuto == -1) {
            startScrollLeft += thumbPerWidth;
            thumbInterval = window.setInterval("thumbPlayPerPreAuto(" + startScrollLeft + ")", thumbPlaySpeed);
        }
        else if (isThumbPlayAuto == 1) {
            thumbInterval = window.setInterval("thumbPlayPerNextAuto(" + startScrollLeft + ")", thumbPlaySpeed);
        }
        isThumbPlayAuto = 0;
    }
}

// 判断翻页button是否显示
function thumbPageButton() {
    var obj = document.getElementById(thumbPageContentID);
    var bt_up = document.getElementById(thumbPagePreDivID);
    var bt_dn = document.getElementById(thumbPageNextDivID);
    if (obj.scrollWidth > obj.clientWidth) {
        if (obj.scrollLeft <= 0) {
            bt_up.style.visibility = "hidden";
        }
        else {
            bt_up.style.visibility = "visible";
        }
        if (obj.scrollLeft + obj.clientWidth >= obj.scrollWidth) {
            bt_dn.style.visibility = "hidden";
        }
        else {
            bt_dn.style.visibility = "visible";
        }

    }
    else {
        bt_up.style.visibility = "hidden";
        bt_dn.style.visibility = "hidden";
    }
}

// 根据 PageMid的宽度，计算出最大显示图片数量
function countImagesLimit() {
    var imageC = imageDefaultCount;
    var mid = document.getElementById("pageMid");
    if (mid) {
        // 计算图片的显示数量，以控制层的宽度不超过pageMid的宽度
        var buttonWidth = 32; 	// 2个左右翻页按钮的宽度
        var divPadding = 10; 	// 样式定义上 module content 每套模板都有padding，这里使用通用值padding=5
        var imageTotalWidth = (imageC * imageMaxWidth) + ((imageC + 1) * tableCellSpacing) + ((imageC) * 2 * imageBorder) + buttonWidth + divPadding;
        while ((mid.clientWidth <= imageTotalWidth) && imageC >= 0) {
            imageC--;
            imageTotalWidth = (imageC * imageMaxWidth) + ((imageC + 1) * tableCellSpacing) + ((imageC) * 2 * imageBorder) + buttonWidth + divPadding;
        }
    }
    // alert(imageC);
    return imageC;
}

function initMarquee() {

    var obj = document.getElementById("thumbPageContent");

    picThumbSize = countImagesLimit();
    obj.style.width = (picThumbSize * imageMaxWidth) + ((picThumbSize + 1) * tableCellSpacing) + ((picThumbSize) * 2 * imageBorder);
    obj.style.height = imageMaxHeight + (picThumbSize * (2 * (tableCellSpacing + imageBorder)));
    obj.style.overflow = "hidden";

    marquee = document.createElement("div");
    var elem = document.createElement("table");
    elem.cellSpacing = tableCellSpacing;
    elem.cellPadding = 0;
    elem.border = 0;
    elem.insertRow();

    if (imageSrcArray.length > 0) {
        for (var i = 0; i < imageSrcArray.length; i++) {
            var elemTD = elem.rows[0].insertCell();
            elemTD.width = imageMaxWidth;
            elemTD.height = imageMaxHeight;
            elemTD.style.overflow = "hidden";
            elemTD.style.align = "center";
            elemTD.style.verticalAlign = "middle";

            var html = "";
            html += "<div style=\"width:" + (imageMaxWidth + 2 * imageBorder) + ";height:" + (imageMaxHeight + 2 * imageBorder) + ";\">";
            html += "<table width=\"100%\" height=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td align=\"center\" valign=\"middle\">";
            html += "<img style=\"cursor:hand;border:2px solid #FFF;margin:auto;\"";
            html += " src=\"" + imageSrcArray[i] + "\" onclick=\"windowOpen('" + imageLinkArray[i] + "');\" alt=\"" + imageNameArray[i] + "\"";
            html += " border=\"0\" />";
            html += "</td></tr></table>";
            html += "</div>";

            elemTD.innerHTML = html;
        }
    }
    else {
        // elemTD = elem.rows[0].insertCell();
        // elemTD.innerHTML = noPicHtml; // noPicHtml
        obj.innerHTML = noPicHtml;
    }
    marquee.appendChild(elem);
    obj.appendChild(marquee);

    thumbPerWidth = imageMaxWidth + 2 * imageBorder + tableCellSpacing;
}










window.$util = {
    _excludeList: {
        _$m: true,
        _$g: true
    },
    setDefaultCopyAttrExcludeList: function(o) {
        window.$util._exclucdeList = {};
        if (o instanceof Array) {
            for (var i = 0; i < o.length; i++) window.$util._exclucdeList[o[i].toString()] = true;
        } else {
            for (var i in o) window.$util._excludeList[i] = true;
        }
    },

    cpAttr: function(des, src, overwrite, exclude) {
        if (des == null || src == null) throw new Error("source or destinition can not be null. source : " + src + "\n destinition : " + des);
        overwrite = overwrite == true;
        exclude = exclude || {};
        var _e = window.$util._excludeList;
        for (var i in src) if ((overwrite || des[i] == null) && exclude[i] == null && _e[i] == null) des[i] = src[i];
    },

    voidFunc: function() { },

    $: function(id, doc) {
        return (doc || document).getElementById(id);
    },
    $$: function(ids, root) {
        var ar = ids.split(".");
        var i = 0;
        root = root || (i++, $util.$(ar[0]));
        if (root == null) return null;
        for (; i < ar.length; i++) {
            var id = ar[i];
            if (id == "") continue;
            if (ar[i - 1] == "") {//deal ".." symbol, to find element in all descendants.		
                var _al = root.getElementsByTagName("*"), _l = _al.length;
                for (var k = 0; k < _l; k++) {
                    if (_al[k].id == id) {
                        var s = $util.$$(ar.slice(i + 1).join("."), _al[k]);
                        if (s != null) return s;
                    }
                }
                return null;
            } else {
                var sb = root.childNodes, jl = sb.length;
                for (var j = 0; j < jl; j++) {
                    var n = sb[j];
                    if (n.nodeType == 1 && n.id == id) {
                        root = n;
                        break;
                    }
                }
                if (j == jl) return null;
            }
        }
        return root;
    },
    $t: function(node, xp) {
        var ar = xp.split("/"), l = ar.length;
        for (var i = 0; i < l; i++) {
            if (ar[i] == "") continue;
            if (ar[i - 1] == "") { //deal with all descendants
            } else {
                var xn = ar[i];
                if (xn == ".") continue;
            }
        }
    },
    tempNode: function(doc) {
        return (doc || document).createElement("div");
    },

    node: function(name, attr, doc) {
        var n = (doc || document).createElement(name);
        for (var i in attr) n[i] = attr[i];
        return n;
    },
    nodeFromHtml: function(html, doc) {
        return $util.nodesFromHtml(html, doc)[0];
    },
    nodesFromHtml: function(html, doc) {
        var e = $util.tempNode(doc);
        e.innerHTML = html;
        return e.childNodes;
    },
    addEL: function(n, e, l, b) {
        b = b != false;

        if (navigator.appName == "Microsoft Internet Explorer") {
            n.attachEvent("on" + e, l);
        } else {
            n.addEventListener(e, l, b);
        }
    },
    getEventSrc: function(e) {
        e = e || window.event;
        return e.target || e.srcElement;
    },
    cancelEvent: function(e) {
        return;
        if (navigator.appName == "Microsoft Internet Explorer") {
            e.returnValue = false;
            e.cancelBubble = true;
        } else
            e.preventDefault();
    },
    urlParam: function(url, params) {
        var s = [];
        for (var i in params) s[s.length] = i + "=" + params[i];
        var l = url.indexOf("?") == -1 ? "?" : "&";
        if (s.length == 0) return url;
        else return url + l + s.join("&");
    },
    getFuncName: function(func) {
        if (func.getName) return func.getName();
        for (var i in window) {
            if (window[i] == func) {
                var name = i;
                func.getName = function() {
                    return name;
                }
                return name;
            }
        }
        return null;
    },

    createGetFuncName: function(func, name) {
        return function() { return name; }
    },
    createFuncCall: function(func) {
        var name = "_func_" + new Date().getTime() + Math.random();
        name = name.replace(/\./g, "");
        window[name] = func;
        return name + "();";
    },
    getStrWrap: function(str, charset) {
        return $str.getStrWrap(str, charset);
    },
    __substr: function(start, len) {
        return $str.__substr(start, len);
    },
    getShort: function(str, len) {
        return $str.getShort(str, len);
    },
    vobj: function(o) {
        if (o.constructor == Object) {
            o.constructor = function() { };
            o.constructor.prototype = o;
        }
        return new o.constructor();
    }
}


var x = window.AlbumBrowser = function(lh, displayAmount) {

    this.displayAmount = displayAmount;
    this.half = 2;
    this.total = 0;
    this.position = 0;
    this.listHolder = lh;
    this.tables = null;
    this.currentId = null;
    this.init();

}

var p = {

    init: function() {
        var tables = this.tables = this.listHolder.getElementsByTagName("table");
        this.position = 0;
        this.total = tables.length;
        var pre = $util.$("movePre");
        var next = $util.$("moveNext");
        var thiz = this;
        $util.addEL(pre, "click", function(e) { thiz.preAlbum(); $util.cancelEvent(e || window.event); });
        $util.addEL(next, "click", function(e) { thiz.nextAlbum(); $util.cancelEvent(e || window.event); });

        for (var i = 0; i < this.total; i++) {
            var tb = this.tables[i];

            if (i < this.displayAmount) {
                tb.style.display = "";
            }



        }


    },




    getSelectId: function() {
        return this.currentId;
    },
    getSelection: function() {
        return this.selection;
    },
    setSelection: function(id, needScroll) {
        needScroll = (needScroll == true);
        this.selection = null;
        this.currentId = id;
        var idx = null;
        for (var i = 0; i < this.total; i++) {
            var tb = this.tables[i];
            tb.markElm = $util.$$("..mark", tb);

            if (tb.id != this.currentId) {
                this.setMark(i, false);
            } else {
                this.setMark(i, true);
                idx = i;
                this.selection = tb
            }
        }
        if (idx != null && needScroll) {
            this.scrollTo(idx);
        }
        return this.selection;
    },
    scrollTo: function(idx) {
        if (idx >= this.total - this.half) idx = this.total - this.half - 1;
        if (idx < this.half) idx = this.half;
        var i1 = idx - this.half, i2 = idx + this.half;
        if (i1 < 0) i1 = 0;
        if (i2 >= this.total) i2 = this.total - 1;
        this.position = i1;
        for (var i = 0; i < this.total; i++) {
            var t = this.tables[i];
            if (i < i1 || i > i2)
                this.hideAlbum(i);
            else
                this.showAlbum(i);
        }
    },
    refresh: function() {
        return;
        var fr = document.getElementById("gallery");
        var r = fr.style.display;
        fr.style.display = "none";
        fr.style.display = r;

    },

    setMark: function(i, f) {
        this.tables[i].markElm.style.display = f ? "" : "none";
    },

    preAlbum: function() {
        var i = this.position, t = i > 0;
        t ? (i = --this.position, this.hideAlbum(i + this.displayAmount), this.showAlbum(i)) : null;
        this.refresh();

    },
    nextAlbum: function() {

        var i = this.position, t = i < (this.total - this.displayAmount);
        t ? (this.hideAlbum(i), this.showAlbum(i + this.displayAmount), ++this.position) : null;
        this.refresh();
    },

    hideAlbum: function(i) {
        this.tables[i].style.display = "none";
    },

    showAlbum: function(i) {

        this.tables[i].style.display = "";
        var img = this.tables[i].getElementsByTagName("img")[1];
        if (img.height > 105) {
            img.height = 105;
        }
    }

}

$util.cpAttr(x.prototype, p, true);

var lastblogPhotoId;
var enableEdit = true;

setSelect = function(photoAlbumId, name) {

    document.getElementById("mark" + lastblogPhotoId).style.display = "none";
    document.getElementById("mark" + photoAlbumId).style.display = "";
    lastblogPhotoId = photoAlbumId;
    document.getElementById("currentPhotoAlbumName").innerText = name;
    document.getElementById("add").setAttribute("photoAlbumId", photoAlbumId);
    document.getElementById("add").href = "addBlogPhoto.aspx?photoAlbumId=" + photoAlbumId;
    if (enableEdit) {
        InitGetBlogPhotoList(photoAlbumId, 12, 1);
    }
    else {
        InitGetBlogPhotoList(photoAlbumId, 10000, 1);
    }
}

InitGetBlogPhotoList = function(photoAlbumId, pageSize, pageIndex) {

    var aParamValues = new Array();
    aParamValues["PageIndex"] = pageIndex;
    aParamValues["pageSize"] = pageSize;
    aParamValues["PageScript"] = "InitGetBlogPhotoList('" + photoAlbumId + "','" + pageSize + "' ,{0})";
    jQuery.ajax({
        type: "POST",
        contentType: "application/json",
        data: "{ BlogPhotoId: '" + photoAlbumId + "',pageIndex:'" + pageIndex + "',pageSize:'" + pageSize + "'}",
        dataType: "json",
        url: "/Service/BlogPhotoAlbum.asmx/GetBlogPhotoList",
        success: function(result) {
            if (enableEdit) {
                onInitGetBlogPhotoList(result.d, aParamValues);
            }
            else {
                onInitSlideGetBlogPhotoList(result.d, aParamValues);
            }
        }
    });

}

onInitGetBlogPhotoList = function(result, aParamValues) {

    var pi = result.List;
    document.getElementById("showListPhoto").innerHTML = "";

    for (var i = 0; i < pi.length; i++) {

        var divPhotoBorder = document.createElement("Div");
        divPhotoBorder.setAttribute("id", "divPhoto" + i);

        //  divPhotoBorder.setAttribute("height","180");


        var tablePhoto = document.createElement("table");
        tablePhoto.setAttribute("className", "divPhotoborder");
        var trl = tablePhoto.insertRow();
        var tdl = trl.insertCell();
        var a = document.createElement("a");
        tdl.appendChild(a);
        a.innerHTML = pi[i].Src;
        var img = a.getElementsByTagName("img");
        img[0].style.cursor = "hand";
        try {
            img[0].border = 0;
        }
        catch (e)
     { }
        var imgAddress = img[0].src.replace("/reduce", "");
        a.setAttribute("href", imgAddress);
        a.setAttribute("target", "_blank");
        tdl.setAttribute("className", "divTablePhoto");

        divPhotoBorder.appendChild(tablePhoto);
        var trl1 = tablePhoto.insertRow();

        var tdl1 = trl1.insertCell();

        trl1.style.height = "25px";

        if (enableEdit == true) {

            var check = document.createElement("input");
            check.setAttribute("type", "checkbox");
            check.setAttribute("picId", pi[i].PkId);
            tdl1.appendChild(check);
        }

        var span = document.createElement("span");
        span.setAttribute("id", i);
        span.className = 'text-overflow';
        span.style.width = "70px";
        span.style.cursor = "hand";



        var textNode = document.createTextNode(pi[i].Name);
        span.appendChild(textNode);
        tdl1.appendChild(span);

        var picNameInput = document.createElement("input");
        picNameInput.setAttribute("type", "text");
        picNameInput.setAttribute("size", "7");
        picNameInput.setAttribute("picId", pi[i].PkId);
        picNameInput.style.display = "none";

        tdl1.appendChild(picNameInput);





        document.getElementById("showListPhoto").appendChild(divPhotoBorder);

        if (enableEdit == true) {
            setPicTitle(span, picNameInput);
            updatePicTitle(span, picNameInput);
        }

    }
    document.getElementById("photoPage").innerHTML = CreatePageNav(aParamValues["PageIndex"], result.PageCount, aParamValues["PageScript"]);
}


window.setPicTitle = function(span, picNameInput) {

    $util.addEL(span, "click", function(e) { span.style.display = "none"; picNameInput.value = span.innerText; picNameInput.style.display = ""; picNameInput.focus(); });


}


window.updatePicTitle = function(span, picNameInput) {

    $util.addEL(picNameInput, "blur", function(e) { actionPicTitle(span, picNameInput) });


}

window.actionPicTitle = function(span, picNameInput) {
    span.style.display = "";
    picNameInput.style.display = "none";
    if (span.innerText != picNameInput.value && picNameInput.value != "") {
        span.innerText = picNameInput.value;
        jQuery.ajax({
            type: "POST",
            contentType: "application/json",
            data: "{ photoId: '" + picNameInput.picId + "',name:'" + picNameInput.value + "'}",
            dataType: "json",
            url: "/Service/BlogPhotoAlbum.asmx/UpdatePhotoName"
        });    
    }
}




selectAllPhoto = function() {
    var checkboxs = document.getElementsByTagName("input");
    for (var i = 0; i < checkboxs.length; i++) {
        if (checkboxs[i].type == "checkbox") {
            checkboxs[i].checked = true;
        }
    }
}

unSelectAllPhoto = function() {
    var checkboxs = document.getElementsByTagName("input");
    for (var i = 0; i < checkboxs.length; i++) {
        if (checkboxs[i].type == "checkbox") {
            checkboxs[i].checked = false;
        }
    }
}
var checkedboxs = new Array();


setPhotoConver = function() {
    checkedboxs = new Array();
    var inputs = document.getElementsByTagName("input");
    var counter = 0;
    for (var i = 0; i < inputs.length; i++) {
        if (inputs[i].type == "checkbox" && inputs[i].checked == true) {
            checkedboxs[counter] = inputs[i];
            counter++;
        }
    }
    if (checkedboxs.length == 0) {
        _error_msg_show("请先选择要设置为相册封面的图片！");
        return;
    }

    if (checkedboxs.length != 1) {
        _error_msg_show("只能选择一张图片设置为相册封面！");
        return;
    }
    jQuery.ajax({
        type: "POST",
        contentType: "application/json",
        data: "{ photoId: '" + checkedboxs[0].picId + "'}",
        dataType: "json",
        url: "/Service/BlogPhotoAlbum.asmx/setPhotoConver"
    });
    _error_msg_show("设置完成！");

}


delSelectPic = function() {
    checkedboxs = new Array();
    var inputs = document.getElementsByTagName("input");
    var counter = 0;
    for (var i = 0; i < inputs.length; i++) {
        if (inputs[i].type == "checkbox" && inputs[i].checked == true) {
            checkedboxs[counter] = inputs[i];
            counter++;
        }
    }
    if (checkedboxs.length == 0) {
        _error_msg_show("请先选择要删除的图片！");
        return;
    }
    _confirm_msg_show("你确定要删除选中的图片？", "click_ok();", null, "标题")
}

window.click_ok = function() {
    for (var i = 0; i < checkedboxs.length; i++) {
        jQuery.ajax({
            type: "POST",
            contentType: "application/json",
            data: "{ photoId: '" + checkedboxs[i].picId + "'}",
            dataType: "json",
            url: "/Service/BlogPhotoAlbum.asmx/DelPhotoByPhotoId"
        });
    }


    if (circleId == 0) {
        setSelect(document.getElementById("add").photoAlbumId, document.getElementById("currentPhotoAlbumName").innerText);
    }
    else {
        setSecondCirclePhotoSelect(document.getElementById("add").photoAlbumId, document.getElementById("add").blogPhotoId, document.getElementById("currentPhotoAlbumName").innerText, document.getElementById("add").copyFrom);

    }
}


transferPic = function() {

    checkedboxs = new Array();
    var inputs = document.getElementsByTagName("input");
    var counter = 0;
    for (var i = 0; i < inputs.length; i++) {
        if (inputs[i].type == "checkbox" && inputs[i].checked == true) {
            checkedboxs[counter] = inputs[i];
            counter++;
        }
    }
    if (checkedboxs.length == 0) {
        _error_msg_show("请先选择要转移的图片！");
        return;
    }
    _error_msg_show(document.getElementById("destSpan").innerHTML, "operateTransferPic()");
    //   _confirm_msg_show(document.getElementById("destSpan").innerHTML,null,null , "标题")
}

var firstSelectPhotoAlbumId;
var selectPhotoAlbumId;

setPhotoAlbumId = function(Id) {
    selectPhotoAlbumId = Id;

}

operateTransferPic = function() {

    if (selectPhotoAlbumId == document.getElementById("add").photoAlbumId) //改blogPhotoId 为 photoAlbumId
    {
        _error_msg_show("请选择不同的相册才能迁移图片！");

        selectPhotoAlbumId = firstSelectPhotoAlbumId;
        return;
    }
    for (var i = 0; i < checkedboxs.length; i++) {
        jQuery.ajax({
            type: "POST",
            contentType: "application/json",
            data: "{ photoId: '" + checkedboxs[i].picId + "',photoAlbumId:'" + selectPhotoAlbumId + "'}",
            dataType: "json",
            url: "/Service/BlogPhotoAlbum.asmx/TransferPhoto"
        });
    }
    _error_msg_show("迁移完成！");

    if (circleId == 0) {
        setSelect(document.getElementById("add").photoAlbumId, document.getElementById("currentPhotoAlbumName").innerText);
    }
    else {
        setCirclePhotoSelect(document.getElementById("add").photoAlbumId, document.getElementById("currentPhotoAlbumName").innerText);
    } selectPhotoAlbumId = firstSelectPhotoAlbumId;
}


//圈子相册第二版，支持个人空间提交，圈子提交

var lastCirclePhotoId;
var circleId = 0;
setSecondCirclePhotoSelect = function(photoAlbumId, blogPhotoId, name, copyFrom) {


    document.getElementById("mark" + lastCirclePhotoId).style.display = "none";
    document.getElementById("mark" + photoAlbumId).style.display = "";
    lastCirclePhotoId = photoAlbumId;
    document.getElementById("currentPhotoAlbumName").innerText = name;
    document.getElementById("add").setAttribute("photoAlbumId", photoAlbumId);
    document.getElementById("add").setAttribute("blogPhotoId", blogPhotoId);
    document.getElementById("add").setAttribute("copyFrom", copyFrom);



    document.getElementById("add").href = "addCirclePhoto.aspx?pkId=" + circleId + "&photoAlbumId=" + photoAlbumId;
    if (copyFrom == 0) {
        if (enableEdit) {
            InitGetCirclePhotoList(photoAlbumId, 12, 1);

        }
        else {
            InitGetCirclePhotoList(photoAlbumId, 1000, 1);
        }

    }

    if (copyFrom == 3) {
        if (enableEdit) {
            InitGetCirclePhotoList(blogPhotoId, 12, 1);
        }
        else {
            InitGetCirclePhotoList(blogPhotoId, 1000, 1);

        }

    }

    if (copyFrom == 1) {

        if (enableEdit) {
            InitGetBlogPhotoList(blogPhotoId, 12, 1);
        }
        else {
            InitGetBlogPhotoList(blogPhotoId, 10000, 1);
        }

    }

}


InitGetCirclePhotoList = function(photoAlbumId, pageSize, pageIndex) {
    var aParamValues = new Array();
    aParamValues["PageIndex"] = pageIndex;
    aParamValues["pageSize"] = pageSize;
    aParamValues["PageScript"] = "InitGetCirclePhotoList('" + photoAlbumId + "','" + pageSize + "' ,{0})";
    jQuery.ajax({
        type: "POST",
        contentType: "application/json",
        data: "{ CirclePhotoId: '" + photoAlbumId + "',pageIndex:'" + pageIndex + "',pageSize:'" + pageSize + "'}",
        dataType: "json",
        url: "/Service/BlogPhotoAlbum.asmx/GetCirclePhotoList",
        success: function(result) {
            if (enableEdit) {
                onInitGetCirclePhotoList(result.d, aParamValues);
            }
            else {
                onInitSlideGetCirclePhotoList(result.d, aParamValues);
            }
        }
    });  

}

onInitGetCirclePhotoList = function(result, aParamValues) {

    var pi = result.List;
    document.getElementById("showListPhoto").innerHTML = "";

    for (var i = 0; i < pi.length; i++) {

        var divPhotoBorder = document.createElement("Div");
        divPhotoBorder.setAttribute("id", "divPhoto" + i);

        //  divPhotoBorder.setAttribute("height","180");


        var tablePhoto = document.createElement("table");
        tablePhoto.setAttribute("className", "divPhotoborder");
        var trl = tablePhoto.insertRow();
        var tdl = trl.insertCell();
        var a = document.createElement("a");
        tdl.appendChild(a);
        a.innerHTML = pi[i].Src;
        var img = a.getElementsByTagName("img");
        img[0].style.cursor = "hand";
        try {
            img[0].border = 0;
        }
        catch (e)
     { }
        var imgAddress = img[0].src.replace("/reduce", "");
        a.setAttribute("href", imgAddress);
        a.setAttribute("target", "_blank");
        tdl.setAttribute("className", "divTablePhoto");

        divPhotoBorder.appendChild(tablePhoto);
        var trl1 = tablePhoto.insertRow();

        var tdl1 = trl1.insertCell();
        trl1.style.height = "25px";
        if (enableEdit == true) {

            var check = document.createElement("input");
            check.setAttribute("type", "checkbox");
            check.setAttribute("picId", pi[i].PkId);
            tdl1.appendChild(check);
        }

        var span = document.createElement("span");
        span.setAttribute("id", i);
        span.className = 'text-overflow';
        span.style.width = "70px";

        var textNode = document.createTextNode(pi[i].Name);
        span.appendChild(textNode);
        tdl1.appendChild(span);

        var picNameInput = document.createElement("input");
        picNameInput.setAttribute("type", "text");
        picNameInput.setAttribute("size", "7");
        picNameInput.setAttribute("picId", pi[i].PkId);
        picNameInput.style.display = "none";
        tdl1.appendChild(picNameInput);





        document.getElementById("showListPhoto").appendChild(divPhotoBorder);

        if (enableEdit == true) {
            setPicTitle(span, picNameInput);
            updatePicTitle(span, picNameInput);
        }

    }
    document.getElementById("photoPage").innerHTML = CreatePageNav(aParamValues["PageIndex"], result.PageCount, aParamValues["PageScript"]);
}



onInitSlideGetBlogPhotoList = function(result, aParamValues) {

    var pi = result.List;
    document.getElementById("thumbPageContent").innerHTML = "";




    var pa1 = "";
    imageSrcArray = new Array();
    imageNameArray = new Array();
    imageLinkArray = new Array();
    imageIdArray = new Array();
    imageSmallSrcArray = new Array();
    imageCommentCountArray = new Array();

    for (var i = 0; i < pi.length; i++) {

        var a = document.createElement("a");

        a.innerHTML = pi[i].Src;
        var img = a.getElementsByTagName("img");



        pa1 = pa1 + "<TD>";
        pa1 = pa1 + "<DIV class=picOther id=thumbDivs";
        pa1 = pa1 + " onmouseover=\"this.className='picOver'\" title=" + pi[i].Name;
        pa1 = pa1 + " onclick=playPicPause(" + i + ");";
        pa1 = pa1 + " onmouseout=\"this.className='picOther';\" Index=\"" + i + "\">";
        pa1 = pa1 + " <IMG  style=\"BORDER-RIGHT: #fff 2px solid; BORDER-TOP: #fff 2px solid; BORDER-LEFT: #fff 2px solid; BORDER-BOTTOM: #fff 2px solid\"";
        pa1 = pa1 + " height=60 src=\"" + img[0].src + "\" ";
        pa1 = pa1 + " width=60></DIV></TD>";



        imageSrcArray[i] = img[0].src.replace("reduce", "");
        imageNameArray[i] = pi[i].Name;
        imageLinkArray[i] = "../view.htm?Id=4028818d187f077201187f869ad500dc";

        imageIdArray[i] = "4028818d187f077201187f869ad500dc";
        imageCommentCountArray[i] = "0";
        imageSmallSrcArray[i] = img[0].src;


    }
    numImgs = pi.length;
    document.getElementById("thumbPageContent").innerHTML = "<TABLE cellSpacing=0 cellPadding=0 width=\"" + pi.length * 70 + "\" border=0><TBODY><tr>" + pa1 + "</tr></TBODY></TABLE>";


    thumbPerWidth = thumbPerWidth;
    albumRightW = document.getElementById("albumright").clientWidth;
    cols = Math.floor((albumRightW - 38) / (thumbPerWidth));
    if (cols > 6 || cols <= 0) {
        cols = 6;
    }
    picThumbSize = cols;
    document.getElementById("imgp").innerHTML = "";
    if (document.getElementById("picThumbDiv") != null) {
        document.getElementById("picThumbDiv").style.width = thumbPerWidth * cols + 38;
        document.getElementById("thumbPageContent").style.width = thumbPerWidth * cols;
        document.getElementById("thumbPageContent").style.overflowX = "hidden";

        setPicOpenInNewWindow(false);
        isNeedPicPagination = false;
        showPic(playPicIndex);
        thumbPageButton();
    }


    init();


}



onInitSlideGetCirclePhotoList = function(result, aParamValues) {

    var pi = result.List;
    document.getElementById("thumbPageContent").innerHTML = "";




    var pa1 = "";
    imageSrcArray = new Array();
    imageNameArray = new Array();
    imageLinkArray = new Array();
    imageIdArray = new Array();
    imageSmallSrcArray = new Array();
    imageCommentCountArray = new Array();

    for (var i = 0; i < pi.length; i++) {

        var a = document.createElement("a");

        a.innerHTML = pi[i].Src;
        var img = a.getElementsByTagName("img");



        pa1 = pa1 + "<TD>";
        pa1 = pa1 + "<DIV class=picOther id=thumbDivs";
        pa1 = pa1 + " onmouseover=\"this.className='picOver'\" title=" + pi[i].Name;
        pa1 = pa1 + " onclick=playPicPause(" + i + ");";
        pa1 = pa1 + " onmouseout=\"this.className='picOther';\" Index=\"" + i + "\">";
        pa1 = pa1 + " <IMG  style=\"BORDER-RIGHT: #fff 2px solid; BORDER-TOP: #fff 2px solid; BORDER-LEFT: #fff 2px solid; BORDER-BOTTOM: #fff 2px solid\"";
        pa1 = pa1 + " height=60 src=\"" + img[0].src + "\" ";
        pa1 = pa1 + " width=60></DIV></TD>";



        imageSrcArray[i] = img[0].src.replace("reduce", "");
        imageNameArray[i] = pi[i].Name;
        imageLinkArray[i] = "../view.htm?Id=4028818d187f077201187f869ad500dc";

        imageIdArray[i] = "4028818d187f077201187f869ad500dc";
        imageCommentCountArray[i] = "0";
        imageSmallSrcArray[i] = img[0].src;


    }
    numImgs = pi.length;
    document.getElementById("thumbPageContent").innerHTML = "<TABLE cellSpacing=0 cellPadding=0 width=\"" + pi.length * 70 + "\" border=0><TBODY><tr>" + pa1 + "</tr></TBODY></TABLE>";


    thumbPerWidth = thumbPerWidth;
    albumRightW = document.getElementById("albumright").clientWidth;
    cols = Math.floor((albumRightW - 38) / (thumbPerWidth));
    if (cols > 6 || cols <= 0) {
        cols = 6;
    }
    picThumbSize = cols;
    document.getElementById("imgp").innerHTML = "";
    if (document.getElementById("picThumbDiv") != null) {
        document.getElementById("picThumbDiv").style.width = thumbPerWidth * cols + 38;
        document.getElementById("thumbPageContent").style.width = thumbPerWidth * cols;
        document.getElementById("thumbPageContent").style.overflowX = "hidden";

        setPicOpenInNewWindow(false);
        isNeedPicPagination = false;
        showPic(playPicIndex);
        thumbPageButton();
    }


    init();


}
	
