/*
* Login
*/
var login = function(data) {
    var cts = $("#logincontent").html();
    $("#logincontent").html("Please Wait..."); 
    $.post("?act=login",data,function(json) {
        // alert(json);
        if(json.code) {
            $("#feedback").html(json.text);
            if(json.redirect!="" && json.code==1) 
            	setTimeout(function(){location.href=json.redirect},800);
            else if(json.code==1) 
            	setTimeout(function(){location.href="?q=users.profile"},800);
            else if(json.code==3)
            	location.reload(true);
        } else
            $("#logincontent").html(cts+" "+json.text);
    },"json");
};

/*
* Logout
*/
$._logout = function() {
	$.getJSON("?act=logout");
};

/*
* Register
*/
$._register = function(data) {
	//alert(data);
	$.post("?act=postuser",data,function(json){
		if(json.code) {
			$('#regconts').html($('#regconf').html());
			setTimeout(function(){location.href="?q=users.profile"},4000);
		}
		else alert(json.error);
	},"json");
};

/*
* Edit a profile
*/
$._reprofile = function(data) {
	
	$.post("?act=reprofile",data,function(json){
		if(json.code) location.href="?q=users.profile";
		$("#feedback").html(json.text);
	},"json");
};

/*
* Change the user password 
*/
$._xpassword = function(data) {
	$.post("?act=xpassword",data,function(json){
		if(json.code) $('#passcont').html($('#passconf').html());
		$("#feedback1").html(json.text);
	},"json");
}





