<div class="content link_lan spread_dialog">
	<table width="480">
		<tbody>
			<tr height="50">
				<td width="90">推广职位：</td>
				<td>{#$jobs_name#}</td>
			</tr>
			<tr height="30">
				<td>推广方案：</td>
				<td width="120">
					{#$promotion_name#}
				</td>
				<td>(每天消耗{#$points_perday#}{#$points_quantifier#}{#$points_byname#})</td>
			</tr>
			<tr>
				<td height="50">推广期限：</td>
				<td><input name="days" type="text" class="input_text_200" id="days" maxlength="4" value=""/></td>
				<td> 天</td>
			</tr>
		    {#$color_list#}
		              		
		</tbody>
	</table>
	<table width="480">
		<tbody>
			<tr>
				<td width="90"></td>
				<td>
					<span style="color:#0066CC" id="count"></span>
				</td>
			</tr>
		</tbody>
	</table>
	<p>推广天数最少：{#$cat_minday#}天<br />推广期每天消耗{#$points_byname#}：{#$points_perday#}{#$points_quantifier#}{#$points_byname#}<br />推广天数最多：{#$cat_maxday#}天</p>
</div>
<div class="spread_but_box">
	<input type="hidden" id="jobid" value="{#$jobid#}">
	<input type="hidden" id="catid" value="{#$catid#}">
	<input type="button" value="确定" class="but95cheng" id="add"/>
	<input type="button" value="取消" class="but95hui" onclick="jacascript:location.reload();"/>
</div>
<script src="{#$site_template#}js/jquery.dialog.js" type='text/javascript' language="javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
	//计算总积分
		$("#days").keyup(function(){	
			var days_points={#$points_perday#};
			var user_points={#$user_points#};
			if((/^(\+|-)?\d+$/.test($(this).val())) && $(this).val()>={#$cat_minday#} && $(this).val()>0 && days_points>0)
			{
			$("#count").html("<br />您推广天数为<strong style=\"color:#009900\">&nbsp;&nbsp;"+$(this).val()+"&nbsp;&nbsp;</strong>天，需要扣除：&nbsp;&nbsp;<strong style=\"color: #009900;\">"+$(this).val()*days_points+"</strong>&nbsp;&nbsp;{#$points_quantifier#}{#$points_byname#}，您目前共有&nbsp;&nbsp;<strong style=\"color: #FF6600;\">"+user_points+"</strong>&nbsp;&nbsp;{#$points_quantifier#}{#$points_byname#}。<br /><br />");   
			}
			else if($(this).val()<{#$cat_minday#}){
				$("#count").html("推广天数不能小于<strong style=\"color: #FF6600;\">{#$cat_minday#}</strong>天");
			}
			else
			{
			$("#count").html("");	
			}
		});
		$("#add").click(function(){
			var jobid = $("#jobid").val();
			var catid = $("#catid").val();
			var days = $("#days").val();
			var val = $("#val").val();
			if(days<{#$cat_minday#}){
				alert_dialog("fail:推广天数不能小于{#$cat_minday#}天","250px","","","");
				return false;
			}
			if(catid==4 && !val){
				alert_dialog("fail:请选择推广颜色","","","","");
				return false;
			}
			$.post("company_ajax.php?act=promotion_add_save",{jobid:jobid,catid:catid,days:days,val:val},function(result){
				if(result=="1"){
					alert_dialog("success:推广成功！","","","","");
					location.reload();
				}else if(result=="-1"){
					alert_dialog("fail:参数错误！","","","","");
					return false;
				}else{
					alert_dialog("fail:"+result,"250px","","","");
					return false;
				}
			});
		});
			menuDown("#val_menu","#val","","#menu1","88px");
			function menuDown(menuId,input,input_cn,menuList,width){
				$(menuId).click(function(){
					$(menuList).css("width",width);
					$(menuList).slideDown('fast');
					//生成背景
					$(menuId).parent("div").before("<div class=\"menu_bg_layer\"></div>");
					$(".menu_bg_layer").height($(".FloatBox").height());
					$(".menu_bg_layer").css({ width: $(".FloatBox").width(), position: "absolute", left: "0", top: "0" , "z-index": "0", "background-color": "#ffffff"});
					$(".menu_bg_layer").css("opacity","0");
					$(".menu_bg_layer").click(function(){
						$(".menu_bg_layer").remove();
						$(menuList).slideUp("fast");
						$(menuId).parent("div").css("position","");
					});
				});

				$(menuList+" li").click(function(){
					var id = $(this).attr("id");
					var title = $(this).attr("title");
					$(input).val(id);
					$(input_cn).val(title);
					$(menuId).html("&nbsp");
					$(menuId).css("background-color",title);
					$(menuList).slideUp('fast');
					$(".menu_bg_layer").remove();
				});
			}
		
});
</script>

