
function ContactFrmSubmit()
  {
    var fname = docElem('ContFormName');
    var femail = docElem('ContFormEmail');
    var fphone = docElem('ContFormPhone');
    var fsubj = docElem('ContFormSubj');
    var fmsg = docElem('ConfFormMsg');
	var fchallenge = docElem('recaptcha_challenge_field');
	var fresponse = docElem('recaptcha_response_field');
	
    var fromname = fname.value = trim(fname.value);
    var fromemail = femail.value = trim(femail.value);
    var phone = fphone.value = trim(fphone.value);
    var subj = fsubj.value = trim(fsubj.value);
    var msg = fmsg.value = trim(fmsg.value);
	var challenge = fchallenge.value = trim(fchallenge.value);
	var response = fresponse.value = trim(fresponse.value);

    if (!fromname.length)
      { alert('Please enter your name'); fname.focus(); return false; }

    if (!msg.length)
      { alert('Please enter a message'); fmsg.focus(); return false; }

    var args = new Array();
    args['FromName'] = fromname;
    args['FromEmail'] = fromemail;
    args['Phone'] = phone;
    args['Subject'] = subj;
    args['Message'] = msg;
	args['Challenge'] = challenge;
	args['Response'] = response;
	
    kjax('SendContactEmail', args, 'ContactFrmSubmitOK', 'ContactFrmSubmitFAIL',0);
  }


function ContactFrmSubmitOK(result)
  {
    var fsubj = docElem('ContFormSubj');
    var fmsg = docElem('ConfFormMsg');
    alert('Message sent - thank you');
    fsubj.value = '';
    fmsg.value = '';
  }


function ContactFrmSubmitFAIL(result)
  {

if(result["error"]=="Incorrect captcha") alert("You have not entered the spam protection text correctly");
else alert_r('ERROR:',result);
//    alert('Sorry, your message could not be sent\n\n'+result['error']);
  }