//
// Copyright (c) 2006 by Conor O'Mahony.
// For enquiries, please email GubuSoft@GubuSoft.com.
// Please keep all copyright notices below.
// Original author of TreeView script is Marcelino Martins.
//
// This document includes the TreeView script.
// The TreeView script can be found at http://www.TreeView.net.
// The script is Copyright (c) 2006 by Conor O'Mahony.
//
// This configuration file is used to demonstrate how to add checkboxes to your tree.
// If your site will not display checkboxes, pick a different configuration file as 
// the example to follow and adapt.  You can find general instructions for this file 
// at www.treeview.net.  Intructions on how to add checkboxes to a tree are provided 
// in this file.
//
USETEXTLINKS = 1;
STARTALLOPEN = 0;
HIGHLIGHT = 0;
PRESERVESTATE = 1;

// NOTE:  If you are going to set USEICONS = 1, then you will want to edit the gif 
// files and remove the white space on the right
USEICONS = 0;

// In this case we want the whole tree to be built, even those branches that are 
// closed. The reason is that otherwise some form elements might not be built at 
// all before the user presses the "Get Values" button.
BUILDALL = 1;
var OpenCheckout;
OpenCheckout = true;


// Some auxiliary functions for the contruction of the tree follow.  You will 
// certainly want to change these functions for your own purposes.
//
// These functions are directly related with the additional JavaScript in the 
// page holding the tree (demoCheckboxLeftFrame.html), where the form handling 
// code resides.

// If you want to add checkboxes to the folder, you will have to create a function 
// similar to this one and then call it in the tree construction section below.
function generateCheckBoxFolder(parentfolderObject, itemLabel, checkBoxDOMId, OnClickMethod) {
  var newObj;

  // For an explanation of insDoc and gLnk, read the online instructions.
  // They are the basis upon which TreeView is based.
  newObj = insFld(parentfolderObject, gFld(itemLabel, "javascript:parent.op()"))

  // The trick to show checkboxes in a tree that was made to display links is to 
  // use the prependHTML. There are general instructions about this member
  // in the online documentation.
  newObj.prependHTML = "<td valign=middle><input type=checkbox id="+checkBoxDOMId+" onClick="+OnClickMethod+"></td>"
  return newObj;
}

function generateCheckBox(parentfolderObject, itemLabel, checkBoxDOMId, Id, Naam, AantalPag, Prijs) {
  var newObj;
 
  evcheckRegio = "javascript:parent.checkRegio(\\\'"+checkBoxDOMId+"\\\');";
  newObj = insDoc(parentfolderObject, gLnk("R", itemLabel, evcheckRegio));

  Naam = escape(Naam);
  OnClickMethod="javascript:bestel('"+Id+"','"+Naam+"',"+AantalPag+","+Prijs+");";
  newObj.prependHTML = "<td valign=middle><input type=checkbox id="+checkBoxDOMId+" onClick="+OnClickMethod+"></td>";

  return newObj;
}


function bestel(Id, Naam, AantalPag,Prijs) {
	AddToCart(Id, unescape(Naam), AantalPag, Prijs);
	if (OpenCheckout)  submitTreeForm();
}

function checkSub(Obj) {
    var subObj;
    var subid;
    var i;
    subObj = null;
    OpenCheckout = false;
    i = 0;
    do
    {
	subObj = getElById(Obj.id + "_" + i);
	if (subObj != null){
//		subObj.checked = !Obj.checked;
		subObj.click();
	}	
    	i++;
    }
    while (subObj != null)
    
subObj = getElById(Obj.id + "_a");
   if (subObj != null)
      subObj.click();
OpenCheckout = true;
    submitTreeForm();
}

// The following code constructs the tree.
