<%@ Page Language="C#" AutoEventWireup="false" debug="true" Inherits="WinLibClass.Form.Admin.Adv.UI_Update"  CodePage="65001" %>

<%
InitData();
%>

<script type="text/javascript"> 

$(document).ready(function(){


	$.formValidator.initConfig({
		formid:"form_add",
		validatorgroup:"4",
		autotip:true
	});


	$("#strTitle").formValidator({
		validatorgroup:"4",
		empty:false,
		tipid:'notetip',
		onshow:"请输入广告标题",
		onfocus:"广告标题不能为空"
	}).inputValidator({
		min:1,
		empty:{leftempty:false,rightempty:false,emptyerror:"两边不能有空格"},
		onerror:"请输入广告标题"
	});


	$("#strHref").formValidator({
		validatorgroup:"4",
		empty:false,
		tipid:'notetip',
		onshow:"请填写",
		onfocus:"网址为空"
		
	}).inputValidator({
		min:0,
		empty:{leftempty:false,rightempty:false,emptyerror:"两边不能有空格"},
		onerror:"请填写网址"
	});


	$("#strExplain").formValidator({
		validatorgroup:"4",
		empty:true,
		tipid:'notetip',
		onshow:"广告描述限100字(50个汉字)以内",
		onfocus:"广告描述限100字(50个汉字)以内"		
	}).inputValidator({
		min:0,
		max:100,
		empty:{leftempty:false,rightempty:false,emptyerror:"两边不能有空格"},
		onerror:"广告描述限100字(50个汉字)以内"
	});


	$("#BtnSubmit").click(function(){

		var pass= true;//$.formValidator.pageIsValid('4');

		if(pass){
			//var queryString = $('#form_add').formSerialize();
			var queryString = $('#form_add').serialize();
		//	alert(queryString);
			$.post(APP+"/Admin/Adv_Update", queryString,function(msg){

				if(msg=='0'){ //先保留msg这个值以备以后使用
					showtips('<%=(Id>0)?"修改":"添加" %>商品信息成功!','tips',1);
					removeDialogbox("#Div_AdminEdit");
					var urlParam = "&AdvType=<%=AdvType%>";
					SimpleAjax(APP+"/Admin/Adv_List"+client_GetPageNoToUrlParam()+urlParam,"");//刷新
	
					
				}else{
					msg = "<%=(Id>0)?"修改":"添加" %>广告信息失败,请检查各项输入是否正确或网络连接状态.代码("+ msg +")";
					showtips(msg,'tips',2);
				}
			});
		}
	});

	//上传图片控件
	$("#ChoosePic").click(function(){
		OpenDlg('PhotoPath');
	});

});

function GetOptionText()
{
	//$('#BrandName').val($('#BrandId').text())
	var o = $('#BrandId')[0];
	if(o!=null)
	{
		var i = o.selectedIndex;
		$('#BrandName').val(o.options[i].text);
	}
}

</script> 

<div class="userAddress clearfix">

	<form id="form_add">
	<table border="0" style="float:left">
	<Tr >
	<td >&nbsp;&nbsp; </td>
	</tr>
	<tr>
	
	<td class="inputWrap fl" colspan="2">
		<input id="AdvType" name="AdvType" type="hidden" class="input"   value="<%=AdvType%>" />
		<label for="AdvSubType">广告位:</label>
		<select id="AdvSubType" name="AdvSubType" style="width:160px;float:left" >
		<%=GetOptionText()%>
		</select>		
		
	</td>
	</tr>	
	<tr>
	<td class="inputWrap fl">
		<label for="strTitle">标题:</label>
		
		<input id="Id" name="Id" type="hidden" class="input"   value="<%=Id%>" />
		<input id="strTitle" name="strTitle" type="text" class="input" style="width:220px;float:left"  value="<%=strTitle%>" />
	</td>
	</tr>
	<tr>
	<td class="inputWrap fl">
		<input id="strPhotoPath" name="strPhotoPath" type="hidden" class="input"   value="<%=strPhotoPath%>" />
		<label for="strHref">链接:(400个英文字符,例:http://www.baidu.com/)</label>
		<input id="strHref" name="strHref" type="text" class="input" style="width:460px;float:left" value="<%=strHref%>" maxlength="180" />
	</td>
	</tr>
	<tr>
	<td class="inputWrap fl">
		<input id="OrderId" name="OrderId" type="hidden" class="input"   value="<%=OrderId%>" />
		<label for="IsChecked">状态:</label>
		<select id="IsChecked" name="IsChecked" style="width:60px;float:left" >
		<option value="0" style="color:red" <%=((IsChecked==0)?"selected":"")%> >停用</option>
		<option value="1" <%=((IsChecked==1)?"selected":"")%> >启用</option>
		</select>	
		</td>
	</tr>		
	

	<tr>
	<td class="inputWrap fl">
		<label for="strExplain">描述:(100个英文字符,无换行)</label>
		<input id="strExplain" name="strExplain" class="input" style="width:460px;float:left" maxlength="100" value="<%=strExplain%>" />
	</td>
	</tr>	
	<tr>
	<td class="inputWrap fl">
	<div class="cb">
		<button type="button" class="button" class="f12" id='BtnSubmit'>确认<%=(Id>0)?"修改":"添加" %></button>
		<span id="notetip"></span>
		<span id="tips"></span> 
		</div>
	</td>
	</tr>
	</table>
</form>
	
</div>
