function validateDropDown(s, a) {
    if (a.Value != 0)
        a.IsValid = true;
    else
        a.IsValid = false;
}

function checkDate(year, month, pdate, age) {
    var cdate = new Date();
    var currentDate = new Date();
    currentDate.setYear(currentDate.getYear() - age);
    cdate.setYear(year);
    cdate.setMonth(month);
    cdate.setDate(pdate);
    if (cdate.getDate() != pdate || cdate.getMonth() != month || (cdate.getYear() + 1900 != year)) {
        return false;
    }
    else {
        return true;
    }
}


function compareDate(year, month, pdate, age) {
    var cdate = new Date();
    var currentDate = new Date();
    currentDate.setYear(currentDate.getYear() - age);
    cdate.setYear(year);
    cdate.setMonth(month);
    cdate.setDate(pdate);
    if (cdate > currentDate) {

        return false;
    }
    else {
        return true;
    }
}

// Checks a string to see if it in a valid date format
// of (D)D/(M)M/(YY)YY and returns true/false
// http://www.qodo.co.uk/blog/javascript-checking-if-a-date-is-valid/
function isValidDate(s) {
    // format D(D)/M(M)/(YY)YY
    var dateFormat = /^\d{1,4}[\.|\/|-]\d{1,2}[\.|\/|-]\d{1,4}$/;
    if (dateFormat.test(s)) {
        // remove any leading zeros from date values
        s = s.replace(/0*(\d*)/gi, "$1");
        var dateArray = s.split(/[\.|\/|-]/);
        // correct month value
        dateArray[1] = dateArray[1] - 1;
        // correct year value
        if (dateArray[2].length < 4) {
            // correct year value
            dateArray[2] = (parseInt(dateArray[2]) < 50) ? 2000 + parseInt(dateArray[2]) : 1900 + parseInt(dateArray[2]);
        }
        var testDate = new Date(dateArray[2], dateArray[1], dateArray[0]);
        if (testDate.getDate() != dateArray[0] || testDate.getMonth() != dateArray[1] || testDate.getFullYear() != dateArray[2]) {
            return false;
        } else {
            return true;
        }
    } else {
        return false;
    }
}

function isValidMDayPhoneNumber(areaCodeId, phoneNumberField1Id, phoneNumberField2Id) {
    var areaCodeStr = document.getElementById(areaCodeId).value;
    var phoneNoFld1 = document.getElementById(phoneNumberField1Id).value;
    var phoneNoFld2 = document.getElementById(phoneNumberField2Id).value;

    var isValid = true;
    
    if (!isInteger(areaCodeStr) || !isInteger(phoneNoFld1) || !isInteger(phoneNoFld2)) {
        isValid = false;
    }
    else {
        var phoneNumberStr = areaCodeStr + "-" + phoneNoFld1 + "-" + phoneNoFld2;
        if (!(/\d{3}\-?\d{3}\-?\d{4}$/).test(phoneNumberStr)) {
            isValid = false;
        }
    }

    return isValid;
}

function isInteger(s) {
    var i;
    for (i = 0; i < s.length; i++) {
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) {
            return false;
        }
    }
    return true;
}




