var mySwiper3= new Swiper(".y_lphomepc_cent_list .swiper-container2",{
        loop : true,
        loopedSlides:4,
        autoplay:0,
        autoplayDisableOnInteraction : false,
        // 濡傛灉闇€瑕佸垎椤靛櫒
        pagination: '.swiper-pagination',
                // 如果需要前进后退按钮
        prevButton:'.swiper-button-prev',
        nextButton:'.swiper-button-next',
        slidesPerView :"auto"
    });

var mySwiper1= new Swiper(".swiper-container1",{
        loop : false,
        autoplay:0,
        autoplayDisableOnInteraction : false,
        // 如果需要分页器
        pagination: '.swiper-pagination',
        slidesPerView :"auto"
    });


// 户型
// function lptype_hx(){
//     var html = '';
//     $.ajax({
//         url: "/house/tall",
//         data:{city:hid},
//         type: "POST",
//         dataType: "json",
//         success: function(data) {//请求成功完成后要执行的方法
//             if (data.code == 200) {
//                 $.each(data.data, function (i, data) {
//                     html += '<li class="clearfix">';
//                     html += '<a href="">';
//                     html += '<div class="left_img"><img src="" alt=""></div>';
//                     html += '<div class="right_text">';
//                     html += '<p>A户型</p>';
//                     html += '<p>三房两厅</p>';
//                     html += '<p>建筑面积:105㎡</p>';
//                     html += '</div>';
//                     html += '</a>';
//                     html += '</li>';
//                 });
//                 $('.lphomeV2type_ul ul').html(html);
//             }
//         }
//     });
// }
// var hid = $('.lphomeV2type_nva a').eq(0).attr('data-id');
// $('.lphomeV2type_nva a').eq(0).attr('class','on');

// $('.lphomeV2type_nva a').on('click',function(){
//     hid = $(this).attr('data-id');
//     $(this).attr('class','on').siblings().attr('class','');
//     lptype_hx ();
// })
// lptype_hx ();


// 热销楼盘 选项卡
function lpindex_lp (){
    var html = '';
    $.ajax({
        url: "/housech/tall",
        data:{city:hid,price:price},
        type: "POST",
        dataType: "json",
        success: function(data) {//请求成功完成后要执行的方法
            if (data.code == 200) {
                $.each(data.data, function (i, data) {
                    var randomX = 300;
                    var randomY = 800;
                    var randvalue = parseInt(Math.random() * (randomX - randomY + 1) + randomY);
                    html+=  '<li>';
                    html+=  '<a href="/housech/'+data.id+'/">';
                    html+=  '<div class="sell_img"><img src="'+data.thumb+'" alt=""><i class="sell_img_i">'+data.city_name+'</i></div>';
                    html+=  '<div class="sell_conter_right">';
                    html+=  '<p class="title">'+data.name+'</p>';
                    if(data.sale_price != 0){
                        html+=  '<p class="jg_ing jg_ingdd" style="margin-top:9px"><span><em>'+ data.sale_price +'</em>'+data.price_unit+'</span></p>';
                    }else{
                        html+=  '<p class="jg_ing jg_ingdd" style="margin-top:9px"><span><em>待定</em></span></p>';
                    }
                    html+=  '<p class="jg_ing" style="margin-top:8px">有效期:'+yxqtime+'</p>';
                    html+=  '</div>';
                    html+=  '<div class="m_gzlx">';
                    html+=  '<p class="attention">已有 <span>'+randvalue+'</span> 人关注</p>';
                    html+=  '<div class="m_gzlx_style">';
                    if(data.characteristic){
                        $.each(data.characteristic,function(k,v){
                            html+=  '<i>'+v+'</i>';
                        })
                    };
                    html+=  '</div>';
                    html+=  '</div>';
                    html+=  '</a>';
                    html+=  '<div class="cal_price"><a href="tel:'+data.tel+'"><img src="/image/index/tel_calltu.png"></a></div>';
                    html+=  '</li>';
                    // console.log(data.citytel);

                });
                $('.y_lphometj_cent_list').html(html);
                
            }
        }
    });
}

var hid = $('.y_lphometj_h li').eq(0).attr('data-id');
var price = null;
$('.y_lphometj_h li').eq(0).attr('class','on');

$('.y_lphometj_h li').on('click',function(){

    if($(this).attr('name') == 'price'){
        price = $(this).attr('data-id');
        //hid = null
        hid = $(this).siblings().attr('data-id');
    }else if($(this).attr('name') == 'city'){
        hid = $(this).attr('data-id');
        price = null;
    }
    $(this).attr('class','on').siblings().attr('class','');
    lpindex_lp ();
})
lpindex_lp ();


// <!-- 展开全部信息 -->
$('.d_hide').hide();
$(".d_show").click(function(){
    $(".anone").removeClass("anone");
    $('.d_hide').show();
    $(this).hide();
})
$(".d_hide").click(function(){
    $(".d_toggle").addClass("anone");
    $(".d_show").show();
    $(this).hide();
})



// 楼盘首页地图
$(function(){
    //获取周边配套
    $('.y_lpdt_list ul li a').on('click',function(){
        // $(this).addClass('on').siblings().removeClass('on');
        var _data = $(this).find('p.y_text').text(); //选择中的内容

        var _longitude =$('#y_lpmap').attr('data-jwd'); //获取经纬度

        var pintx = _longitude.split(',')[0];
        var pinty = _longitude.split(',')[1];
        _longitude = new BMap.Point(pintx,pinty);
        doSearch(_data,_longitude);//调用地图弹窗
    })

    var time_n='';
    var time_y='';
    var deta_time=$('.lphomeV2news_ul .left_deta').attr('data-time');
    if (deta_time) {
        if(deta_time.indexOf("-")!=-1){
            var hutime_arr = deta_time.split('-');
            for(var j = 0; j < hutime_arr.length; j++){
                huxing1=hutime_arr[0];
                huxing2=hutime_arr[1]+'/'+hutime_arr[2];
            };
        }
        $('.lphomeV2news_ul .left_deta p.deta_yue').html(huxing2);
        $('.lphomeV2news_ul .left_deta p.deta_nian span').html(huxing1);
    };


});

// console.log($('#y_lpmap').length >0)
if($('#y_lpmap').length >0){        //判断页面是否存在 标签,
// 百度地图API功能
var map = new BMap.Map("y_lpmap");
var _lTude =$('#y_lpmap').attr('data-jwd');         //获取经纬度
var _lJg =$('#y_lpmap').attr('data-jg');         //获取楼盘价格
var _lTitle =$('#y_lpmap').attr('data-title');         //获取楼盘标题

var pintx = _lTude.split(',')[0];
var pinty = _lTude.split(',')[1];
_lTude = new BMap.Point(pintx,pinty);

map.centerAndZoom(_lTude, 15);
map.enableScrollWheelZoom(); //启用滚轮放大缩小,默认禁用

// 复杂的自定义覆盖物
function ComplexCustomOverlay(_lTude, text, mouseoverText){
    this._point = _lTude;
    this._text = text;
    this._overText = mouseoverText;
}
ComplexCustomOverlay.prototype = new BMap.Overlay();
ComplexCustomOverlay.prototype.initialize = function(map){
    this._map = map;
    var div = this._div = document.createElement("div");
    div.style.position = "absolute";
    div.style.zIndex = BMap.Overlay.getZIndex(this._point.lat);
    div.style.backgroundColor = "#fff";
    div.style.border = "1px solid #e1e1e1";
    div.style.color = "666";
    // div.style.height = "18px";
    div.style.padding = "5px 10px";
    // div.style.lineHeight = "10px";
    div.style.whiteSpace = "nowrap";
    // div.style.MozUserSelect = "none";
    div.style.fontSize = "14px"
    var span = this._span = document.createElement("span");
    div.appendChild(span);
    span.appendChild(document.createTextNode(this._text));
    var that = this;

    var arrow = this._arrow = document.createElement("div");
    arrow.style.background = "url(../../image/ico_map1.png) no-repeat center";
    arrow.style.backgroundSize = "100%";
    arrow.style.position = "absolute";
    arrow.style.width = "20px";
    arrow.style.height = "28px";
    arrow.style.top = "30px";
    arrow.style.left = "25px";
    arrow.style.overflow = "hidden";
    div.appendChild(arrow);

    div.onmouseover = function(){
        this.style.backgroundColor = "#6BADCA";
        this.style.borderColor = "#3487ab";
        this.getElementsByTagName("span")[0].innerHTML = that._overText;
        arrow.style.backgroundPosition = "0px -20px";
    }

    div.onmouseout = function(){
        this.style.backgroundColor = "#EE5D5B";
        this.style.borderColor = "#BC3B3A";
        this.getElementsByTagName("span")[0].innerHTML = that._text;
        arrow.style.backgroundPosition = "0px 0px";
    }

    map.getPanes().labelPane.appendChild(div);

    return div;
}
ComplexCustomOverlay.prototype.draw = function(){
    var map = this._map;
    var pixel = map.pointToOverlayPixel(this._point);
    this._div.style.left = pixel.x - parseInt(this._arrow.style.left) -13 + "px";
    this._div.style.top  = pixel.y - 45 + "px";
}
var txt = _lTitle, mouseoverTxt = txt + " " + _lJg ;
var myCompOverlay = new ComplexCustomOverlay(_lTude, _lTitle ,mouseoverTxt);

map.addOverlay(myCompOverlay);

//map展现结果的地图实例
//autoViewport检索结束后是否自动调整地图视野,false 不调整地图视野
var local = new BMap.LocalSearch(map,{renderOptions:{map:map,autoViewport:true}});

//地址检索
function doSearch(Odata,Opoint){
    var address = Odata;
    local.searchNearby(address,Opoint);
}
}

$(function(){
    $('.y_centerpc').find('img').each(function(){
        var $that = $(this);
        var _alt = $that.attr('alt');
        if(_alt != 'code'){
            $that.removeAttr('width');
            $that.removeAttr('height');
            $that.css({'display':'block','width':'100%','height':'auto'});
        }

    })
    $('.lphomeV2_head_pric span.y_yxq').text('有效期至:'+whtmltimes);
})


// 处理资讯详情页面的底部一个月的有效日期
var myDate = new Date;
var year = myDate.getFullYear(); //获取当前时间年份
var yue = myDate.getMonth()+1;//获取当前时间月份
if (yue<10) {
    yue= '0' + yue; 
}else if(yue == 13){
    yue = '01';
};
// 返回下个月有多少天数
function mGetDate(yue){     
    var date = new Date();     
    var year = date.getFullYear();     
    var d = new Date(year,parseInt(yue), 0);
    return d.getDate();
}
var whtmltimes = year + '/'+ yue + '/' + mGetDate(yue);
var whtmltime = year + '/'+ yue + '/' +'01'+'-'+ year + '/'+ yue + '/' + mGetDate(yue);


var yxqtime=whtmltime;



/*
*  楼盘预售许可证弹窗
*  
*/
$(function(){
    var lic_id;  //为了这些变量在其它地方用;
    $('.y_ckysz').on('click',function(){
        var $that = $(this);
        var height =  $('.y_licence').outerHeight();
        var width =  $('.y_licence').outerWidth();
        CreatePopLayerDivlp(width,width,'/public/licence');
        $('#offDivlp').css({'top':height+'px'}).animate({top:'20%'})
        // 向弹窗传数据
        parent.lic_id = $that.attr('data-id');                        //把楼盘名称传向父级
    })

    // 看房定制数量修改
    var random = Math.floor(Math.random()*150+101);
    // console.log(random)
    $('.y_lpkfdz_dzrs span em').html(random)
})
//创建一个弹出层,width 宽度,height 高度,url
function CreatePopLayerDivlp(width,height,url){
    var Iheight=$(window).outerHeight(); 
    var Iwidth =$(window).outerWidth(); 
    var heights = height || 300; 
    var widths = width || 500; 
    var Oheight= (Iheight -heights) / 2; 
    var Owidth = (Iwidth - widths) /2;
    var div ='<div id="InDivlp" style="width:'+Iwidth+'px;height:'+Iheight+'px;background:rgba(0,0,0,0.6);position:fixed;z-index:10000;top:0;left:0;">';
        div+='<div id="offDivlp" style=" width:100%; height:100%; left:0px; top:30%; position:fixed;z-index:100003;">';
        div+='<div id="Contentlp"></div>';
        div+='</div>';
        div+='</div>';
    $(document.body).append(div); 
    if(url != ""){ 
        $("#Contentlp").load(url); 
    } 
} 
//移除弹出层 
function RemoveDiv1(){
    $("#InDivlp").remove();
    $("#offDivlp").remove();
} 
function btnCloses1(){ 
    RemoveDiv1(); 
}



//项目分析
$(function () {
  $(window).scroll(function () {
    var top = $(window).scrollTop();
    if (top > 240) {
      $('.home_analyze').fadeIn(800);
    } else {
      $('.home_analyze').fadeOut(800);
    }
  }); 
})
$(function(){
    $('#wdemo06').navbarscroll({
      defaultSelect:0,
      scrollerWidth:3,
      fingerClick:0,
      endClickScroll:function(obj){
          // console.log(obj.text())
      }
  });

    //报名验证及提交的调用
        PublicAction.AjaxSend(
            {
                CORID:'appleBm_buttom_ch',                    /*操作ID*/
            }
        );  
})