 
// JQuery
	jQuery(document).ready(function()
	{
		var options = { 
			target:        '#msg',   // target element(s) to be updated with server response 
			beforeSubmit:  showRequest,  // pre-submit callback 
			success:       showResponse,  // post-submit callback 
	 
			// other available options: 
			//url:       url         // override for form's 'action' attribute 
			//type:      post        // 'get' or 'post', override for form's 'method' attribute 
			//dataType:  null        // 'xml', 'script', or 'json' (expected server response type) 
			//clearForm: true        // clear all form fields after successful submit 
			resetForm: true        // reset the form after successful submit 
	 
			// $.ajax options can be used here too, for example: 
			//timeout:   3000 
		}; 
		
		jQuery('#frmContact').submit(function()
		{ 
			jQuery(this).ajaxSubmit(options); 
			return false; 
		}); 
	});
 
	function showRequest(formData, jqForm, options)
	{
		var queryString = jQuery.param(formData); 
		// jqForm is a jQuery object encapsulating the form element.  To access the 
		// DOM element for the form do this: 
		// var formElement = jqForm[0]; 
		//alert('About to submit: \n\n' + queryString); 
		var chk = false;
		chk = chkValid();
		
		if(chk){
			jQuery("#msg").html("<div class=\"red\">Sending...</div>");
		}
		//alert(chk);
		return chk;
	}
 
	function showResponse(responseText, statusText)
	{
		//alert('status: ' + statusText + '\n\nresponseText: \n' + responseText + '\n\nThe output div should have already been updated with the responseText.');
	} 

// chkValid
	function chkValid()
	{
		var f1 = document.getElementById('frmContact'); 
		f1.phone.value = changeValidTelephone(f1.phone.value);
		if(f1.name.value=="")
		{
			//alert("Please fill in your name.");
			jQuery("#msg").html("<div class=\"red\">Please fill in your name.</div>");
			f1.name.focus();
		  //return false;
		  chk = false;
		}
		else if(f1.email.value=='')
		{
			//alert("Please fill in your e-mail.");
			jQuery("#msg").html("<div class=\"red\">Please fill in your e-mail.</div>");
			f1.email.focus();
			//return false;
			chk = false;
		}
		else if(chkMail(f1.email.value)==false)
		{
			jQuery("#msg").html("<div class=\"red\">Wrong Email format.</div>");
			//alert("Wrong Email format.");
			f1.email.focus();
			//return false;
			chk = false;
		}
		else if(f1.turning.value=='')
		{
			jQuery("#msg").html("<div class=\"red\">Wrong Turning Key.</div>"); 
			f1.turning.focus(); 
			chk = false; 
		}
		else
		{
			//return true;
			chk = true;
		}
		return chk;
		//jQuery("#msg").html("<div class=\"green\">Wrong Email format.</div>");
	}
