<!--

var checkflag = "false";
function check(FormName,FieldName) {
//field = document.getElementById(elemid);

var field = document.forms[FormName].elements[FieldName];

if (checkflag == "false") {
  for (i = 0; i < field.length; i++) {
  	field[i].checked = true;
  }
  checkflag = "true";
  return "Uncheck all"; }
else {
  for (i = 0; i < field.length; i++) {
  field[i].checked = 'false'; }
  checkflag = "false";
  return "Check all"; }
}

function SetAllCheckBoxes(FormName, FieldName, CheckValue)
{
	if(!document.forms[FormName])
		return;
	var objCheckBoxes = document.forms[FormName].elements[FieldName];
	if(!objCheckBoxes)
		return;
	var countCheckBoxes = objCheckBoxes.length;
	if(!countCheckBoxes)
		objCheckBoxes.checked = CheckValue;
	else
		// set the check value for all check boxes
		for(var i = 0; i < countCheckBoxes; i++)
			objCheckBoxes[i].checked = CheckValue;
}

function setAttributes (object, attributeName, attributeValue)
{
	var attributeNode = document.createAttribute (attributeName);
	attributeNode.value = attributeValue;
	object.setAttributeNode (attributeNode);
} // end setAttribute method

function insertTablesHere (gTableId,lineNo,spans,whereto,queryargs) {
	var nSpanId = "newtablex";
	createTableX (gTableId,lineNo,spans,nSpanId,'temprow');
	//whereto in case we want to use this script for another destination url
		followLink('http://wishlist.medoingstuff.com/js/process_d_wishlist.php?&viewgroup='+queryargs,nSpanId);
	
}

//Secondary table nested (for gift. inside display_wishlist.php
function insertSecTablesHere (gTableId,lineNo,spans,whereto,queryargs) {
	var nSpanId = "newtablexx";
	createTableX (gTableId,lineNo,spans,nSpanId,'temprow2');
	//whereto in case we want to use this script for another destination url

	followLink('http://wishlist.medoingstuff.com/js/prepare_disp_gift.php?&view_gift='+queryargs,nSpanId);	
}


function createTableX (gTableId,lineNo,spans,nSpanId,temprow) {
	
	if (document.getElementById(temprow)) {
		tempChild = document.getElementById(temprow);
		TableObj = document.getElementById(gTableId);
		TableObj.removeChild(tempChild);
	}
   	
   	var gCell = document.createElement("td");
   	gCell.colSpan=spans;
   	
	var newSpan = document.createElement("span");
	newSpan.id=nSpanId;
   	var spanTxt = document.createTextNode("   ");
	newSpan.appendChild(spanTxt);
	
   	gCell.appendChild(newSpan);
   	
	var gTableB = document.getElementById(gTableId);
   	var gRow = gTableB.insertRow(lineNo);
   	gRow.id = temprow;
   	
   	gRow.appendChild(gCell);

/*
When adding rows to a table:

1. Don't ever user innerHTML (OK, you didn't do that)

2. Don't append rows to the table, append them to a
    tableSection element (tbody, thead or tfoot)

3. Consider using insertRow(-1) on the table or tableSection
    so the row is created and appended in one statement.
*/
}
-->