function ThankYou() {
 if (!checkForm()) return;
   document.forms.frmContactUs.action = "ntgetus.php";
   document.forms.frmContactUs.submit();
}
function checkForm(){
    var lReturn = true;
    var eEMsg  = document.getElementById("msgEmail");
    var eEMsg2 = document.getElementById('msgEmail2');
    makeVisible(document.frmContactUs.Name);
    makeVisible(document.frmContactUs.Email);
    makeVisible(document.frmContactUs.Message);
    eEMsg2.style.display = "none";
    if (   document.frmContactUs.Name.value     == ""
        || document.frmContactUs.Message.value  == ""
		|| document.frmContactUs.Email.value    == ""
		)
		{
      lReturn = false;
   } 
   if ((document.frmContactUs.Email.value != "") && !emailCheck(document.frmContactUs.Email.value)) {
     if (eEMsg.style.display == "none")
       {eEMsg2.style.display = "block";}
     lReturn = false;
   }
   return(lReturn);
}
function makeVisible (obj) {
   var cDisplay = 'none';
   var cID = "msg" + obj.name;
   var e = document.getElementById(cID);
   if ((obj.type == 'text') || (obj.type == 'textarea')) {
     if (obj.value == "") {cDisplay = 'block';}
   }
   else {
     cDisplay = 'block';
   }
   e.style.display = cDisplay;
}
function emailCheck(emailStr){
   var emailPat=/^(.+)@(.+)$/;
   var quotedUser='(\"[^\"]*\")';
   var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
   var validChars="\[^\\s" + specialChars + "\]";
   var atom=validChars + "+";
   var word="(" + atom + "|" + quotedUser + ")";
   var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
   var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
   var matchArray=emailStr.match(emailPat);
   if (matchArray==null) {
   /*  alert("Email (check @ and .'s)");*/
     return false;
   }
   return true;
}

function refreshState(stateValue) {
   var iSelect = document.frmContactUs.lstCountry.selectedIndex;
   for (i=document.frmContactUs.lstState.options.length - 1; i>0; i--) {
       document.frmContactUs.lstState.options[i] = null;
   }	   
   for (i=0; i<StateArray[iSelect].length; i++) {
       document.frmContactUs.lstState.options[i] = new Option(StateArray[iSelect][i].text);
       document.frmContactUs.lstState.options[i].value = StateArray[iSelect][i].text;
   }
   if (stateValue !== "") {
     for (i=document.frmContactUs.lstState.options.length - 1; i>0; i--) {
	   if (document.frmContactUs.lstState.options[i].text == stateValue)
         {document.frmContactUs.lstState.options[i].selected = true;}
     }	   
   }
}
