function chkrfqform() {
    if (document.form_rfq.txt_fname.value.length == 0 || document.form_rfq.txt_fname.value.match(/^\s*$/)) {
        alert("Please enter your first name");
        document.form_rfq.txt_fname.focus();
        return false;
    } else if (isNumeric(document.form_rfq.txt_fname.value) || sc(document.form_rfq.txt_fname.value) || haveNumeric(document.form_rfq.txt_fname.value)) {
        alert("Only alphanumeric Characters are allowed");
        document.form_rfq.txt_fname.focus();
        return false;
    } else if (document.form_rfq.txt_lname.value.length == 0 || document.form_rfq.txt_lname.value.match(/^\s*$/)) {
        alert("Please enter your last name");
        document.form_rfq.txt_lname.focus();
        return false;
    } else if (isNumeric(document.form_rfq.txt_lname.value) || sc(document.form_rfq.txt_lname.value) || haveNumeric(document.form_rfq.txt_lname.value)) {
        alert("Only alphanumeric Characters are allowed");
        document.form_rfq.txt_lname.focus();
        return false;
    } else if (document.form_rfq.txt_email.value.length == 0 || document.form_rfq.txt_email.value.match(/^\s*$/)) {
        alert("Please enter your email address");
        document.form_rfq.txt_email.focus();
        return false;
    } else if (!isEmail(document.form_rfq.txt_email.value)) {
        alert('Please enter a valid email format');
        document.form_rfq.txt_email.focus();
        return false;
    } else if (document.form_rfq.txt_phone.value.length == 0 || document.form_rfq.txt_phone.value.match(/^\s*$/)) {
        alert("Please enter your phone number");
        document.form_rfq.txt_phone.focus();
        return false;
    } else if (!isValidPhone(document.form_rfq.txt_phone.value) || sc(document.form_rfq.txt_phone.value) || letters(document.form_rfq.txt_phone.value)) {
        alert("Only Numeric Characters are allowed");
        document.form_rfq.txt_phone.focus();
        return false;
    }
    document.form_rfq.submit();
}

function chkcontactform() {
    if (document.form_contact.txt_name.value.length == 0 || document.form_contact.txt_name.value.match(/^\s*$/)) {
        alert("Please enter your first name");
        document.form_contact.txt_name.focus();
        return false;
    } else if (isNumeric(document.form_contact.txt_name.value) || sc(document.form_contact.txt_name.value) || haveNumeric(document.form_contact.txt_name.value)) {
        alert("Only alphanumeric Characters are allowed");
        document.form_contact.txt_name.focus();
        return false;
    } else if (document.form_contact.txt_company.value.length == 0 || document.form_contact.txt_company.value.match(/^\s*$/)) {
        alert("Please enter your Company Name");
        document.form_contact.txt_company.focus();
        return false;
    } else if (document.form_contact.txt_email.value.length == 0 || document.form_contact.txt_email.value.match(/^\s*$/)) {
        alert("Please enter your email address");
        document.form_contact.txt_email.focus();
        return false;
    } else if (!isEmail(document.form_contact.txt_email.value)) {
        alert('Please enter a valid email format');
        document.form_contact.txt_email.focus();
        return false;
    } else if (document.form_contact.txt_phone.value.length == 0 || document.form_contact.txt_phone.value.match(/^\s*$/)) {
        alert("Please enter your phone number");
        document.form_contact.txt_phone.focus();
        return false;
    } else if (!isValidPhone(document.form_contact.txt_phone.value) || sc(document.form_contact.txt_phone.value) || letters(document.form_contact.txt_phone.value)) {
        alert("Only Numeric Characters are allowed");
        document.form_contact.txt_phone.focus();
        return false;
    }
    document.form_contact.submit();
}

function isEmail(str) {
    var regex = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
    return regex.test(str);
}

function isValidPhone(str) {
    var regex = /[\-0-9]+/i;
    return regex.test(str);
}

function sc(str) {
    var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?";
    for (var i = 0; i < str.length; i++) {
        if (iChars.indexOf(str.charAt(i)) != -1) {
            return true;
        }
    }
}
function haveNumeric(str) {
    var iChars = "0123456789";
    for (var i = 0; i < str.length; i++) {
        if (iChars.indexOf(str.charAt(i)) != -1) {
            return true;
        }
    }
}

function isNumeric(value) {
    if (value == null || !value.toString().match(/^[-]?\d*\.?\d*$/)) return false;
    return true;
}

function letters(str) {
    var iChars = "qwertyuiolkjhgfdsazxcvbnm";
    for (var i = 0; i < str.length; i++) {
        if (iChars.indexOf(str.charAt(i)) != -1) {
            return true;
        }
    }
}

function openPopup(path, name) {
    xpos2 = 0;
    ypos2 = 0;
    iWidth2 = 300;
    iHeight2 = 200;
    xpos2 = (screen.width - iWidth2) / 2;
    ypos2 = (screen.height - iHeight2) / 2;
    window.open(path, name, 'width=' + iWidth2 + ',height=' + iHeight2 + ',screenx=' + xpos2 + ',screeny=' + ypos2 + ',left=' + xpos2 + ',top=' + ypos2 + '');
}
