// <!-- 双十一专题 -->
 $('.m_jpzpt_gb').on('click',function(){
        $('.m_jpzpt_box').hide();
    })
    $('.m_jpzpt_zhez').on('click',function(){
        $('.m_jpzpt_box').hide();
    })

// 2020.01.03 添加新年标签 弹窗
$(function(){
    // setTimeout(function(){
    //     xiannian_s()
    //     setTimeout(function(){
    //         xiannian_h();
    //     },7000);
    // },2000);
    $('.xiannian_ico_gb a,.xiannian_ico_bg').on('click',function(){
        xiannian_h();
    })
    function xiannian_s(){
        $('.xiannian_ico').show(10);
        $('.xiannian_ico_bg').show();
    }
    function xiannian_h(){
        $('.left_xiannain').show(10)
        $('.xiannian_ico_bg').hide();
        $('.xiannian_ico').hide();
    }

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


// 头部轮播
jQuery(".m_Broadcast").slide({mainCell:".bd ul",effect:"fold",autoPlay:true,trigger:"click",delayTime:1000,interTime:4000});
jQuery(".m_Broadcast .bd").hover(function(){ jQuery(this).find(".prev,.next").stop(true,true).fadeTo("show",1) },function(){ jQuery(this).find(".prev,.next").fadeOut() });



$(function(){

    // 精选房源
    // var inID=0;
    // var length=$('.lp_title_r_maui a').length;
    // var i=1;
    // var oid=0;
    // var  widh=$('.lp_title_r_maui a').innerWidth()
    // $('.lp_title_r_maui').width(((widh*$('.lp_title_r_maui a').length)+100)+'px')
    // if (length>6) {
    //     $('.lp_title_r a.m_PgDn').show()
    // };
    
    // //关键函数:通过控制i ,来显示图片
    // function showImg(i){
    //      $('.lp_title_r_maui a').eq(i).addClass("on").siblings().removeClass("on");
    //      oid=$('.lp_title_r_maui a').eq(i).attr('data-id')
    //      fn_ajax(oid)
    // }
    
    // function slideNext(){
    //     if(inID >= 0 && inID < length-1) {
    //          ++inID;
    //          showImg(inID);
    //          $('.lp_title_r a.m_pgUp').show()
    //     }else{
    //         showImg(0);
    //         inID=0;
    //         aniPx=(length-6)*100+'px';
    //         $(".lp_title_r_maui").animate({ "left": "+="+aniPx },200);
    //         $('.lp_title_r a.m_pgUp').hide()
    //         i=1;
    //         return false;
    //     }
    //     if(i<0 || i>length-6) {return false;}                         
    //    $(".lp_title_r_maui").animate({ "left": "-=100px" },200)
    //    i++;
    // }
     
    // function slideFront(){
    //    if(inID >= 1 ) {
    //          --inID;
    //          showImg(inID);
    //     }
    //     if (inID==0) {
    //         $('.lp_title_r a.m_pgUp').hide()
    //     };
    //    if(i<2 || i>length+6) {return false;}
    //    $(".lp_title_r_maui").animate({ "left": "+=100px" },200)
    //    i--;
    // }
    // $('.lp_title_r_maui a').eq(0).addClass("on");

    // $('.lp_title_r_maui a').click(function(){
    //     inID = $('.lp_title_r_maui a').index(this);
    //     showImg(inID);
    // });
    // $('.lp_title_r a.m_PgDn').click(function(){
    //     slideNext();
    // })
    // $('.lp_title_r a.m_pgUp').click(function(){
    //     slideFront();
    // })

    $('.lp_title_r_maui a').click(function(){
          var oid = $(this).attr('data-id');
          $(this).attr('class','on').siblings().attr('class','');
          fn_ajax(oid);
    });

    function fn_ajax(object){
        $.ajax({
            type: "post",
            url: "/index/choicehouse",
            data: {id:object,csrf_token_f:csrfToken},
            dataType: "json",
            success: function(data){
                $('.lp_conter').html('');
                if(data.code == 200){
                    var data = fn_each(data.data);
                    $('.lp_conter').html('<ul>'+data+'</ul>')
                }
            }
        });
    }
    fn_ajax(0);     //默认请求一次数据
    function fn_each(data){
        var _html="";
        $.each(data,function(k,v){

            _html += '<li>';
            _html += '<div class="lp_conter_img">';
            _html += '<a href="/house/'+v.id+'" target="_blank">';
            _html += '<img src="'+v.thumb+'" alt="">';
             _html += '<p style="display:none;" class="xn_ico"><img src="/image/xn_ico12.png" alt="" /></p>';
            _html += '<p style="display:none;" class="pintuan"><img src="/image/pcico1.png" alt="" /><span>拼团购立减¥20000</span><img src="/image/pcico2.png" alt="" /><span>每月20日出团</span></p>';
            _html += '<div class="lp_conter_price"><span>约</span>'+v.price+'<span></span><p style="font-size:12px; color:#ccc;margin-top:3px;font-weight: 100;">(有效期:'+time_yxq+')</p></div>';
            _html += '</a>';
            _html += '</div>';
            _html += '<div class="lp_font">';
            _html += '<p><a target="_blank" href="/house/'+v.id+'" title="'+v.name+'">'+v.name+'</a></p>';
            _html += '<p title="'+v.city_name+' · '+v.main_units+'">'+v.city_name+' · '+v.main_units+'</p>';
            _html += '</div>';
            _html += '<div class="lp_info">';
            _html += '<div class="lp_info_span c">';
            _html += '<span>推荐理由:';
            if((v.push_reason).length>35){
                _html += (v.push_reason).substr(0,35)+'......';
            }else{
                _html += v.push_reason;
            }
            _html += '</span>';

            _html += '</div>';
            _html += '<p class="c" style="'+style+'">';
            if(v.recent_price != 0 && v.recent_price != null){
                _html += '<i>近一年房价涨幅'+v.recent_price+'</i>';
            }else{
                _html += '<i>近一年房价涨幅:暂无</i>';
            }
            if(v.proportion != 0 && v.proportion != null){
                _html += '<i>参考收益:'+v.proportion+'</i>';
            }else{
                _html += '<i>参考收益:暂无</i>';
            }
            _html += '<a class="applekf-id"  data-module="69" data-button="领取优惠" data-text="免费接机+酒店接送+专车看房,领取优惠,更享有购房立减优惠折扣。" data-type="领取优惠" data-id="0" href="javascript:;"><img src="/image/bmyh.gif" alt=""></a>';
            _html += '</p>';
                _html += '</div>';
            _html += '</li>';
            
        })
        return _html;
    }

   var style = $('.lp_conterdata').attr('style');

});

// 搜索页面 单独加载效果 --报名看房
//创建一个弹出层,width 宽度,height 高度,url
// function CreatePopLayerDiv(width,height,url){
//     var Iheight=$(window).height(); 
//     var Iwidth =$(window).width(); 
//     var heights = height || 300; 
//     var widths = width || 500; 
//     var Oheight= (Iheight -heights) / 2; 
//     var Owidth = (Iwidth - widths) /2;
//     var div ='<div id="InDiv" style="width:'+Iwidth+'px;height:'+Iheight+'px;background:rgba(0,0,0,0.6);position:fixed;z-index:1000;top:0;left:0;">';
//         div+='<div id="offDiv" style="width:'+widths+'px;height:'+heights+'px;left:'+Owidth+'px;position:fixed;z-index:32;border-radius:5px;">';
//         div+='<a id="AClose" class="y_close" href="javascript:;" onclick="btnCloses()"><img src="/image/ico_close.png" alt="" /></a>';
//         div+='<div id="Content"></div>';
//         div+='</div>';
//         div+='</div>';
//     $(document.body).append(div); 

//     if(url != ""){ 
//         $("#Content").load(url); 
//     } 
// } 
// //移除弹出层 
// function RemoveDiv(){
//     $("#AClose").remove(); 
//     $("#HTitle").remove();
//     $("#offDiv").remove(); 
//     $("#InDiv").remove();
// } 
// function btnCloses(){ 
//     RemoveDiv(); 
// } 
// $(function(){
//     // //降价通知
//     var w_type,w_id,w_title,w_module;                          //为了这些变量在其它地方用;
//     $('body').on('click','.applekf-id',function(){
//         var $that = $(this);
//         CreatePopLayerDiv(440,442,"/public/applekf");                   //添加加载页面
//         $('#offDiv').css({'margin-top':'-221px'}).animate({top:'50%'},500);
//         parent.w_type = $that.attr('data-type');                        //把报名窗口 类型传向父级
//         parent.w_id = $that.attr('data-id');                             //把楼盘ID传向父级
//         parent.w_module = $that.attr('data-module');                //来源模块ID
//         parent.w_title = $that.attr('data-name');                           //报名标题
//     });

//     $('#InDiv').on('click',function(){
//         btnCloses();
//     })
// })





$(function(){
    $('em.timew').html(time_yxq);
})



// 改版------------------------------------------------------------------------------------------------------------------
 // 头部轮播
jQuery(".m_lunbov2").slide({mainCell:".bd ul",effect:"fold",autoPlay:true,trigger:"click",delayTime:1000,interTime:4000});
// 精彩推荐
jQuery(".m_video_lb").slide({titCell:".hd ul",mainCell:".bd ul",effect:"left",autoPlay:true,autoPage:"<li><a></a></li>",interTime:4000});

// 开发商
if($('.m_Developerslist ul li').length > 6){
jQuery(".m_Developerslist_box").slide({mainCell:".bd ul",autoPlay:true,effect:"leftMarquee",vis:6,interTime:50,trigger:"click"});
$('.m_Developerslist_box .prev').removeClass('on');
$('.m_Developerslist_box .next').removeClass('on');
}

// 筛选区域
$('.m_Country_list ul li').on('mousemove',function(){
   $(this).addClass('on').siblings().removeClass('on');

   if(!$(this).hasClass('CountryClick')){
     $('.m_CountryRegion_box').hide(); 
   }

})

var _region="";
var _abroad="";
var _py = '';
var being = true;
$('.m_Country_list ul .CountryClick').on('mouseover',function(event){

   if(_region != $(this).attr('data-region')){
     being = true;
   }

   $('.m_CountryRegion_box').show();
   _region = $(this).attr('data-region');
   _py = $(this).attr('data-py');
   _abroad = $(this).attr('data-abroad');

   if(being == true){
      ajax_qy();
      being = false;
   }

})

$('.m_Country_box').on('mouseleave',function(){
   $('.m_CountryRegion_box').hide();
   $('.m_Country_list ul li').removeClass('on');
})

function ajax_qy(){

    var html = '';
    $.ajax({
        url: "/index/getpushcity",  // 索取
        data:{hid:_region},  //传ID
        type: "GET",
        dataType: "json",
        success: function(data) {//请求成功完成后要执行的方法
            // console.log(data)
              if(data.code == 200){
                    // console.log(data);
                  $.each(data.data, function (i, data) {
                     // html+=  '<a href="javascript:void(0)" dataid="'+data.href+'">';

                    if (data.abroad == 2) {
                        html+='<li><a target="_blank" href="/house/search?py='+data.pinyin+'&city='+data.city_id+'"><img src="'+data.img+'" alt=""><i>'+data.city_name+'</i></a></li>';
                    } else {
                        html+='<li><a target="_blank" href="/housech/search?py='+data.pinyin+'&city='+data.city_id+'"><img src="'+data.img+'" alt=""><i>'+data.city_name+'</i></a></li>';
                    }

                  });

                if (_abroad == 2) {
                    html+='<li><a target="_blank" href="/house/search?py='+_py+'&city='+_region+'"><i class="on">更多城市</i></a></li>';
                } else {
                    html+='<li><a target="_blank" href="/housech/search?py='+_py+'&city='+_region+'"><i class="on">更多城市</i></a></li>';
                }

               }

     
             $('.Popular ul').html(html);
        }
    });

} // 筛选区域结束

// 导航
$('.m_Navigation ul li').on('mousemove',function(){
     $('.m_Navigation_list').hide();

})
$('.m_Navigation ul .Navigation_click').on('mousemove',function(){
    
     $(this).find('.m_Navigation_list').show();
})
$('.m_Navigation').on('mouseleave',function(){
   $('.m_Navigation_list').hide();
})



// 头部语言切换
$('.m_HeadMenu ul .m_HeadMenuTop').on('mousemove',function(){
    $('.m_qh').hide();
    $(this).parent().find('.m_qh').show();
})
$('.m_HeadMenu').on('mouseleave',function(){
  $('.m_qh').hide();
})





// 搜索
$('.seek_input p').on('click',function(){
    var txt = $('.seek_input input[type="text"]').val();

    if (txt != '') {
        // window.location.href = '/house/search?name='+ txt;
        window.open('/house/search?name='+ txt);    
    };
    
})