function validateSchoolName(id)
{
	var y = document.getElementById(id).value;

	var val_span = document.getElementById('schoolNameVal');
	
	if (y.length >= 5)
	{
		val_span.innerHTML = "";
//		val_span.style.color = "#009900";
//		val_span.style.fontWeight = "bold";
	}
	else
	{
		val_span.innerHTML = "Minimum 5 Characters";
		val_span.style.color = "#ff0000";
		val_span.style.fontWeight = "bold";
	}
}

function validatePasswordLength(id)
{
	var y = document.getElementById(id).value;

	var val_span = document.getElementById('password1Val');
	
	if (y.length < 6)
	{
		val_span.innerHTML = "Minimum 6 Characters - no whitespace";
		val_span.style.color = "#ff0000";
		val_span.style.fontWeight = "bold";
	}
	else
	{
		var pass = document.getElementById('pass1').value;
		//var pattern = new RegExp("/\s/", pass);
	
		val_span.innerHTML = "--"+pass.match(/\s/)+"--";
		
		if (pass.match(/\s/) != null)
		{
			val_span.innerHTML = "Whitespace is not allowed";
			val_span.style.color = "#ff0000";
			val_span.style.fontWeight = "bold";
		}
		else
		{
			val_span.innerHTML = "";
			val_span.style.color = "#000";
			val_span.style.fontWeight = "normal";
		}
	}
}

function validateEmailAddress(id)
{
	var y = document.getElementById(id).value;
	var val_span = document.getElementById('emailVal');

	//do the validation here
	if (validateEmailv2(y) == false)
	{
		val_span.innerHTML = "Email appears incorrect";
		val_span.style.color = "#ff0000";
		val_span.style.fontWeight = "bold";
	}
	else
	{
		val_span.innerHTML = ".sch.uk .gov .gov.uk";
		val_span.style.color = "#000";
		val_span.style.fontWeight = "normal";
	}
		
}


function validateEmailv2(email)
{
	// a very simple email validation checking. 
	// you can add more complex email checking if it helps 
	    if(email.length <= 0)
		{
		  return true;
		}
		
	    var splitted = email.match("^(.+)@(.+)$");
	    if(splitted == null) return false;
	    if(splitted[1] != null )
	    {
	      var regexp_user=/^\"?[\w-_\.]*\"?$/;
	      if(splitted[1].match(regexp_user) == null) return false;
	    }
	    if(splitted[2] != null)
	    {
	      var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
	      if(splitted[2].match(regexp_domain) == null) 
	      {
		    var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
		    if(splitted[2].match(regexp_ip) == null) return false;
	      }// if
	      return true;
	    }
	    
	    
	    
	return false;
}