function login(f){
    var data = 'user=' + f.user.value + '&pass=' + f.pass.value;
    $.ajax({
        type: "POST",
        url: "action/login",
        data: data,
        dataType: "html",
        success: function(msg){
            var json = UTIL.json(msg);
            if(json.status){
                window.location=".";
            }else{
                var message=errorMessage(json.error);
                $("#errormsg").html("<div class='ui-state-error ui-corner-all' style='padding:3px;'> "+
                    "<span class='ui-icon ui-icon-alert' style='float: left; margin-right: .3em;'></span>"+ 
                    message+"</div>"
                    );
            }
        }
    });
}

function searchpersonal(formid){
    var formvalue = $("#"+formid).serialize();
    $.ajax({
        type: "GET",
        url: "../personal/action/search",
        data: formvalue,
        dataType: "html",
        success:function(msg){
            setSearchResult(msg);
        }
    });
    return false;
}

function logout(){
    $.ajax({
        type: "GET",
        url: "action/logout",
        dataType: "html",
        success: function(msg){
            var json = eval('('+msg+')');
            if(json.status){
                window.location=".";
            }else{
                var message=json.error;
                $("#errormsg").html("<div class='ui-state-error ui-corner-all' style='padding:3px;'> "+
                    "<span class='ui-icon ui-icon-alert' style='float: left; margin-right: .3em;'></span>"+ 
                    message+"</div>"
                    );
            }
        }
    });
    
}

function activateuser(username, value){
    var data="user="+username;
    if(!value){
        data += "&inactive";
    }
    $.ajax({
        type: "POST",
        url: "action/active",
        data:data,
        dataType: "html",
        success: function(msg){
            var json = eval('('+msg+')');
            if(json.status){
                window.location="?id="+UTIL.param('id');
            }
        }
    });
              
}
