<!--#include file="../inc/config.asp"-->
<!--#include file="../inc/conn.asp"-->
<!--#include file="inc/function.asp"-->
<!-- #include file="inc/Session.asp" -->
<!-- #include file="inc/checkrole.asp" -->
<%
'''''''''''''''''''''''''''''''''''''''''''''''
call checkPrevilege(Session("Name"),"p21")
'''''''''''''''''''''''''''''''''''''''''''''''
%>
<!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=gb2312" />
<title>发布分类信息</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style1 {color: #FF0000}
.width100{width:100%;}

-->
</style>
<script type="text/javascript" src="../js/prototype.js"></script>
<script type="text/javascript" src="../js/effects.js"></script>
<script type="text/javascript" src="../js/validation.js"></script>
<script type="text/javascript" src="/js/areas.js"></script>
<script type="text/javascript" src="/member/js/date.js"></script>
<script type="text/javascript">
function selectcity(provinceid,cityid){	
var citySelect=document.PostForm.City;
citySelect.options.length = 0;		
new Ajax.Request('/member/get_citys.asp?pid='+provinceid,
  {
    method:'get',
    onSuccess: function(transport){
			var response = transport.responseXML.documentElement;
			var classidList = response.getElementsByTagName('city');	
			
			for(var i=0;i<classidList.length;i++){
				xx=classidList[i].getElementsByTagName('id');
				yy=classidList[i].getElementsByTagName('title');
				classid=xx[0].firstChild.data
				classtitle=yy[0].firstChild.data				
				citySelect.options[i]=new Option(classtitle,classtitle);							
				if(cityid==classtitle){
					citySelect.options[i].selected=true;
				}
			}
		},
    onFailure: function(){ alert('Something went wrong...') }
  });
}
////////////////////////	
function getCatalogs(pid,cid){
new Ajax.Request('/member/getchilds.asp?classid='+pid,
  {
    method:'get',
    onSuccess: function(transport){
      var response = transport.responseXML.documentElement;
			var classidList = response.getElementsByTagName('catalog');	
			var childs=$('CatalogId');
			childs.length=0;
			for(var i=0;i<classidList.length;i++){
				xx=classidList[i].getElementsByTagName('id');
				yy=classidList[i].getElementsByTagName('title');
				classid=xx[0].firstChild.data
				classtitle=yy[0].firstChild.data				
				childs.options[i]=new Option(classtitle,classid);							
				if(cid==classid){
					childs.options[i].selected=true;
				}
			}
    },
    onFailure: function(){ alert('Something went wrong...') }
  });
}
</script>
<LINK media=screen href="js/dhtmlgoodies_calendar.css" rel=stylesheet></LINK>
<SCRIPT src="js/dhtmlgoodies_calendar.js" type=text/javascript></SCRIPT>
</head>

<body>
<table width="100%"  border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><iframe src="right_top.htm" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" height="30" width="100%"></iframe></td>
  </tr>
</table>
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td valign="top">
	<%
dim act
act=request.querystring("act")
if(act="do") then
	call mod_personalinfook()
	call ActionRecord(UserName,"添加信息",1,"添加分类信息")
	response.write("<p align=""center"">成功发布信息</p>")
	response.write("<p align=""center""><a href=""javascript:history.back();"">继续发布</a></p>")
else
	call mod_personalinfo()
end if
%>    </td>
  </tr>
</table>
<%
sub mod_personalinfook
	dim rs,InfoTypeId,ParentId,CatalogId,DelPass,Title,ExpireDate,ItemsNum,Price,Province,City,ContactMan,Tel,Mobile,QQ,Content,Photo,SavePath,Demons,HomePage,Address,Area,Score,ScoreEndDate
	SavePath="/html/"&chan_data(now())&chan_day(now())&"/"&chan_file(now())&"."&FileExt
	InfoTypeId=Cint(request.Form("InfoTypeId"))
	ParentId=Cint(request.form("ParentId"))
	if(isnumeric(request.Form("CatalogId"))) then
		CatalogId=Cint(request.Form("CatalogId"))
	else
		CatalogId=0
	end if
	DelPass=request.Form("DelPass")
	Title=tohtml(request.Form("Title"))
	ExpireDate=Cint(request.Form("ExpireDate"))
	Price=Csng(request.form("Price"))
	Province=request.Form("Province")
	if(Province<>"") then
		Province=Cint(Province)
	else
		Province=0
	end if
	City=request.Form("City")
	if(City<>"") then
		City=Cint(City)
	else
		City=0
	end if
	if(Province>0) then
		set rs=server.CreateObject("adodb.recordset")
		rs.open "select title from t_area where id="&Province,conn,3,1
		if not rs.eof then
			Area=rs(0)
		end if
		rs.close
		set rs=nothing
	end if
	if(City>0) then
		set rs=server.CreateObject("adodb.recordset")
		rs.open "select title from t_area where id="&City,conn,3,1
		if not rs.eof then
			Area=Area&rs(0)
		end if
		rs.close
		set rs=nothing
	end if
		ContactMan=tohtml(request.Form("ContactMan"))
		Tel=tohtml(request.Form("Tel"))
		QQ=tohtml(request.Form("QQ"))
		Content=request.Form("Content")
		Demons=gotTopic(Content,200)
		Content=tohtml(Content)
		HomePage=tohtml(request.Form("HomePage"))
		Photo=request.Form("Photo")
		Address=tohtml(request.Form("Address"))
		Score=Cint(request.Form("Score"))
		ScoreEndDate=Cdate(request.Form("ScoreEndDate"))
		set rs=server.CreateObject("adodb.recordset")
		rs.open "select * from t_info where 1=0",conn,3,3
		rs.addnew
		rs("UserId")=""
		rs("InfoTypeId")=InfoTypeId
		rs("ParentId")=ParentId
		rs("CatalogId")=CatalogId	
		rs("Photo")=Photo
		rs("Title")=Title
		rs("Price")=Price
		rs("Province")=Province
		rs("City")=City
		rs("ContactMan")=ContactMan
		rs("QQ")=QQ
		rs("Tel")=Tel	
		rs("Content")=Content
		rs("Demons")=Demons
		rs("PubDate")=now()
		rs("ExpireDate")=dateadd("d",ExpireDate,now())
		rs("PubIp")=request.ServerVariables("REMOTE_ADDR")
		rs("Hits")=1
		rs("IsCheck")=1
		rs("IsDel")=0
		rs("IsHot")=0
		rs("IsTop")=0
		rs("DelPass")=DelPass
		rs("SavePath")=SavePath
		rs("HomePage")=HomePage
		rs("Address")=Address
		rs("Area")=Area
		rs("Score")=Score
		rs("ScoreEndDate")=ScoreEndDate
		rs.update
		rs.close
		set rs=nothing
	
end sub
sub mod_personalinfo
	dim rs,userinfo,sql,first
	set rs=server.CreateObject("adodb.recordset")
	sql="select id,title from catalogs where parentid="&PlugIn_InfoId&" order by title asc"
	rs.open sql,conn,3,1
	if not rs.eof and not rs.bof then
		first=rs.GetRows()
	else
		
	end if
	rs.close
	set rs=nothing
%>
<form id="PostForm" name="PostForm" method="post" action="?act=do">
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="1" class="border">
  <tr>
    <td height="28" colspan="2" class="th_title">发布分类信息</td>
  </tr>
  <tr>
    <td class="td_row">服务类型：</td>
    <td class="td_row">
	<select name="InfoTypeId" id="InfoTypeId">
		<option value="1" selected="selected">[供]</option>
		<option value="2">[求]</option>
    </select>    </td>
  </tr>
  <tr>
    <td class="td_row">信息分类：</td>
    <td class="td_row">
		<select name="ParentId" id="ParentId" size="10" onchange="getCatalogs(this.options[this.selectedIndex].value,0)">
		<%
		if isarray(first) then
		 	for i=0 to ubound(first,2)
				if(first(0,i)=12) then
					sel=" selected=""selected"""
				else
					sel=""
				end if
				response.Write("<option value="""&first(0,i)&""""&sel&">"&first(1,i)&"</option>"&Chr(10))
  		next
		end if
		%>
    </select>		
		<select name="CatalogId" id="CatalogId" size="10">
			<option>请选择二级分类</option>
		</select>
		<script type="text/javascript">
		getCatalogs(12,13);	
		</script>    
		提示:左边大类根据拼音排序</td>
  </tr>
  <tr>
    <td class="td_row">标题：(<span class="style1">*</span>)</td>
    <td class="td_row"><input name="Title" type="text" id="Title" size="25" class="validate-title" title="请输入信息标题" /><span id="advice-validate-title-Title" style="display:none; color:#FF0000;">标题5-30个字符</span></td>
  </tr>
  <tr>
    <td width="18%" class="td_row">价格：(<span class="style1">*</span>)</td>
    <td width="82%" class="td_row"><input name="Price" type="text" id="Price" class="validate-number" value="0" size="8" />
    <span id="advice-validate-number-Price" style="display:none; color:#FF0000;">请输入数字</span>0=面议</td>
  </tr>
  <tr>
    <td class="td_row">区市：</td>
    <td class="td_row">
			<select name="Province" id="Province" onchange="GetChilds(this.options[this.selectedIndex].value,0,'City')">
        <option value="0">选择城市</option>
        <script type="text/javascript">
				document.write(GetFirst(3,''));
        </script>
      </select>
      <select name="City" id="City">
        <option value="0">选择地区</option>
      </select>	
      <script type="text/javascript">
				GetChilds(3,0,'City');
      </script>
    </td>
  </tr>
  <tr>
    <td class="td_row">联系人：(<span class="style1">*</span>)</td>
    <td class="td_row"><input name="ContactMan" type="text" id="ContactMan" class="required" /><span id="advice-required-ContactMan" style="display:none; color:#FF0000;">联系人不能为空!</span></td>
  </tr>
  <tr>
    <td class="td_row">电话：(<span class="style1">*</span>)</td>
    <td class="td_row"><input name="Tel" type="text" class="required" /><span id="advice-required-Tel" style="display:none; color:#FF0000;">电话不能为空!</span></td>
  </tr>
  <tr>
    <td class="td_row">QQ：</td>
    <td class="td_row"><input name="QQ" type="text" /></td>
  </tr>
  <tr>
    <td class="td_row">地址：</td>
    <td class="td_row"><input name="Address" type="text" id="Address" size="32" /></td>
  </tr>
  <tr>
    <td class="td_row">网址：</td>
    <td class="td_row"><input name="HomePage" type="text" id="HomePage" value="http://" size="35" /></td>
  </tr>
  <tr>
    <td class="td_row">详细说明：</td>
    <td class="td_row"><textarea name="Content" cols="60" rows="5" id="Content" class="validate-content"></textarea><span id="advice-validate-content-Content" style="display:none; color:#FF0000;">详细说明10-2000字!</span></td>
  </tr>
  <tr>
    <td class="td_row">上传物品图片：</td>
    <td class="td_row"><input name="Photo" type="hidden" id="Photo" size="30" value="/images/nopic.gif" />
      <img src="../images/nopic.jpg" alt="上传图片" width="160" height="130" id="p_view" />
      <input type="button" name="Button" value="上传-&gt;" onclick="upImgs()" />
      提示：系统最大允许上传100K的文件，请确定您的图片处理后小于100K。</td>
  </tr>
  <tr>
    <td class="td_row">信息有效期：</td>
    <td class="td_row"><select name="ExpireDate" id="ExpireDate">
      <option value="7">7天</option>
      <option value="15">15天</option>
      <option value="30">30天</option>
      <option value="90">90天</option>
      <option value="180">180天</option>
      <option value="360">360天</option>
    </select>    </td>
  </tr>
  <tr>
    <td class="td_row">竞价：</td>
    <td class="td_row"><INPUT name="Score" id="Score" onBlur="if(this.value==''){this.value=0}" onClick="if(this.value=='0'){this.value=''}" onKeyUp="this.value=this.value.replace(/\D/g,'');if(this.value!='' && this.value.charAt(0)=='0'){this.value=''}" value="100" size="15" maxlength="50" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/\D/g,''))">
      积分</td>
  </tr>
  <tr>
    <td class="td_row">竞价有效期至：</td>
    <td class="td_row"><input name="ScoreEndDate" type="text" id="ScoreEndDate" onclick="setday(this)" value="<%=date%>" readonly />
      （注:信息过期，竞价费用自动清0）</td>
  </tr>
  <tr>
    <td class="td_row">&nbsp;</td>
    <td class="td_row">
    	<input name="DelPass" type="hidden" id="DelPass" class="validate-password" value="******" title="信息删除密码" />
    	<input type="submit" name="Submit" value="确 定" />
      <input type="reset" name="Submit2" value="取 消" /></td>
  </tr>
</table>
</form>
<script language="javascript">
function upImgs(){
	var ret=window.showModalDialog('upimg.htm','','dialogHeight:140px;dialogWidth:410px;help:no;status:no;scroll:no')+'';
	
	if(ret!='undefined'){
		document.PostForm.Photo.value='/pic/'+ret
		document.getElementById('p_view').src='/pic/'+ret;
	}
}
function formCallback(result, form) {
	window.status = "valiation callback for form '" + form.id + "': result = " + result;
}

var valid = new Validation('PostForm', {immediate : true, onFormValidate : formCallback,useTitles : true});
Validation.addAllThese([
	['validate-password', '信息删除密码6个字符以上(不含password,1234566这样的密码)', {
		minLength : 2,
		notOneOf : ['password','PASSWORD','123456','012345']
	}],
	['validate-content','',{
		minLength:6,
		maxLength : 2000
	}],
	['validate-title','',{
		minLength:5,
		maxLength:30
	}]
]);
</script>
<%
end sub
%>
</body>
</html>
<%
call connclose()
%>