//javascript code for use in GRO web pages

function testit() {
	var text = '<P>Testing javascript file gro.js</P>';
	document.write(text);
    alert(text);
}

function mailFormat(user,isp) {
    var text = '<a href="mailto:' + user + '@' + isp + '">';
    document.write(text);
}

function get_radio_value(form){
    //this function polls the radio buttons to see which one is checked
    var rad_val = "?";

    for (var i=0; i < form.rmode.length; i++) {
        if (form.rmode[i].checked) {
            rad_val = form.rmode[i].value;
        }
    }
    return rad_val;
}

function submitIt(form) {
    // this function acts on the form submit button
    //alert( get_radio_value(form) );
    form.action = "showGRO.php?mode=" + get_radio_value(form);
    return true;
}

function submitB(form,mode) {
    // this function acts on the form submit button
    form.action = "showGRO.php?mode=" + mode +"&year=" + form.s_year.value;
    form.submit();
    return true;
}

function marriagesButtonPress(form) {
    // this function acts on the form submit button
    form.action = "showGRO.php?mode=marriages";
    form.submit();
    return true;
}

function deathsButtonPress(form) {
    // this function acts on the form submit button
    form.action = "showGRO.php?mode=deaths";
    form.submit();
    return true;
}

function birthsButtonPress(form) {
    // this function acts on the form submit button
    form.action = "showGRO.php?mode=births";
    form.submit();
    return true;
}

function yearButtonPress(form, mode) {
    // this function acts on the form submit button
    form.action = "showGRO.php?mode=" + mode +"&year=" + form.s_year.value;
    form.submit();
    return true;
}

function forenameButtonPress(form, mode) {
    // this function acts on the form submit button
    form.action = "showGRO.php?mode=" + mode +"&name=" + form.forename.value;
    form.submit();
    return true;
}

function deleteButtonPress(id, mode, form) {
    form.action = "deleteGroEntry.php?id=" + id + "&mode=" + mode;
    form.submit();
    return true;
}

function updateButtonPress(id, mode, form) {
    form.action = "updateGroEntry.php?id=" + id + "&mode=" + mode;
    form.submit();
    return true;
}

function cancelButtonPress(id, mode, form) {
    form.action = "showGRO.php?mode=" + mode;
    form.submit();
    return true;
}

function submitButtonPress(id, mode, form) {
    form.action = "updateGroEntry.php?id=" + id + "&mode=" + mode + "&update=TRUE";
    form.submit();
    return true;
}

function confirmButtonPress(id, mode, form) {
    form.action = "deleteGroEntry.php?id=" + id + "&mode=" + mode + "&confirm=TRUE";
    form.submit();
    return true;
}




