﻿<!--

function isaPosNum(s) {
return (parseInt(s) >= 0)
}

function check_numbers(item, min, max) {
	var returnVal = false
	if (!isaPosNum(item.value))
	alert("Prašome įvesti teigiamą skaičių.")
	else if (parseInt(item.value) < min)
	alert("Prašome įvesti didesnį skaičių")
	else if (parseInt(item.value) > max)
	alert("Prašome įvesti mažesnį skaičių")
	else
	returnVal = true
	return returnVal
}


function testEmail(StringToTest, RequiredInTheForm, theform, varname){

	eMail=/^(\w{2,}|\w{1,}.\w{1,})(@\w{2,}.|@\w{2,}.\w{2,}.)(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)$/i;

	if (RequiredInTheForm==1 && StringToTest=="") {
		alert("Prašau įvesti el. pašto adresą.");
		eval("theform."+varname+".focus()");
		return false
	} else if (StringToTest!="" && !eMail.exec(StringToTest)) {
		alert("KLAIDA: neteisingas el. pašto adresas.");
		eval("theform."+varname+".focus()");
		return false
	} else return true
}

function validateFieldsOfOrder(theform) {

	if (theform.company.value=="") {
	alert("Prašau įvesti įmonės pavadinimą.");
	theform.company.focus();
	return false
	}

	if (theform.activity.value=="") {
	alert("Prašau nurodyti įmonės veiklos sritį.");
	theform.activity.focus();
	return false
	}

	if (theform.company_address.value=="") {
	alert("Prašau įvesti įmonės adresą");
	theform.company_address.focus();
	return false
	}

	if (theform.company_contacts.value=="") {
	alert("Įveskite bent vieną telefoną.");
	theform.company_contacts.focus();
	return false
	}

	if (!testEmail(theform.email.value,1,theform,'email')) return false

	if (theform.branches.value=="") {
		alert("Įveskite įmonės filialų skaičių.");
		theform.branches.focus();
		return false
	}

	if (!check_numbers(theform.branches, 0, 50)) {
		theform.branches.focus();
		return false
	}


	if (theform.autos.value=="") {
		alert("Prašau įvesti įmonės automobilių skaičių.");
		theform.autos.focus();
		return false
	}

	if (!check_numbers(theform.autos, 1, 100)) {
		theform.autos.focus();
		return false
	}

	if (theform.name_surname.value=="") {
	alert("Prašome nurodyti savo vardą ir pavardę.");
	theform.name_surname.focus();
	return false
	}


	if (theform.position.value=="") {
		alert("Įveskite savo pareigas.");
		theform.position.focus();
		return false
	}

	if (!theform.agree.checked){
		alert("Prašau patvirtinti, kad duomenis pateikiate laisva valia ir jie yra teisingi.");
		theform.agree.focus();
		return false
	}

	theform.submit();
	return true
}

function validateFieldsOfAtsiliepimai(theform) {

	if (theform.name_surname.value=="") {
	alert("Prašome nurodyti savo vardą ir pavardę.");
	theform.name_surname.focus();
	return false
	}

	if (theform.company_contacts.value=="") {
	alert("Įveskite bent vieną telefoną.");
	theform.company_contacts.focus();
	return false
	}

	if (!testEmail(theform.email.value,1,theform,'email')) return false

	theform.submit();
	return true
}

function validateFieldsOfOrderPrivate(theform) {

	if (theform.name_surname.value=="") {
	alert("Prašome nurodyti savo vardą ir pavardę.");
	theform.name_surname.focus();
	return false
	}

	if (theform.private_address.value=="") {
	alert("Prašau įvesti savo adresą");
	theform.private_address.focus();
	return false
	}


	if (theform.private_phones.value=="") {
	alert("Įveskite bent vieną telefoną.");
	theform.private_phones.focus();
	return false
	}

	if (!testEmail(theform.private_email.value,1,theform,'private_email')) return false

	if (theform.my_auto.value=="") {
		alert("Prašau įrašyti kokiu automobiliu važinėjate.");
		theform.my_auto.focus();
		return false
	}


	if (theform.my_auto.value=="") {
		alert("Įveskite kokiais japoniškais automobiliais esate važinėję.");
		theform.my_auto_list.focus();
		return false
	}


	if (!theform.agree.checked){
		alert("Prašau patvirtinti, kad duomenis pateikiate laisva valia ir jie yra teisingi.");
		theform.agree.focus();
		return false
	}

	theform.submit();
	return true
}

function validateFieldsOfOrderCompany(theform) {

	if (theform.name_surname.value=="") {
	alert("Prašome nurodyti savo vardą ir pavardę.");
	theform.name_surname.focus();
	return false
	}

	if (theform.company.value=="") {
	alert("Prašau įvesti firmos, serviso pavadinimą.");
	theform.company.focus();
	return false
	}

	if (theform.company_address.value=="") {
	alert("Prašau įvesti firmos, serviso adresą");
	theform.company_address.focus();
	return false
	}

	if (theform.company_phones.value=="") {
	alert("Įveskite bent vieną firmos, serviso telefoną.");
	theform.company_phones.focus();
	return false
	}

	if (!testEmail(theform.company_email.value,1,theform,'company_email')) return false

	if (theform.auto_belongs_to.value=="none") {
		alert("Prašau nurodyti kam priklauso automobilis.");
		theform.auto_belongs_to.focus();
		return false
	}

	if (theform.my_auto.value=="") {
		alert("Prašau įrašyti kokiu automobiliu važinėjate.");
		theform.my_auto.focus();
		return false
	}


	if (theform.my_auto_list.value=="") {
		alert("Įveskite kokiais japoniškais automobiliais esate važinėję.");
		theform.my_auto_list.focus();
		return false
	}


	if (!theform.agree.checked){
		alert("Prašau patvirtinti, kad duomenis pateikiate laisva valia ir jie yra teisingi.");
		theform.agree.focus();
		return false
	}

	theform.submit();
	return true
}

// -->
