<%@ page contentType="text/html; charset=GBK" %>
<%@ taglib uri="/cms4j" prefix="cms4j" %>
<%@ page import = "cn.com.dekn.cms.util.*,cn.com.dekn.common.util.*" %>


<%
//录入项ID INPUT_ID
String INPUT_ID = StrUtil.getNotNullStringValue(request.getParameter("INPUT_ID"),"");

//录入项默认值 INPUT_DEFAULT_VALUE
String INPUT_DEFAULT_VALUE = StrUtil.getNotNullStringValue(request.getParameter("INPUT_DEFAULT_VALUE"),"");

//录入项可选值 INPUT_VALUE
String INPUT_VALUE = StrUtil.getNotNullStringValue(request.getParameter("INPUT_VALUE"),"");
String[] valueArray = INPUT_VALUE.split("\\|");

//录入项备注 INPUT_REMARK
String INPUT_REMARK = StrUtil.getNotNullStringValue(request.getParameter("INPUT_REMARK"),"");

//是否必填写 INPUT_MUST
String INPUT_MUST = StrUtil.getNotNullStringValue(request.getParameter("INPUT_MUST"),"");

//必选项类型 INPUT_MUST_TYPE
String INPUT_MUST_TYPE = StrUtil.getNotNullStringValue(request.getParameter("INPUT_MUST_TYPE"),"");

//必选项提示消息 INPUT_MUST_MSG
String INPUT_MUST_MSG = StrUtil.getNotNullStringValue(request.getParameter("INPUT_MUST_MSG"),"");

String UPLOAD_URL = StrUtil.getNotNullStringValue(request.getParameter("UPLOAD_URL"),"");
String upLoadUrl = "";
if(null == UPLOAD_URL || UPLOAD_URL.equals("")){
	upLoadUrl = "../editor/uploadIframe.jsp";
}else{
	upLoadUrl =  UPLOAD_URL;
}

String ID = StrUtil.getNotNullStringValue(request.getParameter("ID"),"");

if(INPUT_MUST.equals("1")){
	INPUT_MUST = "true";
}else{
	INPUT_MUST = "false";
}
if(INPUT_MUST.equals("1") && INPUT_MUST_TYPE.equals("")){
	INPUT_MUST_TYPE = "Require";
}
%>

<script language="javascript">
if(typeof uploadImgSubmitForUploadComponent!='function'){
	uploadImgSubmitForUploadComponent = function(inputID){
	  eval("uploadImgLinkTo_"+inputID).myformSubmit();
	}
}
</script>

<input name="<%=INPUT_ID%>" type="hidden" id="<%=INPUT_ID%>" size="60" value="<%=INPUT_DEFAULT_VALUE%>">
<table width="100%"  border="0" cellspacing="0" cellpadding="0" id="uploadToTable<%=INPUT_ID%>">
	<tr>
	<td width="7%">
			<table border="0" cellspacing="0" cellpadding="0" class="img_upload_button_frame">
				<tr >
				  <td valign="center" style="background-image:;cursor:pointer;background-repeat:no-repeat;width:70;height:70; background-position:center">
				  <table width="70" height="22" border="0" cellpadding="0" cellspacing="0"   id="img_oper_bar" style="display:">
					<tr>
					  <td style="text-align:center; font-size:12px" id="<%=INPUT_ID%>_thumbnail_td">&nbsp;</td>
					</tr>
				  </table>
				  </td>
				</tr>
			</table>
	  </td>
		
		<td width="93%" id="<%=INPUT_ID%>_iframe_td">
		<iframe id="uploadImgLinkTo_<%=INPUT_ID%>" name="uploadImgLinkTo_<%=INPUT_ID%>" frameborder=0 src="<%=upLoadUrl%>?type=uploadImgTo&isUploadWarter=no&tdName=<%=INPUT_ID%>&thumbnailRule=M|68|0&isRtnFileSize=true" width="400" height="24" scrolling=no></iframe>&nbsp;<input name="b2" id="b2" type="button" class="b2_ok" onMouseOver="this.className='b2_ok_m'" onMouseOut="this.className='b2_ok'" onClick="uploadImgSubmitForUploadComponent('<%=INPUT_ID%>')" value="上传">
	  </td>
	</tr>
</table>

<script>

if(typeof setThumbnailForUploadComponent!='function'){//只有当前页面没有定义此函数时才会定义此函数
	reUploadForUploadComponent = function(inputID){
		//设置缩略图为空
		var thumbnailTdObj = document.getElementById(inputID+"_thumbnail_td");
		thumbnailTdObj.innerHTML = '&nbsp;';
		//重新显示上传IFAME
		var uploadIframeTdObj = document.getElementById(inputID+"_iframe_td"); 
		uploadIframeTdObj.innerHTML = '<iframe id="uploadImgLinkTo_'+inputID+'" name="uploadImgLinkTo_'+inputID+'" frameborder=0 src="<%=upLoadUrl%>?type=uploadImgTo&isUploadWarter=no&tdName='+inputID+'&thumbnailRule=M|68|0&isRtnFileSize=true" width="400" height="24" scrolling=no></iframe>&nbsp;<input name="b2" type="button" class="b2_cancel" id="b2" onMouseOver="this.className=\'b2_cancel_m\'" onMouseOut="this.className=\'b2_cancel\'" onClick="uploadImgSubmitForUploadComponent(\''+inputID+'\')" value="上传">';
		//设置图片路径
		document.getElementById(inputID).value = "";
	}
	
	setThumbnailForUploadComponent = function(filePath,inputID){
		//设置图片路径
		document.getElementById(inputID).value = filePath;
		//设置缩略图路径
		var dotIndex = filePath.indexOf(".");
		var thumbnailPath = filePath.substring(0,dotIndex)+"_M68_0"+filePath.substring(dotIndex);
		//设置所旅途
		var thumbnailTdObj = document.getElementById(inputID+"_thumbnail_td");
		thumbnailTdObj.innerHTML = '<a href="'+filePath+'" target="_blank"><img src="'+thumbnailPath+'" border="0"></a>';
		//回显上传文件路径
		var uploadIframeTdObj = document.getElementById(inputID+"_iframe_td"); 
		uploadIframeTdObj.innerHTML = '<input type="text" class="form-input" disabled = "disabled" style="width:400px" value="'+filePath+'">&nbsp;<input name="b2" type="button" class="b2_cancel" id="b2" onMouseOver="this.className=\'b2_cancel_m\'" onMouseOut="this.className=\'b2_cancel\'" onClick="reUploadForUploadComponent(\''+inputID+'\')" value="删除">'
	}
}


//初始
if(null!=document.getElementById("<%=INPUT_ID%>")){
	var upload_value = document.getElementById("<%=INPUT_ID%>").value;
	if(upload_value != ""){
		setThumbnailForUploadComponent(upload_value,"<%=INPUT_ID%>");
	}
}
</script>