// Newsletter Signup - AW, 15/04/2008 //

demo = {
	
	request : function() {

		$('.contact').toggle();
		$('#newsletter_title').hide();
		$('#contact_errmsg').hide();
		$.post(_root + 'ajax/requestdemo.php', 
			   'title='            + $('#title').attr('value') + 
			   '&firstname='       + escapeData($('#firstname').attr('value')) + 
			   '&surname='         + escapeData($('#surname').attr('value')) + 
			   '&email='           + escapeData($('#email').attr('value')) + 
			   '&phone='           + escapeData($('#phone').attr('value')) +
			   '&company='         + escapeData($('#company').attr('value')) + 
			   '&checkdemo='       + $('#checkdemo').attr('checked') +
			   '&checknewsletter=' + $('#checknewsletter').attr('checked'),
			   this.response, 'xml'
		);
		
	},
	
	response : function(doc, status) {
		
		if (status != 'success') {
			alert(status);
			return;
		}
		
		var node = doc.firstChild.firstChild;
		var status = node.firstChild.nodeValue;
		
		if (status == 'ok') {
			$('#contact_wait').hide();
			$('#finished').show();
		} else {
			alert(status);
			$('#contact_errmsg').html('<div class="contact_errmsg_title"></div>' + 
			  '<div class="contact_errmsg">' + node.nextSibling.firstChild.nodeValue + '</div>')
				.show();
			$('.contact').toggle();		
		}
		
	}
	
};

