$(function(){

  // 热推看房团
  new Swiper('.hot-box',{
    	slidesPerView :'auto',
		spaceBetween : 20,
		prevButton:'.hotprev',
		nextButton:'.hotnext',
	})
  var oid = false;
  var aClass = $('.widget-box');
  // 关闭按钮
  $('.widget-cls').on('click',function(){
    	aClass.removeClass('adi');
    	oid = aClass.hasClass('adi');
    	aClass.animate({width:'8px',height:'8px',right:'100px',bottom:'325px'},function(){
    		var _this = $(this);
    		_this.animate({bottom:'280px'},function(){
    			_this.hide();
    		})
    	})
  })

    // 点击按钮弹出报名窗口
  $('.alive').on('click',function(){
    	if(!oid){
    		aClass.show();
	    	aClass.animate({width:'8px',height:'8px',right:'100px',bottom:'325px'},function(){
	    		var _this = $(this);
	    		_this.animate({width:'240px',height:'312px',right:'20px',bottom:'350px'})
	    	})
    	}
    	aClass.addClass('adi');
    	oid = aClass.hasClass('adi')
  })


   /*-------------------- 获取地址栏地址并拆分 --------------------------------*/
  function getParams(url) {
    var theRequest = new Object();
    if (!url)
        url = location.href;
    if (url.indexOf("?") !== -1)
    {
        var str = url.substr(url.indexOf("?") + 1) + "&";
        var strs = str.split("&");
        for (var i = 0; i < strs.length - 1; i++)
        {
            var key = strs[i].substring(0, strs[i].indexOf("="));
            var val = strs[i].substring(strs[i].indexOf("=") + 1);
            theRequest[key] = val;
        }
    }
    return theRequest;
  }

    var  objUrl = {}; //获取get参数
    var url = window.location.href;
    

    var params = getParams(url);
    if(!$.isEmptyObject(params)){
        $.each(params,function(key,val){
            objUrl[key] = val;
        })
    }



  // 类目导航
  $('.top-nav-li ul li').on('click',function(){
      var that = $(this);
      var oid = that.attr('data-oid');
      that.addClass('on').siblings('li').removeClass('on');
      objUrl['type'] = oid;
      skipUrl(objUrl);
  })

  // 国家导航
  $('.genera-center-nav ul li').on('click',function(){
      var that = $(this);
      var cid = that.attr('data-city');
      that.addClass('on').siblings('li').removeClass('on');
      objUrl['cid'] = cid;
      skipUrl(objUrl);
  })

  function skipUrl(data){
      // console.log(data)
      var urlParams ="";
      $.each(data,function(key,val){
          urlParams  += key+'='+val+'&';
      })

      var cityUrl = '';
      urlParams = urlParams.substring(0,urlParams.length - 1);

      if(urlParams == '' && cityUrl != ''){
          cityUrl = cityUrl.substring(0,cityUrl.length - 1);
      }

      // console.log(cityUrl)
      // console.log(urlParams)

        window.location.href = '/news/knowledge?'+urlParams;
  }











    /*
	* 调用的方法
	* */
	PublicAction.AjaxSend(
	    {
	        CORID:'apply_submit',                  /*操作ID*/
	    }
	);



  // 问答字数限制

  $('.faqs-box ul li').each(function(){
    var _that=$(this);
    var _txtm=_that.find('.fa span em').text();
    var _txtlength=  _that.find('.fa span em').text().length;
    if (_txtlength > 115) {
      _that.find('.fa span em').text(_txtm.substring(0,num)+"...");
    }
    console.log(_txt);

  })





jQuery.fn.limit=function(){
    var self = $("[limit]");
    self.each(function(){
      var objString = $(this).text();
      var objLength = $(this).text().length;
      var num = $(this).attr("limit");
      if(objLength > num){
        $(this).attr("title",objString);
        objString = $(this).text(objString.substring(0,num)+"...");
      }
      $(this).attr("title"," ")
    })
}


// $(function(){
//   $(".list li a").attr("limit",18)
//   $("#last_show p").attr("limit",35)
//   $(".newsList li a").attr("limit",24)
//   $("[limit]").limit();
// })















})