// This script opens a new browser window and writes
// HTML to display an image with a title and caption

function show_text( pText, pTitle, pCaption, pWidth, pHeight) {

// specify window parameters
  textWin = window.open( "", "pTitle", "width=" + pWidth + ",height=" + pHeight + ",scrollbars,resizable");

// wrote content to window
  textWin.document.write('<html><head><title>' + pTitle + '</title></head>');	
  textWin.document.write('<BODY BGCOLOR=#ffffff TEXT=#000000 LINK=#33CCFF VLINK=#FF6666>');
  textWin.document.write('<center>');
  textWin.document.write('<font size=+3 face="arial,helvetica"><b>' + pTitle + '</b></font><br>');
  textWin.document.write(pText + '<p>');
  textWin.document.write('<font face="arial,helvetica">');	
  textWin.document.write('</p><p><a href="http://G6PDDeficiency.org/index.php">G6PDDeficiency.org</a>');
  textWin.document.write('</p></font></body></html>');
  textWin.document.close();	
	
// If we are on NetScape, we can bring the window to the front
	if (navigator.appName.substring(0,8) == "Netscape") photoWin.focus();

}

// This script opens a new browser window and writes
// HTML to display an image with a title and caption

function text_ad_click( tLocation ) {

// specify window parameters
  adWin = window.open( );


  adWin.document.location = tLocation;	
}

// adds a character counter to textareas in document

	var W3CDOM = document.createElement && document.getElementsByTagName;
	
	window.onload = setMaxLength;
	
	function setMaxLength() {
		if (!W3CDOM) return;
		var textareas = document.getElementsByTagName('textarea');
		var counter = document.createElement('div');
		counter.className = 'counter';
		for (var i=0;i<textareas.length;i++) {
			if (textareas[i].getAttribute('maxlength')) {
				var counterClone = counter.cloneNode(true);
				counterClone.innerHTML = '<span>0</span>/'+textareas[i].getAttribute('maxlength');
				textareas[i].parentNode.insertBefore(counterClone,textareas[i].nextSibling);
				textareas[i].relatedElement = counterClone.getElementsByTagName('span')[0];
				textareas[i].onkeyup = textareas[i].onchange = checkMaxLength;
				textareas[i].onkeyup();
			}
		}
	}
	
	function checkMaxLength() {
		var maxLength = this.getAttribute('maxlength');
		var currentLength = this.value.length;
		if (currentLength > maxLength)
			this.relatedElement.className = 'toomuch';
		else
			this.relatedElement.className = '';	
		this.relatedElement.firstChild.nodeValue = currentLength;
	}
