// JavaScript Document
function setFocus() {
        document.frmThisForm.name.focus();
}

function emptyField(txtValue) {
        if (txtValue.length == 0) return true;
          for (var i=0; i < txtValue.length; ++i) {
                var ch = txtValue.charAt(i);
                if (ch != ' ' && ch != '\t') return false;
          }
          return true;
}

function Check(Word) {
        a = Word.indexOf("<");
        b = Word.indexOf(">");
        if(a != -1)
        return true;
        if(b != -1)
        return true;
}

function validate(theForm){

        if (Check(theForm.enquiry.value)){
                alert('HTML tags such as < and > found in enquiry text. Please remove and try again');
                theForm.enquiry.focus();
                return false;
        }

        if (emptyField(theForm.name.value)){
                alert('Please enter your name, we prefer to deal on a more personal level');
                theForm.name.focus();
                return false;
    }
        if (emptyField(theForm.email.value)){
                alert('Please enter your email address so that we can reply to your enquiry');
                theForm.email.focus();
                return false;
          }

        if (emptyField(theForm.phone.value)){
                alert('Please enter a contact phone number, just put xxx if you do not want us to call you');
                theForm.phone.focus();
                return false;
        }

        if (emptyField(theForm.enquiry.value)){
                alert('Please enter your enquiry, there is not much point sending this email without it');
                theForm.enquiry.focus();
                return false;
        }

        theForm.submit();
}
