<%@ Page CodeFileBaseClass="IlgharCMS.Lib.AdminPageBase" %>
<%@ 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="Config" Object="InstanceConfig" Operation="GetBasicSettings()" 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>
<script type="text/javascript">
var _action = null;
var _uploadProductDefaultThumbnail = false;
function XmlHttpCallBack(xmlHttp)
{
	if (xmlHttp == null || xmlHttp.status == 200)
	{
		if (_action == "Save")
		{
			window.status = "保存基本设置完成！";
	
			if (_uploadProductDefaultThumbnail)
			{
				_action = "UploadProductDefaultThumbnail";
				window.status = "开始上传产品默认小图...";
				_uploader.Init({Status:"正在上传产品默认小图...",Params:"Lang=<%=ContentLang%>&Object=InstanceConfig&Operation=" + _action});
				_uploader.Upload("Product");
			}
			else
			{
				alert("保存成功！");
				document.getElementById("Submit").disabled = false;
				window.status = "";
			}
		}
		else if (_action == "UploadProductDefaultThumbnail")
		{
			if (arguments.length == 2)
				alert(arguments[1]);
			else
				alert("保存成功！");
			document.getElementById("Submit").disabled = false;
			window.status = "";
		}
		else if (_action == "CreateAllProductThumbnail")
		{
			alert("重新生成所有产品小图成功！");
			document.getElementById("CreateAllProductThumbnailButton").disabled = false;
			window.status = "";
		}
	}
	else
	{
		if (_action == "Edit")
			alert("保存失败！请查看日志！");
		else if (_action == "UploadProductDefaultThumbnail")
			alert("上传产品默认小图失败！请查看日志！");
		else if (_action == "CreateAllProductThumbnail")
			alert("重新生成所有产品小图失败！请查看日志！");
		else
			alert("失败！请查看日志！");
	
		document.getElementById("Submit").disabled = false;
		window.status = "";
	}
}

function OnSubmit(form)
{
	if (form.ProductThumbnailFolder.value.length > 0 && form.ProductThumbnailFolder.value.indexOf("/") != 0)
	{
		alert("产品小图上传目录必须以斜杠（/）开头！");
		form.ProductThumbnailFolder.select();
		return false;
	}
	
	if (form.ProductPictureFolder.value.length > 0 && form.ProductPictureFolder.value.indexOf("/") != 0)
	{
		alert("产品大图上传目录必须以斜杠（/）开头！");
		form.ProductPictureFolder.select();
		return false;
	}
	
	if (form.TempFileFolder.value.length > 0 && form.TempFileFolder.value.indexOf("/") != 0)
	{
		alert("文件临时目录必须以斜杠（/）开头！");
		form.TempFileFolder.select();
		return false;
	}
	
	if (form.CMSFolder.value.length > 0 && form.CMSFolder.value.indexOf("/") != 0)
	{
		alert("CMS上传目录必须以斜杠（/）开头！");
		form.CMSFolder.select();
		return false;
	}
	
	if (form.DataFolder.value.length > 0 && form.DataFolder.value.indexOf("/") != 0)
	{
		alert("数据文件上传目录必须以斜杠（/）开头！");
		form.DataFolder.select();
		return false;
	}
	
	if (form.WebSiteFolder.value.length > 0 && form.WebSiteFolder.value.indexOf("/") != 0)
	{
		alert("网站上传目录必须以斜杠（/）开头！");
		form.WebSiteFolder.select();
		return false;
	}
	
	if (!form.ProductThumbnailWidth.value.match(/^\d*$/))
	{
		alert("产品小图宽度必须是数字！");
		form.ProductThumbnailWidth.select();
		return false;
	}	
	
	if (!form.ProductThumbnailHeight.value.match(/^\d*$/))
	{
		alert("产品小图高度必须是数字！");
		form.ProductThumbnailHeight.select();
		return false;
	}	
	
	if (!IsAllowedType(form.ProductDefaultThumbnail.value, form.ProductDefaultThumbnailAllowedType.value))
	{
		alert("产品默认小图类型应为：" + form.ProductDefaultThumbnailAllowedType.value);
		form.ProductDefaultThumbnail.select();
		return false;
	}
	
	if (!form.TaxRate.value.match(/^\d+(\.\d+)?$/))
	{
		alert("税率格式不正确！");
		form.TaxRate.select();
		return false;
	}	
	
	var data = "ProductThumbnailWidth=" +  form.ProductThumbnailWidth.value;
	data += "&ProductThumbnailHeight=" + form.ProductThumbnailHeight.value;
	data += "&ProductThumbnailFolder=" +  encodeURIComponent(form.ProductThumbnailFolder.value);
	data += "&ProductPictureFolder=" +  encodeURIComponent(form.ProductPictureFolder.value);
	data += "&TempFileFolder=" +  encodeURIComponent(form.TempFileFolder.value);
	data += "&CMSFolder=" +  encodeURIComponent(form.CMSFolder.value);
	data += "&DataFolder=" +  encodeURIComponent(form.DataFolder.value);
	data += "&WebSiteFolder=" +  encodeURIComponent(form.WebSiteFolder.value);
	data += "&TaxRate=" + form.TaxRate.value;
	data += "&AutoOrder=" + document.getElementById("AutoOrderYes").checked;
	data += "&ForbiddenDomain=" +  encodeURIComponent(form.ForbiddenDomain.value);
	_uploadProductDefaultThumbnail = _uploader.NeedUpload("Product");
	if (!_uploadProductDefaultThumbnail)
		data += "&ProductDefaultThumbnail=" + encodeURIComponent(form.ProductDefaultThumbnail.value);
	
	document.getElementById("Submit").disabled = true;
	window.status = "正在操作...";
	_action = "Save";
	_ajax.Post("<%=WebPath%>ilghar.aspx?Lang=<%=ContentLang%>&Object=InstanceConfig&Operation=SetBasicSettings", data, XmlHttpCallBack);
	return false;
}

function CreateAllProductThumbnail()
{
	document.getElementById("CreateAllProductThumbnailButton").disabled = true;
	window.status = "正在操作...";
	_action = "CreateAllProductThumbnail";
	_ajax.Post("<%=WebPath%>ilghar.aspx?Lang=<%=ContentLang%>&Object=Product&Operation=CreateAllThumbnail", null, XmlHttpCallBack);
}
</script>
</head>
<body>
<div class="WhiteHeader">
	<div class="Left"><img src="<%=ImagePath%>close_frame.gif" onclick="OpenCloseLeftFrame()" /></div>
	<div class="Title">基本设置</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 Selected"></li>
		<li class="Middle Selected">基本设置</li>
		<li class="Right Selected"></li>
		<li class="Left"></li>
		<li class="Middle"><a href="discount.aspx?Lang=<%=ContentLang%>">会员折扣</a></li>
		<li class="Right"></li>
		<li class="Left"></li>
		<li class="Middle"><a href="percentage.aspx?Lang=<%=ContentLang%>">会员提成</a></li>
		<li class="Right"></li>
		<li class="Left"></li>
		<li class="Middle"><a href="host_server.aspx?Lang=<%=ContentLang%>">服务端设置</a></li>
		<li class="Right"></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>产品小图尺寸（宽度x高度）：</th>
					<td>
						<input type="text" name="ProductThumbnailWidth" value="<%=Config[ProductThumbnailWidth]%>" size="10" class="Text" /> x
						<input type="text" name="ProductThumbnailHeight" value="<%=Config[ProductThumbnailHeight]%>" size="10" class="Text" />
						<button type="button" id="CreateAllProductThumbnailButton" onclick="CreateAllProductThumbnail()">重新生成所有产品小图</button>
					</td>
				</tr>
				<tr>
					<th>产品默认小图：</th>
					<td>
						<input id="ProductTextbox" type="text" name="ProductDefaultThumbnail" value="<%=Config[ProductDefaultThumbnail]%>" size="60" class="Text" onchange="document.getElementById('ProductDefaultThumbnailView').src = this.value" />
						<input id="ProductBrowse" type="button" value="浏览..." />
						<input type="hidden" name="ProductDefaultThumbnailAllowedType" value="gif|jpg|jpeg|png|bmp|png" />
						<a href="<%=Config[ProductDefaultThumbnail]%>" target="_blank"><img src="<%=Config[ProductDefaultThumbnail]%>" height="22" id="ProductDefaultThumbnailView" alt="产品默认小图" style="vertical-align:bottom" /></a>
					</td>
				</tr>
				<tr>
					<th>产品小图上传目录：</th>
					<td>
						<input type="text" name="ProductThumbnailFolder" value="<%=Config[ProductThumbnailFolder]%>" size="60" class="Text" />用斜杠（/）开头
					</td>
				</tr>
				<tr>
					<th>产品大图上传目录：</th>
					<td>
						<input type="text" name="ProductPictureFolder" value="<%=Config[ProductPictureFolder]%>" size="60" class="Text" />用斜杠（/）开头
					</td>
				</tr>
				<tr>
					<th>文件临时目录：</th>
					<td>
						<input type="text" name="TempFileFolder" value="<%=Config[TempFileFolder]%>" size="60" class="Text" />用斜杠（/）开头
					</td>
				</tr>
				<tr>
					<th>CMS上传目录：</th>
					<td>
						<input type="text" name="CMSFolder" value="<%=Config[CMSFolder]%>" size="60" class="Text" />用斜杠（/）开头
					</td>
				</tr>
				<tr>
					<th>数据文件上传目录：</th>
					<td>
						<input type="text" name="DataFolder" value="<%=Config[DataFolder]%>" size="60" class="Text" />用斜杠（/）开头
					</td>
				</tr>
				<tr>
					<th>网站上传目录：</th>
					<td>
						<input type="text" name="WebSiteFolder" value="<%=Config[WebSiteFolder]%>" size="60" class="Text" />用斜杠（/）开头
					</td>
				</tr>
				<tr>
					<th>税率：</th>
					<td>
						<input type="text" name="TaxRate" value="<%=Config[TaxRate]%>" size="5" class="Text" />%
					</td>
				</tr>
				<tr>
					<th>订单自动处理：</th>
					<td>
						<%If Convert.ToBoolean(Config[AutoOrder])%>
							<input type="radio" name="AutoOrder" id="AutoOrderYes" checked="checked" /><label for="AutoOrderYes">是</label>
							<input type="radio" name="AutoOrder" id="AutoOrderNo" /><label for="AutoOrderNo">否</label>
						<%Else%>
							<input type="radio" name="AutoOrder" id="AutoOrderYes" /><label for="AutoOrderYes">是</label>
							<input type="radio" name="AutoOrder" id="AutoOrderNo" checked="checked" /><label for="AutoOrderNo">否</label>
						<%EndIf%>
					</td>
				</tr>
				<tr>
					<th>禁止绑定的域名：</th>
					<td>
						<input type="text" name="ForbiddenDomain" value="<%=Config[ForbiddenDomain]%>" size="60" class="Text" />多个域名用竖杠（|）隔开
					</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">
_uploader.Init({WebPath:"<%=WebPath%>",OnComplete:XmlHttpCallBack});
_uploader.Add("Product", "ProductTextbox", "ProductBrowse");

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