<%@ page contentType="text/html;charset=GBK" %>
<%@ taglib prefix="c" uri="/WEB-INF/c.tld"%>
<html>
<head>
  <title>插入/修改图片</title>

<script type="text/javascript" src="popup.js"></script>

<script type="text/javascript">

window.resizeTo(500, 100);

function Init(flag) {
	
  __dlg_init();
  var param = window.dialogArguments;
  if (param) {
      document.getElementById("f_url").value = param["f_url"];
      document.getElementById("f_alt").value = param["f_alt"];
      document.getElementById("f_border").value = param["f_border"];
      document.getElementById("f_align").value = param["f_align"];
      document.getElementById("f_vert").value = param["f_vert"];
      document.getElementById("f_horiz").value = param["f_horiz"];
      window.ipreview.location.replace(param.f_url);
  }else{
  	
  	if ( flag.length == 0 ){
  		
  		self.location="uploadimage_ad.jsp";
  	}
  }
  document.getElementById("f_url").focus();
};

function onOK() {
  var required = {
    "f_url": "You must enter the URL"
  };
  for (var i in required) {
    var el = document.getElementById(i);
    if (!el.value) {
      alert(required[i]);
      el.focus();
      return false;
    }
  }
  // pass data back to the calling window
  var fields = ["f_url", "f_alt", "f_align", "f_border",
                "f_horiz", "f_vert"];
  var param = new Object();
  for (var i in fields) {
    var id = fields[i];
    var el = document.getElementById(id);
    param[id] = el.value;
  }
  __dlg_close(param);
  return false;
};

function onCancel() {
  __dlg_close(null);
  return false;
};

function onPreview() {
  var f_url = document.getElementById("f_url");
  var url = f_url.value;
  if (!url) {
    alert("You have to enter an URL first");
    f_url.focus();
    return false;
  }
  window.ipreview.location.replace(url);
  return false;
};
</script>

<style type="text/css">
html, body {
  background: ButtonFace;
  color: ButtonText;
  font: 11px Tahoma,Verdana,sans-serif;
  margin: 0px;
  padding: 0px;
}
body { padding: 5px; }
table {
  font: 11px Tahoma,Verdana,sans-serif;
}
form p {
  margin-top: 5px;
  margin-bottom: 5px;
}
.fl { width: 9em; float: left; padding: 2px 5px; text-align: right; }
.fr { width: 6em; float: left; padding: 2px 5px; text-align: right; }
fieldset { padding: 0px 10px 5px 5px; }
select, input, button { font: 11px Tahoma,Verdana,sans-serif; }
button { width: 70px; }
.space { padding: 2px; }

.title { background: #ddf; color: #000; font-weight: bold; font-size: 120%; padding: 3px 10px; margin-bottom: 10px;
border-bottom: 1px solid black; letter-spacing: 2px;
}
form { padding: 0px; margin: 0px; }
</style>

</head>

<body onload="Init('<c:out value="${param.imagePath}"/>')">

<div class="title">插入/修改图片</div>
<!--- new stuff --->
<form action="" name="main" method="get">
<table border="0" width="100%" style="padding: 0px; margin: 0px">
  <tbody>

  <tr>
        <td style="width: 7em; text-align: right">图片路径:</td>
    <td><input type="text" name="url" id="f_url" style="width:55%"
      title="图片的URL" value="<c:out value='${param.imagePath}'/>" />
      <button name="preview" onclick="return onPreview();"
      title="预览图片">预览</button>
       <button name="preview" onclick=" self.location = 'uploadimage_ad.jsp?deleteFile='+this.form.url.value;"
      title="修改图片">修改图片</button>
    </td>
  </tr>
  <tr>
        <td style="width: 7em; text-align: right">提示文本:</td>
    <td><input type="text" name="alt" id="f_alt" style="width:100%"
      title="鼠标悬停时的提示文本" /></td>
  </tr>

  </tbody>
</table>

<p />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

<fieldset style="float: left; margin-left: 5px;">
<legend>图片布局</legend>

<div class="space"></div>

<div class="fl">对齐方式:</div>
<select size="1" name="align" id="f_align"
  title="Positioning of this image">
  <option value=""                             >默认值</option>
  <option value="left"                         >左对齐</option>
  <option value="right"                        >右对齐</option>
  <option value="texttop"                      >文本上方</option>
  <option value="absmiddle"                    >绝对居中</option>
  <option value="baseline" selected="1"        >基线</option>
  <option value="absbottom"                    >绝对底部</option>
  <option value="bottom"                       >底部</option>
  <option value="middle"                       >居中</option>
  <option value="top"                          >顶端</option>
</select>

<p />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

<div class="fl">边框大小:</div>
<input type="text" name="border" id="f_border" size="5"
title="空值表示不要边框" />

<div class="space"></div>

</fieldset>

<fieldset style="float:right; margin-right: 5px;">
<legend>间距</legend>

<div class="space"></div>

<div class="fr">水平:</div>
<input type="text" name="horiz" id="f_horiz" size="5"
title="水平填充" />

<p />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

<div class="fr">垂直:</div>
<input type="text" name="vert" id="f_vert" size="5"
title="垂直 padding" />

<div class="space"></div>

</fieldset>
<br clear="all" />
<table width="100%" style="margin-bottom: 0.2em">
 <tr>
  <td valign="bottom">
    图片预览:<br />
    <iframe name="ipreview" id="ipreview" frameborder="0" style="border : 1px solid gray;" height="200" width="400" src=""></iframe>
  </td>
  <td valign="bottom" style="text-align: right">
    <button type="button" name="ok" onclick="return onOK();">确定</button><br>
    <button type="button" name="cancel" onclick="return onCancel();">取消</button>
  </td>
 </tr>
</table>
</form>
</body>
<script language="javascript">
	window.ipreview.location.replace(main.url.value);
</script>
</html>
