<%@ 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" -->
<ilghar:Get ID="ProductCategory" Object="ProductCategory" InnerID="Request.QueryString['ID']" Validate="True" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>编辑类别</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 _uploadPicture = false;
function XmlHttpCallBack(xmlHttp)
{
	if (xmlHttp.status == 200)
	{
		if (_action == "Edit")
		{
			window.status = "编辑类别完成！";

			if (_uploadPicture)
			{
				_action = "UploadPicture";
				window.status = "开始上传图片...";
				_uploader.Init({Status:"正在上传图片...",Params:"Lang=<%=ContentLang%>&Object=ProductCategory&Operation=" + _action + "&ID=<%=Request.QueryString["ID"]%>"});
				_uploader.Upload("Picture");
			}
			else
			{
				alert("编辑成功！");
				document.getElementById("Submit").disabled = false;
				window.status = "";
			}
		}
		else if (_action == "UploadPicture")
		{
			if (arguments.length == 2)
				alert(arguments[1]);
			else
				alert("编辑成功！");
			document.getElementById("Submit").disabled = false;
			window.status = "";
		}
	}
	else
	{
		if (_action == "Edit")
			alert("编辑失败！请查看日志！");
		else if (_action == "UploadPicture")
			alert("上传图片失败！请查看日志！");
		else
			alert("失败！请查看日志！");
	
		document.getElementById("Submit").disabled = false;
		window.status = "";
	}
}

function OnSubmit(form)
{
	if (form.Name.value == "")
	{
		alert("名称不能空！");
		form.Name.select();
		return false;
	}
	
	if (!IsAllowedType(form.Picture.value, form.PictureAllowedType.value))
	{
		alert("图片类型应为：" + form.PictureAllowedType.value);
		form.Picture.select();
		return false;
	}

	var data = "Name=" + encodeURIComponent(form.Name.value);
	data += "&ParentID=" + form.ParentID.value;
	data += "&MetaKeywords=" + encodeURIComponent(form.MetaKeywords.value);
	data += "&MetaDescription=" + encodeURIComponent(form.MetaDescription.value);
	if (<%=ProductCategory[Recommend]%> == 0 || !document.getElementById("IsRecommendedYes").checked)
		data += "&IsRecommended=" + document.getElementById("IsRecommendedYes").checked;
	if (<%=ProductCategory[Hold]%> == 0 || !document.getElementById("IsHeldYes").checked)
		data += "&IsHeld=" + document.getElementById("IsHeldYes").checked;
	_uploadPicture = _uploader.NeedUpload("Picture");
	if (!_uploadPicture)
		data += "&Picture=" + encodeURIComponent(form.Picture.value);
	
	document.getElementById("Submit").disabled = true;
	window.status = "正在修改类别...";
	_action = "Edit";
	_ajax.Post("<%=WebPath%>ilghar.aspx?Lang=<%=ContentLang%>&Object=ProductCategory&Operation=Modify&ID=<%=Request.QueryString["ID"]%>", 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"><a href="list.aspx?Lang=<%=ContentLang%>&amp;Kind=<%=Request.QueryString["Kind"]%>">类别列表</a> → <span class="<%=ContentLang%>Font"><%=ProductCategory[Name]%></span></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="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>性质：</th>
					<td>
						<%If Request.QueryString["Kind"] == "AutoSite"%>
							智能建站
						<%ElseIf Request.QueryString["Kind"] == "Host"%>
							虚拟主机
						<%ElseIf Request.QueryString["Kind"] == "WebSite"%>
							网站
						<%ElseIf Request.QueryString["Kind"] == "Set"%>
							套餐
						<%Else%>
							其他
						<%EndIf%>
					</td>
				</tr>
				<tr>
					<th>所属类别：</th>
					<td>
						<select name="ParentID" class="<%=ContentLang%>Font">
							<option value="">未指定</option>
							<ilghar:Tree Object="ProductCategory" Condition="Kind=Request.QueryString['Kind']">
								<ilghar:Control>
									<ilghar:Space>&nbsp;&nbsp;</ilghar:Space>
									<ilghar:Line>│</ilghar:Line>
									<ilghar:TopOpen>┌</ilghar:TopOpen>
									<ilghar:Top>┌</ilghar:Top>
									<ilghar:MiddleOpen>├</ilghar:MiddleOpen>
									<ilghar:Middle>├</ilghar:Middle>
									<ilghar:BottomOpen>└</ilghar:BottomOpen>
									<ilghar:Bottom>└</ilghar:Bottom>
								</ilghar:Control>
								<ilghar:Record>
									<%If Guid.Equals(ID, ProductCategory[ParentID])%>
										<option value="<%=ID%>" selected="selected"><%=Control%><%=Name%></option>
									<%Else%>
										<option value="<%=ID%>"><%=Control%><%=Name%></option>
									<%EndIf%>
									<%=ChildRecords%>
								</ilghar:Record>
							</ilghar:Tree>
						</select>
					</td>
				</tr>
				<tr>
					<th>名称：</th>
					<td><input type="text" name="Name" maxlength="50" class="Text <%=ContentLang%>Font" value="<%=ProductCategory[Name]%>" /></td>
				</tr>
				<tr>
					<th>图片：</th>
					<td>
						<input id="PictureTextbox" type="text" name="Picture" value="<%=ProductCategory[Picture]%>" size="55" class="Text" onchange="document.getElementById('PictureView').src = this.value" />
						<input id="PictureBrowse" type="button" value="浏览..." />
						<input type="hidden" name="PictureAllowedType" value="gif|jpg|jpeg|png|bmp" />
						<a href="<%=ProductCategory[Picture]%>" target="_blank"><img src="<%=ProductCategory[Picture]%>" height="22" id="PictureView" alt="预览" style="vertical-align:bottom" /></a>
					</td>
				</tr>
				<tr>
					<th>是否推荐：</th>
					<td>
						<input type="radio" name="IsRecommended" id="IsRecommendedYes" /><label for="IsRecommendedYes">是</label>
						<input type="radio" name="IsRecommended" id="IsRecommendedNo" checked="checked" /><label for="IsRecommendedNo">否</label>
					</td>
				</tr>
				<tr>
					<th>是否置顶：</th>
					<td>
						<input type="radio" name="IsHeld" id="IsHeldYes" /><label for="IsHeldYes">是</label>
						<input type="radio" name="IsHeld" id="IsHeldNo" checked="checked" /><label for="IsHeldNo">否</label>
					</td>
				</tr>
				<tr>
					<th>Meta：</th>
					<td>
						Keywords：<input type="text" name="MetaKeywords" value="<%=ProductCategory[MetaKeywords]%>" size="20" maxlength="255" class="Text <%=ContentLang%>Font" />
						Description：<input type="text" name="MetaDescription" value="<%=ProductCategory[MetaDescription]%>" size="20" maxlength="255" class="Text <%=ContentLang%>Font" />
					</td>
				</tr>
			</tbody>
			<tfoot>
				<tr>
					<td colspan="2"><input type="submit" id="Submit" value="编辑" /></td>
				</tr>
			</tfoot>
		</table>
	</form>
	<div class="Footer"></div>
</div>
<script type="text/javascript">
if (<%=ProductCategory[Recommend]%>)
	document.getElementById("IsRecommendedYes").checked = true;
else
	document.getElementById("IsRecommendedNo").checked = true;
	
if (<%=ProductCategory[Hold]%>)
	document.getElementById("IsHeldYes").checked = true;
else
	document.getElementById("IsHeldNo").checked = true;

_uploader.Init({WebPath:"<%=WebPath%>",OnComplete:XmlHttpCallBack});
_uploader.Add("Picture", "PictureTextbox", "PictureBrowse");

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