//	Requires jquery.blockUI.js and jquery.form.js.

//	Removes all white space from a string and returns the new string.
function white_space(data){
	return (data).replace(/^\s*|\s*$/g,'');
}

$(function(){
	//	Processes the Resume.
	
		//	pre-submit callback
		function preSubmit(formData, jqForm, options){
			var errorMsg = '';
			
			if($("#resume_name").val() == ''){
				errorMsg += "Please enter your Name.\n";
			}
			
			if($("#resume_email").val() == ''){
				errorMsg += "Please enter your Email.\n";
			}
						
			if(errorMsg != ''){
				alert(errorMsg);
				return false;
			}
			$.blockUI({ css: { 
	            border: 'none', 
	            padding: '15px', 
	            backgroundColor: '#000', 
	            '-webkit-border-radius': '10px', 
	            '-moz-border-radius': '10px', 
	            opacity: '.5', 
	            color: '#fff' 
	        } }); 
			return true;
		}
		//	post-submit callback
		function postSubmit(responseObj, statusText){
			$.unblockUI();
			alert(white_space(responseObj.msg));
			if(white_space(responseObj.result) == 'TRUE'){
				$('#frmResume').resetForm();
			}
		}
		$("#frmResume").ajaxForm({beforeSubmit:preSubmit, success:postSubmit, url:"proc.sendResume.php", type:"post", dataType:'json'});
});