/***********************************************************************************************/
//ø
/***********************************************************************************************/
// รูปแบบโทรศัพท์
$().ready(function() {
	$("#ord_tel").mask("999-999-9999");
});

/***********************************************************************************************/
$().ready(function() {

	var options = {
		rules: {},
		messages: {},
		submitHandler: function(form) { // call server script
			var options = {
				dataType: "json",
				beforeSubmit: showRequest,
				success: showResponse
			};
			$(form).ajaxSubmit(options);
			return false;  // always return false to prevent std. browser submit and page navigation
		}
	}

	var validateObj = $("form").validate( options ); // validate form on submit (client & server depend on options)

});

/***********************************************************************************************/

function showRequest(formData, jqForm, options) {


}

/***********************************เปลี่ยนได้แค่ตรงนี้************************************************************/

function showResponse(responseText, statusText) {

	$.each(responseText, function(key, value) { // json format
		if (key == "INSERT_SUCCESS") {
			alert(value);
		} else if (key == "INSERT_LINK_BACK") {
			window.location.href = value;
		} else if (key == "UPLOAD_ERROR") {
			alert(value);
		} else if (key == "UPDATE_LINK_BACK") {
		    window.location.href = value;
		} else {
			$("#" + key).focus().select();
			alert(value);		
		}
	});
	
}

/***********************************************************************************************/
