function toggleImages(id,rows,src){
	img = document.getElementById('projectImage');
	for(i=1;i<=rows;i++){
		if(document.getElementById('img'+i).className  == 'project-images-links-bottom-selected'){
			document.getElementById('img'+i).className  = 'project-images-links-bottom-not-selected';
		}
	}
	document.getElementById(id).className ='project-images-links-bottom-selected';
	img.src=src;
}

function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}


function validateContactForm(){

	var ok = 1;
	var messages='';

	if(getCheckedValue(document.forms['contact'].elements['gender']) == ""){
		//gender.className = 'wrong_info';
		messages+='Selecteer een geslacht<br>';
		ok = 0;
	}
	else{
		//gender.className = '';	
	}

	naam = document.getElementById('naam');
	if(naam.value == ''){
		naam.className = 'wrong_info';
		messages+='Uw naam is niet ingevuld<br>';
		ok = 0;
	}
	else{
		naam.className = '';	
	}
	email = document.getElementById('mail');
	if(email.value == ''){
		email.className = 'wrong_info';
		messages+='Uw e-mail adres is niet ingevuld!<br>';
		ok = 0;
	}
	else{
		email.className = '';	
	
		if(validateEmail(email.value) == 0){
			email.className = 'wrong_info';
			messages+='Uw e-mail adres is onjuist (bijv.naam@domein.nl)<br>';
			ok = 0;
		}
		else{
			email.className = '';	
		}
	}
	telephone = document.getElementById('telefoon');
	if(telephone.value == ''){
		telephone.className = 'wrong_info';
		messages+='Uw telefoonnummer is niet ingevuld<br>';
		ok = 0;
	}	
	else{
		telephone.className = '';	
	
		if(!checknumber(telephone.value)){
			telephone.className = 'wrong_info';
			messages+='Geef een geldig telefoonnummer<br>';
			ok = 0;
		}
		else{
			telephone.className = '';	
		}
	}
	if(ok==0){
		document.getElementById('contact').innerHTML=messages;
		return false
		}
		else
			return true;
}

function validateEmail(addr) {

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

      return 0;
   }
}
for (i=0; i<addr.length; i++) {
   if (addr.charCodeAt(i)>127) {

      return 0;
   }
}

var atPos = addr.indexOf('@',0);
if (atPos == -1) {

   return 0;
}
if (atPos == 0) {

   return 0;
}
if (addr.indexOf('@', atPos + 1) > - 1) {

   return 0;
}
if (addr.indexOf('.', atPos) == -1) {

   return 0;
}
if (addr.indexOf('@.',0) != -1) {
 
   return 0;
}
if (addr.indexOf('.@',0) != -1)
	return 0;
if (addr.indexOf('..',0) != -1)
	return 0;
/*
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 0;
}
*/
return 1;
}

function checknumber(phone_number){

var digits = "0123456789";
var phoneNumberDelimiters = "()- ext.";
var validWorldPhoneChars = phoneNumberDelimiters + "+";
var minDigitsInIPhoneNumber = 10;
s=stripCharsInBag(phone_number,validWorldPhoneChars);
is_ok = isInteger(s) && s.length >= minDigitsInIPhoneNumber;
if(!is_ok)
	return 0;
	else return 1;
}
function stripCharsInBag(s, bag)
{ 
	var valid_number = 1;
	var i;
	var returnString = "";
	// Search through string's characters one by one.
	// If character is not in bag, append to returnString.
	for (i = 0; i < s.length; i++)
	{
	// Check that current character isn't whitespace.
	var c = s.charAt(i);
	if (bag.indexOf(c) == -1) returnString += c;
	}
	return returnString;
	}
	function isInteger(s)
	{ var i;
	for (i = 0; i < s.length; i++)
	{
	// Check that current character is number.
	var c = s.charAt(i);
	if (((c < "0") || (c > "9"))) return false;
	}
	// All characters are numbers.
	return true;
}

