<!--

//alert('validate_1_8 loaded');

function validate_1_8(invar) 
{

//alert('In validate_1_8');

var formObj

formObj = document.frmSurvey;
//formObj.q1_8a.value = 'Hi';


if (invar == 0)
{
document.frmSurvey.q1_8a.value = ''
}


if (invar == 1)
{
//alert(document.frmSurvey.q1_8.length)
for (i=0; i < document.frmSurvey.q1_8.length; i++)
{
document.frmSurvey.q1_8[i].checked = false
}
}


//return false;
  
} //validate_1_8


function noenter() 
{

//alert(window.event + ' - ' + window.event.keyCode)

if (window.event && window.event.keyCode == 13)
{
//alert('Return pressed');
return false;
}
else
{
//alert('Return NOT pressed');
return true;
}

  //return !(window.event && window.event.keyCode == 13); 
}


function CheckIfNumeric(formitem) {

var str

str = formitem.value

if (str.length != 0)
{			
for (j=0; j<str.length; j++) {
if ((str.charAt(j) != "0") && (str.charAt(j) != "1") && (str.charAt(j) != "2") && (str.charAt(j) != "3") && (str.charAt(j) != "4") && (str.charAt(j) != "5") && (str.charAt(j) != "6") && (str.charAt(j) != "7") && (str.charAt(j) != "8") && (str.charAt(j) != "9"))
  {
  	  alert('The value you entered is not a number. Please check your input.');
	  formitem.value = '';
	  formitem.focus();
	  return false 
  }
  }
}
  
}// CheckIfNumeric


function checkDate_onchange_new(str,formitem) {
 
  if (str.length < 6) 
  { 
  alert("Please check the date entered. Whether you use a mmddyy or mm/dd/yy format you need at least 6 character for a valid date.");
  formitem.value = '';
  formitem.focus();
  return false 
  }
  
  var slashcount,slashonepos,slashtwopos;
  slashcount = 0;
  slashonepos = 0;
  slashtwopos = 0;
  
  for (j=0; j<str.length; j++) {
  
  if (str.charAt(j) == "/" || str.charAt(j) == "-")
  {
  slashcount = slashcount + 1;
  
  if(slashcount == 1)
  {
  slashonepos = j;
  }
  
  if(slashcount == 2)
  {
  slashtwopos = j;
  }
  
  
  // alert('slashcount = ' + slashcount); 
  if (slashcount == 1 && j == 3)
  {
  alert("Please check the date entered.");
  formitem.focus();
  return false
  }
  
 
  }
  
  
  if ((j == 0) || (j == str.length - 1))
  {
  
   if ((str.charAt(j) != "0") && (str.charAt(j) != "1") && (str.charAt(j) != "2") && (str.charAt(j) != "3") && (str.charAt(j) != "4") && (str.charAt(j) != "5") && (str.charAt(j) != "6") && (str.charAt(j) != "7") && (str.charAt(j) != "8") && (str.charAt(j) != "9"))
  {
  	  alert('Please check the date entered. It appears that you have used an invalid character "' + str.charAt(j) + '" in the date you entered.');
	    formitem.value = '00/00/0000';
  		formitem.focus();
	  return false
  }
  
  }
  else
  {
  if ((str.charAt(j) != "/") && (str.charAt(j) != "-") && (str.charAt(j) != "0") && (str.charAt(j) != "1") && (str.charAt(j) != "2") && (str.charAt(j) != "3") && (str.charAt(j) != "4") && (str.charAt(j) != "5") && (str.charAt(j) != "6") && (str.charAt(j) != "7") && (str.charAt(j) != "8") && (str.charAt(j) != "9"))
	{
	 alert('Please check the date entered. It appears that you have used an invalid character "' + str.charAt(j) + '" in the date you entered.');
	    formitem.value = '00/00/0000';
  		formitem.focus();
	  return false
	
	}
  }
  
  
  } // end of for
  
 // alert("slashcount after loop = " + slashcount);
  
   if (slashcount == 1 || slashcount > 2) 
  {
  alert("Please check the date entered. If using a '/' or '-' the date format must be mm/dd/yy, mm/dd/yyyy, m/d/yy, mm-dd-yy, mm-dd-yyyy or m-d-yy.");
  formitem.value = '00/00/0000';
  formitem.focus();
  return false 
  }
  else if  (slashcount == 0)
  {
  alert("Please check the date entered. The date format must be mm/dd/yy, mm/dd/yyyy or m/d/yy.");
  formitem.value = '00/00/0000';
  formitem.focus();
  return false 
  }
  
  
  
  
   /* 
  for (j=0; j<str.length; j++) {
    if ((j == 0) || (j == str.length - 1)) {
      if (str.charAt(j) != "/") 
	  { 
	  alert('Please check the date entered. Be sure to use the "/" in the mm/dd/yyyy format.');
	  return false 
	  }
    } else {
      if ((str.charAt(j) < "0") || (str.charAt(j) > "9")) 
	  {
	  alert("Please check the date entered. Be sure to use only numerics for month, day and year for example 01/29/2001.");
	  return false 
	  }
    }
  }

*/

/*
  var month = str.charAt(0) == "0" ? parseInt(str.substring(1,2)) : parseInt(str.substring(0,2));
  var day = str.charAt(3) == "0" ? parseInt(str.substring(4,5)) : parseInt(str.substring(3,5));
  var begin = str.charAt(6) == "0" ? (str.charAt(7) == "0" ? (str.charAt(8) == "0" ? 9 : 8) : 7) : 6;
  var year = parseInt(str.substring(begin, 10));
*/

var monthstr = str.substring(0,slashonepos);
var daystr = str.substring(slashonepos + 1,slashtwopos);
var yearstr = str.substring(slashtwopos + 1,str.length);

//alert('month -' + monthstr + '-  day -' + daystr + '- year -' + yearstr + '-');

if (monthstr.charAt(0) == "0")
{
month = eval(monthstr.charAt(1))
}
else
{
month = eval(monthstr)
}

if (daystr.charAt(0) == "0")
{
day = eval(daystr.charAt(1))
}
else
{
day = eval(daystr)
}



if ( yearstr.length == 2)
{
if (yearstr.charAt(0) == "0")
{
year = eval(yearstr.charAt(1))
}
else
{
year = eval(yearstr.charAt(0) + yearstr.charAt(1))
}
}
else if (yearstr.length == 4)
{

var yearlimit

//alert(formitem.name);

if (formitem.name == 'lastvisit_date')
{
yearlimit = 1900;
}
else
{
yearlimit = 2002;
}

//alert('year limit -' + yearlimit + '-');

if (eval(yearstr) < eval(yearlimit))
{
alert("Please check the date entered. You entered an invalid value for the year.");
 formitem.focus();
 return false
}

if (yearstr.charAt(2) == "0")
{
year = eval(yearstr.charAt(3))
}
else
{
year = eval(yearstr.charAt(2) + yearstr.charAt(3))
}
}
else
{
 alert("Please check the date entered. You entered an invalid value for the year.");
 formitem.focus();
 return false 
}


//alert('month -' + month + '- day -' + day + '- year -' + year);

//alert('month -' + month + '-\n' + 'day -' + day + '-\n' + 'year -' + year + '-\n slashcount -' + slashcount);
//return false;

  if ((day == 0) || (day == undefined) || (daystr.length = 0 || daystr.length > 2 ))
  { 
  alert("Please check the date entered. You entered an invalid value for the day.");
  formitem.focus();
  return false 
  }
  if ((month == 0 || month > 12) || (month == undefined) || (monthstr.length = 0 || monthstr.length > 2 ) ) 
  { 
  alert("Please check the date entered. You entered an invalid month.");
  formitem.focus();
  return false 
  }
  if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) {
    if (day > 31) 
	{ 
	alert("Please check the date entered. You entered an invalid day for the month you entered.");
	formitem.focus();
	return false 
	}
  } else {
    if (month == 4 || month == 6 || month == 9 || month == 11) {
      if (day > 30) 
	  { 
	  alert("Please check the date entered. You entered an invalid day for the month you entered.");
	  formitem.focus();
	  return false 
	  }
    } else {
      if (year%4 != 0) {
        if (day > 28) 
		{ 
		alert("Please check the date entered. You entered an invalid day for the month you entered.");
		formitem.focus();
		return false 
		}
      } else {
        if (day > 29) { 
		alert("Please check the date entered. You entered an invalid day for the month you entered.");
		formitem.focus();
		return false 
		}
      }
    }
  }
  
  
  return true;
}//function checkDate_onchange_new(str)

//-->