if(!qcms){
    var qcms = {}
}

qcms.login = {model:null}
qcms.login.authenticate = function (){
    var _id = qcms.login.model
    if (_id.match(/^oauth2/i)){
        ;
    }else{
        var _args = qcms.login.get()
        var http = HttpClient.instance()
        http.setHeader('Content-Type','application/json')
        http.setHeader('method',_id)
        http.setData( JSON.stringify(_args))
        var _uri = ([qcms.context,'/login']).join('')
        http.post(_uri,(x)=>{

            if(x.readyState == 4 && x.status == 200){

                window.open(x.responseURL,'_self');
            }else{
                $('.qcms-login-error').slideDown()
            }
        })

    }
    

}
qcms.login.get = function (){
    var _args = {}
    var _nodes = $('.qcms-login-input INPUT')
    _nodes.each((_index)=>{
        var _key = $(_nodes[_index]).attr('class')
        var _value = $(_nodes[_index]).val()
        _args[_key] = _value
    })
    return _args
}
qcms.login.cancel = function (){
    var _nodes = $('.qcms-login-input INPUT')
    _nodes.each((_index)=>{
        $(_nodes[_index]).val('')
    })
    $('.qcms-login-error').slideUp()
}

