// JavaScript Document

var empty = new Image(); empty.src = "images/misc/fieldError.gif";
var haveerrors = 0;

function showImage(imagename, imageurl, errors) {
document[imagename].src = imageurl;
if (!haveerrors && errors) haveerrors = errors;
}

function countLeasingSum(imagename, imageurl, errors) {
document[imagename].src = imageurl;

if (!haveerrors && errors) haveerrors = errors;
}

function validateNewsletterRequest() {
	var oFrm = document.oForm;

haveerrors = 0;
(oFrm.oCompany.value.length < 1)
? showImage("oCompanyError", "../images/misc/fieldError.gif", true)
: showImage("oCompanyError", "../images/misc/fieldBlank.gif", false);

(oFrm.oFirstname.value.length < 1)
? showImage("oFirstnameError", "../images/misc/fieldError.gif", true)
: showImage("oFirstnameError", "../images/misc/fieldBlank.gif", false);

(oFrm.oLastname.value.length < 1)
? showImage("oLastnameError", "../images/misc/fieldError.gif", true)
: showImage("oLastnameError", "../images/misc/fieldBlank.gif", false);

(oForm.oEmail.value.search("@") == -1 || oForm.oEmail.value.search(".") == -1)
? showImage("oEmailError", "../images/misc/fieldError.gif", true)
: showImage("oEmailError", "../images/misc/fieldBlank.gif", false);

return (!haveerrors);
}

function validateCatalogueRequest() {
	var oFrm = document.oForm;

haveerrors = 0;
(oFrm.oCompany.value.length < 1)
? showImage("oCompanyError", "../images/misc/fieldError.gif", true)
: showImage("oCompanyError", "../images/misc/fieldBlank.gif", false);

(oFrm.oAddress.value.length < 1)
? showImage("oAdressError", "../images/misc/fieldError.gif", true)
: showImage("oAdressError", "../images/misc/fieldBlank.gif", false);

(oFrm.oPostal.value.length < 1)
? showImage("oPostalError", "../images/misc/fieldError.gif", true)
: showImage("oPostalError", "../images/misc/fieldBlank.gif", false);

(oFrm.oCity.value.length < 1)
? showImage("oCityError", "../images/misc/fieldError.gif", true)
: showImage("oCityError", "../images/misc/fieldBlank.gif", false);
(oFrm.oPhone.value.length < 1)
? showImage("oPhoneError", "../images/misc/fieldError.gif", true)
: showImage("oPhoneError", "../images/misc/fieldBlank.gif", false);

return (!haveerrors);
}

function validateLeasing() {
	var oFrm = document.oForm;

haveerrors = 0;
(oFrm.oSum.value.length < 1)
? countLeasingSum("oSumError", "../images/misc/fieldError.gif", true)
: countLeasingSum("oSumError", "../images/misc/fieldBlank.gif", false);

(oFrm.oMonths.value.length < 1)
? countLeasingSum("oMonthsError", "../images/misc/fieldError.gif", true)
: countLeasingSum("oMonthsError", "../images/misc/fieldBlank.gif", false);

return (!haveerrors);

}

function validateLeasingRequest() {
	var oFrm = document.oForm;

haveerrors = 0;
(oFrm.oCompany.value.length < 1)
? showImage("oCompanyError", "../images/misc/fieldError.gif", true)
: showImage("oCompanyError", "../images/misc/fieldBlank.gif", false);

(oFrm.oFirstname.value.length < 1)
? showImage("oFirstnameError", "../images/misc/fieldError.gif", true)
: showImage("oFirstnameError", "../images/misc/fieldBlank.gif", false);

(oFrm.oLastname.value.length < 1)
? showImage("oLastnameError", "../images/misc/fieldError.gif", true)
: showImage("oLastnameError", "../images/misc/fieldBlank.gif", false);

(oForm.oEmail.value.search("@") == -1 || oForm.oEmail.value.search(".") == -1)
? showImage("oEmailError", "../images/misc/fieldError.gif", true)
: showImage("oEmailError", "../images/misc/fieldBlank.gif", false);

(oFrm.oPhone.value.length < 1)
? showImage("oPhoneError", "../images/misc/fieldError.gif", true)
: showImage("oPhoneError", "../images/misc/fieldBlank.gif", false);

return (!haveerrors);
}

function justNumbers() {
	var key = event.keyCode;

	if( key == 45 || key == 48 || key == 49 || key == 50 || key == 51 || key == 52 || key == 53 || key == 54 || key == 55 || key == 56 || key == 57){
	}
	else{
	return false;
	}
}
