function validEmail(email)
{
  var invalidChars = " /:,;";
  
  // cannot be empty
  if (email == "") {return false;}
  // does it contain any invalid characters?
  for (i=0; i<invalidChars.length; i++) 
  {
    badChar = invalidChars.charAt(i);
    if (email.indexOf(badChar,0) > -1) {return false;}
  }
  // there must be one "@" symbol
  atPos = email.indexOf("@",1);
  if (atPos == -1) {return false;}
  // only one "@" symbol
  if (email.indexOf("@",atPos+1) != -1) {return false;}
  // at least one "." after the "@"
  periodPos = email.indexOf(".",atPos);
  if (periodPos == -1) {return false;}
  // must be at least 2 characters after the "."
  if (periodPos+3 > email.length)  {return false;}
  return true;
}
//-----------------------------------------------------------
function NumericValidator (DataName2, szDesc)
{
  var checkOK = "0123456789-.";
  var checkStr = stripCharString(DataName2.value, "$,'");
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  var ch
  if ((checkStr==null) || (checkStr.length==0))
  {
    DataName2.value=0;
  }
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
      if (j == checkOK.length)
      {
        allValid = false;
        break;
      }
      if (ch == ".")
      {
        allNum += ".";
        decPoints++;
      }
      else
        allNum += ch;
  }
  if (!allValid)
  {
    alert('Please enter only numbers for the ' + szDesc);
    DataName2.focus();
    return (false);
  }
  if (decPoints > 1)
  {
    alert('Please enter a valid number. Too many decimals points in the ');
    DataName2.focus();
    return (false);
  }
  return (true);
}
//-----------------------------------------------------------
function stripCharString (InString, CharString)
{
  OutString="";
  for (Count=0; Count < InString.length; Count++)
  {
    TempChar=InString.substring (Count, Count+1);
    Strip = false;
    for (Countx = 0; Countx < CharString.length; Countx++)
    {
      StripThis = CharString.substring(Countx, Countx+1)
      if (TempChar == StripThis)
      {
        Strip = true;
        break;
      }
    }
    if (!Strip)
    {
      OutString=OutString+TempChar;
    }
  }
  return (OutString);
}
//----------------------------------------------------------
function fValidateLength(oItem,szDesc) 
{
   if(oItem.value.length == 0)
   {
      alert("Please enter a valid " + szDesc);
      oItem.focus();
      return false;
   }
   else
   {
      return true;
   }
}
function fValidateSelect(oItem,iDefault,szDesc)
{

if (oItem.name == "Q_D_89")
	{
	for (var i = 0; i < oItem.length; i++) 
	{
		if (oItem[1].selected || oItem[14].selected ||  oItem[34].selected) 
		{
		alert("You cannot select: Software, Hardware or Service Choices’ for the ‘What is your main area of business")
		return false; 
		}
	}

}
  if(oItem.selectedIndex == iDefault)
  { 
     if(szDesc!="")
     {
      alert(szDesc);
      oItem.focus();
     }
     return false;   
  }
  else
  {
     return true;
  }
}
function fValidateRadio(oItem, szDesc) 
{
  myOption = -1;
  for (i=0; i<oItem.length; i++) {
    if (oItem[i].checked) {
      myOption = i;
    }
  }
  if (myOption == -1) {
    alert(szDesc);
    return false;
  }
  return true;
}
	function popup(thisUrl,thisWidth,thisHeight,thisTop,thisLeft) {
	  optionString = ('width=' + thisWidth + ',height=' + thisHeight + ',top=' + thisTop + ',left=' + thisLeft + ',toolbar=no, location=no, directories=no,status=no,menubar=no,resizable=yes,scrollbars=yes');
	  mainWin = window.open(thisUrl,"CVN",optionString);
	  mainWin.opener = self;
	}