/* Javascript */
/* Zidiot for Zidiot */
/* Author, Lucas Winckers, studio@zidiot.com */
/* Last version, December 2, 2008 */


// Zidiot contact form


// Name
// string is preset

function testName(strng) {
var error = ""; 
  if (strng == "Name and Company") {
     error = "-> You didn't enter a name and company.\n";
  }
  else if (strng.length == 0) {
     error = "-> You didn't enter a name and company.\n"
  }
return error;
}


// E-mail

function testEmail(strng) {
var error="";
if (strng == "E-mail") {
   error = "-> Please enter a valid e-mail address.\n";
}

    var emailFilter=/^.+@.+\..{2,3}$/;
    if (!(emailFilter.test(strng))) { 
       error = "-> Please enter a valid e-mail address.\n";
    }
    else {
//test email for illegal characters
       var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
         if (strng.match(illegalChars)) {
          error = "-> The e-mail address contains illegal characters.\n";
       }
    }
return error;    
}


// Phone

function testPhone(strng) {
var error = "";
if (strng == "Phone") {
   error = "-> You didn't enter a phone number.\n";
}

var stripped = strng.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters
    if (isNaN(parseInt(stripped))) {
       error = "-> The phone number contains illegal characters.";
  
    }
    if (!(stripped.length == 10)) {
	error = "-> The phone number is not in the right format. Use 10 characters, example: 010 3500000 or 06 35000000.\n";
    } 
return error;
}


// Drop down menu: Informatie

function testDropdown(choice) {
    var error = "";
    if (choice == 0) {
       error = "-> You didn't make a choice.\n";
    }
return error;
}


// Message
// string is preset

function testMessage(strng) {
var error = ""; 
  if (strng == "Message") {
     error = "-> You didn't enter a message.\n";
  }
  else if (strng.length == 0) {
     error = "-> You didn't enter a message.\n"
  }
return error;
}
