function validateemail(addr) {
var invalidChars = '\/\'\\ ";:?!()[]\{\}^|';
for (i=0; i<invalidChars.length; i++) {
   if (addr.indexOf(invalidChars.charAt(i),0) > -1) {
       return false;
   }
}
for (i=0; i<addr.length; i++) {
   if (addr.charCodeAt(i)>127) {
         return false;
   }
}

var atPos = addr.indexOf('@',0);
if (atPos == -1) {
     return false;
}
if (atPos == 0) {
     return false;
}
if (addr.indexOf('@', atPos + 1) > - 1) {
     return false;
}
if (addr.indexOf('.', atPos) == -1) {
     return false;
}
if (addr.indexOf('@.',0) != -1) {
     return false;
}
if (addr.indexOf('.@',0) != -1){
     return false;
}
if (addr.indexOf('..',0) != -1) {
     return false;
}
var suffix = addr.substring(addr.lastIndexOf('.')+1);
if (suffix.length != 2 && suffix != 'com' && suffix != 'net' && suffix != 'org' && suffix != 'edu' && suffix != 'int' && suffix != 'mil' && suffix != 'gov' & suffix != 'arpa' && suffix != 'biz' && suffix != 'aero' && suffix != 'name' && suffix != 'coop' && suffix != 'info' && suffix != 'pro' && suffix != 'museum') {
     return false;
}
return true;
}

function checkinput(e)
{
var unicode=e.charCode? e.charCode : e.keyCode;
var okay = false;
if(unicode==8)
//backspace
okay = true;
if(unicode==9)
//tab
okay = true;
else if (unicode>47 && unicode<58)
okay = true;
//all numbers
else if(unicode>96 && unicode<123)
//all lower case letters
okay = true;
return okay;
}

function validateform(form)
{
var arruba = "@";
var blank = "";
var name = form.name.value;
var phone = form.phone.value;
var email = form.email.value;
var stringindex = email.indexOf(arruba);
var subject = form.subject.value;
var message = form.message.value;

if (name == blank)
{
alert("Name cannot be blank. Please try again");
form.name.focus();
return false;
}
if (phone == blank)
{
alert("Phone cannot be blank. Please try again");
form.phone.focus();
return false;
}
if (email == blank)
{
alert("Email cannot be blank. Please try again");
form.email.focus();
return false;
}

if (validateemail(email)==false)
{
alert("Your email address does not look like a normal email address. Please try again");
form.email.value=blank;
form.email.focus();
return false;
}

if (subject == blank)
{
alert("Subject cannot be blank. Please try again");
form.subject.focus();
return false;
}

if (message == blank)
{
alert("Message cannot be blank. Please try again");
form.message.focus();
return false;
}



return true;
}
