<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="MultiplePhotoType.ascx.cs"
    Inherits="PowerEasy.Module.General.WebSite.Admin.Controls.FieldControl.MultiplePhotoType" %>
<%@ Import Namespace="PowerEasy.Framework.Common" %>
<script type="text/javascript">
    jQuery(document).ready(function () {
        if ($.browser.msie && $.browser.version === "6.0") {
            var overlay;
            $("#<%= m_JSPrefix %>UploadButton").click(function (event) {
                var floatingDialog = $("#floatingDialog<%=m_JSPrefix%>");
                overlay = $('<div id="jqDnrFloatDivBg" style="background-color: rgb(0, 0, 0);filter:Alpha(opacity=40); position: absolute; top: 0px; left: 0px; opacity: 0.6; z-index: 49; width: 1216px; height: 1855px; "><iframe style="position:absolute;width:100%;height:100%;_filter:alpha(opacity=0);opacity=0;border-style:none;"></iframe> </div>');
                $("body").append(overlay);
				$(document).on('click', '#jqDnrFloatDivBg', function(event){
                //$('#jqDnrFloatDivBg').live("click", function (event) {
                    floatingDialog.hide();
                    $(this).remove();
                });
                floatingDialog.attr("z-index", 50);
                var bodyTop = document.documentElement.scrollTop + document.body.scrollTop;
                floatingDialog.show();
                floatingDialog.offset({ top: bodyTop+30, left: ($('body').width() - floatingDialog.width()) / 2 })
            });
            $('#close<%=m_JSPrefix%>').click(function (event) {

                $("#floatingDialog<%=m_JSPrefix%>").hide();
                overlay.remove();
            });
        } else {
            jQuery("#floatingDialog<%=m_JSPrefix%>").floatForm({ controlTag: "#<%= m_JSPrefix %>UploadButton" });
        }

        // jQuery("#silverlightControlHost<%=m_JSPrefix%>").show();
        //$('#floatingDialog<%=m_JSPrefix%>').hide();
    });

</script>
<%--<div id="<%= m_JSPrefix %>overlay"  style="background-color: rgb(0, 0, 0); position: absolute; top: 0px; left: 0px; opacity: 0.6; z-index: 49; width: 1216px; height: 1855px; display:none ">
</div>--%>
<table border="0" cellpadding="0" cellspacing="0" >
    <tr>
        <td class='tdbg' align='left'>
            <div class="DivWordBreak">
                <table width="100%" border="0" cellpadding="0" cellspacing="0">
                    <tr>
                        <td width="100%">
                            <asp:HiddenField ID="HdnPhotoUrls" runat="server" />
                            <table id="<%= m_JSPrefix%>_table" style="width: 100%; margin: 0 auto;" border="0"
                                cellpadding="0" cellspacing="0">
                                <pe:ExtendedLiteral runat="server" ID="LiPhotoUrls" HtmlEncode="false"></pe:ExtendedLiteral>
                            </table>
                            <input id="addphotourl" type="button" class="inputbutton" value="添加外部地址" onclick="<%= m_JSPrefix%>addphoto();" /><pec:FloatingDialog
                                ID="FileFloatingDialog" Visible="false" runat="server" ShowType="1" Width="550"
                                Height="350" Name="<%$ Res: Controls_FieldControl_MultiplePhotoType_SelectFiles , 从已上传文件中选择 %>"
                                Skin="inputbutton" Title="<%$ Res: Controls_FieldControl_MultiplePhotoType_SelectFiles , 从已上传文件中选择 %>" />
                            <input id="<%= m_JSPrefix %>UploadButton" type="button" class="inputbutton" value="<%= Resources.DynamicPageResources.Controls_FieldControl_MultiplePhotoType_UploadFilesButton%>" />
                        </td>
                    </tr>
                </table>
                <span style="color: Green">
                    <%= Description %>
                </span>
            </div>
            <div id="floatingDialog<%=m_JSPrefix%>" style="position: absolute; width: 510px; height: 350px;"  class="floatingDialog">
                <div id="floatingDialog_handle<%=m_JSPrefix%>" class="fdtop floatingDialog_handle">
                    <dl>
                        <dd>
                            <ul>
                                <li class="close"><a id="close<%=m_JSPrefix%>" href="javascript:void(0)" title="关闭"
                                    class="floatingDialogClose"></a></li>
                                <li class="title">上传文件</li>
                            </ul>
                        </dd>
                    </dl>
                </div>
                <div id="floatingDialog_content<%=m_JSPrefix%>" class="floatingDialog_content">
                    <div id='errorLocation<%=m_JSPrefix%>' style="font-size: small; color: Gray;">
                    </div>
                    <div id="silverlightControlHost<%=m_JSPrefix%>">
                        <pe:FileUploadControl Pattern="Popup" ID="fileuploader" runat="server" />
                      
                    </div>
                </div>
                <div class="fdbottom">
                    <dl>
                        <dt></dt>
                    </dl>
                </div>
                <iframe id="iframe_IE6_Z-Index<%=m_JSPrefix%>" width="100%" frameborder="0" height="382px"
                    style="position: absolute; top: 0px; z-index: -1; border-style: none;"></iframe>
            </div>
        </td>
    </tr>
</table>
<pe:FloatDivDialog ID="FdvSelectFile" runat="server" EnableViewState="false" Width="550"
    Height="380" Title="选择文件" Enabled="true">
</pe:FloatDivDialog>
<script type="text/javascript">
var selectobj;

function showDiv(obj) {
    selectobj=obj;
    var requestUrl ="../Accessories/ShowUploadFiles.aspx?Type=NewMultiplePhotoSelect&JSPrefix=<%=m_JSPrefix %>";    
    $('#<%=FdvSelectFile.ClientID %>' + '__HdnLoadUrl').prop('value', requestUrl);
    $('#<%=FdvSelectFile.ClientID %>' + '__LitID').click();
}


var showPath='<%= m_ShowPicPath%>';
function <%= m_JSPrefix%>addphoto()
{
  <%= m_JSPrefix %>_ClearEmptyPic();
  $("#<%= m_JSPrefix%>_table").append('<tr><td class="tdbg" align="center" width="130px" height="120px"><img src="../../Uploadfiles/nopic.gif" width="100px" height="90px" /></td><td class="tdbg" align="left" height="120px">地址：<input type="text" style="width: 300px;" class="inputtext" id="<%= m_JSPrefix%>TxtPicUrl" name="<%= m_JSPrefix%>TxtPicUrl" onchange="changepic(this);" /><br />简介：<textarea style="height: 80px; width: 300px;" class="inputtext" id="<%= m_JSPrefix%>TxtPicIntro" cols="20" rows="2" name="<%= m_JSPrefix%>TxtPicIntro"></textarea><br /></td><td align="left" width="130px"><input type="button" class="inputbutton" value="选 择" onclick="showDiv(this);"/><br /><input type="button" class="inputbutton" value="删 除" onclick="deletePic(this);"/><br /><input type="button" class="inputbutton" value="向上移动" onclick="MovePicUp(this);"/><br /><input type="button" class="inputbutton" value="向下移动" onclick="MovePicDown(this);"/><br /></td></tr>');
}

function <%= m_JSPrefix%>selectphotourl(url)
{
   var p=$(selectobj).parent().prev();
   $(p).find("input").eq(0).prop("value",url);
   url=showPath + url;
   $(p).prev().find("img").eq(0).attr("src",url);
}

function <%= m_JSPrefix%>addphotourl(url)
{
    <%= m_JSPrefix %>_ClearEmptyPic();
  $("#<%= m_JSPrefix%>_table").append('<tr><td class="tdbg" align="center" width="130px" height="120px"><img src="'+ showPath + url +'" width="100px" height="90px" /></td><td class="tdbg" align="left" height="120px">地址：<input type="text" style="width: 300px;" class="inputtext" id="<%= m_JSPrefix%>TxtPicUrl" name="<%= m_JSPrefix%>TxtPicUrl" value="'+ url +'" onchange="changepic(this);" /><br />简介：<textarea style="height: 80px; width: 300px;" class="inputtext" id="<%= m_JSPrefix%>TxtPicIntro" cols="20" rows="2" name="<%= m_JSPrefix%>TxtPicIntro"></textarea><br /></td><td align="left" width="130px"><input type="button" class="inputbutton" value="选 择" onclick="showDiv(this);"/><br /><input type="button" class="inputbutton" value="删 除" onclick="deletePic(this);"/><br /><input type="button" class="inputbutton" value="向上移动" onclick="MovePicUp(this);"/><br /><input type="button" class="inputbutton" value="向下移动" onclick="MovePicDown(this);"/><br /></td></tr>');
}

function deletePic(obj)
{
  if(confirm("确实要删除？"))
  {
    $(obj).parent().parent().remove(); 
  } 
}

function changepic(obj)
{
   var p=$(obj).parent().prev();
   var picPath=$(obj).val();
   if(picPath.indexOf("://")==-1)
   {
     picPath=showPath + picPath;
   }
   $(p).find("img").eq(0).attr("src",picPath);
}

function MovePicUp(obj)
{
  var t=$(obj).parent().parent();
  var p=$(t).prev();
  if(p.length>0)
  {
     $(t).insertBefore(p); 
  }
  else
  {
   alert("已经在顶部了！");
  } 
}

function MovePicDown(obj)
{
  var t=$(obj).parent().parent();
  var n=$(t).next();
  if(n.length>0)
  {
     $(t).insertAfter(n); 
  }else
  {
    alert("已经在底部了！");
  } 
}

function <%= m_JSPrefix %>ErrMessage(message)
{
    alert(message);
}

function <%= m_JSPrefix %>DealwithUpload(path,size,id,thumbpath)
{
   <%= m_JSPrefix%>addphotourl(path);
}

function <%= m_JSPrefix %>ChangeHiddenFieldValue()
{
    var obj = document.getElementById("<%= HdnPhotoUrls.ClientID %>");
    var value = "";
    for(i=0;i<photoUrls.length;i++)
    {
        if(value!="")
        {
            value = value+ "$$$";
        }
        value = value + photoUrls.options[i].value;
    }
    obj.value = value;
}

    function <%= m_JSPrefix %>ChangeThumbField(path,size,id,thumbpath)
{
    <%= m_JSPrefix %>DealwithUpload(path,size,id,thumbpath);
    if (thumbpath && jQuery.trim(thumbpath)!='') {
        try  //首页图片
        {
            setTimeout("try{homeImageAssignment('" + thumbpath + "')}catch(e){}", 1000);
        }
        catch(e)
        {
           // console.log(path,thumbpath);
        } 
    }
  
}

function <%= m_JSPrefix %>_getUploadPath(path,sizes,ids,thumbpath)
{
    if(path && jQuery.trim(path)!='')
    {
        var pathArray = path.split(",");
        for(var i=0;i<pathArray.length;i++)
        {
            <%= m_JSPrefix%>addphotourl(pathArray[i]);
        }
    }
    if (thumbpath && jQuery.trim(thumbpath)!='') {
        try  //首页图片
        {
            setTimeout("try{homeImageAssignment('" + thumbpath + "')}catch(e){}", 1000);
        }
        catch(e)
        {
           // console.log(path,thumbpath);
        } 
    }
}

function <%= m_JSPrefix %>_ClearEmptyPic()
{
    jQuery("#<%= m_JSPrefix%>_table tr").each(function(){
        if(jQuery(this).find("input[type='text']").val()=="")
        {
            jQuery(this).remove();
        }
    });
}

//-->
</script>
