
var Validate = function()
{
    this.required = function(id)
    {
        var inputVal=$(id).val();
        if(inputVal=="") {
            return false;
        } else {
            return true;
        }
    };
    this.mobile = function (id)
    {
        var inputVal=$(id).val();
        var tel=new RegExp("^[1][3-8]+\\d{9}");
        if(tel.test(inputVal)) {
            return true;
        } else {
            return false;
        }
    }
};

var CountDown = function(time)
{
    if(isNaN(time)) {
        return;
    }
    
    this.time = time;
    this.countDown = function()
    {
        if(this.isStart())
        {
            return false;
        }
        else
        {
            var that=this;
            var target=event.target;
            var time = parseInt(that.time);
            var a = setInterval(function()
            {
                time = time - 1;
                target.innerHTML = time;
                if(time <= 0) {
                    clearInterval(a);
                    target.innerHTML = '重新发送';
                }
            },1000);
        }
    };
    this.isStart = function()
    {
        var target = event.target;
        if(target.innerHTML == '重新发送' || target.innerHTML == '获取验证码') {
            return false;
        } else {
            return true;
        }
    }

};

var ajaxServer = function(type,url,data,callback)
{
    $.ajax({
        type:type,
        dataType:'json',
        url:url,
        data:data,
        success:callback
    });
};


var app = function()
{
    var app=navigator.userAgent.toLowerCase(),//判断设备
        app_nav=navigator.appVersion.toLowerCase(),
        href='';
    if (app_nav.indexOf('iphone')>-1&&app.indexOf('iphone')){
        href='http://a.app.qq.com/o/simple.jsp?pkgname=com.lrlz.beautyshop';
    } else if (app.indexOf('micromessenger')>-1 && app_nav.indexOf('android')>-1) {
        href = "http://p.lrlz.com/hfive/android_down/index.html";
    }
    else {
        href="javascript:void(0)";
    }
    return href;
};

