alreadytyped = false;

function initArea(evt){
	var ta = document.getElementById("disdistract");
	if(!alreadytyped){
		alreadytyped = true;

		if(ta.hasChildNodes()){
			for(var n=0; n<ta.childNodes.length; ++n){
				//alert(n);
				ta.removeChild(ta.childNodes[n]);
			}
		}
	}
}


function checkStatus(evt){

	var ta = evt.currentTarget;
	var kc = evt.keyCode;

	switch(kc){
		case 10 :
		case 13 :
			ta.rows += 1;
			break;
	}
}

function helpOut(evt){
	alert("use F11 to get to and from full screen mode\n\nTo save, copy and paste into word processor");
}

function init() {
	var ta = document.getElementById("disdistract");
	var hp = document.getElementById("help");

/** /
	ta = ta.parentNode.replaceChild(ta.cloneNode(false), ta);
	ta.id = "disdistract";
	/**/

	// right here get the size of the browser window and set the rows
	//alert(window.innerHeight / 16);
	// find out the height of the text
	ta.rows = window.innerHeight / 14;
	//ta.rows="40";
	ta.cols="65";

	if(ta.hasChildNodes()){
		for(var n=0; n<ta.childNodes.length; ++n){
				ta.removeChild(ta.childNodes[n]);
		}
	}
	ta.appendChild(document.createTextNode("Start typing here ... "));

	ta.addEventListener("keypress",  checkStatus, false);
	ta.addEventListener("focus", initArea, false);

	hp.addEventListener("click", helpOut, false);
}

