{include file="page_header.htm"}
{insert_scripts files="../js/utils.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:350px;"  />
			<span class="required">&nbsp;</span>
		</td>
		</tr>
		
		<tr style="display:none;">
		<td class="label" width="110">所属栏目:</td>
		<td>
			<select name="channel_id_{$list.language_id}" class="channel_select" id="channel_id_{$list.language_id}" style="padding-top:3px; padding-bottom:3px;">
				{foreach from=$list.channel_tree item=val}
				{if $val.channel_id|in_array:$sub_channel && ($val.show_type == $channel_type.channel_type_list || $val.show_type == $channel_type.channel_type_image)}
				<option value="{$val.channel_id}"{if $val.channel_id == $information.channel_id} selected{/if}>{'--'|str_repeat:$val.level}{$val.name}</option>
				{/if}
				{/foreach}
			</select>
			<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" multiple /> 图片最佳尺寸1：1，按Shift同时上传多个图片
		<div id="information_image_box" align="center" width="100%">
		{if $form_act == 'update'}
			{foreach from=$information_image item=image_list 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="../{$image_list.thumb}" width="150" height="150" />
					<div style="margin-top:3px;">
					<input type="hidden" name="information_image[]" value="{$image_list.image}" />
					描述:<input type="text" name="information_image_desc[]" value="{$image_list.name}" style="width:100px;" />
					</div>
					<div style="margin-top:3px;">
					排序:<input type="text" name="information_image_sort[]" value="{$image_list.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 $information.channel_id!=16 && $information.channel_id!=17}
		<tr>
		<td class="label">文件上传:</td>
		<td>
			<input type="file" class="upload_file_btn" id="file_{$list.language_id}" name="file_{$list.language_id}" ref="{$list.language_id}" />
			<div id="information_file_box_{$list.language_id}" align="center" width="100%">
			{foreach from=$list.information_file item=file name=foo}
			<div class="gpic-box" id="information_file_box_{$list.language_id}_{$smarty.foreach.foo.index}" style="float:left;margin-right:6px;">
				<div class="gpic" style="height:100px;">
					<a href="information.php?act=download&id={$file.information_file_id}"><strong>{$file.name}</strong></a>
					<div style="margin-top:3px;">
					<input type="hidden" name="information_file_{$list.language_id}[]" value="{$list.image}" />
					描述:<input type="text" name="information_file_desc_{$list.language_id}[]" value="{$list.name}" style="width:100px;" />
					</div>
					<div style="margin-top:3px;">
					排序:<input type="text" name="information_file_sort_{$list.language_id}[]" value="{$list.sort_order}" style="width:100px;" />
					</div>
					<div>
						<a href="javascript:void(0);" onclick="drop_file('information_file_box_{$list.language_id}_{$smarty.foreach.foo.index}');"  title="删除">删除</a>
					</div>
				</div>
			</div>
			{/foreach}
			</div>
		</td>
		</tr>			
		{/if}
		
		<tr>
		<td class="label">描述:</td>
		<td>{$list.description}</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':true,
	'width':'94',
	'height':'25',
	'buttonText':'',
	'buttonImage':'images/add_image_1.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();
}

$('.upload_file_btn').each(function(){
	var obj = this;
	$(this).uploadify({
		'formData': {
			'rand_str' 	: '{/literal}{$rand_str}{literal}',
			'hash'     	: '{/literal}{$hash}{literal}',
			'session_id' : '{/literal}{$session_id}{literal}',
			'img_type'  : 'file'
		},	
		'multi':true,
		'width':'94',
		'height':'25',
		'buttonText':'',
		'buttonImage':'images/add_file.png',
		'swf':'images/uploadify.swf',
		'uploader' : 'uploadify.php',
		'fileTypeDesc' : 'Upload Files',
		'fileSizeLimit' : '2048KB',
		'fileTypeExts' : '*.doc; *.xls; *.zip; *.rar; *.pdf; *.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="information_file_box_'+$(obj).attr('ref')+'_'+result.id+'" style="float:left;margin-right:6px;">';
				html =html+'	<div class="gpic" style="height:100px;">';
				html =html+'		<strong><a href="../'+result.file+'" target="_blank">'+result.name+'</a></strong>';
				html =html+'		<div style="margin-top:3px;">';
				html =html+'		<input type="hidden" name="information_file_'+$(obj).attr('ref')+'[]" value="'+result.file+'" />';
				html =html+'		描述:<input type="text" name="information_file_desc_'+$(obj).attr('ref')+'[]" value="'+result.name+'" style="width:100px;" />';
				html =html+'		</div>';
				html =html+'		<div style="margin-top:3px;">';
				html =html+'		排序:<input type="text" name="information_file_sort_'+$(obj).attr('ref')+'[]" value="" style="width:100px;" />';
				html =html+'		</div>';
				html =html+'		<div>';
				html =html+'	<a href="javascript:void(0);" onclick="drop_file(\'information_file_box_'+$(obj).attr('ref')+'_'+result.id+'\');"  title="删除">删除</a>';
				html =html+'		</div>';
				html =html+'	</div>';
				html =html+'</div>';
				$('#information_file_box_'+$(obj).attr('ref')).append(html);
			}
		 }
	});
});

function drop_file(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"}