<%= render_flash_messages %>
<div id="put-bid-form" style="display: none">
	<script type="text/javascript">
		function j_submit () {
			alert('start');
			var  submit_homework = function(){
				$('#add_homework_form').clone().attr('action', '<%= url_for({:controller => "bids", :action => "add_homework"})+".js" %>').ajaxSubmit()
			};
			alert('stop');
			$.globalEval(submit_homework());
			return false;
		}

        function show()
        {
            $("#what_is_project_div").slideToggle();
        }

        $(document).ready(
            function()
            {
                <% if !@is_teacher && @homework_list.count > 0 && @bid.comment_status == 1%>
                    //登录者不是老师，且作业列表数目不为0，且作业处于开启匿评阶段
                    var alert_model =  "'#ajax-modal'";
                    $('#ajax-modal').html('<%= escape_javascript(render :partial => 'homework_attach/praise_alert') %>');
                    showModal('ajax-modal', '480px');
                    $('#ajax-modal').css('height','240px');
                    $('#ajax-modal').siblings().remove();
                    $('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" +
                            "<a href='javascript:' onclick='hiddent_alert_model();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
                    $('#ajax-modal').parent().css("top","").css("left","").css("width","511");
                    $('#ajax-modal').parent().addClass("alert_praise");
                <% end %>

                <% unless @is_teacher%>
                    <% if @bid.comment_status == 0 && @bid.open_anonymous_evaluation == 1%>
                        $("#my_homework").click();
                    <% elsif @bid.comment_status == 2 || @bid.open_anonymous_evaluation == 0%>
                        $("#all_homeworks").click();
                    <% end %>
                <% end %>
            }
        );

        function hiddent_alert_model(){hideModal($('#popbox02'));}

        function hidden_homework_atert_form(cur_page,cur_type)
        {
          hideModal($("#popbox"));
        }

        function search_homework_member(url)
        {
            $.get(
                url,
                { name: $.trim($("#homework_member_search").val()) },
                function (data) {

                }
            );
        }

//        $(window).scroll(function(){
//            //获取窗口的滚动条的垂直位置
//            var s = $(window).scrollTop();
//            //当窗口的滚动条的垂直位置大于页面的最小高度时，让返回顶部元素渐现，否则渐隐
//            if( s > 600){
//                $("#gotoTop").fadeIn(100);
//            }else{
//                $("#gotoTop").fadeOut(200);
//            };
//        });
        $(function(){goTopEx();});

        var Sys = {};
        var ua = navigator.userAgent.toLowerCase();
        var s;
        (s = ua.match(/msie ([\d.]+)/)) ? Sys.ie = s[1] :
                (s = ua.match(/firefox\/([\d.]+)/)) ? Sys.firefox = s[1] :
                        (s = ua.match(/chrome\/([\d.]+)/)) ? Sys.chrome = s[1] :
                                (s = ua.match(/opera.([\d.]+)/)) ? Sys.opera = s[1] :
                                        (s = ua.match(/version\/([\d.]+).*safari/)) ? Sys.safari = s[1] : 0;

        function goTopEx() {
            var obj = document.getElementById("goTopBtn");
            var scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
            function getScrollTop() {
                var xsun = document.documentElement.scrollTop;
                if (Sys.chrome) {
                    xsun=document.body.scrollTop;
                }
                return xsun;
            }
            function setScrollTop(value) {
                if (Sys.chrome) {
                    document.body.scrollTop = value;
                }
                else {
                    document.documentElement.scrollTop = value;
                }
            }
            window.onscroll = function () { getScrollTop() > 0 ? obj.style.display = "" : obj.style.display = "none"; };
            obj.onclick = function () {
                var goTop = setInterval(scrollMove, 10);
                function scrollMove() {
                    setScrollTop(getScrollTop() / 1.1);
                    if (getScrollTop() < 1) clearInterval(goTop);
                }
            }
        }
	</script>
</div>
<div id='bidding_project_list'>
	<%= render :partial => 'homework_list' %>
</div>
