$(function(){


    // 获取浏览器可见区域的宽高
    var h = $(window).height();
    var w = $(window).width();


    // 点击展示侧边栏
    $('.menu').on('click',function(){
         $(".sidebar_box").animate({right:"0"});
         $('.ground').css({"width":w,"height":h});
    })
    // 点击隐藏侧边栏
    $('.sidebar_img').on('click',function(){
        $(".sidebar_box").animate({right:"-100%"});
        $('.ground').css({"width":'0',"height":'0'});
    })
    // 点击底层隐藏
    $('.ground').on('click',function(){
        $(".sidebar_box").animate({right:"-100%"});
        $(this).css({"width":'0',"height":'0'});
    })

     $('.m_language').on('click',function(){
        $('.m_language_text').toggle();
     })

     $('.m_language_text span').on('click',function(){
        $(this).parent().attr('id','none');
        console.log(1);
     })

    // 楼盘列表
    // 屏幕滚动
    $(window).scroll(function (){
        var ster = $(this).scrollTop();
        navign(ster);
    });
     // 2019-12-24  首页、列表悬挂报名 --------------------------- 开始----------------
    $('.m_hqDiscountgb').on('click',function(){
        $('.m_hqDiscount_box').hide();
    })
    $('.flonh').on('click',function(){
        $('.m_hqDiscount_box').show();
    })
    /*
    * 调用的方法
    * */
    PublicAction.AjaxSend(
        {
            CORID:'wflbtn',               /*操作ID*/
        }
    );
    /*-------------------end------------------------*/
  

})

 /*
 *   获取 DOC 超出可视区域的高度
 */
 var dir = $(document).scrollTop();  
 navign(dir);

function navign(st){
    if(st >180){
        $('.y_header').css('background','rgba(0,0,0,0.6)');
    }else if(st>80 && st <= 180){
        $('.y_header').css('background','rgba(0,0,0,0.2)');
    }else{
        $('.y_header').css('background','rgba(0,0,0,0)');
    }
}

// 处理资讯详情页面的底部一个月的有效日期
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 time_yxq= whtmltime;
var timew =whtmltimes

$('.youxiaoqi_sj').html('有效期至:'+timew+'');


/*---------------------------------------COOKIE方法 end-----------------------------------------*/
// 封装一个COOKIE方法
var cookie = {
    //设置cookie方法
    set:function(key,val,time){
        var date=new Date(); //获取当前时间
        var expiresDays=time;  //将date设置为n天以后的时间
        date.setTime(date.getTime()+expiresDays*24*3600*1000); //格式化为cookie识别的时间
        document.cookie=key + "=" + val +";expires="+date.toGMTString();  //设置cookie
    },
    //获取cookie方法
    get:function(key){
        /*获取cookie参数*/
        var getCookie = document.cookie.replace(/[ ]/g,"");  //获取cookie,并且将获得的cookie格式化,去掉空格字符
        var arrCookie = getCookie.split(";")  //将获得的cookie以"分号"为标识 将cookie保存到arrCookie的数组中
        var tips;  //声明变量tips
        for(var i=0;i<arrCookie.length;i++){   //使用for循环查找cookie中的tips变量
            var arr=arrCookie[i].split("=");   //将单条cookie用"等号"为标识,将单条cookie保存为arr数组
            if(key==arr[0]){  //匹配变量名称,其中arr[0]是指的cookie名称,如果该条变量为tips则执行判断语句中的赋值操作
                tips=arr[1];   //将cookie的值赋给变量tips
                break;   //终止for循环遍历
            }
        }
        return tips;
    },
    //删除cookie方法
    delete:function(key){ 
        var date = new Date(); //获取当前时间
        date.setTime(date.getTime()-10000); //将date设置为过去的时间
        document.cookie = key + "=v; expires =" +date.toGMTString();//设置cookie
    }
}
// 调用方法
// cookie.set("www","54165165",24);//设置为24天过期
// console.log(cookie.get("www"));//获取cookie
/*---------------------------------------COOKIE方法 end-----------------------------------------*/