function pagefunctions(){
	var keyuser = localStorage.getItem('keyuser');
	$.ajax({
        type: "POST",
        crossDomain: true,
        url: 'http://m2s.es/app/api/notifications.php',
        data: {"key": keyuser},
        cache: false,
        dataType: 'json',
        success: function (result) {
		   	if (result.listnotify != null) {
			   	$('#list-notifications').html('');
		   		for (var i = 0; i < result.listnotify.length; i++) {
                    id = result.listnotify[i].id;
                    username = result.listnotify[i].username;
                    imgp = result.listnotify[i].imgp;
                    if(imgp == null){
						imgp = 'images/icon-user-default.png';
			        }
                    type = result.listnotify[i].type;
                    if (type == 'friend-request') {
                        itemlist = '<div class="item" id="fr-' + id + '">';
                    }else{
                        if (type == 'addgroup-request') {
                            itemlist = '<div class="item" id="fgr-' + id + '">';
                        }else{
                            if(type == 'message'){
                                itemlist = '<div class="item chmsmb-' + id + '">';
                            }else{
                                if(type == 'message-group'){
                                    itemlist = '<div class="item chgrmsmb-' + id + '">';
                                }else{
                                    temlist = '<div class="item">';
                                }
                            }
                        }
                    }
                    itemlist += '<img src="' + imgp + '"/>';
                    itemlist += '<div class="right-img">';
                    itemlist += '<span>' + username + '</span>';
                    if (type == 'friend-request') {
                        itemlist += ' '+Language.wantsyourfriend;
                        itemlist += '<button id="acceptfriend-' + id + '" class="btn btn-lg btn-info" onclick="acceptfriend(' + id + ')">'+Language.accept+'</button>';
                        itemlist += '<button id="blockuser-' + id + '"  class="btn btn-lg btn-danger" onclick="blockuser(' + id + ')">'+Language.block+'</button>';
                    };
                    if (type == 'message') {
                        msm = result.listnotify[i].msm;
                        itemlist += ' '+Language.saidyou+': ' + msm;
                        var url = 'chat.html?id=' + id;
                        itemlist += '<a href="' + url + '" id="close-click"><button class="btn btn-lg btn-info">'+Language.read+'</button></a>';
                    };
                    if (type == 'message-group') {
                        msm = result.listnotify[i].msm;
                        namegroup = result.listnotify[i].namegroup;
                        itemlist += ' '+Language.saidingroup+' ' + namegroup + ': ' + msm;
                        itemlist += '<a href="chatgr.html?id='+id+'"><button class="btn btn-lg btn-info">'+Language.read+'</button></a>';
                    }
                    if (type == 'addgroup-request') {
                        idgroup = result.listnotify[i].idgroup;
                        namegroup = result.listnotify[i].namegroup;
                        itemlist += ' '+Language.joinyourgroup+' ' + namegroup;
                        itemlist += '<button onclick="acceptgrj(' + idgroup + ',' + id + ')" id="acceptpeogroup-' + id + '" class="btn btn-lg btn-info">'+Language.accept+'</button>';
                        itemlist += '<button onclick="blockgrj(' + idgroup + ',' + id + ')" id="blockpeogroup-' + id + '" class="btn btn-lg btn-danger">'+Language.block+'</button>';
                    }
                    itemlist += '</div></div>';
                    $('#list-notifications').append(itemlist);
                }
			}else{
				document.location.href = localStorage.getItem('lasturl');
			}
		},
		error: function (XMLHttpRequest, textStatus, errorThrown) {
            console.error(textStatus + ' ' + XMLHttpRequest.status);
        }
	})
}