<%@Page Language="C#" Inherits="IWMS.Admin.StyleMan" MasterPageFile="admin.master"%>
<asp:Content ContentPlaceHolderId="cphHead" runat="server">
	<script type="text/javascript">
	<!--
	function Export(){
		var id = parseInt("<%=allStyle.SelectedValue%>");
		var ifm = document.getElementById("ifm_export");
		if (id>0){
			ifm.src = "admin_export.aspx?id="+id+"&w=style";
		}
		return false;
	}
	
	function Preview(){
		var o = document.getElementById("con_piccss");
		//alert(o.getElementsByTagName("input").length+","+o.getElementsByTagName("img").length);
		var arrInput = o.getElementsByTagName("input");
		var arrImg = o.getElementsByTagName("img");
		for(var i=0; i<arrImg.length; i++){
			var ii = i*2;	// input索引
			if (arrInput[ii].value.length>0){
				arrImg[i].src=arrInput[ii].value;
				arrImg[i].style.display="";
				arrImg[i].align="absmiddle";
			}else{
				arrImg[i].style.display="none";
			}
		}
		return true;
	}
	
	
	var navVersion=navigator.appVersion.toLowerCase();
	var bIsIE5 = (navVersion.indexOf("msie 5.0")!=-1) || (navVersion.indexOf("msie 5.5")!=-1) || (navVersion.indexOf("msie 6.0")!=-1) || (navVersion.indexOf("msie 7.0")!=-1);
	var frame;
	// 打开修改指定样式表内容
	function iwms_style(fname){
		if (fname.indexOf("name=null")>0){
			// prompt栏目名取消会是null
			return;
		}
		if (fname.indexOf(".")<0){
			fname = fname + ".htm";
		}
		
		if (bIsIE5){
			showModalDialog("styleEdit/"+ fname, window, "dialogWidth:270px; dialogHeight:140px; status:0; help:0; scroll:no");
		}else{
			var styleWin = window.open("","styleWin","width=270,height=120");
			if (styleWin) {
				styleWin.focus();
			}else{
				alert("Please turn off your PopUp blocking software");
				return;
			}
		
			launchParameters = new Object();
			launchParameters['styleWin'] = window;
			styleWin.launchParameters = launchParameters;
			styleWin.location.href="styleEdit/"+ fname;
		}
	}
	
	// 返回当前样式表内容
	function iwms_getStyle(){
		var obj = document.getElementById("<%=cssBody.ClientID%>");
		return obj.value;
	}
	
	// 返回样式表路径
	function iwms_getPath(){
		var obj = document.getElementById("<%=path.ClientID%>");
		return obj.value;
	}
	
	// 设置样式表
	function iwms_setStyle(selector, rule){
		var obj = document.getElementById("<%=cssBody.ClientID%>");
		var s = obj.value;
		var re = new RegExp("(\\r\\n|^)\\s*"+ selector+"\\s*?\{(.|\n)*?\}", "ig");
		s = s.replace(re, "");
		// rule里相对地址转换
		re = new RegExp("url\\(../"+ iwms_getPath() +"(.+?)\\)","ig");
		if (rule.length>0){
			rule = rule.replace(re, "url($1)");
			s += "\r\n"+ selector+" {"+ rule +"}";
		}
		obj.value = s;
		
		var o_modcss = document.getElementById("<%=modifyCss.ClientID%>");
		if (!o_modcss.checked){
			o_modcss.checked = true;
			o_modcss.fireEvent("onclick");
		}
	}
	
	-->
	</script>
</asp:Content>
<asp:Content ContentPlaceHolderId="cphMain" runat="server">

	<div class="mframe">
	<div class="tl"></div>
	<div class="tr"></div>
	<div class="tm">
		<a style="float:right" href="http://www.iwms.net/n773c48.aspx" target="_blank"><img src="pic/admin_help.gif" alt="帮助" /></a><span class="tt">管理风格&nbsp; <a href="http://www.iwms.net/buy/resources.aspx?type=2" target="_blank">更多风格</a></span>
	</div>
	<div class="wrapper">
	<div class="ml"></div>
	<div class="mr"></div>
	<div class="mm">
		<asp:Label id="myLabel" class="msgBar" EnableViewState="false" runat="server"/>
		<form enctype="multipart/form-data" runat="server">
		<asp:ValidationSummary 
			 DisplayMode="BulletList" 
			 EnableClientScript="true"
			 ShowSummary="false"
			 ShowMessageBox="true"                        
			 HeaderText="请正确填写以下内容"
			 runat="server"/>
		<table align="center" width="95%" cellpadding="3" >
		<tr>
		<td colspan="2" class="tdbg-dark">
		<asp:RadioButtonList id="allStyle"
			AutoPostBack=true
			OnSelectedIndexChanged="allStyle_CheckedChanged"
			RepeatDirection="Horizontal"
			RepeatColumns="6"
			runat="server"/>
			<asp:RequiredFieldValidator
				ControlToValidate="allStyle"
				ErrorMessage="必须选择一种风格"
				Display="None"
				runat="server"/>
		</td></tr>
		<tr><td width="200">
			<strong>风格名称：</strong>
		</td><td>
			<asp:TextBox id="name" 
				Columns="20"
				MaxLength="50"
				runat="server"
				/>
			&nbsp; <strong><a href="default.aspx?styleid=<%=selStyle.ID%>" target="_blank">预览风格</a></strong>
			<asp:RequiredFieldValidator
				ControlToValidate="name"
				ErrorMessage="风格名称必须填写"
				Display="None"
				runat="server"
				/>
		</td></tr>
		<tr><td valign="top"><strong>风格目录：</strong>
		</td>
		<td>
			<asp:TextBox id="path"
				Columns="50"
				MaxLength="255"
				runat="server"
				/>
			<asp:RequiredFieldValidator
				ControlToValidate="path"
				ErrorMessage="风格目录必须填写"
				Display="None"
				runat="server"
				/>
		</td></tr>
		<%if(Request.UserAgent.IndexOf("MSIE 8.0")>=0 && false){%>
		<tr><td colspan="2"><strong>设计风格：</strong>
			<span style="background:infobackground; border:1px solid #999999; padding:2px; font-weight:bold;">
			<a href="javascript:iwms_style('body');">页面样式设计</a>&nbsp;
			<% if (selStyle.ID!=-1){%>
			<a href="javascript:iwms_style('headfoot');">头部/底部样式</a>&nbsp;
			<a href="javascript:iwms_style('menu');">菜单样式</a>&nbsp;
			<a href="javascript:iwms_style('news');">新闻显示样式</a>&nbsp;
			<a href="javascript:iwms_style('frame.htm?name=lframe');">侧边栏目样式</a>&nbsp;
			<%}%>
			<a href="javascript:iwms_style('frame.htm?name=mframe');">主栏目样式</a>&nbsp;
			<% if (selStyle.ID!=-1){%>
			<script type="text/javascript">
			function DispClasses(){
				var o = document.getElementById('lyClasses');
				if (o.style.display=='none'){
					var oCss = document.getElementById("<%=cssBody.ClientID%>");
					if (o.innerHTML!=""){
						o.innerHTML = "";
					}
					var s;
					var re = new RegExp(/\.(\w+) \.mm/ig);
					var arr = oCss.value.match(re);
					for(var i=0; i<arr.length; i++){
						var r = new RegExp(/.(\w+)/ig);
						var ar = r.exec(arr[i]);
						if (ar[1]=="lframe" || ar[1]=="mframe"){
							continue;
						}
						s = "<a href=\"javascript:DispClasses();iwms_style('frame.htm?name="+ ar[1] +"');\"><font color='white'>"+ ar[1] +"</a></a><br/>";
						o.innerHTML += s;
					}
					s = "<input type='text' size='6' id='ipt_class' style='font-size:9pt'/><input type='button' value='ok' style='font-size:9pt' onclick='DispClasses();CrtClass();'/>";
					o.innerHTML += s;
					o.style.display='';
				}else{
					o.style.display='none';
				}
			}
			function CrtClass()
			{
				var o = document.getElementById("ipt_class");
				if (o.value!=""){
					iwms_style("frame.htm?name="+ o.value);
				}
			}
			</script>
			<a href="javascript:DispClasses();" title="点击显示/隐藏">指定栏目样式</a>&nbsp;<span id="lyClasses" style="position:absolute;background:#999999;padding:5px;border:3px double #666666;line-height:150%;overflow:auto;display:none"></span>&nbsp;
			<%}%>
			<a href="#" title="设计完风格后需点击修改风格生效,同时需style目录写权限">？</a>
			</span>
		</td></tr>
		<%}%>
		<tr><td valign="top"><strong>样式表内容：</strong>
		<asp:CheckBox id="modifyCss" Text="修改样式表" runat="server"/>
		<br/>
		<iframe src="inc/admin_style.htm?<%=style.Css%>" width="200" height="200" frameborder="0" style="display:"></iframe>
		<script type="text/javascript">
		function SwitchCss(enable)
		{
			var o = document.getElementById("<%=cssBody.ClientID%>");
			if (enable){
				o.disabled = false;
			}else{
				o.disabled = true;
			}
		}
		</script>
		</td>
		<td>
			<asp:TextBox id="cssBody"
				Rows="15"
				TextMode="multiLine"
				Columns="70"
				Enabled="false"
				runat="server"
				/>
			<asp:RequiredFieldValidator
				ControlToValidate="cssBody"
				ErrorMessage="样式表内容必须填写"
				Display="None"
				runat="server"
				/>
		</td></tr>
		</table>
		
		
		<table align="center" width="95%" cellspacing="0" cellpadding="3">
		<tr><td colspan="2" class="tdbg-dark" style="cursor:pointer;<%=selStyle.ID==-1 ? "display:none;" : ""%>" onclick="DispPicCss();">
			》》<strong>图片与样式表设置</strong>　(点击展开)
			<script type="text/javascript">
				function DispPicCss()
				{
					var o = document.getElementById("con_piccss");
					if (o.style.height==""){
						o.style.height = '160px';
					}else{
						o.style.height = "";
					}
				}
			</script>
		</td></tr>
		<tr><td>
		<div id="con_piccss" style="height:160px;overflow:auto;">
		<table cellpadding="2">
		<tr>
		<td><strong>本日热门新闻</strong></td>
		<td>
			栏目名图片：<asp:TextBox id="picDayHot" 
				Columns="30"
				runat="server"
				/>
			样式表：<asp:TextBox id="cssDayHot" 
				Columns="20"
				runat="server"
				/>
			<img src="" alt="" style="display:none"/>
		</td></tr>
	
		<tr>
		<td><strong>本周热门新闻</strong></td>
		<td>
			栏目名图片：<asp:TextBox id="picWeekHot" 
				Columns="30"
				runat="server"
				/>
			样式表：<asp:TextBox id="cssWeekHot" 
				Columns="20"
				runat="server"
				/>
			<img src="" alt="" style="display:none"/>
		</td></tr>
	
		<tr>
		<td><strong>总热门新闻</strong></td>
		<td>
			栏目名图片：<asp:TextBox id="picHot" 
				Columns="30"
				runat="server"
				/>
			样式表：<asp:TextBox id="cssHot" 
				Columns="20"
				runat="server"
				/>
			<img src="" alt="" style="display:none"/>
		</td></tr>
	
		<tr>
		<td><strong>网站信息</strong></td>
		<td>
			栏目名图片：<asp:TextBox id="picSiteInfo" 
				Columns="30"
				runat="server"
				/>
			样式表：<asp:TextBox id="cssSiteInfo" 
				Columns="20"
				runat="server"
				/>
			<img src="" alt="" style="display:none"/>
		</td></tr>
	
		<tr>
		<td><strong>网站地图</strong></td>
		<td>
			栏目名图片：<asp:TextBox id="picSiteMap" 
				Columns="30"
				runat="server"
				/>
			样式表：<asp:TextBox id="cssSiteMap" 
				Columns="20"
				runat="server"
				/>
			<img src="" alt="" style="display:none"/>
		</td></tr>
	
		<tr>
		<td><strong>网站调查</strong></td>
		<td>
			栏目名图片：<asp:TextBox id="picPoll" 
				Columns="30"
				runat="server"
				/>
			样式表：<asp:TextBox id="cssPoll" 
				Columns="20"
				runat="server"
				/>
			<img src="" alt="" style="display:none"/>
		</td></tr>
	
		<tr>
		<td><strong>友情链接</strong></td>
		<td>
			栏目名图片：<asp:TextBox id="picLink" 
				Columns="30"
				runat="server"
				/>
			样式表：<asp:TextBox id="cssLink" 
				Columns="20"
				runat="server"
				/>
			<img src="" alt="" style="display:none"/>
		</td></tr>
	
		<tr>
		<td><strong>头条新闻</strong></td>
		<td>
			栏目名图片：<asp:TextBox id="picHeadline" 
				Columns="30"
				runat="server"
				/>
			样式表：<asp:TextBox id="cssHeadline" 
				Columns="20"
				runat="server"
				/>
			<img src="" alt="" style="display:none"/>
		</td></tr>
	
		<tr>
		<td><strong>图片新闻</strong></td>
		<td>
			栏目名图片：<asp:TextBox id="picImgNews" 
				Columns="30"
				runat="server"
				/>
			样式表：<asp:TextBox id="cssImgNews" 
				Columns="20"
				runat="server"
				/>
			<img src="" alt="" style="display:none"/>
		</td></tr>
	
		<tr>
		<td><strong>新闻分类导航</strong></td>
		<td>
			栏目名图片：<asp:TextBox id="picSortNav" 
				Columns="30"
				runat="server"
				/>
			样式表：<asp:TextBox id="cssSortNav" 
				Columns="20"
				runat="server"
				/>
			<img src="" alt="" style="display:none"/>
		</td></tr>
	
		<tr>
		<td><strong>热点新闻</strong></td>
		<td>
			栏目名图片：<asp:TextBox id="picHotNews" 
				Columns="30"
				runat="server"
				/>
			样式表：<asp:TextBox id="cssHotNews" 
				Columns="20"
				runat="server"
				/>
			<img src="" alt="" style="display:none"/>
		</td></tr>
	
		<tr>
		<td><strong>新闻专题</strong></td>
		<td>
			栏目名图片：<asp:TextBox id="picTopic" 
				Columns="30"
				runat="server"
				/>
			样式表：<asp:TextBox id="cssTopic" 
				Columns="20"
				runat="server"
				/>
			<img src="" alt="" style="display:none"/>
		</td></tr>
	
		<tr>
		<td><strong>左则分类导航</strong></td>
		<td>
			栏目名图片：<asp:TextBox id="picLeftNav" 
				Columns="30"
				runat="server"
				/>
			样式表：<asp:TextBox id="cssLeftNav" 
				Columns="20"
				runat="server"
				/>
			<img src="" alt="" style="display:none"/>
		</td></tr>
	
		<tr>
		<td><strong>新闻搜索</strong></td>
		<td>
			栏目名图片：<asp:TextBox id="picSearch" 
				Columns="30"
				runat="server"
				/>
			样式表：<asp:TextBox id="cssSearch" 
				Columns="20"
				runat="server"
				/>
			<img src="" alt="" style="display:none"/>
		</td></tr>
	
		<tr>
		<td><strong>会员修改资料</strong></td>
		<td>
			栏目名图片：<asp:TextBox id="picModify" 
				Columns="30"
				runat="server"
				/>
			样式表：<asp:TextBox id="cssModify" 
				Columns="20"
				runat="server"
				/>
			<img src="" alt="" style="display:none"/>
		</td></tr>
	
		<tr>
		<td><strong>会员激活</strong></td>
		<td>
			栏目名图片：<asp:TextBox id="picActive" 
				Columns="30"
				runat="server"
				/>
			样式表：<asp:TextBox id="cssActive" 
				Columns="20"
				runat="server"
				/>
			<img src="" alt="" style="display:none"/>
		</td></tr>
	
		<tr>
		<td><strong>会员注册</strong></td>
		<td>
			栏目名图片：<asp:TextBox id="picReg" 
				Columns="30"
				runat="server"
				/>
			样式表：<asp:TextBox id="cssReg" 
				Columns="20"
				runat="server"
				/>
			<img src="" alt="" style="display:none"/>
		</td></tr>
	
		<tr>
		<td><strong>找回密码</strong></td>
		<td>
			栏目名图片：<asp:TextBox id="picFindPass" 
				Columns="30"
				runat="server"
				/>
			样式表：<asp:TextBox id="cssFindPass" 
				Columns="20"
				runat="server"
				/>
			<img src="" alt="" style="display:none"/>
		</td></tr>
	
		<tr>
		<td><strong>会员资料</strong></td>
		<td>
			栏目名图片：<asp:TextBox id="picProfile" 
				Columns="30"
				runat="server"
				/>
			样式表：<asp:TextBox id="cssProfile" 
				Columns="20"
				runat="server"
				/>
			<img src="" alt="" style="display:none"/>
		</td></tr>
	
		<tr>
		<td><strong>相关新闻</strong></td>
		<td>
			栏目名图片：<asp:TextBox id="picRelate" 
				Columns="30"
				runat="server"
				/>
			样式表：<asp:TextBox id="cssRelate" 
				Columns="20"
				runat="server"
				/>
			<img src="" alt="" style="display:none"/>
		</td></tr>
	
		<tr>
		<td><strong>本文评论</strong></td>
		<td>
			栏目名图片：<asp:TextBox id="picRemarks" 
				Columns="30"
				runat="server"
				/>
			样式表：<asp:TextBox id="cssRemarks" 
				Columns="20"
				runat="server"
				/>
			<img src="" alt="" style="display:none"/>
		</td></tr>
	
		<tr>
		<td><strong>阅读新闻</strong></td>
		<td>
			栏目名图片：<asp:TextBox id="picReadNews" 
				Columns="30"
				runat="server"
				/>
			样式表：<asp:TextBox id="cssReadNews" 
				Columns="20"
				runat="server"
				/>
			<img src="" alt="" style="display:none"/>
		</td></tr>
		</table>
		</div>
		</td></tr>
		<tr><td colspan="2" align="center">
			<asp:Button id="Submit" Text="修改" onclick="Submit_Onclick" runat="server"/>&nbsp; 
			<asp:Button id="Delete" Text="删除" onclick="Delete_Onclick" runat="server"/>
			<asp:Button id="Add" Text="添加为新风格" onclick="Add_Onclick" runat="server"/>
			<asp:Button id="export" Text="导出" runat="server"/>&nbsp; 
		</td></tr>
		<asp:PlaceHolder id="ph_import" runat="server">
		<tr><td colspan="2" height="30">
			导入风格 <input type="file" id="upStyle" size="20" runat="server"/> 
			<asp:Button id="import" Text="导入" onclick="import_Onclick" runat="server"/>&nbsp; 
		</td></tr>
		</asp:PlaceHolder>
		<tr><td colspan="2">
		</td></tr>
		<tr><td colspan="2" >
			<b>导出说明</b>：请打包你的风格目录和导入的xml文件，图片与样式表中设置图片请放在你的风格目录中。<br/>
			<b>导入说明</b>：请先上传解压的风格目录到新闻style目录下然后导入解压出的xml文件
		</td></tr>
		</table>
		
			
		</form>	
	</div>
	</div>
	<div class="bl"></div>
	<div class="br"></div>
	<div class="bm"></div>
	</div>
	
	<iframe id="ifm_export" src="about:blank" height="0" width="0" style="visibility: hidden"></iframe>
	<script type="text/javascript">Preview();</script>
</asp:Content>