﻿/*****************************************************************************
                    jPhoto
-----------------------------------------------------------------
功能：按照不同的分类方式显示照片
作者：陈建平
Email： ieditor@126.com
最后更改：2009-5-21       
*******************************************************************************/

function GetPhotoCollectionsWebServiceUrl()
{
    return "../AjaxServer/Server.ashx?service=photoset&method=get";
}
function ParseNodeQuery(currNode)
{
	var F = null;
	var G = null;
	var S = null;
	var A = null;
	var U = null;
	var C = null;
	var P = null;
	var T = null;
	var L = null;
	var H = null;
	
	var node = currNode;
	while(node.sourceIndex!='')
	{
	    var segLoc = node.sourceIndex.indexOf("_");
	    var nodeId = node.sourceIndex.substring(segLoc+1);
	    var fatherNodeId = node.sourceIndex.substring(0,segLoc);
	    //alert("Father:"+fatherNodeId+"  node:"+nodeId);
        switch(nodeId.substring(0,1))
        {
            case "F":
                F = nodeId.substring(1);
                break;
            case "G":
                G = nodeId.substring(1);
                break;
            case "S":
                S = nodeId.substring(1);
                break;
            case "A":
                A = nodeId.substring(1);
                break;
            case "U":
                U = nodeId.substring(1);
                break;
            case "C":
                C = nodeId.substring(1);
                break;
            case "P":
                P = nodeId.substring(1);
                break;
            case "T":
                C = nodeId.substring(1);
                break;
            case "L":
                L = nodeId.substring(1);
                break;
            case "H":
                H = nodeId.substring(1);
                break;
            default:
                break;
        }
	    node = node.parentNode;
	}
	//alert("F="+F+" G="+G+" S="+S+" A="+A+" U="+U+" C="+C+" P="+P+" T="+T+" L="+L+" H="+H);
	ShowPhotoCollections("PhotoListDiv",F,G,S,A,U,C,P,T,L,H,50,1);
}

// 根据物种（任意阶元：TaxonLevel 指定阶元；cSpId 指定物种库的 ID）
function ShowPhotoSet(showTargetDivId,cTaxonLevel,cSpId,cAlbumId,cAuthor,cCountry,cProvince,cCity,cPlace,nHeight,nPageSize,nPage)
{
    // 等待实现
}

// 根据物种、地名、用户、相册、高程查询照片集合
// 参数的要求：如果没有值，参数为 null
function ShowPhotoCollections(showTargetDivId,cFamilyId,cGenusId,cSpId,cAlbumId,cAuthor,cCountry,cProvince,cCity,cPlace,nHeight,nPageSize,nPage)
{
    // 1. 分析参数，只取必要的参数。构建照片集合（可称为“查询相册”）唯一标识，也就是查询参数
    
    // 查询相册标识（分页后请求别的页码时有用）
    var QueryAlbumId = "";
    
    // 后台服务请求地址
    var QueryUrl = "";
    
    // 查询参数组合类型
    var QueryParaGroup = "";
    
    // 分析物种参数
    if (cSpId !=null)
    {
        QueryAlbumId += "(S)"+cSpId;
        QueryUrl += "&spid="+cSpId;
        QueryParaGroup += "S";
    }
    else
    {
        if (cGenusId!=null)
        {
            QueryAlbumId += "(G)"+cGenusId;
            QueryUrl += "&genusid="+cGenusId;
            QueryParaGroup += "G";
        }
        else
        {
            if (cFamilyId!=null)
            {
                QueryAlbumId += "(F)" + cFamilyId;
                QueryUrl += "&familyid=" + cFamilyId;               
                QueryParaGroup += "F";
            }
        }
    }
    
    // 分析用户、相册参数
    if (cAlbumId!=null)
    {
        QueryAlbumId += "(A)"+cAlbumId;
        QueryUrl += "&albumid="+cAlbumId;
        QueryParaGroup += "A";
    }
    else
    {
        if (cAuthor!=null)
        {
            QueryAlbumId += "(U)"+cAuthor;
            QueryUrl += "&username="+cAuthor;
            QueryParaGroup += "U";
        }
    }
    
    // 分析地理参数
    if (cCountry!=null)
    {
        QueryAlbumId += "(C)"+cCountry;
        QueryUrl += "&country="+cCountry; 
        QueryParaGroup += "C";
    }    
    if (cProvince!=null)
    {
        QueryAlbumId += "(P)"+cProvince;
        QueryUrl += "&province="+cProvince; 
        QueryParaGroup += "P";
    }
    if (cCity!=null)
    {
        QueryAlbumId += "(T)"+cCity;
        QueryUrl += "&city="+cCity; 
        QueryParaGroup += "T";
    }
    if (cPlace!=null)
    {
        QueryAlbumId += "(L)"+cPlace;
        QueryUrl += "&place="+ cPlace;
        QueryParaGroup += "L";
    }            
    ShowQueryAlbumByUrl(showTargetDivId,QueryUrl,nPageSize,nPage);
}

function ShowSitePhotoCollections(showTargetDivId, cFamilyId, cGenusId, cSpId, cSiteId, cAlbumId, cAuthor, cCountry, cProvince, cCity, cPlace, nHeight, nPageSize, nPage)
{
    // 1. 分析参数，只取必要的参数。构建照片集合（可称为“查询相册”）唯一标识，也就是查询参数

    // 查询相册标识（分页后请求别的页码时有用）
    var QueryAlbumId = "";

    // 后台服务请求地址
    var QueryUrl = "";

    // 查询参数组合类型
    var QueryParaGroup = "";

    // 分析物种参数
    if (cSpId != null)
    {
        QueryAlbumId += "(S)" + cSpId;
        QueryUrl += "&spid=" + cSpId;
        QueryParaGroup += "S";
    }
    else
    {
        if (cGenusId != null)
        {
            QueryAlbumId += "(G)" + cGenusId;
            QueryUrl += "&genusid=" + cGenusId;
            QueryParaGroup += "G";
        }
        else
        {
            if (cFamilyId != null)
            {
                QueryAlbumId += "(F)" + cFamilyId;
                QueryUrl += "&familyid=" + cFamilyId;
                QueryParaGroup += "F";
            }
        }
    }

    // 分析 Site
    if (cSiteId != null)
    {
        QueryAlbumId += "(W)" + cSiteId;
        QueryUrl += "&siteid=" + cSiteId;
        QueryParaGroup += "W";
    }

    // 分析用户、相册参数
    if (cAlbumId != null)
    {
        QueryAlbumId += "(A)" + cAlbumId;
        QueryUrl += "&albumid=" + cAlbumId;
        QueryParaGroup += "A";
    }
    else
    {
        if (cAuthor != null)
        {
            QueryAlbumId += "(U)" + cAuthor;
            QueryUrl += "&username=" + cAuthor;
            QueryParaGroup += "U";
        }
    }

    // 分析地理参数
    if (cCountry != null)
    {
        QueryAlbumId += "(C)" + cCountry;
        QueryUrl += "&country=" + cCountry;
        QueryParaGroup += "C";
    }
    if (cProvince != null)
    {
        QueryAlbumId += "(P)" + cProvince;
        QueryUrl += "&province=" + cProvince;
        QueryParaGroup += "P";
    }
    if (cCity != null)
    {
        QueryAlbumId += "(T)" + cCity;
        QueryUrl += "&city=" + cCity;
        QueryParaGroup += "T";
    }
    if (cPlace != null)
    {
        QueryAlbumId += "(L)" + cPlace;
        QueryUrl += "&place=" + cPlace;
        QueryParaGroup += "L";
    }
    ShowQueryAlbumByUrl(showTargetDivId, QueryUrl, nPageSize, nPage);
}



function GetQueryUrlFromQueryAlbumId(cQueryAlbumId)
{
    var cQueryUrl = cQueryAlbumId.replace("(F)","&familyid=");
    cQueryUrl = cQueryUrl.replace("(G)","&genusid=");
    cQueryUrl = cQueryUrl.replace("(S)","&spid=");
    cQueryUrl = cQueryUrl.replace("(A)","&albumid=");
    cQueryUrl = cQueryUrl.replace("(U)","&username=");
    cQueryUrl = cQueryUrl.replace("(C)","&country=");
    cQueryUrl = cQueryUrl.replace("(P)","&province=");
    cQueryUrl = cQueryUrl.replace("(T)","&city=");
    cQueryUrl = cQueryUrl.replace("(L)", "&place=");
    cQueryUrl = cQueryUrl.replace("(W)", "&siteid=");
    
    return cQueryUrl;    
}
// 通过查询相册的ID 显示查询相册集合的某一页
function ShowQueryAlbumById(showTargetDivId,cQueryAlbumId,nPageSize,nPage)
{
    //ShowDebugMsg(cQueryAlbumId);
    var cQueryUrl = GetQueryUrlFromQueryAlbumId(cQueryAlbumId);
    //ShowDebugMsg(cQueryUrl);
    ShowQueryAlbumByUrl(showTargetDivId,cQueryUrl,nPageSize,nPage);
}
// 通过URL显示查询相册集合的某一页
function ShowQueryAlbumByUrl(showTargetDivId,cQueryUrl,nPageSize,nPage)
{
    var fullUrl = encodeURI(GetPhotoCollectionsWebServiceUrl()+cQueryUrl);
    //alert(fullUrl);
    
    // 初始化照片显示框架
    initPhotoArea(showTargetDivId);
    // 显示正在加载...提示
    ShowLoadingTips(showTargetDivId);

    // 向后台服务提出查询请求，等待结果，收到数据后显示

    fullUrl = fullUrl.replace(/@#/g, "_"); // 将@#代替的_换回来
    $.getJSON(fullUrl,{pagesize:nPageSize,page:nPage},function(json){ ShowPhotoAlbum(json,showTargetDivId); } );
}

function ShowDebugMsg(msg)
{
    $("#debug").append("<p>"+msg+"</p>");
}
// 显示查询结果
function ShowPhotoAlbum(json,showTargetDivId)
{
    // 如果出错，显示错误信息
    
    // 将“查询相册标识符”、页数、页码写入页面的分页控制参数内
    
    // 格式化照片集合，显示在指定的区域内
    
    // 显示分页控制命令按钮组

    if (json.Error!="")
    {
      $("#"+showTargetDivId).html("<div>抱歉，查询出错，可能是查询参数有误！</div>");
      return;
    }
    if (json.PhotoCount<1)
    {
       $("#"+showTargetDivId).html("<div>抱歉，没有找到当前指定搜索条件的照片。<br />"+
       "建议：<br />"+
       "指定更详细的搜索条件，例如：点击分类树节点前的+号，展开树，点击更具体的节点<br />"+
       "</div>");
       return;
    }
    
    var tTotalPages = Math.ceil(parseInt(json.PhotoCount)/parseInt(json.pagesize));
    
    
    // 写入参数
    writePagingParam(json.albumid,json.pagesize,json.page,tTotalPages,json.PhotoCount);
    
    // 分页代码
    //$("#txtPageSnInfo").html("共有"+json.PhotoCount+"张照片，当前是"+json.page + "/" +tTotalPages +"页");
    
    // 生成照片列表
    var PhotoListHtml = "<div class='clear' style='height:20px;'></div>";
    PhotoListHtml += "<span style='margin-left:50px;'>当前节点（不包括子节点）共有 " + json.PhotoCount + " 张照片</span><br />";
    
    var photoAppBase = "";

    
    for (iPhoto=0;iPhoto<json.CurrPagePhotoCount;iPhoto++)
    {
        if (typeof site =="object")
        {
            photoAppBase = "/subsite/ShowPhoto.aspx?siteid="+site.Id+"&photoid=";
            photoAppBase += json.photolist[iPhoto].photoid;
            photoAppBase += "' target='_blank'><img src='";
            photoAppBase += json.photolist[iPhoto].thumbnail;
            photoAppBase += "' id='img_";
            photoAppBase += json.photolist[iPhoto].photoid; 
        }
        else
        {
            photoAppBase = "/Album/Show";

            if (json.ParaGroup=="S" || json.ParaGroup=="F" || json.ParaGroup=="G")
               photoAppBase += "Sp";

            if (json.ParaGroup == "C" || json.ParaGroup == "CPTL")
               photoAppBase += "Geo";
          
            photoAppBase += "Photo.aspx?virtualalbumid=";
            // json.albumid;--- 虚拟相册
            photoAppBase += json.albumid;
            // 下面采用真实相册
            //photoAppBase += json.photolist[iPhoto].folderid;
            photoAppBase += "&page=";
            photoAppBase += json.page;
            photoAppBase += "&photoid=";
            photoAppBase += json.photolist[iPhoto].photoid;
            photoAppBase += "' target='_blank'><img src='";
            photoAppBase += json.photolist[iPhoto].thumbnail;
            photoAppBase += "' id='img_";
            photoAppBase += json.photolist[iPhoto].photoid; 
        }
    
       PhotoListHtml += "<div class=\"photoItem\"><div align=\"center\" style=\"margin-bottom:10px;\" class=\"photoFrame\"><a href='";
       PhotoListHtml += photoAppBase;
       
       PhotoListHtml += "' alt='";
       PhotoListHtml += (json.photolist[iPhoto].author == undefined) ? "" : json.photolist[iPhoto].author ;
       PhotoListHtml += (json.photolist[iPhoto].authorsn == undefined) ? "" : json.photolist[iPhoto].authorsn;
       PhotoListHtml += "' title='Author:";
       if (json.photolist[iPhoto].author==json.photolist[iPhoto].username)
       {
            PhotoListHtml += json.photolist[iPhoto].username+ " " + json.photolist[iPhoto].authorsn;
       }
       else
       {
            PhotoListHtml += json.photolist[iPhoto].username+" "+json.photolist[iPhoto].author + " " + json.photolist[iPhoto].authorsn;
       }
       
       var cShowName = json.photolist[iPhoto].lname;
       if (json.photolist[iPhoto].lname=="" && json.photolist[iPhoto].cname=="")
       {
           cShowName = json.photolist[iPhoto].filename;
       }
       
       PhotoListHtml += "' author='";
       PhotoListHtml += (json.photolist[iPhoto].author == undefined) ? "" : json.photolist[iPhoto].author;
       PhotoListHtml += "' username='";
       PhotoListHtml += (json.photolist[iPhoto].username == undefined) ? "" : json.photolist[iPhoto].username;      
       PhotoListHtml += "' class='smallphoto' /></a></div>";
       PhotoListHtml += "<div class=\"photoLName\"><a href='/";
       PhotoListHtml += json.photolist[iPhoto].spid;
       PhotoListHtml += ".spid' target='_blank'>";
       PhotoListHtml += "<span id='spname_la_";
       PhotoListHtml += json.photolist[iPhoto].photoid;
       PhotoListHtml += "'>";
       PhotoListHtml += cShowName;
       PhotoListHtml += "</span></a></div>";
       PhotoListHtml += "<div class=\"photoCName\" style=\"margin-top:5px;\"><span id='spname_zh_";
       PhotoListHtml += json.photolist[iPhoto].photoid;
       PhotoListHtml += "'>";
       PhotoListHtml += json.photolist[iPhoto].cname;
       PhotoListHtml += "</span>";
       PhotoListHtml += "<input id='sel_" + json.photolist[iPhoto].photoid + "' pid='" + json.photolist[iPhoto].photoid + "' canref='" + json.photolist[iPhoto].canref + "' type=\"checkbox\" style=\"margin-left:30px;\" class=\"PhotoSelector\" onclick=\"PhotoSelected()\" /></div></div>";
    }
    PhotoListHtml += "<div class='clear'></div>";
    
    // 将图像写入页面
    $("#jPhoto_PhotoBrowser").html(PhotoListHtml);
    
    if (tTotalPages>1)
        $("#jPhoto_PagingControl").show();
    
    // 清除正在加载提示
    ClearLoadingTips(showTargetDivId);

    EnableBatSelect();
}

// 初始化图像显示区框架
function initPhotoArea(showTargetDivId)
{
    $("#"+showTargetDivId).empty();
    
    var jPhotoFrameHtml = "";
    jPhotoFrameHtml += '<div id="jPhoto_loading" style="display:none;"><img src="../images/loading.gif" />正在加载相册</div>';
    jPhotoFrameHtml += '<div style="display:none">';
    jPhotoFrameHtml += '<div id="jPhoto_ContainerId">'+showTargetDivId+'</div>';
    jPhotoFrameHtml += '<div id="jPhoto_QueryAlbumID"></div>';
    jPhotoFrameHtml += '<div id="jPhoto_PageSn"></div>';
    jPhotoFrameHtml += '<div id="jPhoto_PageSize"></div>';
    jPhotoFrameHtml += '<div id="jPhoto_PageTotal"></div>';
    jPhotoFrameHtml += '<div id="jPhoto_PhotoTotal"></div>';
    jPhotoFrameHtml += '</div>';

    // Bat Action
    jPhotoFrameHtml += '<table>';
    jPhotoFrameHtml += '<tr>';
    jPhotoFrameHtml += '<td width="30"></td>';
    jPhotoFrameHtml += '<td colspan="2"><span id="Span1" style="color:#f00;">提示：单击选择框选定照片，或者按下鼠标划过照片一次性选择多张。</span></td>';
    jPhotoFrameHtml += '</tr>';
    jPhotoFrameHtml += '<tr>';
    jPhotoFrameHtml += '<td width="30"></td>';
    jPhotoFrameHtml += '<td align="center">';
    jPhotoFrameHtml += '<div id="BtnBatRef" class="BtnDiv" style="width:80px;float:left;margin-left:10px;" onclick="';
    jPhotoFrameHtml += "$('#RefPanel').toggle();GetBatRefCode();";
    jPhotoFrameHtml += '">批量引用</div>';
    jPhotoFrameHtml += '<div id="BtnShowHideBatIdent" class="BtnDiv" style="width:80px;float:left;margin-left:10px;" onclick="';
    jPhotoFrameHtml += "$('#BatIdentArea').toggle();";
    jPhotoFrameHtml += '">批量鉴定</div>';
    jPhotoFrameHtml += '<div id="BtnBatDelete" class="BtnDiv" style="width:80px;float:left;margin-left:10px;" onclick="';
    jPhotoFrameHtml += "$('#BatDeleteDialog').toggle();";
    jPhotoFrameHtml += '">批量删除</div>';
    jPhotoFrameHtml += '</td>';
    jPhotoFrameHtml += '<td>';
    jPhotoFrameHtml += '<div id="IdentMessage" style="margin-left:20px;color:#f00;"></div>';
    jPhotoFrameHtml += '<span id="labSelectedPhotoCount" style="margin:20px;"></span>';
    jPhotoFrameHtml += '<span id="SpanCmd" style="cursor:pointer;margin-left:30px;color:Blue;" onclick="ClearAllSelect()">【清除选择】</span>';
    jPhotoFrameHtml += '</td>';
    jPhotoFrameHtml += '</tr>';
    jPhotoFrameHtml += '</table>';

    jPhotoFrameHtml += '<div id="BatIdentArea" class="IdentArea" style="display:none;">';
    jPhotoFrameHtml += '<table>';
    jPhotoFrameHtml += '<tr>';
    jPhotoFrameHtml += '<td width="100px;">';
    jPhotoFrameHtml += '<b>批量鉴定</b>';
    jPhotoFrameHtml += '</td>';
    jPhotoFrameHtml += '<td width="280"></td>';
    jPhotoFrameHtml += '<td>';
    jPhotoFrameHtml += '<span id="BtnCloseBatIdent" style="cursor:pointer;margin-left:10px;color:Blue;" onclick="';
    jPhotoFrameHtml += "$('#BatIdentArea').hide();";
    jPhotoFrameHtml += '">【关闭】</span>';
    jPhotoFrameHtml += '<textarea id="txtSelectedPhotoList" cols="20" rows="2" style="display:none;"></textarea>';
    jPhotoFrameHtml += '</td>';
    jPhotoFrameHtml += '</tr>';
    jPhotoFrameHtml += '</table>';
    jPhotoFrameHtml += '<br />';
    jPhotoFrameHtml += '<div id="IdentTypeNormal" class="DivTabActive" onclick="ActiveIdentTypeTitle(\'IdentTypeNormal\');$(\'#NormalBatIdent\').show();$(\'#TmpIdentArea\').hide();">通过物种库鉴定</div>';
    jPhotoFrameHtml += '<div id="IdentTypeTmp" class="DivTab" onclick="ActiveIdentTypeTitle(\'IdentTypeTmp\');$(\'#NormalBatIdent\').hide();$(\'#TmpIdentArea\').show();">提交临时鉴定（当前物种库中没有收录时）</div>';
    jPhotoFrameHtml += '<hr size="1" align="left" style="clear:both; margin-top:-8px; width:450px;" />';
    jPhotoFrameHtml += '<div id="NormalBatIdent">';
    jPhotoFrameHtml += '<table style="width: 100%;">';
    jPhotoFrameHtml += '<tr>';
    jPhotoFrameHtml += '<td colspan="2"></td>';
    jPhotoFrameHtml += '</tr>';
    jPhotoFrameHtml += '<tr>';
    jPhotoFrameHtml += '<td width="100px;">学名</td>';
    jPhotoFrameHtml += '<td>';
    jPhotoFrameHtml += '<input id="txtQuickIdent_LName" value="" style="width:300px;"  onchange="clearIdentHistory();" onclick="clearIdentHistory();" />';
    jPhotoFrameHtml += '</td>';
    jPhotoFrameHtml += '</tr>';
    jPhotoFrameHtml += '<tr>';
    jPhotoFrameHtml += '<td>俗名</td>';
    jPhotoFrameHtml += '<td><input id="txtQuickIdent_AName" value="" style="width:300px;"  onchange="clearIdentHistory();" onclick="clearIdentHistory();" /></td>';
    jPhotoFrameHtml += '</tr>';
    jPhotoFrameHtml += '<tr id="QueryResultSpList_Row" style="display:none;">';
    jPhotoFrameHtml += '<td>物种库条目：</td>';
    jPhotoFrameHtml += '<td id="QueryResultSpList"></td>';
    jPhotoFrameHtml += '</tr>';
    jPhotoFrameHtml += '<tr><td>鉴定备注</td>';
    jPhotoFrameHtml += '<td><textarea id="txtQuickIdent_Memo" style="width:300px;"></textarea></td>';
    jPhotoFrameHtml += '</tr>';
    jPhotoFrameHtml += '<tr><td>签名</td>';
    jPhotoFrameHtml += '<td><input id="txtQuickIdent_SignName" value="" style="width:300px;" /></td>';
    jPhotoFrameHtml += '</tr>';
    jPhotoFrameHtml += '<tr id="SubmitCmdRow">';
    jPhotoFrameHtml += '<td></td>';
    jPhotoFrameHtml += '<td>';
    jPhotoFrameHtml += '<table style="width: 300px;">';

    jPhotoFrameHtml += '<tr><td></td><td>';
    jPhotoFrameHtml += '<div id="BtnSubmitIdent" style="padding:3px 10px; border:solid 1px #333;cursor:pointer; text-align:center; width:150px;" onclick="BatIdentSimaple();">提交鉴定</div>';
    jPhotoFrameHtml += '</td></tr>';
    jPhotoFrameHtml += '</table>';

    jPhotoFrameHtml += '</td></tr></table></div>';
    jPhotoFrameHtml += '<div id="TmpIdentArea" style="display:none;">';
    jPhotoFrameHtml += '<table style="width: 100%;">';
    jPhotoFrameHtml += '<tr><td width="100px;">学名</td>';
    jPhotoFrameHtml += '<td><input id="tmpLName" value="" style="width:300px;" /></td>';
    jPhotoFrameHtml += '</tr>';
    jPhotoFrameHtml += '<tr><td>中名</td>';
    jPhotoFrameHtml += '<td><input id="tmpCName" value="" style="width:300px;" /></td></tr>';
    jPhotoFrameHtml += '<tr><td>鉴定备注</td>';
    jPhotoFrameHtml += '<td><textarea id="tmpIdentMemo" style="width:300px;"></textarea></td>';
    jPhotoFrameHtml += '</tr>';
    jPhotoFrameHtml += '<tr><td>签名</td>';
    jPhotoFrameHtml += '<td><input id="txtTmpIdent_SignName" value="" style="width:300px;" /></td>';
    jPhotoFrameHtml += '</tr>';
    jPhotoFrameHtml += '<tr id="Tr2">';
    jPhotoFrameHtml += '<td></td>';
    jPhotoFrameHtml += '<td><div id="BtnTempIdentSubmit" class="BtnDiv" style="width:80px;" onclick="BatAddTmpIdent()">提交临时鉴定</div></td>';
    jPhotoFrameHtml += '</tr></table></div></div>';

    jPhotoFrameHtml += '<div id="BatDeleteDialog" style="background:#FF0; border:solid 2px #f00; display:none;width:400px;margin:20px;padding:20px;">';
    jPhotoFrameHtml += '<table>';
    jPhotoFrameHtml += '<tr><td>警告：批量删除后无法恢复！</td></tr>';
    jPhotoFrameHtml += '<tr>';
    jPhotoFrameHtml += '<td>';
    jPhotoFrameHtml += '<div id="BtnExecuteBatDelete" class="BtnDiv" style="width:80px;float:left;margin-left:10px;" onclick="BatDelete();">确认删除</div>';
    jPhotoFrameHtml += '<div id="BtnCancelBatDelete" class="BtnDiv" style="width:80px;float:left;margin-left:10px;" onclick="$(\'#BatDeleteDialog\').hide();">取消</div>';
    jPhotoFrameHtml += '</td>';
    jPhotoFrameHtml += '</tr>';
    jPhotoFrameHtml += '<tr><td><div id="BatDeleteResultMsg"></div></td></tr>';
    jPhotoFrameHtml += '</table></div>';

    jPhotoFrameHtml += '<div id="RefPanel" style="margin-top:10px; float:left; width:650px; padding:30px; border:solid 2px #000; background-color:#E8F2F9; display:none;">';
    jPhotoFrameHtml += '<div style="clear:both"></div>';
    jPhotoFrameHtml += '<span id="RefCodePanel_Title" style="font-size:14px;padding:5px; font-weight:bold;">直接拷贝代码，在其他网站引用选定照片</span><span style="margin-left:50px; color:Red; font-weight:bold; cursor:pointer;" onclick="$(\'#RefPanel\').hide();">【关闭】</span>';
    jPhotoFrameHtml += '<div id="RefCodePanel">';
    jPhotoFrameHtml += '<div class="RefCtrl">';
    jPhotoFrameHtml += '<label class="reflabel" onclick="$(\'.refVal_TextArea\').hide();$(\'#refcode_wiki\').show();copySelectUrl(\'refcode_wiki\',\'复制成功，您可以在本站的博客、百科等应用中使用\')">CFH Wiki 代码: 在本站的博客、Wiki当中引用的代码</label>';
    jPhotoFrameHtml += '<textarea name="refcode_wiki" id="refcode_wiki" wrap="physical" class="refVal_TextArea"></textarea>';
    jPhotoFrameHtml += '</div>';
    jPhotoFrameHtml += '<div class="RefCtrl">';
    jPhotoFrameHtml += '<label class="reflabel" onclick="$(\'.refVal_TextArea\').hide();$(\'#refcode_url\').show();copySelectUrl(\'refcode_url\',\'复制成功，您可以发送地址到QQ或MSN等通讯工具和朋友分享\')">本照片网址: 通过Email/QQ/MSN分享给好友</label>';
    jPhotoFrameHtml += '<textarea name="refcode_url" id="refcode_url" wrap="physical" class="refVal_TextArea"></textarea>';
    jPhotoFrameHtml += '</div>';
    jPhotoFrameHtml += '<div class="RefCtrl">';
    jPhotoFrameHtml += '<label class="reflabel" onclick="$(\'.refVal_TextArea\').hide();$(\'#refcode_ubbimg\').show();copySelectUrl(\'refcode_ubbimg\',\'复制成功，您可以粘贴到其他网站，与人分享或者邀请专家进行鉴定！\')">UBB贴图代码: 支持普兰塔等论坛</label>';
    jPhotoFrameHtml += '<textarea name="refcode_ubbimg" id="refcode_ubbimg" wrap="physical" class="refVal_TextArea" ></textarea>';
    jPhotoFrameHtml += '</div>';
    jPhotoFrameHtml += '<div class="RefCtrl">';
    jPhotoFrameHtml += '<label class="reflabel" onclick="$(\'.refVal_TextArea\').hide();$(\'#refcode_flash\').show();copySelectUrl(\'refcode_flash\',\'复制成功，您可以粘贴到其他网站，与人分享或者邀请专家进行鉴定！\')">Flash地址: 在各种场合下均可使用</label>';
    jPhotoFrameHtml += '<textarea name="refcode_flash" id="refcode_flash" wrap="physical" class="refVal_TextArea"></textarea>';
    jPhotoFrameHtml += '</div>';
    jPhotoFrameHtml += '<div class="RefCtrl">';
    jPhotoFrameHtml += '<label class="reflabel" onclick="$(\'.refVal_TextArea\').hide();$(\'#refcode_ubbflash\').show();copySelectUrl(\'refcode_ubbflash\',\'复制成功，您可以粘贴到其他网站，与人分享或者邀请专家进行鉴定！\')">Flash版引用代码: 支持UBB [flash] 格式发帖子;<b>推荐在本站论坛当中使用！</b></label>';
    jPhotoFrameHtml += '<textarea name="refcode_ubbflash" id="refcode_ubbflash" wrap="physical" class="refVal_TextArea"></textarea>';
    jPhotoFrameHtml += '</div>';
    jPhotoFrameHtml += '<div class="RefCtrl">';
    jPhotoFrameHtml += '<label class="reflabel" onclick="$(\'.refVal_TextArea\').hide();$(\'#refcode_ubbswf\').show();copySelectUrl(\'refcode_ubbswf\',\'复制成功，您可以粘贴到其他网站，与人分享或者邀请专家进行鉴定！\')">Flash版引用代码: 支持UBB [swf] 格式发帖子</label>';
    jPhotoFrameHtml += '<textarea name="refcode_ubbswf" id="refcode_ubbswf" wrap="physical"  class="refVal_TextArea"></textarea>';
    jPhotoFrameHtml += '</div>';
    jPhotoFrameHtml += '<div class="RefCtrl">';
    jPhotoFrameHtml += '<span id="RefCodeMsg" style="color:Red;"></span>';
    jPhotoFrameHtml += '</div>'
    jPhotoFrameHtml += '<br />';
    jPhotoFrameHtml += '<div style="clear:both"></div>';
    jPhotoFrameHtml += '</div></div>';


    jPhotoFrameHtml += '<div id="jPhoto_PhotoBrowser"></div>';
    jPhotoFrameHtml += '<div id="jPhoto_PagingControl" class="ToolbarFooter" style="display:none;">';
    jPhotoFrameHtml += '<img src="/images/Buttons/First.gif" onclick="ShowFirstPage()" alt="第一页" style="margin-left:1px; cursor:pointer" />';
    jPhotoFrameHtml += '<img src="/images/Buttons/Pre.gif" onclick="ShowPrevPage()" alt="前一页" style="margin-left:1px; cursor:pointer" />';
    jPhotoFrameHtml += '<img src="/images/Buttons/Next.gif" onclick="ShowNextPage()" alt="后一页" style="margin-left:1px; cursor:pointer" />';
    jPhotoFrameHtml += '<img src="/images/Buttons/Last.gif" onclick="ShowLastPage()" alt="最后一页" style="margin-left:1px; cursor:pointer" />';
    jPhotoFrameHtml += '<span id="jPhoto_txtPageSnInfo" style="margin-left:10px; margin-right:10px;"></span>';
    jPhotoFrameHtml += '<img src="/images/Buttons/go.gif" alt="跳转到" style="cursor:pointer" onclick="GotoPage()" />';
    jPhotoFrameHtml += '<input id="jPhoto_txtPageSn" type="text" style="width:30px" />';
    jPhotoFrameHtml += '</div>';
    
    $("#"+showTargetDivId).html(jPhotoFrameHtml);
}
function ShowLoadingTips(showTargetDivId)
{
    // 显示正在加载提示...
    $("#jPhoto_loading").show();
}
function ClearLoadingTips(showTargetDivId)
{
    // 清除正在加载提示...
    $("#jPhoto_loading").hide();
}
// 给页面当中写入当前的查询相册状态
function writePagingParam(cQueryAlbumId,nPageSize,nPage,nPageTotal,nPhotoTotal)
{
    $("#jPhoto_QueryAlbumID").text(cQueryAlbumId);
    $("#jPhoto_PageSn").text(nPage);
    $("#jPhoto_PageSize").text(nPageSize);
    $("#jPhoto_PageTotal").text(nPageTotal);
    $("#jPhoto_PhotoTotal").text(nPhotoTotal);
    $("#jPhoto_txtPageSnInfo").html("共有"+nPhotoTotal+"张照片，当前是"+nPage+ "/" +nPageTotal+"页");
}

// 取得一个新的照片集合页
function GetPage(nPage)
{
    //alert(nPage);
    var cAlbumId = $("#jPhoto_QueryAlbumID").text();
    var nPageSize = $("#jPhoto_PageSize").text();
    var cContainerId = $("#jPhoto_ContainerId").text();
    ShowQueryAlbumById(cContainerId,cAlbumId,nPageSize,nPage);
}
function GotoPage() {  GetPage($("#jPhoto_txtPageSn").val()); }
function ShowFirstPage() { GetPage("1"); }
function ShowPrevPage() 
{ 
    var CurrPage = parseInt($("#jPhoto_PageSn").text());
    CurrPage = (CurrPage-1 < 1)?1:(CurrPage-1);
    GetPage(CurrPage);
}
function ShowNextPage()
{ 
    var nTotalPage = parseInt($("#jPhoto_PageTotal").text());
    var CurrPage = parseInt($("#jPhoto_PageSn").text());
    CurrPage = (CurrPage+1 > nTotalPage)?nTotalPage:(CurrPage+1);
    GetPage(CurrPage);
}
function ShowLastPage() 
{ 
    GetPage($("#jPhoto_PageTotal").text());
}


