{include file="page_header.htm"}
{insert_scripts files="../js/utils.js,../js/DatePicker/WdatePicker.js"}

<div id="tabbody-div">
	<form enctype="multipart/form-data" name="theForm" action="information.php" method="post" onsubmit="return validate()">
	{foreach from=$information_info item=list name=information}
	<table width="100%"  border="0" cellspacing="0" cellpadding="0" class="table_form1" {if $smarty.foreach.information.index>0} style="display:none" {/if} id="language_{$list.language_id}-table">	
		
		<tr>
		<td class="label" width="110">姓名:</td>
		<td>
			<input name="name_{$list.language_id}" type="text" value="{$list.name|escape}" class="FormSmall" style="width:250px;"  />
			<span class="required">&nbsp;</span>
		</td>
		</tr>
		
		{if $smarty.foreach.information.index == 0}				
		<tr>
		<td class="label">人物图片:</td>
		<td>
		<input class="upload_image_btn" id="upload_image" name="upload_image" type="file"  />图片最佳尺寸1：1
		<div id="information_image_box" align="center" width="100%">
		{if $form_act == 'update'}
			{foreach from=$information_image item=i_image name=foo}
			<div class="gpic-box" id="information_image_box_{$smarty.foreach.foo.index}" style="float:left;margin-right:6px;">
				<div class="gpic">
					<img src="../{$i_image.thumb}" width="150" height="150" />
					<div style="margin-top:3px;">
					<input type="hidden" name="information_image[]" value="{$i_image.image}" />
					描述:<input type="text" name="information_image_desc[]" value="{$i_image.name}" style="width:100px;" />
					</div>
					<div style="margin-top:3px;">
					排序:<input type="text" name="information_image_sort[]" value="{$i_image.sort_order}" style="width:100px;" />
					</div>
					<div>
						<a href="javascript:void(0);" onclick="drop_image('information_image_box_{$smarty.foreach.foo.index}');"  title="删除">删除</a>
					</div>
				</div>
			</div>
			{/foreach}
		 {/if}
	   </div> 
		</td>
		</tr>
		{/if}
		
		{if $channel_id == 16}
		<tr>
		<td class="label" width="120">出生年月:</td>
		<td><input name="ext_field_{$list.language_id}[birth]" type="text" value="{$list.ext_field.birth}" style="width:250px;" class="FormSmall" readonly="readonly" onFocus="{literal}WdatePicker({dateFmt:'yyyy-MM-dd'}){/literal}" /> </td>
		</tr>
		
		<tr>
		<td class="label" width="110">籍贯:</td>
		<td><input name="ext_field_{$list.language_id}[place_origin]" type="text" value="{$list.ext_field.place_origin}" style="width:250px;" class="FormSmall" /> </td>
		</tr>
			
		<tr>
		<td class="label" width="110">毕业院校:</td>
		<td><input name="ext_field_{$list.language_id}[graduate_schools]" type="text" value="{$list.ext_field.graduate_schools}" style="width:250px;" class="FormSmall" /> </td>
		</tr>			
			
		<tr>
		<td class="label" width="110">主要成就:</td>
		<td><input name="ext_field_{$list.language_id}[major_achievements]" type="text" value="{$list.ext_field.major_achievements}" style="width:250px;" class="FormSmall" /> </td>
		</tr>
		
		<tr>
		<td class="label" width="110">人生格言:</td>
		<td><input name="ext_field_{$list.language_id}[life_motto]" type="text" value="{$list.ext_field.life_motto}" style="width:250px;" class="FormSmall" /> </td>
		</tr>							
		{/if}
		
		{if $channel_id == 17}
		<tr>
		<td class="label" width="110">职务:</td>
		<td><input name="ext_field_{$list.language_id}[position]" type="text" value="{$list.ext_field.position}" style="width:250px;" class="FormSmall" /> </td>
		</tr>	
		{/if}
		
		<tr>
		<td class="label">{if $channel_id == 16}个人经历:{elseif $channel_id == 17}简要介绍:{/if}</td>
		<td>{$list.description}</td>
		</tr>
		
		<tr style="display:none;">
		<td class="label" width="110">所属栏目:</td>
		<td>
			<input type="hidden" name="channel_id_{$list.language_id}" value="{$channel_id}" />
		</td>
		</tr>			
		
		{if $smarty.foreach.information.index == 0} 
		<tr>
		<td class="label">选项:</td>
		<td>

		<label><input type="checkbox" name="is_featured" value="1" {if $information.is_featured}checked="checked"{/if} /> 推荐 </label>
		<label><input type="checkbox" name="status" value="1" {if $information.status} checked="checked" {/if} {if $form_act =='insert'} checked="checked" {/if} /> 显示</label>

		</td> 		
		</tr>	
		
		<tr>
		<td class="label">排序:</td>
		<td><input name="sort_order" type="text" value="{$information.sort_order}" class="FormSmall" style="width:100px;" /></td>
		</tr>		
		{/if}		
			
		<tr>
		<td class="label">模版:</td>
		<td colspan="3">
		<select name="template_{$list.language_id}" class="select_input">
		<option value="">默认</option>
		{foreach from=$template item=t}
		<option value="{$t}" {if $list.template == $t}selected{/if}>{$t}</option>
		{/foreach}
		</select>
		</td>
		</tr>			
	
		
	</table>
	{/foreach}
	
	<table width="100%" border="0" cellspacing="0" cellpadding="0" class="table_form">
		<tr>
			<td style="border:none;" class="label">&nbsp;</td>
			<td style="border:none;">
			
				<input type="hidden" name="channel_id" value="{$channel_id}" />
				<input type="hidden" name="information_id" value="{$information.information_id}" />
				<input type="hidden" name="act" value="{$form_act}" />
					<input name="submit" type="submit" value=" 确定 " class="bginput" />
				<input name="reset" type="reset" value=" 重置 " class="bginput" />
			</td>
		</tr>
	</table>
	</form>
</div>

<script language="JavaScript">
var informationId = '{$information.information_id}';
{literal}
$(document).ready(function(){
	$('.channel_select').change(function(){
		var sel_id = $(this).val();
		$('.channel_select').val(sel_id);
	})
}) 

function validate(){
	var validator = new Validator('theForm');
	validator.required('name_{/literal}{$language[0].language_id}{literal}', '姓名不能为空.');
	return validator.passed();
}

$('.upload_image_btn').uploadify({
	'formData'     : {
		'rand_str' 	: '{/literal}{$rand_str}{literal}',
		'hash'     	: '{/literal}{$hash}{literal}',
		'session_id' : '{/literal}{$session_id}{literal}',
		'thumb_width'  : '150',
		'thumb_height' : '150',
		'img_type'  : 'image'
	},	
	'multi':false,
	'width':'107',
	'height':'25',
	'buttonText':'',
	'buttonImage':'images/add_image.png',
	'swf':'images/uploadify.swf',
	'uploader' : 'uploadify.php',
	'fileTypeDesc' : 'Image Files',
	'fileSizeLimit' : '2048KB',
	'fileTypeExts' : '*.gif; *.jpg; *.png',
	'onUploadStart' : function(file) {
		//$("#loading").fadeIn("fast");
	},
	'onUploadSuccess' : function(file, data, response) {
		result = $.parseJSON(data);
		if(result.error == 1){
			alert(result.message);
		}else{
			html ='<div class="gpic-box" id="'+result.id+'" style="float:left;margin-right:6px;">';
			html =html+'	<div class="gpic">';
			html =html+'		<div><img src="../'+result.image+'" width="150" height="150" /></div>';
			html =html+'		<div style="margin-top:3px;">';
			html =html+'		<input type="hidden" name="information_image[]" value="'+result.image+'" />';
			html =html+'		描述:<input type="text" name="information_image_desc[]" value="'+result.name+'" style="width:70px;" /><br />';
			html =html+'		</div>';
			html =html+'		<div style="margin-top:3px;">';
			html =html+'		排序:<input type="text" name="information_image_sort[]" value="" style="width:70px;" />';
			html =html+'		</div>';
			html =html+'		<div>';
			html =html+'			<a href="javascript:void(0);" onclick="drop_image(\''+result.id+'\');"  title="删除">删除</a>';
			html =html+'		</div>';
			html =html+'	</div>';
			html =html+'</div>';
			$('#information_image_box').append(html);
		}
	 }
});

function drop_image(id){
	$('#'+id).remove();
}


function checkUrlAlias(url,language_id){
	if(url == ''){
		return ;
	}
	$.ajax({
			url:"information.php",
			type:"GET",
			dataType:"json",
			data:{"act":"check_url_alias","id":{/literal}{$information.information_id}{literal},"url":url,"language_id":language_id,"is_ajax":1},
			beforeSend:function(){
				$("#loading").fadeIn("fast");
			},
			complete:function(){
				$("#loading").stop();
				$("#loading").fadeOut("fast");
			},
			success:function(result){
			  if (result.error == 0){
					if(result.content == true){
						$("#url_alias_"+language_id+"_box").show();
						$("#url_alias_"+language_id+"_box").html('这个URL已经存在,请更换其它的URL');
					}else{
						$("#url_alias_"+language_id+"_box").hide();
					}
				  
			  }
			}
	});
}
{/literal}
</script>
{insert_scripts files="tab.js,validator.js"}
{include file="page_footer.htm"}