function init() {
updateNames();
queryDB('','child',childAction);
// no id yet, so no child addition necessary --
// fill clink with marriage search instead
var searchttp = ''+localize("strQuery")+'';
// document.getElementById("clink").innerHTML = searchttp;
// also sort of a ### HACK ###
var wideness = document.getElementsByName('HUSB_SURN')[0].style.width;
for(var i=0; i ' + localize("strQuery") + '';
document.getElementById("hlink").innerHTML = namehttp;
}
if (wife != '' && wife != null && wife != 0) {
queryDB(wife,'read',nameAction);
} else {
var namehttp = ' ' + localize("strQuery") + '';
document.getElementById("wlink").innerHTML = namehttp;
}
}
function queryAction(http_request) {
var result = http_request.responseText;
//document.getElementById('zone').innerHTML = result;
// No results from search
if (result.indexOf('Nichts.') > 0 || result.indexOf('Nothing.') > 0 ||
result.indexOf('false') > 0) {
document.getElementById('zone').innerHTML = localize("strNothing");
return;
}
// More than 1 result from search
if (result.indexOf('Results') >=0 ) {
var begin = result.indexOf('Results');
var back = '
';
document.getElementById('zone').innerHTML = back + result.substring(begin);
document.getElementById('marriage').style.visibility = 'hidden';
return;
}
// Exactly one result from search
marriage = JSON.parse(result);
for (var key in marriage) {
var val = marriage[key];
// if (key == 'ID') var id=val;
elements = document.getElementsByName(key);
if (elements[0] != null && val !=" NULL") {
elements[0].value = val;
elements[0].style.color = 'black';
}
}
updateNames();
queryDB('','child',childAction);
document.getElementById('zone').innerHTML = "Done ...";
}
function insertAction(http_request) {
var result = http_request.responseText;
//document.getElementById("zone").innerHTML = result;
var begin = result.indexOf('');
var end = result.indexOf(' ',begin);
document.getElementById("zone").innerHTML = result.substring(begin,end);
//alert(result);
// update names for HUSB and WIFE
updateNames();
// update marr id
var begin = result.indexOf('#')+1;
var end = result.indexOf(' ',begin);
document.getElementsByName("ID")[0].value = result.substring(begin,end);
// update WIFE_SURN
var begin = result.indexOf('WIFE_SURN')+10;
var end = result.indexOf(' ',begin);
var result2 = result.substring(begin,end);
document.getElementsByName("WIFE_SURN")[0].value = result2;
document.getElementsByName('REV')[0].value = 0;
clearHighlight();
}
function updateAction(http_request) {
var result = http_request.responseText;
document.getElementById("zone").innerHTML = result;
var begin = result.indexOf('');
var end = result.indexOf(' ',begin);
//document.getElementById("zone").innerHTML = result.substring(begin,end);
// if not successful return
if (result.indexOf('nicht') > 0) {
document.getElementById("zone").innerHTML = result;
return;
}
// update revision
var rev = parseInt(document.getElementsByName('REV')[0].value) + 1;
document.getElementsByName('REV')[0].value = rev.toString();
// husb or wife has been changed
var wid = document.getElementsByName('WIFE')[0].value;
var hid = document.getElementsByName('HUSB')[0].value;
if (wid != wife_orig || hid != husb_orig) {
// update children
queryDB('','child',childAction);
wife_orig = wid;
husb_orig = hid;
// update names
updateNames();
}
clearHighlight();
}
function deleteAction(http_request) {
var result = http_request.responseText;
// document.getElementById('zone').innerHTML = result;
var begin = result.indexOf('');
var end = result.indexOf(' ',begin);
document.getElementById("zone").innerHTML = result.substring(begin,end);
// clear all fields
for (i=4; i ' + localize("strOpen") + '';
var namehttp = pinfo.name;
if (pinfo.birth != '') {
namehttp += ', ' + strBirth + ': ' + pinfo.birth + ' ';
} else if (pinfo.chris != '') {
namehttp += ', ' + strChris + ': ' + pinfo.chris + ' ';
}
if (pinfo.death != '') namehttp += ', ' + strDeath + ': ' + pinfo.death + ' ';
if (pinfo.sex == "M" && pinfo.name != '') {
document.getElementById("hname").innerHTML = namehttp;
document.getElementById("hlink").innerHTML = linkhttp;
}
if (pinfo.sex == "F" && pinfo.name != '') {
document.getElementById("wname").innerHTML = namehttp;
document.getElementById("wlink").innerHTML = linkhttp;
}
// make add child link
var id = document.getElementsByName('ID')[0].value;
if (id != '' && id != null && id != 0 && pinfo.sex == "M") {
var husb = document.getElementsByName('HUSB')[0].value;
var wife = document.getElementsByName('WIFE')[0].value;
var chilhttp = '' + localize("strInsertChild") + '';
//document.getElementById("clink").innerHTML = chilhttp;
}
}
// global variables
var persid = 0;
var db_select = "select.php";
var db_mselect = "mselect.php";
var wife_orig = 0;
var husb_orig = 0;
function queryDB(id,cmd,action) {
//alert('query : ' + id + " " + cmd);
if (id == null || id == '' || id == 0) {
if (cmd == 'query') {
var poststr = cmd + "=" + cmd;
for (i=4; i= 20;
if ( wid != wife_orig && children) {
if (confirm("Kinder update, Frau?") == true) {
url += "?owid=" + wife_orig;
}
}
if ( hid != husb_orig && children) {
if (confirm("Kinder update, Mann ?") == true) {
url += "?ohid=" + husb_orig;
}
}
if (cmd == 'delete') {
var text = document.getElementById("strConfDel").innerHTML;
if (confirm(text) == false || id == null || id == '') return;
} else if (cmd == 'insert') {
if (id != null && id != '' ) return;
} else if (cmd == 'update') {
if (id == null || id == '' || hid == '') return;
}
for (i=4; i