<%@ 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="Goods" Object="Goods" InnerID="Request.QueryString['ID']" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>属性</title>
<link rel="stylesheet" type="text/css" href="<%=CommonPath%>jquery/themes/lightness/all.css" />
<ilghar:Comment><link rel="stylesheet" type="text/css" href="../../S01/CHS/css/common.css" /></ilghar:Comment>
<link rel="stylesheet" href="<%=CssPath%>common.css" />
<ilgharUC:Ime Ime="true" Eot="true" runat="server" />
<script type="text/javascript">
var _page = "goods_property";
var _lang = "<%=ContentLang%>";
var _webPath = "<%=WebPath%>";
var _imagePath = "<%=ImagePath%>";
var _goodsID = "<%=Goods[ID]%>";
var _properties = new Array();
var _options = new Array();
var _values = new Array();
var _valueIndex = 0;
var _lang_working = "正在操作...";
var _lang_operation_fail = "操作失败！";
var _lang_operation_success = "操作成功！";

<ilghar:List Object="Type.Property" Condition="TypeID=Goods[TypeID]">
	<ilghar:Record>
		_properties[_properties.length] = new Object();
		_properties[_properties.length - 1].ID = "<%=ID%>";
		_properties[_properties.length - 1].InnerID = "<%=InnerID%>";
		_properties[_properties.length - 1].Name = "<%=Name%>";
		_properties[_properties.length - 1].Control = "<%=Control%>";
		<%If !String.Equals(Control, "Text") && !String.Equals(Control, "TextArea")%>
			<ilghar:List Object="Type.Property.Option" Condition="PropertyID=ID">
				<ilghar:Record>
					_options[_options.length] = new Object();
					_options[_options.length - 1].ID = "<%=ID%>";
					_options[_options.length - 1].InnerID = "<%=InnerID%>";
					_options[_options.length - 1].PropertyID = "<%=PropertyID%>";
					_options[_options.length - 1].Name = "<%=Name%>";
				</ilghar:Record>
			</ilghar:List>
		<%EndIf%>
	</ilghar:Record>
</ilghar:List>

<ilghar:List Object="Goods.Property" Condition="GoodsID=Goods[ID]">
	<ilghar:Record>
		_values[_values.length] = new Object();
		_values[_values.length - 1].ID = "<%=ID%>";
		_values[_values.length - 1].PropertyID = "<%=PropertyID%>";
		_values[_values.length - 1].OptionInnerIDs = "<%=OptionInnerIDs%>";
		_values[_values.length - 1].Value = "<%=Value%>";
	</ilghar:Record>
</ilghar:List>

function WriteProperty()
{
	var html = "";
	for (var i = 0; i < _properties.length; i++)
	{
		var optionInnerIDs = "";
		var value = "";
		for (var k = 0; k < _values.length; k++)
		{
			if (_values[k].PropertyID == _properties[i].ID)
			{
				optionInnerIDs = _values[k].OptionInnerIDs;
				value = _values[k].Value;
				break;
			}
		}
		
		html += "<tr class='<%=ContentLang%>Font'>";
		html += "<th>" + _properties[i].Name + "：</th>";
		html += "<td>";
		switch (_properties[i].Control)
		{
			case "Text":
				html += "<input type=\"text\" name=\"P" + _properties[i].InnerID + "\" value=\"" + value + "\" />";
				break;
			case "TextArea":
				html += "<textarea cols=\"40\" rows=\"3\" name=\"P" + _properties[i].InnerID + "\">" + value + "</textarea>";
				break;
			case "Select":
				html += "<select name='P" + _properties[i].InnerID + "' class='<%=ContentLang%>Font'>";
				for (var j = 0; j < _options.length; j++)
				{
					if (_options[j].PropertyID != _properties[i].ID)
						continue;
					
					if (_options[j].InnerID == optionInnerIDs)
						html += "<option value='" + _options[j].InnerID + "' selected='selected'>" + _options[j].Name + "</option>";
					else
						html += "<option value='" + _options[j].InnerID + "'>" + _options[j].Name + "</option>";
				}
				html += "</select>";
				break;
			case "List":
				html += "<select name='P" + _properties[i].InnerID + "' size='4' class='<%=ContentLang%>Font'>";
				for (var j = 0; j < _options.length; j++)
				{
					if (_options[j].PropertyID != _properties[i].ID)
						continue;
					
					if (_options[j].InnerID == optionInnerIDs)
						html += "<option value='" + _options[j].InnerID + "' selected='selected'>" + _options[j].Name + "</option>";
					else
						html += "<option value='" + _options[j].InnerID + "'>" + _options[j].Name + "</option>";
				}
				html += "</select>";
				break;
			case "CheckBox":
				for (var j = 0; j < _options.length; j++)
				{
					if (_options[j].PropertyID != _properties[i].ID)
						continue;
					
					if (optionInnerIDs.indexOf("|" + _options[j].InnerID + "|") != -1)
						html += "<input type='checkbox' id='O" + _options[j].InnerID + "' name='P" + _properties[i].InnerID + "' value='" + _options[j].Name + "' checked='checked' /><label for='O" + _options[j].InnerID + "' class='<%=ContentLang%>Font'>" + _options[j].Name + "</label>";
					else
						html += "<input type='checkbox' id='O" + _options[j].InnerID + "' name='P" + _properties[i].InnerID + "' value='" + _options[j].Name + "' /><label for='O" + _options[j].InnerID + "' class='<%=ContentLang%>Font'>" + _options[j].Name + "</label>";
				}
				break;
			case "Radio":
				for (var j = 0; j < _options.length; j++)
				{
					if (_options[j].PropertyID != _properties[i].ID)
						continue;
					
					if (_options[j].InnerID == optionInnerIDs)
						html += "<input type='radio' id='O" + _options[j].InnerID + "' name='P" + _properties[i].InnerID + "' value='" + _options[j].Name + "' checked='checked' /><label for='O" + _options[j].InnerID + "' class='<%=ContentLang%>Font'>" + _options[j].Name + "</label>";
					else
						html += "<input type='radio' id='O" + _options[j].InnerID + "' name='P" + _properties[i].InnerID + "' value='" + _options[j].Name + "' /><label for='O" + _options[j].InnerID + "' class='<%=ContentLang%>Font'>" + _options[j].Name + "</label>";
				}
				break;
		}
		html += "</td>";
		html += "</tr>";
	}
	
	document.write(html);
}
</script>
</head>
<body>
<div class="WhiteHeader">
	<div class="Left"><img src="<%=ImagePath%>close_frame.gif" /></div>
	<div class="Title"><a href="list.aspx?Lang=<%=ContentLang%>">商品列表</a> → <span class="<%=ContentLang%>Font"><%=Goods[Name]%></span></div>
	<div class="Right">
		<ilgharUC:LanguageMenu runat="server" />
		<img height="15" src="<%=ImagePath%>dropdown.gif" /> 语言：<%=CurrentLanguage%>
	</div>
</div>
<div class="Block">
	<ul class="TabMenu">
		<li class="Left"></li>
		<li class="Middle"><a href="edit.aspx?Lang=<%=ContentLang%>&amp;ID=<%=Request.QueryString["ID"]%>">编辑</a></li>
		<li class="Right"></li>
		<li class="Left"></li>
		<li class="Middle"><a href="description.aspx?Lang=<%=ContentLang%>&amp;ID=<%=Request.QueryString["ID"]%>">描述</a></li>
		<li class="Right"></li>
		<li class="Left Selected"></li>
		<li class="Middle Selected">属性</li>
		<li class="Right Selected"></li>
		<li class="Left"></li>
		<li class="Middle"><a href="parameter.aspx?Lang=<%=ContentLang%>&amp;ID=<%=Request.QueryString["ID"]%>">参数</a></li>
		<li class="Right"></li>
		<li class="Left"></li>
		<li class="Middle"><a href="part.aspx?Lang=<%=ContentLang%>&amp;ID=<%=Request.QueryString["ID"]%>">配件</a></li>
		<li class="Right"></li>
		<li class="Left"></li>
		<li class="Middle"><a href="pictures.aspx?Lang=<%=ContentLang%>&amp;ID=<%=Request.QueryString["ID"]%>">更多图片</a></li>
		<li class="Right"></li>
		<%If String.Equals(Goods[Kind], "Card")%>
			<li class="Left"></li>
			<li class="Middle"><a href="card.aspx?Lang=<%=ContentLang%>&amp;ID=<%=Request.QueryString["ID"]%>">虚拟卡</a></li>
			<li class="Right"></li>
		<%EndIf%>
	</ul>
	<ul class="Title">
		<li class="Left"></li>
		<li class="Middle"></li>
		<li class="Right"></li>
	</ul>
	<form>
		<table border="0" cellpadding="4" cellspacing="1">
			<tfoot>
				<tr><td colspan="2"><input type="submit" value="编辑" /></td></tr>
			</tfoot>
			<tbody>
				<script type="text/javascript">
				WriteProperty();
				</script>
			</tbody>
		</table>
	</form>
	<div class="Footer"></div>
</div>
<script type="text/javascript" src="<%=CommonPath%>jquery/core.js"></script>
<script type="text/javascript" src="<%=CommonPath%>jquery/ui.js"></script>
<script type="text/javascript" src="<%=CommonPath%>utility.js"></script>
<script type="text/javascript" src="<%=JsPath%>global.js"></script>
<script type="text/javascript" src="<%=JsPath%>shop.js"></script>
</body>
</html>