// *********************************************************************
// * CchDocPrinter
// *
// * Copyright 2008 CCH, a Wolters Kluwer business.
// *********************************************************************

function CchDocPrinter( )
{
	this.ignoreList = new Array();
}

CchDocPrinter.prototype.addIgnore = function(ignoreId)
{
	this.ignoreList.push(ignoreId);
}

CchDocPrinter.prototype.clone = function(el)
{
	var rEl = el.cloneNode(false);
	var removeAttr = new Array();
	for (var i = 0; i < rEl.attributes.lenght; rEl++)
	{
		if (rEl.attributes[i].name.substr(0, 2).toLowerCase() == "on")
		{
			removeAttr.push(rEl.attributes[i].name);
		}
	}
	for (var i = 0; i < removeAttr.length; i++)
	{
		rEl.removeAttribute(removeAttr[i]);
	}
	for (var i = 0; i < el.childNodes.length; i++)
	{
		if (el.childNodes[i].nodeType == 1)
		{
			if (el.childNodes[i].nodeName.toLowerCase() != "script")
			{
				if (!this.ignore(el.childNodes[i]))
				{
					rEl.appendChild(this.clone(el.childNodes[i]));
				}
			}
		}
		else
		{
			rEl.appendChild(el.childNodes[i].cloneNode(false));
		}
	}
	
	return rEl;
}

CchDocPrinter.prototype.ignore = function(el)
{
	var id = el.getAttribute("id");
	if (id == null) return false;
	for (var i = 0; i < this.ignoreList.length; i++)
	{
		if (this.ignoreList[i] == id)
		{
			this.ignoreList.splice(i, 1);
			return true;
		}
	}
	return false;
}