// ADO is used for all operations
function newwindow(newwinop) {
var conf = confirm("You cannot save with this version, hit ok to contact us for online use or code purchase - we charge a small handling fee only. We are also happy to quote for XML based consultancy and implementation work.");
if (conf) opWindow = open("ContactUsJava.htm","output") ;
}

function move(operation) {

 switch (operation) {
  case 1 :
    // move to first position
    xmldb.recordset.moveFirst();
    break ;
  case 2 :
    // move to previous position
    if(xmldb.recordset.absoluteposition > 1) {
      xmldb.recordset.movePrevious();
    }
    break ;
  case 3 :
    // move to next position
    if(xmldb.recordset.absoluteposition < xmldb.recordset.recordcount) {
      xmldb.recordset.moveNext();
    }
    break ;
  case 4 :
    // move to last position
    xmldb.recordset.moveLast();
    break ;
  default :
    // unknown command - do nothing
    break ;
 }
}

function adddelRec(adddelop) {
// Add=1 or Delete=2 a record to/from database
  if (adddelop == 1) {
    xmldb.recordset.AddNew() ;
    move(4) ;
  }
  if (adddelop == 2) {
     if (xmldb.recordset.absoluteposition > 1) {
       xmldb.recordset.Delete() ;
       if (xmldb.recordset.absoluteposition < 0) {
         move(4) ;
       }
     } else {
       if (xmldb.recordset.absoluteposition == 1) {
         alert("You cannot delete the first record - but you can change it");
       }
     }
  }
}


function savexml(whichsave) {
  var dataFile = "xmldbase.xml";
  var handle;
  var xobj =new ActiveXObject("Scripting.FileSystemObject");
  var write = 2;
  if (whichsave == 2) {
    dataFile = "xmltitle.xml"; //save titles
  }
  handle = xobj.OpenTextFile(dataFile,write,true);
  if (whichsave == 2) {
    handle.Write(xmltablehdr.xml);
  }
  else {
    handle.Write(xmldb.xml);
  }
  handle.Close();
}

