var Notification = {

     draw : function(data,n){
	 
	 var notif = new Array;
	 notif[0] = data.friendaccepted;
	 notif[1] = data.comment;
	 notif[2] = data.message;
	 notif[3] = data.friendrequest;
	 notif[4] = data.event;
	 notif[5] = data.defaut;
	 var next;
	 
        if(notif[0].notif == "" && notif[1].notif == "" && notif[2].notif == "" && notif[3].notif == "" && notif[4].notif == ""){
		
			$('#notificationArea').html(notif[5].notif);
		
		}
		else {			
				if (notif[n].notif != "") {
					$('#notificationArea').html(notif[n].notif);
					if (notif[n].urgent == 1) {
						$('#notificationArea').addClass("urgent");
						$('#notificationArea').removeClass("non_urgent");
					} else {
						$('#notificationArea').removeClass("urgent");
						$('#notificationArea').addClass("non_urgent");
					}

					var int_cookie = parseInt(n);
					int_cookie = (int_cookie+1)%5;
					var next = int_cookie+'';
					setCookie('notif',next);

				}
				else {
				var int_cookie = parseInt(n);
				int_cookie = (int_cookie+1)%5;
				var next = int_cookie+'';
				Notification.draw(data,next);
				
				}			
		}

    },

    run : function(n){

        
        $.get("/command/notification/",
                        {},
                        function(data) {Notification.draw(data,n);},
                        "json"
                     );

    }
}