<% port = ":3000" if Rails.env.development? %>

<script type="text/javascript">
    $(document).ready(function() {
        var prefix = '';
        if(location.href.indexOf('ros') >= 0)
        {
            prefix = '/ros'
        }
        $("#province").html("<option value='0' selected = true style='display: none;'></option>");
        $.ajax({
            type :"POST",
            url :prefix + '/school/get_province',
            data: "send",
            success: function(data, textStatus){
                $("#province").append(data.text);
                $("#schoollist").html(data.text_s);
            }
        })
    });
    function get_school(value){
        var prefix = '';
        if(location.href.indexOf('ros') >= 0)
        {
            prefix = '/ros'
        }
        $.ajax({
            type :"POST",
            url :prefix + '/school/get_schoollist/'+encodeURIComponent(value),
            data :'text',
            success: function(data){
                $("#schoollist").html(data);
            }
        })
    }
    function test(id){
        location.href = encodeURI('http://<%= Setting.host_course %>/?school_id='+id);
    }
    function ssearch(){
        //alert($("#key_word").val());
        var value = $("#key_word").val();
        var province = $("#province").val();
        //alert(value);
        if(value == "")
        {
            alert("<%= l(:label_search_conditions_not_null) %>");
            return;
        }
        var prefix = '';
        if(location.href.indexOf('ros') >= 0)
        {
            prefix = '/ros'
        }
        $.ajax({
            type :"POST",
            url :prefix + '/school/search_school/?key_word='+encodeURIComponent(value)+'&province='+encodeURIComponent(province),
            data :'text',
            success: function(data){
                $("#schoollist").html(data);
            }
        })
    }
    function word_keydown(e){
        if(e&& e.keyCode==13){
            ssearch();
        }
    }
</script>
<div style="background: white;padding: 10px 0;margin-top: 20px">
  <div>
    <p class="mb20">
      <%= link_to l(:label_all_schol),school_index_path  %>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      <% if User.current.logged? %>
          <a href="http://<%= Setting.host_course %>">
            <%= l(:label_my_school) %>
          </a>
      <% end %>
    </p>
    <ul>
      <li style="width: 40%; float: left;">
        <%= l(:label_select_province) %>:
        <select id="province" name="province" onchange="get_school(this.value)" class="task-form-30 task-height-30"></select>
      </li>
      <li style="width: 50%; float: left">
        <input type="text" id="key_word" name="key_word"  onkeydown="word_keydown(event);" class="fl task-form-35 task-height-30"/>
        <a href="javascript:void(0);" class="fl task-btn task-btn-orange ml5 mt3" onclick="ssearch()" value="<%= l(:label_search) %>">搜索</a>
        <!--<input type="button" class="enterprise fl task-btn task-btn-orange task-height-30 ml20 " value="<%= l(:label_search) %>" onclick="ssearch()" >-->
      </li>
    </ul>
  </div>
  <div style="clear:both"></div>
  <div class="school-index ml20">
    <ul id="schoollist" style="line-height: 25px;overflow: hidden">
    </ul>
  </div>
</div>
<% html_title(l(:label_school_all)) -%>