

// Submit button lenyomasa eseten

function checkdata(theForm){

// marka, tipus, cm3, evjarat, futottkm, ar, felado, tel, email, www, megj

	var errors="";
	var error=false;
       // nev
        if(theForm.nev.value.length == 0){
                errors+="<li>n&eacute;v &uuml;res</li>";
                error=true;
        }
       // cim
        if(theForm.cim.value.length == 0){
                errors+="<li>c&iacute;m &uuml;res</li>";
                error=true;
        }
	// email
	if (! isValidEmailAddress(theForm.email.value)){
		errors+="<li>az email c&iacute;m hib&aacute;s vagy &uuml;res</li>";
                error=true;
	}
// jegyrendelesek ellenorzese
//	if (theForm.dbutalalldays.value.length == 0 && theForm.dbutalfirstday.value.length == 0 && theForm.dbutalsecondday.value.length == 0 && theForm.dbhelyszinalldays.value.length == 0 && theForm.dbhelyszinfirstday.value.length == 0 && theForm.dbhelyszinsecondday.value.length == 0 ){
//		errors+="<li>nincs jegy rendelve</li>";
//		error=true;
//	}

if(! theForm.megertettem.checked){
                errors+="<li>nem fogadta el a lemond&aacute;s felt&eacute;teleit!</li>";
                error=true;
        }

	// ha hibas volt valami.
	if(error==true){
		nincsWin=window.open('error.html','win','toolbar=no,scrollbars=no,width=400,height=200');
		nincsWin.document.write("<table bgcolor=#BD001C width=100%><tr><td><font color=#ffffff>Hiba!</font></td></tr></table>");
		nincsWin.document.write(errors);
		nincsWin.document.write("<input type=button value='Bezárás' onClick='document.close();'>");
		nincsWin.document.title="Hiba";
		nincsWin.document.bgColor="ffffff";
		return false;
	} else {
		return true;
	}
};





// email cim ellenorzese.

function isValidEmailAddress(emailAddress)
{

   /* Check for empty address or invalid characters */

   if (emailAddress == "" || hasInvalidChar(emailAddress))
   {
      return false;
   }

   /* check for presence of the @ character */

   var atPos = emailAddress.indexOf("@", 1)
   if (atPos == -1)
   {
      return false;
   }
   
   /* Check that there are no more @ characters */

   if (emailAddress.indexOf("@", atPos + 1) > -1)
   {
      return false;
   }

   /* Check for the presence of a dot somewhere after @ */

   var dotPos = emailAddress.indexOf(".", atPos + 1);
   if (dotPos == -1)
   {
      return false;
   }

   /* Check for presence of two or more characters after last dot */

   var lastDotPos = emailAddress.lastIndexOf(".");
   if (lastDotPos + 3 >  emailAddress.length)
   {
      return false;
   }
   return true;
}

/*
   Return true if the given email address has an invalid character
   in it, else return false.
*/
function hasInvalidChar(emailAddress)
{
   var invalidChars = "/;:,"; // this list is not complete

   for (var k = 0; k < invalidChars.length; k++)
   {
      var ch = invalidChars.charAt(k);
      if (emailAddress.indexOf(ch) > -1)
      {
         return true;
      }
   }
   return false;
}


