/* #############################################################################

NS: TESCODIRECT.app.button
	static: yes

dependancies:
	TESCODIRECT.lib.event
	TESCODIRECT.lib.DOM.node
	
############################################################################# */

TESCODIRECT.app.button = new function() {
	this.VERSION = "1.0.0";
	this.NAME = "TESCODIRECT.app.button";

	this.insert = function(id, buttonText, functionPointer, imgSrc) {
		if(document.getElementById && document.createTextNode) {
			var o = document.getElementById(id);
			if(o) {
				var oA = TESCODIRECT.lib.DOM.node.create("a");
				oA.style.textDecoration = "none";
				oA.href = "#";
				oA.tabIndex = -1;
				oA.setAttribute("buttonId", id);
				TESCODIRECT.lib.event.attach(oA, "click", functionPointer);
				o.appendChild(oA);
		
				if(imgSrc) {
					var oImg = TESCODIRECT.lib.DOM.node.create("img");
					oImg.src = imgSrc;
					oImg.alt = buttonText;
					oA.appendChild(oImg);
				} else {
					var oButton = TESCODIRECT.lib.DOM.node.create("input");
					oButton.type = "button";
					oButton.value = buttonText;
					oA.appendChild(oButton);
				}
			}
		}
		
		return false;
	}
	
	this.insertPrint = function(id, buttonText, imgSrc) {
		if(window.print) {
			return this.insert(id, (buttonText ? buttonText : "Print this page"),
				function(e) {
					e.stopEvent();
					window.print();
				},
				(imgSrc ? imgSrc : "/direct/i/b/printPageWhiteBg.gif"));
		}
	}
}


