<%@ Page CodeFileBaseClass="IlgharCMS.Lib.AdminPageBase" %>
<%@ Register TagPrefix="IlgharUC" TagName="Ime" Src="../../ime.dwt.ascx"%>
<%@ Register TagPrefix="IlgharUC" TagName="LanguageMenu" Src="../../language_menu.dwt.ascx"%>
<!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>
<!-- TemplateInfo codeOutsideHTMLIsLocked="true" -->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>添加CMS</title>
<ilghar:Comment><link rel="stylesheet" type="text/css" href="../../S01/CHS/css/common.css" /></ilghar:Comment>
<link rel="stylesheet" href="<%=CssPath%>common.css" />
<script type="text/javascript" src="<%=CommonPath%>ajax.js"></script>
<script type="text/javascript" src="<%=CommonPath%>uploader.js"></script>
<script type="text/javascript" src="<%=JsPath%>common.js"></script>
<ilgharUC:Ime Ime="true" Eot="true" runat="server" />
<script type="text/javascript">
var _action = null;
var _upload = false;
function XmlHttpCallBack(xmlHttp)
{
	if (xmlHttp == null || xmlHttp.status == 200)
	{
		if (_action == "Add")
		{
			window.status = "添加完成！";
	
			if (_upload)
			{
				_action = "GetInnerIDFromGuid";
				_ajax.Post("<%=WebPath%>ilghar.aspx?Lang=<%=ContentLang%>&Object=CMS&Operation=" + _action + "&ID=" + xmlHttp.responseText, null, XmlHttpCallBack);
			}
			else
			{
				alert("添加成功！");
				document.getElementById("Submit").disabled = false;
				window.status = "";
			}
		}
		else if (_action == "GetInnerIDFromGuid")
		{
			_action = "Upload";
			window.status = "开始上传文件...";
			_uploader.Init({Status:"正在上传文件...",Params:"Lang=<%=ContentLang%>&Object=CMS&Operation=" + _action + "&ID=" + xmlHttp.responseText});
			_uploader.Upload("File");
		}
		else if (_action == "Upload")
		{
			if (arguments.length == 2)
				alert(arguments[1]);
			else
				alert("添加成功！");
			document.getElementById("Submit").disabled = false;
			window.status = "";
		}
	}
	else
	{
		if (_action == "Add")
			alert("添加失败！请查看日志！");
		else if (_action == "GetInnerIDFromGuid")
			alert("获取InnerID失败！请查看日志！");
		else if (_action == "Upload")
			alert("上传失败！请查看日志！");
	
		document.getElementById("Submit").disabled = false;
		window.status = "";
	}
}

function OnSubmit(form)
{
	if (form.Name.value == "")
	{
		alert("名称不能空！");
		form.Name.select();
		return false;
	}
	
	if (form.Number.value == "")
	{
		alert("编号不能空！");
		form.Number.select();
		return false;
	}
	
	if (!IsAllowedType(form.File.value, form.FileAllowedType.value))
	{
		alert("文件类型应为：" + form.FileAllowedType.value);
		form.File.select();
		return false;
	}
	
	_upload = _uploader.NeedUpload("File");	
	
	var data = "Name=" + encodeURIComponent(form.Name.value);
	data += "&Number=" + encodeURIComponent(form.Number.value);
	data += "&Version=" + encodeURIComponent(form.Version.value);
	data += "&Description=" + encodeURIComponent(form.Description.value);
	
	document.getElementById("Submit").disabled = true;
	_action = "Add";
	_ajax.Post("<%=WebPath%>ilghar.aspx?Lang=<%=ContentLang%>&Object=CMS&Operation=Add", data, XmlHttpCallBack);
	return false;
}
</script>
</head>
<body>
<div class="WhiteHeader">
	<div class="Left"><img src="<%=ImagePath%>close_frame.gif" onclick="OpenCloseLeftFrame()" /></div>
	<div class="Title">添加CMS</div>
	<div class="Right">
		<ilgharUC:LanguageMenu runat="server" />
		<img height="15" src="<%=ImagePath%>dropdown.gif" onmouseover="this.src='<%=ImagePath%>dropdown_over.gif';ShowLanguageMenu(this);" onmouseout="this.src='<%=ImagePath%>dropdown.gif'" />
		语言：<%=CurrentLanguage%>
	</div>
</div>
<div class="Block">
	<ul class="TabMenu">
		<li class="Left"></li>
		<li class="Middle"><a href="list.aspx?Lang=<%=ContentLang%>">CMS列表</a></li>
		<li class="Right"></li>
		<li class="Left Selected"></li>
		<li class="Middle Selected">添加CMS</li>
		<li class="Right Selected"></li>
	</ul>
	<ul class="Title">
		<li class="Left"></li>
		<li class="Middle"></li>
		<li class="Right"></li>
	</ul>
	<form method="post" onsubmit="return OnSubmit(this)">
		<table border="0" cellpadding="4" cellspacing="1">
			<tbody>
				<tr>
					<th width="120">名称：</th>
					<td><input type="text" name="Name" size="50" maxlength="50" class="Text <%=ContentLang%>Font" /></td>
				</tr>
				<tr>
					<th>编号：</th>
					<td><input type="text" name="Number" size="50" maxlength="100" class="Text" /></td>
				</tr>
				<tr>
					<th>版本：</th>
					<td><input type="text" name="Version" maxlength="50" class="Text" /></td>
				</tr>
				<tr>
					<th>描述：</th>
					<td>
						<textarea name="Description" cols="70" rows="6" wrap="off" class="Text <%=ContentLang%>Font"></textarea>
					</td>
				</tr>
				<tr>
					<th>文件：</th>
					<td>
						<input id="FileTextbox" type="text" name="File" size="60" disabled="disabled" class="Text" />
						<input id="FileBrowse" type="button" value="浏览..." />
						<input type="hidden" name="FileAllowedType" value="zip" />
					</td>
				</tr>
			</tbody>
			<tfoot>
				<tr>
					<td colspan="2"><input type="submit" id="Submit" class="Button" value="添加" /></td>
				</tr>
			</tfoot>
		</table>
	</form>
	<div class="Footer"></div>
</div>
<script type="text/javascript">
_uploader.Init({WebPath:"<%=WebPath%>",OnComplete:XmlHttpCallBack});
_uploader.Add("File", "FileTextbox", "FileBrowse");

HandleFake404();
</script>
</body>
</html>