var NotificationFormatter = {
	message: function (n) { return new MessageWebNotification(n.id, n.type, n.creationDate, n.expiresIn, n.timeToLive, n.text,
			new WebProfile(	n.sender.id,
						n.sender.nick,
						n.sender.gender,
						n.sender.ageLocation,
						n.sender.avatar
				));
	},
	
	kiss: function (n) { return new KissWebNotification(n.id, n.type, n.creationDate, n.expiresIn, n.timeToLive, n.text,
			new WebProfile(	n.sender.id,
					n.sender.nick,
					n.sender.gender,
					n.sender.ageLocation,
					n.sender.avatar
			));
	},
	
	roomChat: function (n) { return new ChatRoomWebNotification(new ChatRoom(n.roomId, n.category, n.roomName, n.roomName),
			n.id, n.type, n.creationDate, n.expiresIn, n.timeToLive, n.text,
			new WebProfile(	n.sender.id,
						n.sender.nick,
						n.sender.gender,
						n.sender.ageLocation,
						n.sender.avatar
				));
	},

	chat: function (n) { return new PrivateChatWebNotification(n.notified, n.notifiedSessions, n.id, n.type, n.creationDate, n.expiresIn, n.timeToLive, n.text,
			new WebProfile(	n.sender.id,
					n.sender.nick,
					n.sender.gender,
					n.sender.ageLocation,
					n.sender.avatar
			));
	},

	comment: function (n) {
		return new CommentWebNotification(n.statusPostId,
			new WebProfile(	n.statusPostUser.id,
					n.statusPostUser.nick,
					n.statusPostUser.gender,
					n.statusPostUser.ageLocation,
					n.statusPostUser.avatar
			),
			n.id, n.type, n.creationDate, n.expiresIn, n.timeToLive, n.text,
			new WebProfile(	n.sender.id,
					n.sender.nick,
					n.sender.gender,
					n.sender.ageLocation,
					n.sender.avatar
			));
	},

	signIn: function (n) { return new SignInWebNotification(n.channel, n.id, n.type, n.creationDate, n.expiresIn, n.timeToLive, n.text,
			new WebProfile(	n.sender.id,
					n.sender.nick,
					n.sender.gender,
					n.sender.ageLocation,
					n.sender.avatar
			));
	},

	presence: function (n) { return new PresenceWebNotification(n.channel, n.online, n.id, n.type, n.creationDate, n.expiresIn, n.timeToLive, n.text,
			new WebProfile(	n.sender.id,
					n.sender.nick,
					n.sender.gender,
					n.sender.ageLocation,
					n.sender.avatar
			));
	},
	
	content: function (n) { return new ContentWebNotification(n.mediaType, n.contentId, n.encryptedContentId, n.id, n.type, n.creationDate, n.expiresIn, n.timeToLive, n.text,
			new WebProfile(	n.sender.id,
					n.sender.nick,
					n.sender.gender,
					n.sender.ageLocation,
					n.sender.avatar
			));
	},

	takenTest: function (n) { return new TakenTestWebNotification(n.id, n.type, n.creationDate, n.expiresIn, n.timeToLive, n.text,
			new WebProfile(	n.sender.id,
					n.sender.nick,
					n.sender.gender,
					n.sender.ageLocation,
					n.sender.avatar
			));
	},

	visitor: function (n) { return new VisitorWebNotification(n.id, n.type, n.creationDate, n.expiresIn, n.timeToLive, n.text,
			new WebProfile(	n.sender.id,
					n.sender.nick,
					n.sender.gender,
					n.sender.ageLocation,
					n.sender.avatar
			));
	},
	
	profileSearch: function (n) { return new ProfileSearchWebNotification(new Search(n.targetGender, n.locationId, n.location, n.minAge, n.maxAge),
			n.id, n.type, n.creationDate, n.expiresIn, n.timeToLive, n.text,
			new WebProfile(	n.sender.id,
					n.sender.nick,
					n.sender.gender,
					n.sender.ageLocation,
					n.sender.avatar
			));
	},

	status: function (n) {
		var statusTypes = {
			standard: function (n) {
				return new StandardStatusWebNotification(n.subtype, n.statusPostId, n.id, n.type, n.creationDate, n.expiresIn, n.timeToLive, n.text,
					new WebProfile(	n.sender.id,
					n.sender.nick,
					n.sender.gender,
					n.sender.ageLocation,
					n.sender.avatar
				));
			},
			
			shout: function (n) {
				return new ShoutStatusWebNotification(n.subtype, n.statusPostId, n.id, n.type, n.creationDate, n.expiresIn, n.timeToLive, n.text,
					new WebProfile(	n.sender.id,
					n.sender.nick,
					n.sender.gender,
					n.sender.ageLocation,
					n.sender.avatar
				));
			},
			
			answer: function (n) {
				return new AnswerStatusWebNotification(new Question(new WebProfile(n.questionUser.id,
						n.questionUser.nick,
						n.questionUser.gender,
						n.questionUser.ageLocation,
						n.questionUser.avatar), n.question),
					n.subtype, n.statusPostId, n.id, n.type, n.creationDate, n.expiresIn, n.timeToLive, n.text,
					new WebProfile(	n.sender.id,
						n.sender.nick,
						n.sender.gender,
						n.sender.ageLocation,
						n.sender.avatar
				));
			},
			
			photo: function (n) {
				return new PhotoStatusWebNotification(n.contentId, n.encryptedContentId, n.subtype, n.statusPostId, n.id, n.type, n.creationDate, n.expiresIn, n.timeToLive, n.text,
					new WebProfile(	n.sender.id,
					n.sender.nick,
					n.sender.gender,
					n.sender.ageLocation,
					n.sender.avatar
				));
			},
			
			video: function (n) {
				return new VideoStatusWebNotification(n.contentId, n.encryptedContentId, n.subtype, n.statusPostId, n.id, n.type, n.creationDate, n.expiresIn, n.timeToLive, n.text,
					new WebProfile(	n.sender.id,
					n.sender.nick,
					n.sender.gender,
					n.sender.ageLocation,
					n.sender.avatar
				));
			},
			
			link: function (n) {
				return new LinkStatusWebNotification(n.link, n.id, n.subtype, n.statusPostId, n.type, n.creationDate, n.expiresIn, n.timeToLive, n.text,
					new WebProfile(	n.sender.id,
					n.sender.nick,
					n.sender.gender,
					n.sender.ageLocation,
					n.sender.avatar
				));
			}
		};
		
		return statusTypes[n.subtype](n);
	}
};

// Classe base
var WebNotification = function(id, type, creationDate, expiresIn, timeToLive, text, sender) {
	this.id = id;
	this.type = type;
	this.creationDate = creationDate;
	this.expiresIn = expiresIn;
	this.timeToLive = timeToLive;
	this.text = text;
	this.sender = sender;
}

var PersistentWebNotification = function(notified, notifiedSessions, id, type, creationDate, expiresIn, timeToLive, text, sender) {
	// parent
	this.webNotification = new WebNotification(id, type, creationDate, expiresIn, timeToLive, text, sender);
	
	this.notified = notified;
	this.notifiedSessions = notifiedSessions;
};

var PrivateChatWebNotification = function (notified, notifiedSessions, id, type, creationDate, expiresIn, timeToLive, text, sender) {
	// parent
	// this.persistentWebNotification = new PersistentWebNotification(notified, notifiedSessions, id, type, creationDate, expiresIn, timeToLive, text, sender);
	this.webNotification = new WebNotification(id, type, creationDate, expiresIn, timeToLive, text, sender);
	
	this.notified = notified;
	this.notifiedSessions = notifiedSessions;
	
	this.notifierFormat = function () {
		return '<a href="javascript:UserActions.acceptChat(\'' + this.webNotification.id + '\', \'' + this.webNotification.sender.profile_id + '\', \'' + this.webNotification.sender.nick + '\');" class="accetta" title="chatta"><span>chatta</span></a>' + 
				'<a href="javascript:UserActions.rejectChat(\'' + this.webNotification.id + '\');" class="elimina" title="elimina"><span>elimina</span></a>';
	};
	
	this.popupFormat = function () {
		return RtfUtilities.createAvatar(this.webNotification.sender, this.webNotification.id) +
				RtfUtilities.createNick(this.webNotification.sender.nick) + '<br/>' +
				'ti invita in chat' +
				'<div class="actions"><a href="javascript:UserActions.acceptChat(\'' + this.webNotification.id + '\', \'' + this.webNotification.sender.profile_id + '\', \'' + this.webNotification.sender.nick + '\');" class="accetta" title="chatta"><span>chatta</span></a>' + 
				'<a href="javascript:UserActions.rejectChat(\'' + this.webNotification.id + '\');" class="elimina" title="elimina"><span>elimina</span></a></div>';
	};
}

var ChatRoomWebNotification = function (chatRoom, id, type, creationDate, expiresIn, timeToLive, text, sender) {
	// parent
	this.webNotification = new WebNotification(id, type, creationDate, expiresIn, timeToLive, text, sender);
	
	this.chatRoom = chatRoom;
	
	this.popupFormat = function () {
		return RtfUtilities.createAvatar(this.webNotification.sender, this.webNotification.id) +
				RtfUtilities.createNick(this.webNotification.sender.nick) + '<br/>' +
				'è in chat nella stanza ' +
				'<a href="javascript:Utilities.openChatRoom(' + this.chatRoom.id + ', \'' + this.chatRoom.name + '\', \'' + this.chatRoom.title + '\');" title="Entra in stanza">' + this.chatRoom.name + '</a>';		
	};
}

var ContentWebNotification = function (mediaType, contentId, encryptedContentId, id, type, creationDate, expiresIn, timeToLive, text, sender) {
	// parent
	this.webNotification = new WebNotification(id, type, creationDate, expiresIn, timeToLive, text, sender);
	
	this.mediaType = mediaType;
	this.contentId = contentId;
	this.encryptedContentId = encryptedContentId;
	
	this.rtsFormat = function () {
		return RtfUtilities.createAvatar(this.webNotification.sender, this.webNotification.id) +
				RtfUtilities.createNick(this.webNotification.sender.nick) + ' ' +
				'ha aggiunto un' + ((this.mediaType == 'photo') ? 'a foto' : ' video') + ' al suo profilo' +
				'<span class="timestamp">' + Utilities.prettyDate(this.webNotification.creationDate) + '</span>';
	};
	
	this.rtfFormat = function () {
		return RtfUtilities.createAvatar(this.webNotification.sender, this.webNotification.id) +
		'<div class="detail">' +
		RtfUtilities.createNick(this.webNotification.sender.nick) + ' ha pubblicato un nuovo ' +
			'<a href="http://' + this.webNotification.sender.nick + '.' + conf.domain + '/gallery/' + this.mediaType +'_detail/1/' + this.contentId + '" title="' + this.webNotification.text + '">CONTENUTO</a>' +
			'<div class="preview">' +
				'<a title="' + this.webNotification.text + '"' +
						"href='javascript:OverlayConfiguration.viewer.showPhoto(\"" + this.encryptedContentId + "\");'>" +
					'<img alt="' + this.webNotification.text + '" src="' + Utilities.getUrlByContentId(this.encryptedContentId) + '"/>' +
				'</a>' +
			'</div>' +
			'<div class="type content"></div>' +
			RtfUtilities.createFooter(this.webNotification.id, this.webNotification.sender, this.webNotification.creationDate, this.contentId, this.mediaType) +
		'</div>';
	}
}

var VisitorWebNotification = function (id, type, creationDate, expiresIn, timeToLive, text, sender) {
	// parent
	this.webNotification = new WebNotification(id, type, creationDate, expiresIn, timeToLive, text, sender);
	
	this.rtsFormat = function () {
		return RtfUtilities.createAvatar(this.webNotification.sender, this.webNotification.id) +
				RtfUtilities.createNick(this.webNotification.sender.nick) + ' ' +
				'ha visitato il tuo profilo' + 
				'<span class="timestamp">' + Utilities.prettyDate(this.webNotification.creationDate) + '</span>';
	};
	
	this.rtfFormat = function () {
		return RtfUtilities.createAvatar(this.webNotification.sender, this.webNotification.id) +
		'<div class="detail">' +
		RtfUtilities.createNick(this.webNotification.sender.nick) + ' ha visitato il tuo profilo' +
			'<div class="type visitor"></div>' +
			RtfUtilities.createFooter(this.webNotification.id, this.webNotification.sender, this.webNotification.creationDate) +
		'</div>';
	};

	this.popupFormat = function () {
		return RtfUtilities.createAvatar(this.webNotification.sender, this.webNotification.id) +
			RtfUtilities.createNick(this.webNotification.sender.nick) + '<br/>' +
			'ha visitato il tuo profilo';
	};
}

var ProfileSearchWebNotification = function (search, id, type, creationDate, expiresIn, timeToLive, text, sender) {
	// parent
	this.webNotification = new WebNotification(id, type, creationDate, expiresIn, timeToLive, text, sender);
	
	this.search = search;
	
	this.rtsFormat = function () {
		return RtfUtilities.createAvatar(this.webNotification.sender, this.webNotification.id) +
				RtfUtilities.createNick(this.webNotification.sender.nick) + ' ' +
				this._formatString() +
				'<span class="timestamp">' + Utilities.prettyDate(this.webNotification.creationDate) + '</span>';
	};
	
	this.rtfFormat = function () {
		return RtfUtilities.createAvatar(this.webNotification.sender, this.webNotification.id) +
		'<div class="detail">' +
		RtfUtilities.createNick(this.webNotification.sender.nick) +
		this._formatString() +
		'<div class="type search"></div>' +
			RtfUtilities.createFooter(this.webNotification.id, this.webNotification.sender, this.webNotification.creationDate) +
		'</div>';
	};
	
	this.popupFormat = function () {
		return RtfUtilities.createAvatar(this.webNotification.sender, this.webNotification.id) +
				RtfUtilities.createNick(this.webNotification.sender.nick) + '<br/>' +
				this._formatString();		
	};
	
	this._formatString = function () {
		return ' sta cercando ' + (!this.search.minAge || this.search.minAge < 30 ? ('ragazz' + (this.search.tGender == 'M' ? 'i' : 'e')) : (this.search.tGender == 'M' ? 'uomini' : 'donne')) +
		(this.search.location ? ' di ' + this.search.location : '') +
		(this.search.minAge && this.search.maxAge ? ' tra ' + this.search.minAge + ' e ' + this.search.maxAge + ' anni ' : '');
	};
}

var SignInWebNotification = function (channel, id, type, creationDate, expiresIn, timeToLive, text, sender) {
	// parent
	this.webNotification = new WebNotification(id, type, creationDate, expiresIn, timeToLive, text, sender);
	
	// TODO: modificare una volta impostato il canale
	this.channel = (channel ? channel : 'web');
	
	this.rtsFormat = function () {
		return RtfUtilities.createAvatar(this.webNotification.sender, this.webNotification.id) +
				RtfUtilities.createNick(this.webNotification.sender.nick) + ' ' +
				'si è appena iscritt' + (this.webNotification.sender.gender == 'M' ? 'o ' : 'a ') +
				(this.channel ? ' tramite ' + this.channel : '') +
				'<span class="timestamp">' + Utilities.prettyDate(this.webNotification.creationDate) + '</span>';
	};
	
	this.rtfFormat = function () {
		return RtfUtilities.createAvatar(this.webNotification.sender, this.webNotification.id) +
		'<div class="detail">' +
		RtfUtilities.createNick(this.webNotification.sender.nick) + ' ' +
		'si è appena iscritt' + (this.webNotification.sender.gender == 'M' ? 'o ' : 'a ') +
		// ' tramite ' + this.channel +
			'<div class="type signIn"></div>' +
			RtfUtilities.createFooter(this.webNotification.id, this.webNotification.sender, this.webNotification.creationDate) +
		'</div>';
	};
}

var PresenceWebNotification = function (channel, online, id, type, creationDate, expiresIn, timeToLive, text, sender) {
	// parent
	this.webNotification = new WebNotification(id, type, creationDate, expiresIn, timeToLive, text, sender);
	
	this.channel = channel;
	this.online = online;
	
	this.rtsFormat = function () {
		return RtfUtilities.createAvatar(this.webNotification.sender, this.webNotification.id) +
				RtfUtilities.createNick(this.webNotification.sender.nick) + ' ' +
				'è andat' + (this.webNotification.sender.gender == 'M' ? 'o ' : 'a ') + ((this.online) ? 'on' : 'off') + 'line!' +
				(this.channel && this.channel != 'web' ? ' da ' + this.channel : '') +
				'<span class="timestamp">' + Utilities.prettyDate(this.webNotification.creationDate) + '</span>';
	};
	
	this.rtfFormat = function () {
		return RtfUtilities.createAvatar(this.webNotification.sender, this.webNotification.id) +
			'<div class="detail">' +
			RtfUtilities.createNick(this.webNotification.sender.nick) + ' ' +
			'è andat' + (this.webNotification.sender.gender == 'M' ? 'o ' : 'a ') + ((this.online) ? 'on' : 'off') + 'line!' +
			// (this.channel && this.channel != 'web' ? ' da ' + this.channel : '') +
				'<div class="type presence"></div>' +
				// RtfUtilities.createFooter(this.webNotification.id, this.webNotification.sender, this.webNotification.creationDate) +
				'<div>' +
					'<div class="timestamp">' + Utilities.prettyDate(this.webNotification.creationDate) + (this.channel && this.channel != 'web' ? ' - via ' + this.channel.toUpperCase() : '') + '</div>' +
					RtfUtilities.createActions(this.webNotification.id, this.webNotification.sender) +
				'</div>' +
				(Utilities.isUserHome() ? RtfUtilities.createComments(this.webNotification.id, 0) : '');
			'</div>';
	};

	this.popupFormat = function () {
		return RtfUtilities.createAvatar(this.webNotification.sender, this.webNotification.id) +
		RtfUtilities.createNick(this.webNotification.sender.nick) + '<br/>' +
		'è andat' + (this.webNotification.sender.gender == 'M' ? 'o ' : 'a ') + ((this.online) ? 'on' : 'off') + 'line!' +
		(this.channel && this.channel != 'web' ? ' da ' + this.channel : '');
	};
}

var MessageWebNotification = function (id, type, creationDate, expiresIn, timeToLive, text, sender) {
	// parent
	this.webNotification = new WebNotification(id, type, creationDate, expiresIn, timeToLive, text, sender);
	
	this.notifierFormat = function (notifyId, notifyType) {
		return '<a href="javascript:UserActions.readMessage(\'' + this.webNotification.id + '\', \'' + this.webNotification.type + '\');" class="leggi" title="leggi il messaggio"><span>leggi il messaggio</span></a>'; 
				// '<a href="javascript:UserActions.deleteMessage(\'' + this.webNotification.id + '\', \'' + this.webNotification.type + '\');" class="elimina" title="elimina"><span>elimina</span></a>';
	};

	this.popupFormat = function () {
		return RtfUtilities.createAvatar(this.webNotification.sender, this.webNotification.id) +
		RtfUtilities.createNick(this.webNotification.sender.nick) + '<br/>' +
		'ti ha inviato un messaggio' +
		'<div class="actions"><a href="javascript:UserActions.readMessage(\'' + this.webNotification.id + '\');" class="leggi" title="leggi il messaggio"></a>' + 
		// '<a href="javascript:UserActions.deleteMessage(\'' + this.webNotification.id + '\');" class="elimina" title="elimina"></a>' +
		'</div>';
	};
}

var TakenTestWebNotification = function (id, type, creationDate, expiresIn, timeToLive, text, sender) {
	// parent
	this.webNotification = new WebNotification(id, type, creationDate, expiresIn, timeToLive, text, sender);
	
	this.rtsFormat = function () {
		return RtfUtilities.createAvatar(this.webNotification.sender, this.webNotification.id) +
				RtfUtilities.createNick(this.webNotification.sender.nick) + ' ' +
				'ha completato un test di compatibilità' +
				'<span class="timestamp">' + Utilities.prettyDate(this.webNotification.creationDate) + '</span>';
	};
	
	this.rtfFormat = function () {
		return RtfUtilities.createAvatar(this.webNotification.sender, this.webNotification.id) +
		'<div class="detail">' +
		RtfUtilities.createNick(this.webNotification.sender.nick) + ' ha completato un test di compatibilità' +
			'<div class="type takenTest"></div>' +
			RtfUtilities.createFooter(this.webNotification.id, this.webNotification.sender, this.webNotification.creationDate) +
		'</div>';
	};
}

var CommentWebNotification = function (statusPostId, statusPostUser, id, type, creationDate, expiresIn, timeToLive, text, sender) {
	// parent
	this.webNotification = new WebNotification(id, type, creationDate, expiresIn, timeToLive, text, sender);
	
	this.statusPostId = statusPostId;
	this.statusPostUser = statusPostUser;
	
	this.rtsFormat = function () {
		return RtfUtilities.createAvatar(this.webNotification.sender, this.webNotification.id) +
				RtfUtilities.createNick(this.webNotification.sender.nick) + ' ' +
				'ha aggiunto un nuovo commento' +
				'<span class="timestamp">' + Utilities.prettyDate(this.webNotification.creationDate) + '</span>';
	};
	
	this.rtfFormat = function () {
		return RtfUtilities.createAvatar(this.webNotification.sender, this.webNotification.id) +
			'<div class="detail">' +
			RtfUtilities.createNick(this.webNotification.sender.nick) + 
				' ha commentato uno <a href="http://' + this.webNotification.sender.nick + '.' + conf.domain + '/home/index/single_status/' + this.statusPostId + '">status</a> di ' + this.statusPostUser.nick +
				'<div class="type comment"></div>' +
				RtfUtilities.createFooter(this.webNotification.id, this.webNotification.sender, this.webNotification.creationDate) +
			'</div>';
	};	
}

var KissWebNotification = function (id, type, creationDate, expiresIn, timeToLive, text, sender) {
	// parent
	this.webNotification = new WebNotification(id, type, creationDate, expiresIn, timeToLive, text, sender);
	
	this.notifierFormat = function (notifyId, notifyType) {
		return '<a href="javascript:UserActions.readKiss(\'' + this.webNotification.id + '\');" class="leggi" title="Guarda il bacio"><span>Guarda il bacio</span></a>'; 
				// '<a href="javascript:UserActions.rejectKiss(\'' + this.webNotification.id + '\');" class="elimina" title="elimina"><span>elimina</span></a>';
	};

	this.popupFormat = function () {
		return RtfUtilities.createAvatar(this.webNotification.sender, this.webNotification.id) +
		RtfUtilities.createNick(this.webNotification.sender.nick) + '<br/>' +
		'ti ha baciato!' +
		'<div class="actions"><a href="javascript:UserActions.readKiss(\'' + this.webNotification.id + '\');" class="leggi" title="Guarda il bacio"></a>' + 
		'</div>';
	};
}

var StatusPostWebNotification = function (subtype, statusPostId, id, type, creationDate, expiresIn, timeToLive, text, sender) {
	// parent
	this.webNotification = new WebNotification(id, type, creationDate, expiresIn, timeToLive, text, sender);
	
	this.subtype = subtype;
	this.statusPostId = statusPostId;
}

var StandardStatusWebNotification = function (subtype, statusPostId, id, type, creationDate, expiresIn, timeToLive, text, sender) {
	// parent
	// this.statusWebNotification = new StatusPostWebNotification(subtype, id, type, creationDate, expiresIn, timeToLive, text, sender);
	this.webNotification = new WebNotification(id, type, creationDate, expiresIn, timeToLive, text, sender);
	this.subtype = subtype;
	this.statusPostId = statusPostId;

	this.rtfFormat = function () {
		return RtfUtilities.createAvatar(this.webNotification.sender, this.webNotification.id) +
			'<div class="detail">' +
			RtfUtilities.createNick(this.webNotification.sender.nick) + ' sta pensando "' + this.webNotification.text + '"' +
				'<div class="type standard"></div>' +
				RtfUtilities.createFooter(this.webNotification.id, this.webNotification.sender, this.webNotification.creationDate, this.statusPostId) +
			'</div>';
	};
}

var ShoutStatusWebNotification = function (subtype, statusPostId, id, type, creationDate, expiresIn, timeToLive, text, sender) {
	// parent
	// this.statusWebNotification = new StatusPostWebNotification(subtype, id, type, creationDate, expiresIn, timeToLive, text, sender);
	this.webNotification = new WebNotification(id, type, creationDate, expiresIn, timeToLive, text, sender);
	this.subtype = subtype;
	this.statusPostId = statusPostId;
	
	this.rtfFormat = function () {
		return RtfUtilities.createAvatar(this.webNotification.sender, this.webNotification.id) +
			'<div class="detail">' +
				RtfUtilities.createNick(this.webNotification.sender.nick) + ' ' + this.webNotification.text +
				'<div class="type shout"></div>' +
				RtfUtilities.createFooter(this.webNotification.id, this.webNotification.sender, this.webNotification.creationDate, this.statusPostId) +
			'</div>';
	};
}

var AnswerStatusWebNotification = function (question, subtype, statusPostId, id, type, creationDate, expiresIn, timeToLive, text, sender) {
	// parent
	// this.statusWebNotification = new StatusPostWebNotification(subtype, id, type, creationDate, expiresIn, timeToLive, text, sender);
	this.webNotification = new WebNotification(id, type, creationDate, expiresIn, timeToLive, text, sender);
	this.subtype = subtype;
	this.statusPostId = statusPostId;
	
	this.question = question;
	
	this.rtfFormat = function () {
		return '<div class="question">' +
				RtfUtilities.createAvatar(this.question.user, this.webNotification.id) +
				'<div class="detail">' + this.question.text + '</div>' +
				'</div>' +
				'<div class="answer">' +
				RtfUtilities.createAvatar(this.webNotification.sender, this.webNotification.id) +
				'<div class="detail">' +
				RtfUtilities.createNick(this.webNotification.sender.nick) + ' ' + this.webNotification.text +				
				'<div class="type answer"></div>' +
				RtfUtilities.createFooter(this.webNotification.id, this.webNotification.sender, this.webNotification.creationDate, this.statusPostId) +
			'</div></div>';
	};
}

var PhotoStatusWebNotification = function (contentId, encryptedContentId, subtype, statusPostId, id, type, creationDate, expiresIn, timeToLive, text, sender) {
	// parent
	// this.statusWebNotification = new StatusPostWebNotification(subtype, id, type, creationDate, expiresIn, timeToLive, text, sender);
	this.webNotification = new WebNotification(id, type, creationDate, expiresIn, timeToLive, text, sender);
	this.subtype = subtype;
	this.statusPostId = statusPostId;
	
	this.contentId = contentId;
	this.encryptedContentId = encryptedContentId;
	
	this.rtfFormat = function () {
		var escapedText = escape(this.webNotification.text);
		
		return RtfUtilities.createAvatar(this.webNotification.sender, this.webNotification.id) +
			'<div class="detail">' +
				RtfUtilities.createNick(this.webNotification.sender.nick) + " " + this.webNotification.text +
				'<div class="preview">' +
					'<a title="' + this.webNotification.text + '"' +
							// "href='javascript:OverlayConfiguration.viewer.showPhoto(\"" + this.encryptedContentId + "\", \"" + escapedText + "\");'>" +
					"href='javascript:OverlayConfiguration.viewer.showPhoto(\"" + this.encryptedContentId + "\");'>" +
						'<img alt="' + this.webNotification.text + '" src="' + Utilities.getUrlByContentId(this.encryptedContentId) + '"/>' +
					'</a>' +
				'</div>' +
				'<div class="type photo"></div>' +
				RtfUtilities.createFooter(this.webNotification.id, this.webNotification.sender, this.webNotification.creationDate, this.statusPostId) +
		'</div>';
	};
}

var VideoStatusWebNotification = function (contentId, encryptedContentId, subtype, statusPostId, id, type, creationDate, expiresIn, timeToLive, text, sender) {
	// parent
	// this.statusWebNotification = new StatusPostWebNotification(subtype, id, type, creationDate, expiresIn, timeToLive, text, sender);
	this.webNotification = new WebNotification(id, type, creationDate, expiresIn, timeToLive, text, sender);
	this.subtype = subtype;
	this.statusPostId = statusPostId;
	
	this.contentId = contentId;
	this.encryptedContentId = encryptedContentId;
	
	this.rtfFormat = function () {
		return RtfUtilities.createAvatar(this.webNotification.sender, this.webNotification.id) +
				'<div class="detail">' +
				'<div class="preview"><a title="' + this.webNotification.text + '" href="javascript:OverlayConfiguration.viewer.showVideo(\'' + this.encryptedContentId + '\', ' + 320 + ', ' + 240 +');"><img alt="' + this.webNotification.text + '" src="' + Utilities.getUrlByContentId(this.encryptedContentId, 494) + '"/></a></div>' +
				'<div class="type video"></div>' +
				RtfUtilities.createFooter(this.webNotification.id, this.webNotification.sender, this.webNotification.creationDate, this.statusPostId) +
		'</div>';
	};
}

var LinkStatusWebNotification = function (link, subtype, statusPostId, id, type, creationDate, expiresIn, timeToLive, text, sender) {
	// parent
	// this.statusWebNotification = new StatusPostWebNotification(subtype, id, type, creationDate, expiresIn, timeToLive, text, sender);
	this.webNotification = new WebNotification(id, type, creationDate, expiresIn, timeToLive, text, sender);
	this.subtype = subtype;
	this.statusPostId = statusPostId;
	
	this.link = link;
	
	this.rtfFormat = function () {
		return RtfUtilities.createAvatar(this.webNotification.sender, this.webNotification.id) +
			'<div class="detail">' +
				RtfUtilities.createNick(this.webNotification.sender.nick) + ' ' +
				'ha pubblicato un nuovo link' +
				'<div class="type link"></div>' +
				RtfUtilities.createFooter(this.webNotification.id, this.webNotification.sender, this.webNotification.creationDate, this.statusPostId) +
		'</div>';
	};
}

// Profile
var WebProfile = function (profile_id, nick, gender, ageLocation, avatar) {
	this.profile_id = profile_id;
	this.nick = nick;
	this.gender = (gender ? gender.toUpperCase() : 'K');
	this.ageLocation = ageLocation;
	this.avatar = avatar;
}

// Question
var Question = function (questionUser, question, questionId) {
	this.user = questionUser;
	this.text = question;
	this.id = questionId;
}

// ChatRoom
var ChatRoom = function (id, category, name, title) {
	this.id = id;
	this.category = category;
	this.name = name;
	this.title = title;
}

// Search
var Search = function (tGender, locationId, location, minAge, maxAge) {
	this.tGender = tGender;
	this.locationId = locationId;
	this.location = location;
	this.minAge = minAge;
	this.maxAge = maxAge;	
}