{template 'phpcms','header'}
<script type="text/javascript">
// 表单提交检测
function doCheck(){
	// 检测表单的有效性
	// 如：标题不能为空，内容不能为空，等等....
	if ($('catid').value=='0'){
		alert('指定的栏目不允许添加图片！只允许在其子栏目中添加图片。');
		$('catid').focus();
		return false;
	}
	if ($('title').value=='') {
		alert('对不起，标题不能为空！');
        $('title').focus();
		return false;
	}
	{if $MOD['check_code']}
	if ($('checkcodestr').value=='') {
		alert("请输入验证码！");
		$('checkcodestr').focus();
		return false;
	}
	{/if}

}


function ShowPreview(){
var obj = $('pictureurls');
var r = document.selection.createRange();
var s = "TMP";
var rt = r.text;
var rv = rt+s;
r.text = rt+s;
var i = obj.value.indexOf(rv);
obj.value = obj.value.replace(s, '');
obj.blur();
var str;
if(obj.value.indexOf("\r") == -1){
	str = "\n";
}else{
	str = "\r\n";
}
var p = obj.value.substring(obj.value.lastIndexOf("|", i)+1, i)+obj.value.substring(i, obj.value.indexOf(str, i));
var l = obj.value.substring(i, obj.value.length);
if(l.indexOf("\n")==-1) p = obj.value.substring(obj.value.lastIndexOf("|", i)+1, i)+l;
var u = <?php echo "'";echo imgurl($CHA['channeldir'].'/'.$MOD['upload_dir'].'/');echo "'"; ?>;
if(p.indexOf("://") != -1) u = '';
var m = p.match(/^[^\r\n\|]+\.(jpg|gif|png|bmp)$/);
if(m != null)
{
	window.open(u+p);
}
}

</script>


<div class="memberborder_1">
<div class="memberborder_2">
<h1>发布图片</h1>
<form action="{$CHA[linkurl]}/contribute.php" method="post" name="myform" onsubmit="return doCheck();">
<table cellpadding="2" cellspacing="1" class="righttable">
<tbody>
    <tr>
<td class="td_right" width="15%"><strong>类别</strong></td>
<td class="td_left" width="85%">{$category_select}</td>
</tr>
<tr>
<td class="td_right"><font color="red">*</font> <strong>标题</strong></td>
<td class="td_left">{$type_select} <input type="text" name="title" size="50"> </td>
</tr>
<tr> 
<td class="td_right"><strong>标题图片</strong> </td>
<td class="td_left">
<input name="thumb" type="text" id="thumb" size="50"> <input type="button" value="上传图片" onclick="javascript:openwinx('{PHPCMS_PATH}uppic.php?channelid={$channelid}&uploadtext=thumb&type=thumb&width=150&height=150','upload','360','300')"></td>
</tr>
<tr>
<td class="td_right"><font color="red">*</font> <strong>内容</strong></td>
<td class="td_left">
<textarea name="content" id="content" cols="100" rows="25"></textarea>{$editor("content",$MOD['editor_mode'],$MOD['editor_width'],$MOD['editor_height'])}
</td>
</tr>
<tr>
<td class="td_right"><font color="red">*</font> <strong>图片名称|地址</strong></td>
<td class="td_left">
		<table cellpadding="0" cellspacing="1" width="100%">
		<tr>
		<td colspan="2"><font color="red">图片地址举例：</font>图片说明|图片地址 <a href="###" onclick="alert('PHPCMS简体中文版|http://soft.phpcms.cn/phpcms_gbk.jpg\nPHPCMS繁体中文版|http://soft.phpcms.cn/phpcms_big5.jpg\nPHPCMS一键安装包|http://soft.phpcms.cn/pc_server.jpg');">一个图片图片占一行，点这里查看实例</a></td>
		</tr>
		<tr>
		<td width="500"><textarea name="pictureurls" cols="70" rows="6" id="pictureurls" style="width:500px;height:100px;overflow:visible;" ondblclick="ShowPreview();" title="提示:如果您使用的是IE6+浏览器，在图片名上双击鼠标可在新窗口中弹出图片..."></textarea>
		<textarea name="allpictureurls" id="allpictureurls" style="display:none;"></textarea>
		<br/>
		<font color="blue">Tips:</font>如果需要彻底删除某个图片地址（包括图片），请在其后加标识符[d]<br/>
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;如果您使用的是IE6+浏览器，在图片名上双击鼠标可在新窗口中弹出图片
		</td>
		<td valign="top" style="light-height:22px;">
		<input type="button" value="上传图片" onclick="javascript:openwinx('{PHPCMS_PATH}uppic.php?channelid={$channelid}&uploadtext=temp&type=both&width=150&height=150&upload_dir={$MOD[upload_dir]}','upload','360','300')">
		<input type="hidden" name="temp" id="temp" value="" onpropertychange="Picurls();">
		</td>
		</tr>
		</table>
</td>
</tr>
{$fields}
{if $MOD['check_code']}
    <tr> 
      <td class="td_right"><strong>验证码</strong></td>
      <td class="td_left"><input name="checkcodestr" type="text" size="15" id="checkcodestr">
	  <img src="<?=PHPCMS_PATH?>checkcode.php" id="checkcode" onclick="this.src='{PHPCMS_PATH}checkcode.php?id='+Math.random()*5;" style="cursor:pointer;" alt="验证码,看不清楚?请点击刷新验证码" align="absmiddle"/></td>
    </tr>
{/if}
<tr>
<td class="td_right"></td>
<td class="td_left">
<input type="submit" name="dosubmit" value="发布图片">
</td>
</tr>
</tbody>
</table>
</form>
</div>
</div>
<script type="text/javascript">
function Picurls() {
	if($('temp').value != '') {
	var ss = $("pictureurls").value == '' ? '' : "\n";
	$('pictureurls').value += ss+'图片说明|'+$('temp').value.replace(/<?=$CHA['channeldir']?>\/<?=$MOD['upload_dir']?>\//g, '');
	$('allpictureurls').value += ss+$('temp').value.replace(/<?=$CHA['channeldir']?>\/<?=$MOD['upload_dir']?>\//g, '');
	$('temp').value = '';
	}
}
</script>
{template 'phpcms','footer'}