<%@ page language="C#" autoeventwireup="true" inherits="CommonUI_FileSelect, App_Web_xrqyekjk" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>选择文件</title>
    <base target="_self"/>
    <link rel="stylesheet" href="../style/Common.css" />
    <link rel="stylesheet" href="../style/Dialog.css" />

    <script type="text/javascript" src="../Script/Common.js"></script>
    <script type="text/javascript">
var TreeFrame, lbSelect, tbSelect, chkUpload, fuUpload, btnConfirm, btnCancel;
function Page_Init()
    {
	TreeFrame = $('TreeFrame');
	lbSelect = $('lbSelect');
	tbSelect = $('tbSelect');
	chkUpload = $('chkUpload');
	fuUpload = $('fuUpload');
	btnConfirm = $('btnConfirm');
	btnCancel = $('btnCancel');
	
	chkUpload.onclick = ByState;
    	fuUpload.onchange = fuUpload_Change;
	tbSelect.onchange = tbSelect_Change;
	tbSelect.onkeyup = tbSelect_Change;
	tbSelect.onblur = tbSelect_Change;
    }
var SiteName, isUpload=false, isSelectOK=false, isUploadOK=false;
function Page_Load()
    {
	SiteName = Common.GetQueryString('sitename');
	ByState();
    }
function ByState()
    {
	if( isUpload != chkUpload.checked )
	    tbSelect.value = '';
	isUpload = chkUpload.checked;
	var treeUrl = new UrlText( 'FileTree.aspx', ['sitename', SiteName], 'uni' );
	if( isUpload ){
	    fuUpload.disabled = false;
	    lbSelect.innerText = "上传到";
	    treeUrl.Add( ['optype', 'foldertree'] );
	    TreeFrame.src = treeUrl.Text;  //"FileTree.aspx?sitename=" + SiteName + "&optype=foldertree";
//	    tbSelect.disabled = true;
	} else{
	    fuUpload.disabled = true;
	    lbSelect.innerText = "已选择";
	    TreeFrame.src = treeUrl.Text;  //"FileTree.aspx?sitename=" + SiteName;
//	    tbSelect.disabled = false;
	}
    }
function ByBtnState()
    {
	if( isUpload ){
	    if( isUploadOK && isSelectOK ) btnConfirm.disabled = false;
	    else                           btnConfirm.disabled = true;
	} else{
	    if( isSelectOK ) btnConfirm.disabled = false;
	    else             btnConfirm.disabled = true;
	}
    }
function SelectPath( isFile, path )
    {
	if( isUpload ){
	    if( !isFile ) tbSelect.value = path;
	    else          tbSelect.value = '';
	} else{
	    if( isFile ) tbSelect.value = path;
	    else         tbSelect.value = '';
	}
	tbSelect_Change();
    }
function fuUpload_Change()
    {
	if( fuUpload.value ) isUploadOK = true;
	else                 isUploadOK = false;
	ByBtnState();
    }
function tbSelect_Change()
    {
	if( tbSelect.value ) isSelectOK = true;
	else                 isSelectOK = false;
	ByBtnState();
    }
    </script>
</head>
<body><form id="form1" runat="server">

    <div class="TopArea">
        <h1>选择文件</h1>
        <div class="HeadLogo"></div>
    </div>
    
    <div class="ContentArea">
        <table style="width:100%;">
            <tr>
                <td style="width:20%;"><asp:CheckBox ID="chkUpload" runat="server" Text="上传文件:" Checked="true" /></td>
                <td style="width:80%;"><asp:FileUpload ID="fuUpload" runat="server" Width="100%" /></td>
            </tr>
            <tr><td colspan="2">
                <iframe id="TreeFrame" width="100%" height="320" frameborder="0" style="border:1px solid gray"></iframe>
            </td></tr>
            <tr>
                <td><asp:Label ID="lbSelect" runat="server" Text="已选择：" /></td>
                <td><asp:TextBox ID="tbSelect" runat="server" Width="98%" /></td>
            </tr>
        </table>
    </div>
     
    <div class="BottomArea">
        <span class="LeftBlock">
            <asp:Label ID="lbResult" runat="server" ForeColor="Red"></asp:Label>
        </span>
        <span class="RightBlock">
            <asp:Button ID="btnConfirm" runat="server" CssClass="Button" Text="确定" Enabled="false" OnClick="btnConfirm_Click" />
            <%--<input id=""  type="button" class="" value="" onclick="btnConfirm_Click();" disabled="disabled"/>--%>
            <input id="btnCancel" type="button" class="Button" value="取消" onclick="window.close();" />
        </span>
    </div>

</form>
<script type="text/javascript" language="javascript">
try{ Page_Init(); }catch(ex){;}
try{ Page_Resize(); window.onresize=Page_Resize; }catch(ex){;}
try{ Page_Load(); }catch(ex){;}
</script>
</body>
</html>
