<script>
function showPreview(source) {
    var file = source.files[0];
    if(window.FileReader) {
        var fr = new FileReader();
        fr.onloadend = function(e) {
            document.getElementById("avatar_image").src = e.target.result;
        };
        fr.readAsDataURL(file);
    }
}
</script>

<%= form_tag(upload_school_path(@school.id),method: "post",  multipart: true,:id => "school_form") do %>
	<%#= text_field_tag 'school'%>
    <div style="padding:15px; border: 1px solid #dddddd;">
      <input type="hidden" value="<%= @school_name%>" name="school_name">
      <%= image_tag(@school.logo_link, id: "avatar_image", :class=>"school_avatar")%>
      <a type="button" onclick="$('#file').click();" style="margin: 86px 0 0 15px;float: left;padding: 2px 5px;border: 1px solid #eaeaea;cursor: pointer;text-decoration: none;width: 55px;">上传图片</a>
      <%= file_field_tag 'logo',:style => "display:none;", :id => "file", :onchange => "showPreview(this)"%>
      <div style="clear: both;"></div>
      <div class="mt15">学校名称：<input type="text" name="name" placeholder="现在对应的学校名称" value="<%= @school.name%>" class="schoolName ml4"/></div>
      <div class="mt10">学校省份：
        <select class="provinceSelect" name="province">
          <option value="">--请选择省份--</option>
          <option value="北京市" <%= @school.province == '北京市' ? 'selected':'' %>>北京</option>
          <option value="上海市" <%= @school.province == '上海市' ? 'selected':'' %>>上海</option>
          <option value="广东省" <%= @school.province == '广东省' ? 'selected':'' %>>广东</option>
          <option value="江苏省" <%= @school.province == '江苏省' ? 'selected':'' %>>江苏</option>
          <option value="浙江省" <%= @school.province == '浙江省' ? 'selected':'' %>>浙江</option>
          <option value="重庆市" <%= @school.province == '重庆市' ? 'selected':'' %>>重庆</option>
          <option value="安徽省" <%= @school.province == '安徽省' ? 'selected':'' %>>安徽</option>
          <option value="福建省" <%= @school.province == '福建省' ? 'selected':'' %>>福建</option>
          <option value="甘肃省" <%= @school.province == '甘肃省' ? 'selected':'' %>>甘肃</option>
          <option value="广西省" <%= @school.province == '广西省' ? 'selected':'' %>>广西</option>
          <option value="贵州省" <%= @school.province == '贵州省' ? 'selected':'' %>>贵州</option>
          <option value="海南省" <%= @school.province == '海南省' ? 'selected':'' %>>海南</option>
          <option value="河北省" <%= @school.province == '河北省' ? 'selected':'' %>>河北</option>
          <option value="黑龙江省" <%= @school.province == '黑龙江省' ? 'selected':'' %>>黑龙江</option>
          <option value="河南省" <%= @school.province == '河南省' ? 'selected':'' %>>河南</option>
          <option value="湖北省" <%= @school.province == '湖北省' ? 'selected':'' %>>湖北</option>
          <option value="湖南省" <%= @school.province == '湖南省' ? 'selected':'' %>>湖南</option>
          <option value="江西省" <%= @school.province == '江西省' ? 'selected':'' %>>江西</option>
          <option value="吉林省" <%= @school.province == '吉林省' ? 'selected':'' %>>吉林</option>
          <option value="辽宁省" <%= @school.province == '辽宁省' ? 'selected':'' %>>辽宁</option>
          <option value=" 内蒙古自治区" <%= @school.province == ' 内蒙古自治区' ? 'selected':'' %>>内蒙古</option>
          <option value="宁夏回族自治区" <%= @school.province == '宁夏回族自治区' ? 'selected':'' %>>宁夏</option>
          <option value="青海省" <%= @school.province == '青海省' ? 'selected':'' %>>青海</option>
          <option value="山东省" <%= @school.province == '山东省' ? 'selected':'' %>>山东</option>
          <option value="山西省" <%= @school.province == '山西省' ? 'selected':'' %>>山西</option>
          <option value="陕西省" <%= @school.province == '陕西省' ? 'selected':'' %>>陕西</option>
          <option value="四川省" <%= @school.province == '四川省' ? 'selected':'' %>>四川</option>
          <option value="天津市" <%= @school.province == '天津市' ? 'selected':'' %>>天津</option>
          <option value=" 新疆维吾尔自治区" <%= @school.province == ' 新疆维吾尔自治区' ? 'selected':'' %>>新疆</option>
          <option value="西藏自治区" <%= @school.province == '西藏自治区' ? 'selected':'' %>>西藏</option>
          <option value="云南省" <%= @school.province == '云南省' ? 'selected':'' %>>云南</option>
          <option value="香港" <%= @school.province == '香港' ? 'selected':'' %>>香港特别行政区</option>
          <option value="澳门" <%= @school.province == '澳门' ? 'selected':'' %>>澳门特别行政区</option>
          <option value="台湾" <%= @school.province == '台湾' ? 'selected':'' %>>台湾</option>
          <option value="海外" <%= @school.province == '海外' ? 'selected':'' %>>海外</option>
        </select>
      </div>
      <div style="margin-top: 10px;">
        <input type="button" value="提交" onclick="submit_edit_school($(this));" class="mr5 submit_btn_s" />
        <input type="button" value="取消" onclick="history.go(-1);" class="cancel_btn" />
        <%#= submit_tag('提交',:class=>'mr5') %>
        <%#= submit_tag('取消') %>
      </div>
    </div>
<% end %>
<script>
  function submit_edit_school(dom){
    $("#school_form").submit();
  }
</script>

