function SetCookie(name, value)//两个参数，一个是cookie的名子，一个是值
{
    var Days = 30; //此 cookie 将被保存 30 天
    var exp = new Date();    //new Date("December 31, 9998");
    exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 1000);
    document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString() + ";path=/";
}
function getCookie(name)//取cookies函数        
{
    var arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
    if (arr != null) return unescape(arr[2]); return null;
}

function Move(Cookie_name) {
    document.cookie = Cookie_name + "=;expires=Fri, 02-Jan-1970 00:00:00 GMT";
}
var config = {};
config.ztShow = function(boxId, boxHeight, tabsId, tabsOn, times, e) {
    var getNodeList = function(nodeList) {//获取标签下结点数
        var New = []; var n = 0;
        for (var i = 0; i < nodeList.length; ++i) { if (nodeList[i].nodeType == 1) { n++; New.push(nodeList[i]); nodeList[i].setAttribute("num", n); } }
        return New;
    }
    var $ = function(id) { return document.getElementById(id); } //定义ID查询器；
    if ($(tabsId).nodeType == 1) { var as = getNodeList($(tabsId).childNodes); nums = as.length; as[0].id = tabsOn; }
    if (boxId) { var imgs = getNodeList($(boxId).childNodes); nums = as.length; } //取得轮换图片数组;
    var tabsKey = true; //定义定时轮换KEY开关；
    var tabsNum = 0; //定义当前轮换数组位置坐标数；

    if ($(tabsId).nodeType == 1) {
        for (var i = 0; i < as.length; i++) {
            if (!e) {
                as[i].onclick = function() {
                    if (boxId) { imgs[0].style.marginTop = "-" + ((this.attributes["num"].nodeValue - 1) * boxHeight) + "px"; }
                    $(tabsOn).id = ""; this.id = tabsOn;
                }
            } else {
                as[i].onclick = function() {
                    tabsKey = false;
                    if (boxId) { imgs[0].style.marginTop = "-" + ((this.attributes["num"].nodeValue - 1) * boxHeight) + "px"; }
                    $(tabsOn).id = ""; this.id = tabsOn;
                }
            }
            if (times != 0) {
                as[i].onmouseout = function() {
                    tabsKey = true;
                    tabsNum = this.attributes["num"].nodeValue - 1;
                }
            }
        }
    }

    if (boxId) {
        for (var i = 0; i < imgs.length; i++) {
            imgs[i].onclick = function() { tabsKey = false; }
            imgs[i].onmouseout = function() { tabsKey = true; }
        }
    }

    if (times != 0) {
        this.setInterval(function() {
            if (tabsKey) {
                if ($(tabsId).nodeType == 1) { $(tabsOn).id = ""; as[tabsNum].id = tabsOn };
                if ($(tabsId).nodeType == 1) { imgs[0].style.marginTop = "-" + ((tabsNum) * boxHeight) + "px"; }
                tabsNum++;
                if (tabsNum == imgs.length) { tabsNum = 0; }
            }
        }, times);
    }
}

/**
* 时间对象的格式化;
*/
Date.prototype.format = function(format) {
    /*
    * eg:format="YYYY-MM-dd hh:mm:ss";
    */
    var o = {
        "M+": this.getMonth() + 1,  //month
        "d+": this.getDate(),     //day
        "h+": this.getHours(),    //hour
        "m+": this.getMinutes(),  //minute
        "s+": this.getSeconds(), //second
        "q+": Math.floor((this.getMonth() + 3) / 3),  //quarter
        "S": this.getMilliseconds() //millisecond
    }

    if (/(y+)/.test(format)) {
        format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    }

    for (var k in o) {
        if (new RegExp("(" + k + ")").test(format)) {
            format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
        }
    }
    return format;
}
var city = {};

city.Getareas = function(select2, select3) {
    document.body.focus();
    $.ajax({
        url: '/member/ashx/member.ashx',
        type: 'get',
        dataType: "json",
        data: "parm=Getareas&father=" + $("#" + select2).val(),
        error: function() {
            alert('加载数据出现错误,请刷新后操作！');
        },
        success: function(json) {
            $("#" + select3).find("option").remove();
            for (var nodes in json) {
                if (json[nodes].areaID != null)
                    $("#" + select3).append("<option value='" + json[nodes].areaID + "'>" + json[nodes].area + "</option>");
            }
        },
        error: function(err, obj) {
            alert('加载数据出现错误,请刷新后操作！');
        }
    });
}
city.Getcitys = function(select1, select2, select3) {
    document.body.focus();
    $.ajax({
        url: '/member/ashx/member.ashx',
        type: 'get',
        dataType: "json",
        data: "parm=Getcitys&father=" + $("#" + select1).val(),
        error: function() {
            alert('加载数据出现错误,请刷新后操作！');
        },
        success: function(json) {
            $("#" + select2).find("option").remove();
            for (var nodes in json) {
                if (json[nodes].cityID != null)
                    $("#" + select2).append("<option value='" + json[nodes].cityID + "'>" + json[nodes].city + "</option>");
            }
            city.Getareas(select2, select3);
            $("#" + select2).change(function() {
                city.Getareas(select2, select3);
            });
        },
        error: function(err, obj) {
            alert('加载数据出现错误,请刷新后操作！');
        }
    });
}
city.Getselect_sms_category = function(select1, select2, select3) {
    try {
        $.ajax({
            url: '/member/ashx/member.ashx',
            type: 'get',
            dataType: "json",
            data: "parm=Getcity",
            error: function() {
                alert('加载数据出现错误,请刷新后操作！');
            },
            success: function(json) {
                $("#" + select1).append("<option value='-100'>请选择</option>");
                for (var nodes in json) {
                    if (json[nodes].provinceID != null)
                        $("#" + select1).append("<option value='" + json[nodes].provinceID + "'>" + json[nodes].province + "</option>");
                }
                $("#" + select1).change(function() {
                    city.Getcitys(select1,select2,select3);
                });
            },
            error: function(err, obj) {
                alert('加载数据出现错误,请刷新后操作！');
            }
        });
    }
    catch (er) {
        alert(er)
    }
}
function startdiv(msg) {
    $('#lod').html(msg);
    $.blockUI({ message: $('#lod'),
        css: {
            top: ($(window).height() - 40) / 2 + 'px',
            left: ($(window).width() - 250) / 2 + 'px',
            width: '250px',
            border: "3px solid #d1e7fc"
        }
    });
}
function enddiv(msg) {
    $('#lod').html(msg);
    $('#lod').css("background", "url(/images/drop-yes.gif) no-repeat 20px 12px ");
}

//验证手机号
config.valphone =function(obj) {
    if (/^(((1[0-9][0-9]{1})|(15[0-9]{1}))+\d{8})$/.test(obj)) {
        return true;
    }
    else {
        return false;
    }
}
config.isPhone = function(txt) {//检测是否为固定电话号码
    if (txt == null || txt == "") { return false; }
    else {
        var regex = /[0-9]{1}[0-9]{2,3}-[1-9]{1}[0-9]{5,8}/;
        return regex.test(txt);
    }
}
config.AboPostcode = function(txt) {//检测是否为固定电话号码
    if (txt == null || txt == "") { return false; }
    else {
        var regex = /^[0-9]{6}$/;
        return regex.test(txt);
    }
}

