News = function(opt) {
	this.opt = opt;
	var me = this;
	
	/**
	* This function loads the template file
	* Next, it will load the data
	*/
	this.init = function() {
		if (this.opt.templateUrl != undefined) {
			$.ajax({
				url: this.opt.templateUrl,
				type: 'GET',
				dataType: 'html',
				success: function(data) {
					$('#'+me.opt.div).html(data);
					me.getData();
				}
			});
		} else {
			this.getData();
		}
	}
	
	this.getData = function() {
		$.ajax({
			url: this.opt.url,
			type: 'POST',
			dataType: 'json',
			data: {action: 'get_news'},
			success: function(data) {
				me.displayData(data);
			}
		});
	}
	
	this.displayData = function(data) {
		html = '<ul>';
		$.each(data, function(i, val) {
			html += '<li class="marquee"><div class="news-title">'+val.news_titre+'</div><div style="display:none;"><div class="news-body">'+val.news_body+'</div></div>';
			if (me.opt.editor != undefined) {
				html += me.opt.editor.getHtml({id:val.Id_News});
			}
			html+='<br><br><br><br><br><br></li>';
		});
		html+='</ul>';
		$('#'+this.opt.div+'-contents marquee').html(html);
		if (this.opt.editor != undefined) {
			this.opt.editor.render();
		}
		$('#'+this.opt.div+'-contents marquee').marquee().mouseover(function () {
				$(this).trigger('stop');
		}).mouseout(function () {
		  $(this).trigger('start');
		}).mousemove(function (event) {
		  if ($(this).data('drag') == true) {
		    this.scrollLeft = $(this).data('scrollX') + ($(this).data('x') - event.clientX);
		  }
		});
		
		$('.news-title').css({cursor:'pointer'}).click(function(){
			new Boxy($(this).siblings().children(), {modal:true, clone: true, title:$(this).text()});
		});
	}
}