function requiredInt(field,label,min,max)
{
	var el=document.getElementById(field);
	var val=document.getElementById(label);
	if(el.value>=min&&el.value<=max)
	{
		val.style.display="none";
		val.style.visibility="hidden";
		return true;
	}

	else
	{
		val.style.display="block";
		val.style.visibility="visible";
		if(el.focus)
			el.focus()
		return false;
	}
}

function requiredString(field,label,min,max)
{
	var el=document.getElementById(field);
	var length=el.value.length
	if(!length)
		length=0
	var val=document.getElementById(label);

	if((length>=min)&&(length<=max))
	{
		val.style.display="none";
		val.style.visibility="hidden";
		return true;
	}

	else
	{
		val.style.display="block";
		val.style.visibility="visible";
		if(el.focus)
			el.focus()
		return false;
	}
}

function validateRegex(field,label,regEx,regCase)
{
	var el=document.getElementById(field);
	var val=document.getElementById(label);
	if(regCase)
		var flags="i";
	else

		var flags="";
	re = new RegExp(regEx,flags)

	if(re.exec(el.value))
	{
		val.style.display="none";
		val.style.visibility="hidden";
		return true;
	}

	else
	{
		val.style.display="block";
		val.style.visibility="visible";
		if(el.focus)
			el.focus()
		return false;
	}
}

// Email Validation Javascript
// copyright 23rd March 2003, by Stephen Chapman, Felgall Pty Ltd

// You have permission to copy and use this javascript provided that
// the content of the script is not changed in any way.

function validateEmail(field,label,man,db) {
	var el=document.getElementById(field);
	var addr=el.value
	var val=document.getElementById(label);
	db=false;
	pass=true;
if (addr == '' && man) {
   if (db) alert('email address is mandatory');
   pass= false;
}
var invalidChars = '\/\'\\ ";:?!()[]\{\}^|';
for (i=0; i<invalidChars.length; i++) {
   if (addr.indexOf(invalidChars.charAt(i),0) > -1) {
      if (db) alert('email address contains invalid characters');
      pass= false;
   }
}
for (i=0; i<addr.length; i++) {
   if (addr.charCodeAt(i)>127) {
      if (db) alert("email address contains non ascii characters.");
      pass= false;
   }
}

var atPos = addr.indexOf('@',0);
if (atPos == -1) {
   if (db) alert('email address must contain an @');
   pass= false;
}
if (atPos == 0) {
   if (db) alert('email address must not start with @');
   pass= false;
}
if (addr.indexOf('@', atPos + 1) > - 1) {
   if (db) alert('email address must contain only one @');
   pass= false;
}
if (addr.indexOf('.', atPos) == -1) {
   if (db) alert('email address must contain a period in the domain name');
   pass= false;
}
if (addr.indexOf('@.',0) != -1) {
   if (db) alert('period must not immediately follow @ in email address');
   pass= false;
}
if (addr.indexOf('.@',0) != -1){
   if (db) alert('period must not immediately precede @ in email address');
   pass= false;
}
if (addr.indexOf('..',0) != -1) {
   if (db) alert('two periods must not be adjacent in email address');
   pass= 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') {
   if (db) alert('invalid primary domain in email address');
   pass= false;
}
if(pass)
{
	val.style.display="none";
	val.style.visibility="hidden";
	return true;
}
else
{
	val.style.display="block";
	val.style.visibility="visible";
	if(el.focus)
			el.focus()
	return false;
}
}


function validatePhone(field,label)
{
   re = /\(?\d{3}\)?([-\/\.])\d{3}\1\d{4}/
      
   var el=document.getElementById(field);
   var telNumber=el.value
   var val=document.getElementById(label);
   var pass=false;
   
   if(el.match(re))
      pass=true;
   else
   	  pass=false;
   if(pass)
   {
	   val.style.display="none";
   	   val.style.visibility="hidden";
	   return true;
   }
   else
   {
	   val.style.display="block";
	   val.style.visibility="visible";
	   if(el.focus)
		  el.focus()
	   return false;
   }
}