function checkEmailAddress(field) {
var goodEmail = field.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);

if (goodEmail){
return false;
} else {
return true;
}
}

function showLoginForm(){
	document.getElementById('suForm').className='show';
	//document.getElementById('username').focus();
}

function getHTTPObject()
        {
        try {
        req = new XMLHttpRequest();
          } catch (err1)
          {
          try {
          req = new ActiveXObject("Msxml12.XMLHTTP");
          } catch (err2)
          {
          try {
            req = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (err3)
            {
	req = false;
            }
          }
	}
        return req;
	}
	
var http = getHTTPObject(); // We create the HTTP Object  
var userOK = 'UNKNOWN USER';

function handlePCResponse() {
        if (http.readyState == 4) {
            userOK = http.responseText;
            if(userOK!='' && userOK!='INVALID USER') {
				document.getElementById('username').style.color= '#003366';
				document.getElementById('password').style.color= '#003366';
	        	document.getElementById('username').disabled = true;
				document.getElementById('username').disabled = true;
			  	document.loginForm.code.value = userOK;
				document.loginForm.submit();
              return true;
           }
        }
      }

function verifyPassword(field) {
	tTimer = window.setTimeout( function() { checkUserLogin(field); }, 1000);
	}

function checkUserLogin(field) {
   passWd = field.value;
   usrName = document.getElementById('username').value;
   http.open("GET", 'http://www.mcgraphic.nl/verifyUsername.php?user=' + escape(usrName) + '&password=' + escape(passWd), true);
   http.onreadystatechange = handlePCResponse;
   http.send(null);

}

function checkContactForm() {
        // First the normal form validation
        if(document.contactForm.name.value=='') {
          alert('Vult u svp uw naam in');
          document.contactForm.name.focus();
          return false;
          }
          
        if(document.contactForm.email.value=='') {
          alert('Vult u aub het veld "email" in');
          document.contactForm.email.focus();
          return false;
          }
          
        if(checkEmailAddress(document.contactForm.email)) {
          alert('Het opgegeven email-adres is niet geldig. Voert u aub uw juiste email-adres in.');
          document.contactForm.email.focus();
          return false;
          }
          
          if(document.contactForm.remarks.value=='') {
          alert('U heeft geen bericht ingevoerd.');
          document.contactForm.remarks.focus();
          return false;
          }
          

        }