// JavaScript Document

$(document).ready(function(){
					   
	// password reset link handler
	$('#webinar').submit(function() {
		var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (!filter.test($('#emailaddress').val()))
			alert('Please provide a valid email address');
		else {
			$("#txtAjaxMessageBox").removeClass().addClass('messagebox').text('Processing...').fadeIn(900);
			//check the username exists or not from ajax 

			$.getJSON("webinar.php",{ company:$('#company').val(), contactname:$('#contactname').val(), phone:$('#phone').val(), email:$('#emailaddress').val(), 
									  typeofbusiness:$('#typeofbusiness').val(), comments:$('#comments').val(), datepref:$('#datepref').val()
									}, function(jsondata) 
			{
				if("SUCCESS"==jsondata.message) //if correct login detail 
				{
					$("#txtAjaxMessageBox").fadeTo(200,0.1,function() //start fading the messagebox
					{
						//add message and change the class of the box and start fading
						$(this).html('Contact request sent.').addClass('messageboxok').fadeTo(900,1);
					});
				}
				else
				{
					$("#txtAjaxMessageBox").fadeTo(200,0.1,function() //start fading the messagebox
					{
						//add message and change the class of the box and start fading
						$(this).html("Error sending contact request.<br />Please call Engleman Associates at 1-888-421-8372 for assistance").addClass('messageboxerror').fadeTo(900,1);
					});
				}
			});
		}
		return false;
	});

});