// Generated by CoffeeScript 1.8.0
(function() {
  var  loadData;
  getCurrent = function(newsType){
	  if(newsType==1127){
		  $("#1127").attr("class","current");
		  $("#1128").attr("class","");
		  $("#1129").attr("class","");
		  $("#1130").attr("class","");
	  }
	  if(newsType==1128){
		  $("#1127").attr("class","");
		  $("#1128").attr("class","current");
		  $("#1129").attr("class","");
		  $("#1130").attr("class","");
	  }
	  if(newsType==1129){
		  $("#1127").attr("class","");
		  $("#1128").attr("class","");
		  $("#1129").attr("class","current");
		  $("#1130").attr("class","");
	  }
	  if(newsType==1130){
		  $("#1127").attr("class","");
		  $("#1128").attr("class","");
		  $("#1129").attr("class","");
		  $("#1130").attr("class","current");
	  }
  };
  loadData = function() {

    var item, swp,top,newsType;
    newsType = GetQueryString("newsType");
    if(newsType===null||newsType===""||newsType==="null"||newsType===undefined){
    	newsType=1127;
    }
    item = $("#itemTpl")[0].innerHTML;
    swp = new $.compent.swiper("#newsList", {
      tpl: item,
      refreshEnabled: false,
    });
    
    swp.convert();
    swp.dataSource = function(pageIndex, s, opt) {
      return Ajax({
        url: baseUrl + '/api/news/list.do',
        data: {
          pageIndex: pageIndex,
          newsType:newsType
        },
        callback: function(res) {
			$.each(res.datas,function(idx,item){
				item.pubTime = item.pubTime.substr(0,10)
      	    });
			if(pageIndex>1&&res.datas.length===0){
	  			  var a = $(".swiper-wrapper").children('div:last-child');
	  				a.after("<div class=\"swiper-slide\" style=\"height:15px\"></div>");
	  		  }
          swp.dataList(res.datas);
        },
        error: function(res) {
          opt['timeStatu'] = res.status;
          return swp.timeOut();
        }
      });
    };
    return swp.initData();
  };

  
	var newsType = GetQueryString("newsType");
	if(newsType===null||newsType===""||newsType==="null"||newsType===undefined){
	   newsType=1127;
	}
	getCurrent(newsType);
	
  $(function() {
	  $("#text").html("新三板");
    loadData();
    $(document).on("click", ".full", function() {
  	  return location.href = "./detail.html?newsId=" + $(this).data("id");
  	});

    $("#img").attr("onclick",
   	   'location.href="../product/index.html"'
     );
   
  });
}).call(this);
