// JavaScript Document
$.validator.setDefaults({
	submitHandler: function() { 
	
		var options = {
		type: "POST",
		url: "modules/contact_us/contact_us1.php",
		success: function(responseText) {

				dt1 = responseText.split("@@");
			 	
				if( Number(dt1[0]) == '1' )
			  	{
					$('#error_message').html("<span style='color:#FF0000; font-size:20px;'>"+dt1[1]+"</span>");
					$('#form1').clearForm();
				}
				else if( Number(dt1[0]) == '0' )
				{
					$('#error_message').html("<span style='color:#FF0000; font-size:20px;'>"+dt1[1]+"</span>");
					$("#code_number").focus();  
				}
				else
				{
					$('#error_message').html("<span style='color:#FF0000; font-size:20px;'>"+dt1[0]+"</span>");
				}

			}
		};
		
		$('#form1').ajaxSubmit(options);
	 
	}

});

$.fn.clearForm = function() {
  return this.each(function() {
    var type = this.type, tag = this.tagName.toLowerCase();
    if (tag == 'form')
      return $(':input',this).clearForm();
    if (type == 'text' || type == 'password' || tag == 'textarea')
      this.value = '';
    else if (type == 'checkbox' || type == 'radio')
      this.checked = false;
    else if (tag == 'select')
      this.selectedIndex = -1;
  });
};