<%@ page contentType="text/html; charset=GBK" session="false"%>
<%@ taglib uri="/cmsTag" prefix="cms"%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<%
			response.setHeader("Pragma", "No-cache");
			response.setHeader("Cache-Control", "no-cache");
			response.setDateHeader("Expires", 0);
		%>
		<title>图片处理</title>

		<!--加载 js -->

		<link rel="stylesheet" type="text/css" href="../../style/default/main.css" />
		<script language="javascript" type="text/javascript" src="../javascript/commonUtil.js"></script>

		<style type="text/css">
<!--
body {
	margin: 0px;
	padding:0px;

}

.uploadImg
{
	cursor:pointer

}
-->
</style>
	</head>
	<script language="JavaScript" type="text/javascript">
function sumbitTempPic(file)
{
if(!file.value.match(/.jpg|.jpeg|.gif|.png|.bmp/i))
{
	alert('文件类型必须是: .jpg,.jpeg, .gif, .bmp, .png !');
	return;
}

var emptyFlag =true;


if(document.all.classImg.value!='' )
{

	emptyFlag=false;
}


if(emptyFlag)
{
	alert('请选择图片！');
	return;
}
 
 //alert(document.all.classImg.value);
document.all.uploadForm.action="../../content/uploadUserDefinePhoto.cmd";
 //alert('ddddd');
uploadForm.submit();

}
</script>




	<form method="post" name='uploadForm' id='uploadForm' enctype="multipart/form-data">
		<fieldset >
			<legend class="title_td">
				当前图片
			</legend>

			<table>
				<tr>
					<td>
						<table>
							<tr>
								<td>
									<img id="preImg1" class='uploadImg' src="images/addpicture.jpg" alt="栏目显示图片" style="width:76px;height:57px;background-color:#ccc" />
								</td>
							</tr>


						</table>
					</td>
					<td>
						<input name="classImg" type="file" id='classImg' size="30">

						<input name="classImgFile" type="hidden" id='classImgFile' value="${param.classImgFile}">

						<input name="classImgURLsite" type="hidden" id='classImgURLsite' value="${param.classImgURL}">

						<input name="classPhotoURL" type="hidden" id='classPhotoURL' value="${param.classPhotoURL}">
					</td>
				</tr>
			</table>


			<input type="button" id="s1" value="上传" onClick="javascript:sumbitTempPic(document.getElementById('classImg'));">
			
			<input type="button" id="crop" value="裁剪" onClick="javascript:gotoCropPic();">

		</fieldset>
      
        <input type="hidden" id="filedSign" name="filedSign" value="${param.fieldSign}" ></input>
	</form>


<script language="JavaScript" type="text/javascript">
//document.all.classImg.style.display='none';
//document.all.contentImg.style.display='none';
//document.all.headImg.style.display='none';



var havPic = false;
var targetPicFile='';

//当前photo，来自数据库或服务器
var current = window.parent.document.getElementById("${param.fieldSign}").value;

var photoFileName = document.getElementById('classImgFile').value;
 
 
 

//来自服务器，表示上传了photo
if('' != photoFileName)
{
      window.parent.document.getElementById("${param.fieldSign}").value = photoFileName;
      document.all.preImg1.src = "<cms:Domain/>/UPLOAD/"+photoFileName;
      havPic=true;
      targetPicFile=photoFileName;
   //alert('X');
}
else
{//当前服务器没有返回任何photo
    if('' != current)
    {    
      //当前展示图片
      document.getElementById('preImg1').src="<cms:Domain/>/UPLOAD/"+current;
      havPic=true;
      targetPicFile=current;
      // alert('X0');
    }
}


//alert(window.parent.document.getElementById("${param.fieldSign}").value);
//alert(document.all.classImgFile.value);






if("true" == "${param.editMode}")
{
  document.getElementById("preImg1").src="<cms:Domain/>/${param.imgResizeFileName}";
  havPic=true;
  targetPicFile="${param.imgFileName}";
}

function gotoCropPic()
{
     
	if(havPic)
	{
	
		//window.open("CropPicture.jsp?targetPicFile="+targetPicFile,null,"");
	 
	   window.showModalDialog("CropPicture.jsp?targetPicFile="+targetPicFile,"","dialogWidth=1600px;dialogHeight=1200px;status=no");
	   window.location.reload();
	}
	else
	{
		alert("当前没有图片!");
		return;
	}


}

</script>
</html>

