function showBaptised(value) {
    if (value==1) {
        document.getElementById('divBaptised').style.display="block";
        show_opt_in_baptised(0);
    } else {
        document.getElementById('divBaptised').style.display="none";
        show_opt_in_baptised(1);
    }
}

function checkBaptisedList(sender, args) {
    if (document.getElementById('divBaptised').style.display == "block") {
        if (args.Value == 0) {
            args.IsValid = false;
        }
    }
}

function checkChurch(sender, args) {
    if (document.getElementById('divChurch').style.display == "block") {
        if (args.Value == "") { args.IsValid = false; }
    }
}

function show_opt_in_baptised(value) { 
    if (value==1) { document.getElementById('div_opt_in_baptised').style.display="block";} 
    else {
        document.getElementById('div_opt_in_baptised').style.display="none";
        document.getElementById('opt_in_baptised').checked = false;
    }
}
function listKM(value) {
    if (value==1) {
        document.getElementById('div_KMList').style.display="block";
        show_opt_in_KM(0);
    } else {
        document.getElementById('div_KMList').style.display="none";
        show_opt_in_KM(1);
    }
}
function show_opt_in_KM(value) {
    if (value==1) { document.getElementById('div_opt_in_KM').style.display="block"; } 
    else { 
        document.getElementById('div_opt_in_KM').style.display="none";
        document.getElementById('opt_in_KM').checked = false;
    }
}
function show_opt_in_SOM(value) {
    if (value==1) { document.getElementById('div_opt_in_som').style.display="block"; } 
    else {
        document.getElementById('div_opt_in_som').style.display="none";
        document.getElementById('opt_in_SOM').checked = false;
    }
}
function listMinistry(value) {
    document.getElementById('div_MinistryList').style.display="block";
    if (value==1) { show_opt_in_Ministry(0); } 
    else { show_opt_in_Ministry(1); }
    var ministry = document.aspnetForm.ministry;
    for (var i = 0; i < ministry.length; i++) {
        ministry[i].checked = false;
    }
}
function prepopulateMinistry(value) {
    for (i=0; i<document.aspnetForm.ministry.length; i++) {
        var strToBeScanned = 'A' + document.aspnetForm.ministry[i].value + 'A';
        if (value.indexOf(strToBeScanned)!=-1){document.aspnetForm.ministry[i].checked = true; }
    }
}
function show_opt_in_Ministry(value) { 
    if (value==1) { document.getElementById('div_opt_in_Ministry').style.display="block"; }
    else {
        document.getElementById('div_opt_in_Ministry').style.display="none";
        document.getElementById('opt_in_Ministry').checked = false;
    }
}
function checkDOB(sender, args){
    var dobDay = document.aspnetForm.dobDay;
    var dobMonth = document.aspnetForm.dobMonth;
    var selection = null;
    if (dobDay.value == "0") {args.IsValid=false;} 
    else if (dobMonth.value == "0") {args.IsValid=false;} 
    else {args.IsValid=true;}
    return false;
}
function checkBaptised(sender, args){
    var baptised = document.aspnetForm.isBaptised;
    var selection = null;
    for (var i = 0; i < baptised.length; i++){
        if (baptised[i].checked){selection=baptised[i].value;}
    }
    if(selection!=null){args.IsValid=true;}
    else{args.IsValid=false;}
    return false;
}
function checkSOM(sender, args){
    var selection = null;
    var som = document.aspnetForm.isInvolvedSOM;
    for (var i = 0; i < som.length; i++){
        if(som[i].checked){selection=som[i].value;}
    }
    if(selection!=null){args.IsValid=true;}
    else{args.IsValid=false;}
    return false;
}
function checkKM(sender, args){
    var selection = null;
    var km = document.aspnetForm.isJoinedKM;
    for(var i = 0; i < km.length; i++){
        if(km[i].checked){selection = km[i].value;}
    }
    if(selection!=null){args.IsValid = true;}
    else{args.IsValid = false;}
    return false;
}
function checkMinistry(sender, args){
    var ministry = document.aspnetForm.isInvolvedMinistry;
    var selection = null;
    for(var i = 0; i < ministry.length; i++){
        if(ministry[i].checked){selection = ministry[i].value;}
    }
    if (selection != null){args.IsValid = true;}
    else{args.IsValid = false;}
    return false;
}