function select_sub_brand(){
    
}


function select_time(week_array) { 
    //time获取当前小时数
    
    var st = '<div class="date_mask">';
	st +='<div class="cont">';
        st +='<div class="tabBox" id="weekSelect">';
        st +='<div class="week_box hd">';
        st +='<span class="prev"></span>';
        st +='<ul class="week_list"></ul>';
        st +='<span class="next"></span>';
        st +='</div>';
        st +='<div class="week_time_box">';
        st +='<div class="bd">';
        st +='</div>';
        st +='</div></div></div></div>';

    $('body').append(st);
    
    
    var html = '';
    $('.next').hide();
    for(var i=1;i<=7;i++){
        if(i==1){
           html+='<div class="week_time" id="wt'+i+'" style="display:block;"><ul class="list">'; 
        }else{
            html+='<div class="week_time" id="wt'+i+'"><ul class="list">';
        }
        
        for(var ii=9;ii<=20;ii++){
            html+='<li hour="'+ii+'">'+ii+':00</li>';
        }
        html+='</ul></div>';
    }
 
    var week='';
    $.each(week_array, function(key, value){
         week+='<li val="'+(parseInt(key)+parseInt(1))+'" id="wl'+(parseInt(key)+parseInt(1))+'"><p>'+value.w+'</p><p class="graycl" style="font-size:10px;">'+value.d+'</p></li>';
    })
    

    $('.week_list').html(week);
    $('.bd').html(html);
    $('#wl1').addClass('on');
    $('#service_time').attr('week',$('#wl1 .graycl').text());//设置默认选中周一
    
    
    $('.week_list li').click(function(){
        $('.week_list li').removeClass('on');
        $(this).addClass('on');
        var val = $(this).attr('val');
        $('.week_time').hide();
        $('#wt'+val).show();
        $('#service_time').attr('week',$(this).find('.graycl').text());
    })
    $('.bd li').click(function(){

        if($('#service_time').attr('week') == ''){
            alert('没有选择日期！');
            return false;
        }
        $('.bd li').removeClass('on');
        $(this).addClass('on');
        var hour = $(this).attr('hour');
        var week = $('#service_time').attr('week');
        $('#service_time').attr('hour',hour);
        $('#service_time').val(week+' '+hour+':00');
        $(".date_mask").remove();
        
    })
    
    var prev = 0;
    $('.prev').click(function(){
        prev = prev +1;
        if(prev >2){
            prev = 1;
        }
             if(prev == 1){
                $('.next').show();
             }
             if(prev == 2){
                 $(this).hide();
             }
             $('.week_list li').removeClass('on');
             
             $('#wl'+prev).hide().removeClass('on');
             $('#wl'+(parseInt(prev)+parseInt(1))).addClass('on');
             
             $('#wt'+prev).hide();
             $('.week_time').hide();
             $('#wt'+(parseInt(prev)+parseInt(1))).show();
    })

    var next = 3;
    $('.next').click(function(){
        next = next-1;
        if(next <1){
            next = 2;            
        }
             if(next == 1){
                $(this).hide();
                $('.prev').show();
             }

             $('.week_list li').removeClass('on');
             $('#wl'+next).show().addClass('on');
             $('.week_time').hide();
             $('#wt'+next).show();


    })
    
    $('.date_mask').show();


}




//写cookies
function setCookie(name,value,day)
{
    var exp = new Date();
    exp.setTime(exp.getTime() + day*24*60*60*1000);
    document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString()+";path=/xiche";
}

//读取cookies
function getCookie(name)
{
    var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
 
    if(arr=document.cookie.match(reg))
 
        return unescape(arr[2]);
    else
        return null;
}

//删除cookies
function delCookie(name)
{
    var exp = new Date();
    exp.setTime(exp.getTime() - 1);
    var cval=getCookie(name);
    if(cval!=null)
    document.cookie= name + "="+cval+";expires="+exp.toGMTString();
} 





function warning(msg,link){
    var dia = $.dialog({
        title: '温馨提示',
        content: msg,
        button: ["确定", "取消"],
    });


    dia.on("dialog:action", function (e) {
        if (e.index == 0) {
            if(link){
                window.location.href=link;
            }else{
                location.reload(true);
            }
        }
    });
}




function GetDistance(lat1,lng1,lat2,lng2){  //经纬度计算公式
        var radLat1 = Rad(lat1);
       var radLat2 = Rad(lat2);
       var a = radLat1 - radLat2;
       var  b = Rad(lng1) - Rad(lng2);
       var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a/2),2) +
       Math.cos(radLat1)*Math.cos(radLat2)*Math.pow(Math.sin(b/2),2)));
       s = s *6378.137 ;// EARTH_RADIUS;
       s = Math.round(s * 10000) / 10000; //输出为公里
       //s=s.toFixed(4);
       return s;
}