<%@ page contentType="text/html;charset=UTF-8" errorPage="../error.jsp"%>
<%@ page import="java.util.ArrayList"%>
<%@ page import="java.util.Properties"%>
<%@ page import="com.hongshee.ejforum.util.PageUtils"%>
<%@ page import="com.hongshee.ejforum.data.UserDAO.UserInfo"%>
<%@ page import="com.hongshee.ejforum.data.OptionVO"%>
<%@ page import="com.hongshee.ejforum.common.ForumSetting"%>
<%@ page import="com.hongshee.ejforum.common.IConstants"%>
<%
	UserInfo userinfo = PageUtils.getAdminUser(request, response);
	if (userinfo == null) return;
	String styleID = PageUtils.getParam(request,"style");
	ForumSetting setting = ForumSetting.getInstance();

	OptionVO[] styles = setting.getStyles();
	if (styleID == null || styleID.length() == 0)
		styleID = "default";
		
	String styleName = null;
    for (int i=0; i<styles.length; i++)
    {
		if (styleID.equals(styles[i].name.substring(2)))
		{
			styleName = styles[i].value;
			break;
		}
	}
	String[] keys = {"PageWidth","WinBg","PageBg","PageCoBg","MenuBg","PopmenuBg",
					 "TableOutHeaderBg","TableInHeaderBg","InfoBoxBg","InputBgColor",
					 "NormalFontColor","MenuFontColor","HeaderFontColor","InfoFontColor",
					 "LinkFontColor","LightLinkColor","NoticeFontColor","MemoFontColor",
					 "TableBorderColor","BoxBorderColor","DashBorderColor"};
	String[] names = {"最大页面宽度","页面侧边背景","页面背景颜色","页面背景配色","主菜单背景","下拉菜单背景",
					  "版块表头背景","内表头背景","信息框背景","输入框背景颜色",
					  "正常文字颜色","菜单文字颜色","表头文字颜色","说明信息文字颜色",
					  "正常超链接文字颜色","加亮超链接文字颜色","提示信息文字颜色","脚注文字颜色",
					  "版块表格边线颜色","单元格边线颜色","信息框虚边线颜色"};
	Properties props = setting.getStyleValues(styleID, keys);
%>
<!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>
<META http-equiv=Content-Type content="text/html; charset=UTF-8">
<LINK href="../style/admin.css" type=text/css rel=stylesheet>
<SCRIPT src="../../js/common.js" type=text/javascript></SCRIPT>
<SCRIPT src="../js/admin.js" type=text/javascript></SCRIPT>
<script type="text/JavaScript">
var imagePath = "../../styles/<%= styleID %>/";
function doPreview(obj) {
	var code = $(obj + '_v').value.toLowerCase();
	var p = code.indexOf('url(');
	if(p >= 0) {
		var tmpStr = code.substr(0, p);
		code = trim(code.substr(p+4));
		if (code.indexOf("http://")==0 || code.indexOf("https://")==0 || code.indexOf("/")==0)
			code = "url(" + code;
		else
			code = "url(" + imagePath + code;
		code = tmpStr + code;
	}
	$(obj).style.background = code;
}
</script>
</HEAD>
<BODY topMargin=10>
<TABLE cellSpacing=6 cellPadding=2 width="100%" border=0>
  <TBODY>
  <TR>
    <TD>
      <TABLE class=guide cellSpacing=0 cellPadding=0 width="100%" border=0>
        <TBODY>
        <TR>
          <TD><A onclick="parent.location='../index.htm';return false;" 
            href="#">后台管理首页</A>&nbsp;&raquo;&nbsp;编辑界面风格</TD></TR></TBODY></TABLE><BR>
      <TABLE class=info_tb cellSpacing=0 cellPadding=0 width="100%" border=0>
        <TBODY>
        <TR class=header>
          <TD>
            <DIV style="FLOAT: left; MARGIN-LEFT: 0px; PADDING-TOP: 8px"><A 
            onclick="collapse_change('tip','../images')" href="#">技巧提示</A></DIV>
            <DIV style="FLOAT: right; PADDING-BOTTOM: 9px; MARGIN-RIGHT: 4px"><A 
            onclick="collapse_change('tip','../images')" href="#">
			<IMG id=menuimg_tip src="../images/menu_reduce.gif" border=0></A></DIV></TD></TR>
        <TBODY id=menu_tip>
        <TR>
          <TD>
            <UL>
              <LI><%= PageUtils.getString("style_info_1") %></LI>
              <LI><%= PageUtils.getString("style_info_2") %></LI>
              <LI><%= PageUtils.getString("style_info_3") %></LI>
            </UL></TD></TR></TBODY></TABLE><BR>
      <FORM id="settings" name="settings" onSubmit="checkfields(this); return false;" action="../perform.jsp" method=post>
	  <INPUT type=hidden name="act" value="basic_style_info">
	  <INPUT type=hidden name="styleID" value="<%= styleID %>">
      <A name=tb01></A>
      <TABLE class=info_tb cellSpacing=0 cellPadding=0 width="100%" border=0>
        <TBODY>
        <TR class=header>
          <TD colSpan=2>编辑界面风格&nbsp;-&nbsp;<%= styleName %><A onClick="collapse_change('tb01','../images')" href="#">
  		    <IMG id=menuimg_tb01 style="MARGIN-TOP: -12px; FLOAT: right; MARGIN-RIGHT: 4px" 
             src="../images/menu_reduce.gif" border=0></A></TD></TR>
        <TBODY id=menu_tb01>
<%
	String aValue = null;
	String tmpStr = null;
	String imagePath = "../../styles/" + styleID + "/";
	int p = -1;
%>
        <TR>
          <TD class=altbg1 width="35%"><B><%= names[0] %>:</B><br/><span 
  	class="smalltxt">设定最大页面宽度（以像素px为单位），"0px"表示不限制页面宽度</span>
		  </TD>
          <TD class=altbg2 nowrap><INPUT size=50 name="PageWidth" id="w_page_v" 
		   	value='<%= props.getProperty(keys[0])==null?"0px":props.getProperty(keys[0]) %>'>
		  </TD></TR>
<%	
	for (int i=1; i<keys.length; i++) {
		aValue = props.getProperty(keys[i]).toLowerCase();
		p = aValue.indexOf("url(");
		if (p >= 0)
		{
			tmpStr = aValue.substring(0, p);
			aValue = aValue.substring(p+4);
			if (!aValue.startsWith("http://") && !aValue.startsWith("https://") && !aValue.startsWith("/"))
				aValue = "url(" + imagePath + aValue;
			else
				aValue = "url(" + aValue;
			aValue = tmpStr	+ aValue;
		}
%>		
        <TR>
          <TD class=altbg1 width="35%"><B><%= names[i] %>:</B><br/><span 
  	class="smalltxt"><%= PageUtils.getString("style_info_4") %><% if (i==1||i==4||i==5||i==6||i==7||i==8) out.write("或图片链接"); 
				if (i==1) out.write("，当屏幕宽度大于最大页面宽度时，页面侧边才会显示出来"); %></span>
		  </TD>
          <TD class=altbg2 nowrap><INPUT size=50 name="<%= keys[i] %>" id="c<%= i %>_v" 
		   	value='<%= props.getProperty(keys[i]) %>' onchange="doPreview('c<%= i %>')">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		    <input id="c<%= i %>" onclick="c<%= i %>_frame.location='showcolor.htm?c<%= i %>';showMenu('c<%= i %>')" 
		    class="colorpad" style='background: <%= aValue %>' type="button">
			<span id="c<%= i %>_menu" style="display: none">
			<iframe name="c<%= i %>_frame" scrolling="no" width="166" frameborder="0" height="166"></iframe></span>
		  </TD></TR>
<%
	}
%>		  
	  </TBODY></TABLE><BR>
      <CENTER><INPUT class=button type=submit value="提 交"></CENTER></FORM>
	  </TD></TR></TBODY></TABLE><BR><BR>
<script language="javascript">
function checkfields(theform) {
	theform.submit();
}
</script>	  
<%= PageUtils.getAdminFooter(request) %>
</BODY></HTML>