function validate_supplier_addedit(oForm) {
  var reSpace = new RegExp(' ', 'g');
  var sName = (new String(oForm.name.value)).replace(reSpace, '');
  var sUsername = (new String(oForm.username.value)).replace(reSpace, '');
  var sPassword = (new String(oForm.password.value)).replace(reSpace, '');
  var sPasswordConfirm = (new String(oForm.passwordConfirm.value)).replace(reSpace, ''); 
  var sEmail = (new String(oForm.email.value)).replace(reSpace, '');
  var sErrors = 'The following errors occurred:\n';
  var bSuccess = true;

  
  if (sName.length <= 0) {
    sErrors += '- The supplier name is required.\n';
    bSuccess = false;
  }

  if (sUsername.length <= 0) {
    sErrors += '- The username is required.\n';
    bSuccess = false;
  }

  if (sPassword.length <= 0) {
    sErrors += '- A password is required.\n';
    bSuccess = false;
  }
  
  if (sPassword != sPasswordConfirm) {
    sErrors += '- The password and confirm password fields do not match.\n';
    bSuccess = false;
  }
  
  if (!checkEmail(sEmail)) {
    sErrors += '- A valid email is required.\n';
    bSuccess = false;
  }
 
  if (!bSuccess) {
    alert(sErrors);
  }
  return bSuccess;
 }
 
 
 
function s()
{

var cnt = wordCount(document.getElementById('productrange')); 
   if (cnt > 75){ 
  		alert("too many words");  
		return false;
	} 
	else
	{ 
		return true;
	}
  }


function wordCount(thing)
{  
  var txt= thing.value; 
  txt = txt.replace(/<[^>]*>/g,''); //don't count html 
  var words = txt.match(/\b\w+\b/g); //magic! 
  return words.length;
 
 }

var MaximumWords = "75";
var FormName = "formProductItem";
var TextFieldName = "productrange";
var CharactersTypedFieldName = "CharsTyped";
var CharactersLeftFieldName = "CharsLeft";
var WordsTypedFieldName = "WordsTyped";
var WordsLeftFieldName = "WordsLeft";
var WordsMonitor = 0;
var MaxWords = parseInt(MaximumWords);
var textfield = 'document.' + FormName + '.' + TextFieldName + '.value';

function WordLengthCheck(s,l) { 
WordsMonitor = 0;
var f = false;
var ts = new String();
for(var vi = 0; vi < s.length; vi++) {
	vs = s.substr(vi,1);
	if((vs >= 'A' && vs <= 'Z') || (vs >= 'a' && vs <= 'z') || (vs >= '0' && vs <= '9')) { 
		if(f == false)	{
			f = true;
			WordsMonitor++;
			if((l > 0) && (WordsMonitor > l)) {
				s = s.substring(0,ts.length);
				vi = s.length;
				WordsMonitor--;
				}
			}
		}
	else { f = false; }
	ts += vs;
	}
return s;
} // function WordLengthCheck()


function InputWordLengthCheck() {
if(MaxWords <= 0) { return; }
var currentstring = new String();
eval('currentstring = ' + textfield);
var currentlength = currentstring.length;
eval('currentstring = WordLengthCheck(' + textfield + ',' + MaxWords + ')');
if (WordsLeftFieldName.length > 0) {
	var left = MaxWords - WordsMonitor;
	if(left < 0) { left = 0; }
	eval('document.' + FormName + '.' + WordsLeftFieldName + '.value = ' + left);
	if(currentstring.length < currentlength) { eval(textfield + ' = currentstring.substring(0)'); }
	}
	if (WordsTypedFieldName.length > 0) {
	eval('document.' + FormName + '.' + WordsTypedFieldName + '.value = ' + WordsMonitor);
	if(currentstring.length < currentlength) { eval(textfield + ' = currentstring.substring(0)'); }
	}
} // function InputWordLengthCheck()

function InputLengthCheck() {
	InputWordLengthCheck();
} // function InputLengthCheck()

//-->