


function validateFieldSize(formName, fieldName, invalidBackgroundColor, fieldSize) {
    var currentFormValidity = false;
    eval("var selectedField = document." + formName + "." + fieldName);

    if (selectedField.value.length != fieldSize) {
        selectedField.style.backgroundColor = invalidBackgroundColor;
    } else {
        currentFormValidity = true;
        selectedField.style.backgroundColor = validBackgroundColor;
    }

}



function validate() {

    currentFormValidity = true
    emailValidity = 'true'



    if (!validateFieldNotBlank('support','name','text','#73C017','#333366','#333366','#73C017')){
        currentFormValidity = false;
    }

    if (!validateFieldNotBlank('support','msisdn','text','#73C017','#333366','#333366','#73C017')){
        currentFormValidity = false;
    } else if (!validateInputtedNumber(document.support.msisdn.value,'document.support.msisdn')) {
        currentFormValidity = false;
        alert("Please insert a valid cell number\n" +
              "(no dashes or spaces\n" +
              "eg. 1112223333)\n" +
              "We only deliver to american networks");
        document.support.msisdn.style.backgroundColor = '#333366';
        document.support.msisdn.style.color = '#FFFFFF';
    }

    if (!validateFieldNotBlank('support','emailAddress','text','#73C017','#333366','#333366','#73C017')){
        currentFormValidity = false;
    }

    if (!validateFieldNotBlank('support','customerMessage','text','#73C017','#333366','#333366','#73C017')){
        currentFormValidity = false;
    }

    if (!isEmailValid('support','emailAddress')) {
        emailValidity = false;
        alert("Please insert a valid email address");
    }

    if (isNaN(document.all.support.transactionId.value)) {
        currentFormValidity = false;
        alert("Please insert a valid order code");
    }



    if (currentFormValidity && emailValidity) {
        //alert("ok");
            document.support.submit();

    } else if (!currentFormValidity) {
        alert("Please complete blue boxes");
    }

}
