function Newsletter(baseUrl) {

	this._baseurl	= baseUrl;

	this.addNewsletterSubmission = function(email, text, icon) {
	
		if(this.validateNewsletterSubmission(email)) {
	
			$.ajax({
				type: "GET",
				async: false,
				url: this._baseurl + "request.php",
				data: {
							'function': 'submit',
							'email': email
						},
						success: function(transport) {
						
							var rawJSON = eval(transport);
						
							$('#' + text).text(rawJSON[0].returnMessage);
							
							if(rawJSON[0].returnCode == 1) {
								
								$('#' + text).css({ 
																							'color': '#33cc00',
																							'font-weight': 'bold'
																						});
								$('#' + icon).css('backgroundImage','url(includes/newsletter/image/succes.png)');
							
							} else if(rawJSON[0].returnCode == 2) {
					
								$('#' + text).css({ 
																							'color': '#cc9900',
																							'font-weight': 'bold'
																						});
								$('#' + icon).css('backgroundImage','url(includes/newsletter/image/warning.png)');
									
							} else if(rawJSON[0].returnCode == 3) {
								
								$('#' + text).css({ 
																							'color': '#cc0000',
																							'font-weight': 'bold'
																						});
								$('#' + icon).css('backgroundImage','url(includes/newsletter/image/error.png)');
									
							}

						}

			});
		
		}
	
	}
	
	this.validateNewsletterSubmission = function(email, text, icon) {
	
		var allow = false;
	
		$.ajax({
			type: "GET",
			async: false,
			url: this._baseurl + "request.php",
			data: {
						'function': 'validate',
						'email': email
					},
					success: function(transport) {

						if(parseInt(transport) == 1) {
						
							$('#' + text).text("Druk op enter om u aan te melden.");
							$('#' + text).css({ 
																						'color': '#33cc00'
																					});
							$('#' + icon).css('backgroundImage','url(includes/newsletter/image/succes.png)');
						
							allow = true;
							
						} else {
						
							$('#' + text).text("Dit is geen geldig e-mail adres.");
							$('#' + text).css({ 
																						'color': '#cc0000'
																					});
							$('#' + icon).css('backgroundImage','url(includes/newsletter/image/error.png)');
							
							allow = false;
						
						}

					}

		});
		
		return allow;
	
	}
	
	this.noSignupEmail = function() {
	
		var allow = false;
	
		$.ajax({
			type: "GET",
			async: false,
			url: this._baseurl + "request.php",
			data: {
						'function': 'noSignupEmail',
						'email': 'none'
					},
					success: function(transport) {

						$('#emailContentBlock_one').slideUp("slow", function() {
						
							$('#hoverDivBlack').fadeOut(1000, function() {
							
								$('#emailContentBlock_one').remove();
								$('#hoverDivBlack').remove();
							
							});
						
						});

					}

		});
	
	}
	
	this.checkIp = function(sessionId) {
	
		var allow = false;
	
		$.ajax({
			type: "GET",
			async: false,
			url: this._baseurl + "request.php",
			data: {
						'function': 'checkIp',
						'email': 'none',
						'osCsid_tommy' : sessionId
						},
					success: function(transport) {

						if(transport > 0) {
						
							allow = false;
						
						} 

						if(transport < 1) {
						
							allow = true;
						
						}

					}

		});
		
		return allow;
	
	}
	
	this.createPopupBox = function(email, classObject) {
	
		var newElem = $("<div></div>");
		newElem.attr("id", "hoverDivBlack");
		newElem.attr("style", "display: none; background-color: #000000; position: absolute; float: left; width: 100%; height: 100%; left: 0px; top: 0px; filter:alpha(opacity=50); -moz-opacity:0.5; -khtml-opacity: 0.5; opacity: 0.5;");
		$("body").append(newElem);
		newElem.fadeIn(1000, function() {
		
			var newSubElem = $("<div></div>");
			newSubElem.attr("id", "emailContentBlock_one");
			newSubElem.attr("style", "display: none; float: left; background-image: url('includes/newsletter/image/popup_nieuwsbrief_voorbeeld.png'); margin-top: 100px; position: absolute; float: left; width: 394px; height: 229px; left: 50%; margin-left: -150px; top: 0px;");
			$("body").append(newSubElem);
			newSubElem.slideDown("slow", function() {
				
				var newCancelElem = $('<div></div>');
				newCancelElem.attr('id', 'emailContentCancel_one');
				newCancelElem.click(function() {
				
					classObject.noSignupEmail();
				
				});
				
				newSubElem.append(newCancelElem);
			
				var newInputElem = $('<input type="text"></input>');
				newInputElem.attr('id', 'emailContentInput_one');
				newSubElem.keyup(function(e) {
				
					if(e.keyCode == 13) {
					
						classObject.addNewsletterSubmission($('#emailContentInput_one').val(), 'emailContentWarningText_one', 'emailContentWarningIcon_one');
					
					} else {
					
						classObject.validateNewsletterSubmission($('#emailContentInput_one').val(), 'emailContentWarningText_one', 'emailContentWarningIcon_one');
					
					}
				
				});
				
				newSubElem.append(newInputElem);
				
				var newWarningIconElem = $('<div></div>');
				newWarningIconElem.attr('id', 'emailContentWarningIcon_one');
				newSubElem.append(newWarningIconElem);
				
				var newWarningTextElem = $('<div></div>');
				newWarningTextElem.attr('id', 'emailContentWarningText_one');
				newSubElem.append(newWarningTextElem);
				
				var newOkElem = $('<input type="button"></input>');
				newOkElem.attr('id', 'emailContentOk_one');
				newSubElem.append(newOkElem);
				newOkElem.click(function() {
				
					if(classObject.validateNewsletterSubmission($('#emailContentInput_one').val(), 'emailContentWarningText_one', 'emailContentWarningIcon_one')) {
					
						classObject.noSignupEmail();
					
					}
					classObject.addNewsletterSubmission($('#emailContentInput_one').val(), 'emailContentWarningText_one', 'emailContentWarningIcon_one');
				
				});
			
			});
		
		});
	
	}

}