<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<link rel="stylesheet" type="text/css" href="{-:*__THEME__-}/admin/css/c.css" />
<link rel="stylesheet" type="text/css" href="{-:*__THEME__-}/admin/css/mf.css" />
<link rel="stylesheet" type="text/css" href="{-:*__PUBLIC__-}/js/calendar/calendar.css" />
<script type="text/javascript" src="{-:*__PUBLIC__-}/js/calendar/calendar.js"></script>
<script type="text/javascript" src="{-:*__PUBLIC__-}/js/calendar/lang/{-:+lang-}.js"></script>
</head>

<body>
<form id="formAdd" action="" method="post">
<dl class="abox">
	<dt><strong>{-:@ADD-}{-:@AD-}</strong></dt>
	<dd>
		<table class="formTable">
			<tr>
				<td class="inputTitle">{-:@AD_SPACE-}</td>
				<td></td>
			</tr>
			<tr>
				<td class="inputArea">
					{-:$_ASI['as_name']-}
				</td>
				<td class="inputTip">
					<span class="fc_r">*</span> {-:@AD_SPACE_TIP-}
				</td>
			</tr>
			<tr>
				<td class="inputTitle">{-:@TYPE-}</td>
				<td></td>
			</tr>
			<tr>
				<td class="inputArea">
					{-if:1 == $_ASI['as_type']-}{-:@CODE-}{-:/if-}
					{-if:2 == $_ASI['as_type']-}{-:@TEXT-}{-:/if-}
					{-if:3 == $_ASI['as_type']-}{-:@IMAGE-}{-:/if-}
					{-if:4 == $_ASI['as_type']-}{-:@FLASH-}{-:/if-}
					{-if:5 == $_ASI['as_type']-}{-:@SLIDE-}{-:/if-}
				</td>
				<td class="inputTip">
					<span class="fc_r">*</span> <span class="fc_gry">{-:@AS_TYPE_TIP-}</span>
				</td>
			</tr>
			<tr>
				<td class="inputTitle">{-:@NAME-}</td>
				<td></td>
			</tr>
			<tr>
				<td class="inputArea">
					<input class="required i" type="text" value="" name="a_name" maxlength="96" size="30">
				</td>
				<td class="inputTip">
					<span class="fc_r">*</span> <span class="fc_gry">{-:@AD_NAME_TIP-}</span>
				</td>
			</tr>
			<tr {-if:1 == $_ASI['as_type'] or 2 == $_ASI['as_type']-} style="display:none"{-:/if-}>
				<td colspan="2" class="inputArea">
					{-:@FILE-}<br />
					<input id="a_file" class="i" type="text" value="" name="a_file" maxlength="255" size="50">
					<input id="a_file_uploader" to="#a_file" btntext="{-:@UPLOAD-}" typeset='all' class="uploader" type="file"  />
				</td>
			</tr>
			<tr id="a_content"{-if:1 != $_ASI['as_type']-} style="display:none"{-:/if-}>
				<td class="inputArea">
					{-:@CONTENT-}<br />
					<textarea class="i" name="a_content" style="width:360px;height:80px;"></textarea>
				</td>
				<td class="inputTip">
					<span class="fc_r">*</span> <span class="fc_gry">{-:@AD_CONTENT_TIP-}</span>
				</td>
			</tr>
			<tr>
				<td class="inputTitle">{-:@LINK-}</td>
				<td></td>
			</tr>
			<tr>
				<td class="inputArea">
					<input class="required i" type="text" value="#" name="a_link" id="a_link" maxlength="96" size="50">
				</td>
				<td class="inputTip">
					<span class="fc_r">*</span> <span class="fc_gry">{-:@AD_LINK_TIP-}</span>
				</td>
			</tr>
			<tr>
				<td class="inputTitle">{-:@TIME_LIMIT-}</td>
				<td></td>
			</tr>
			<tr>
				<td class="inputArea">
					<label><input type="radio" value="0" name="a_time_limit" checked="checked"> {-:@NOT_LIMIT-}</label>
					<label><input type="radio" value="1" name="a_time_limit"> {-:@VALIDITY_PERIOD-}</label>
				</td>
				<td class="inputTip">
					<span class="fc_r">*</span> <span class="fc_gry">{-:@AD_TIME_LIMIT_TIP-}</span>
				</td>
			</tr>
			<tr>
				<td class="inputTitle">{-:@VALIDITY_PERIOD-}</td>
				<td></td>
			</tr>
			<tr>
				<td class="inputArea">
					<input class="i" type="text" value="{-php:echo date('Y-m-d', time());-}" id="a_start_time" name="a_start_time" maxlength="20" size="10"> ~ 
					<input class="i" type="text" value="{-php:echo date('Y-m-d', time()+86400*30);-}" id="a_end_time" name="a_end_time" maxlength="20" size="10">
					<script type="text/javascript">
						Calendar.setup({
							inputField : 'a_start_time',
							trigger : 'a_start_time',
							onSelect : function() {this.hide()},
							weekNumbers : true,
							showTime : false,
							dateFormat : '%Y-%m-%d'
						});
						Calendar.setup({
							inputField : 'a_end_time',
							trigger : 'a_end_time',
							onSelect : function() {this.hide()},
							weekNumbers : true,
							showTime : false,
							dateFormat : '%Y-%m-%d'
						});
					</script>
				</td>
				<td class="inputTip">
					{-:@AD_VALIDITY_PERIOD_TIP-}
				</td>
			</tr>
			<tr>
				<td class="inputTitle">{-:@DISPLAY_ORDER-}</td>
				<td></td>
			</tr>
			<tr>
				<td class="inputArea">
					<input class="required i" type="text" value="50" name="a_display_order" maxlength="20" size="10">
				</td>
				<td class="inputTip">
					<span class="fc_r">*</span> <span class="fc_gry">{-:@AD_DISPLAY_ORDER_TIP-}</span>
				</td>
			</tr>
		</table>
	</dd>
</dl><!--/.abox-->
<div id="operation">
	<input type="hidden" value="{-:$_ASI['ad_space_id']-}" name="ad_space_id">
	<span class="btn_b submit" action="{-url:ad/add_ad_do-}" to="#formAdd">{-:@SUBMIT-}</span>
</div>
</form>
<script type="text/javascript" src="{-:*__PUBLIC__-}/js/jquery.js"></script>
<script type="text/javascript" src="{-:*__PUBLIC__-}/js/uploadify/uploadify.js"></script>
<script type="text/javascript">
{-php:
	$o_upload = M('Option')->get_option('upload');
	$_FS['img'] = '*.'.implode(';*.', explode(',', $o_upload['imgtype']));
	$_FS['file'] = '*.'.implode(';*.', explode(',', $o_upload['filetype']));
	$_FS['all'] = $_FS['img'].';'.$_FS['file'];
-}
$(document).ready(function(){
	$('.uploader').each(function(){
		var btntext = $(this).attr('btntext'),
			to_id = $(this).attr('to'),
			typeset = $(this).attr('typeset'),
			thumb = $(this).attr('thumb'),
			preview_id = $(this).attr('preview'),
			fileTypeDesc, fileTypeExts, uploader;
		if('image' == typeset){
			fileTypeDesc = '{-:@IMAGE-}';
			fileTypeExts = '{-:$_FS['img']-}';
			if('yes' == thumb)
			{
				uploader = '{-url:upload/upload_file?type_set=image&upload_type=ad&thumb=yes-}';
			}
			else
			{
				uploader = '{-url:upload/upload_file?type_set=image&upload_type=ad-}';
			}
		}
		else if('all' == typeset){
			fileTypeDesc = '{-:@FILE-}';
			fileTypeExts = '{-:$_FS['all']-}';
			uploader = '{-url:upload/upload_file?type_set=all&upload_type=ad-}';
		}
		$(this).uploadify({
			'buttonClass' : 'btn_upload',
			'buttonImage' : '',
			'buttonText' : btntext,
			'fileObjName' : 'upload',
			'fileTypeDesc' : fileTypeDesc,
			'fileTypeExts' : fileTypeExts,
			'formData' : {
				'{-php:echo session_name();-}' : '{-php:echo session_id();-}'
			},
			'swf' : '{-:*__PUBLIC__-}/js/uploadify/uploadify.swf',
			'uploader' : uploader,
			'height' : 27,
			'width' : 80,
			'multi' : false,
			'queueID' : 'uwa_id',
			'onInit': function(){
				$("#uwa_id").hide();
			},
			'onUploadSuccess' : function(file, data, response){
				$(to_id).val(data);
				if(preview_id)
				{
					$(preview_id).attr('src', data);
				}
			},
			'onUploadError' : function(file, errorCode, errorMsg, errorString){
				alert(errorString);
			}
		});
	});
});
</script>
<script type="text/javascript" src="{-:*__THEME__-}/admin/js/c.js"></script>
</body>
</html>