$(document).ready(function(){
// Show/hide form
$('#dialog').dialog( {
	autoOpen : false,
	modal : true,
	height : 550,
	width : 400,
	show : 'slow',
	overlay: { 
        opacity: 0.7, 
        background: '#73111e' 
    }
	});
	$('.requestDialog').click(function(){
		$('#dialog').dialog('open');
		return false;
	});
	$('#cancel').click(function(){
		$('#dialog').dialog('close');
		return false;
	});
	$('#close').click(function(){
		$('#dialog').dialog('close');
		return false;
	});
// Process form submission	
	$('form#modalForm').submit(function($e){
		//$e.preventDefault();
		var noSubmit = false;
		var filter = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
		var email_address = document.getElementById('email'); 
		if (!filter.test(email_address.value)) { 
		$('.no-email').show();
		noSubmit = true;
		}
		else {$('.no-email').hide();
		} 
		if (document.reqForm.fullname.value == "") { 
		$('.no-name').show(); 
		noSubmit = true;
		}
		else {$('.no-name').hide();
		}  
		if (document.reqForm.company.value == "") { 
		$('.no-company').show(); 
		noSubmit = true;
		}
		else {$('.no-company').hide();
		}
		if (document.reqForm.city.value == "") { 
		$('.no-city').show(); 
		noSubmit = true;
		}
		else {$('.no-city').hide();
		}  
		if (document.reqForm.state.value == "") { 
		$('.no-state').show(); 
		noSubmit = true;
		}
		else {$('.no-state').hide();
		} 
		if (document.reqForm.zip.value == "") { 
		$('.no-zip').show(); 
		noSubmit = true;
		}
		else {$('.no-zip').hide();
		} 
		if (document.reqForm.phone.value == "") { 
		$('.no-phone').show(); 
		noSubmit = true;
		}
		else {$('.no-phone').hide();
		} 
		if ($('input[@name=area_of_interest]:checked').size() == 0) { 
		$('.no-aoi').show(); 
		noSubmit = true;
		}
		else {$('.no-aoi').hide();
		}
		if ($('#contact_time').val() == "") { 
		$('.no-time').show(); 
		noSubmit = true;
		}
		else {$('.no-time').hide();
		}
		if (noSubmit == false){
			var formData = $('form').serialize();
			$.post('/send_request.asp',formData);
			$('form#modalForm').remove();
			$('#pleaseWait').show();
			$('#pleaseWait').html('<img src="/images/ajax-loader.gif" alt="" width="31" height="31" align="absmiddle" />&nbsp;One Moment Please')
				setTimeout( function() { $('#pleaseWait').hide() }, 3000);
				setTimeout( function() { $('#submitSuccess').show() }, 3500);
		}
		return false;
	});
});