var ie4 = (document.all) ? true : false;
var ns4 = (document.layers) ? true : false;
var ns6 = (document.getElementById && !document.all) ? true : false;

function hidelayer(lay) {
try {
if (ie4) {document.all[lay].style.visibility = "hidden";}
if (ns4) {document.layers[lay].visibility = "hide";}
if (ns6) {document.getElementById([lay]).style.visibility = "hidden";}
} catch(er) {
	//alert("there was an error with layer " + lay)
	return;
	};

}
function showlayer(lay) {
try {
if (ie4) {document.all[lay].style.visibility = "visible";}
if (ns4) {document.layers[lay].visibility = "show";}
if (ns6) {document.getElementById([lay]).style.visibility = "visible";}
} catch(er) {
	//alert("there was an error with layer " + lay)
	return;
	};
}

function changeColor(lay,color) {
if (color == ""){color="#e0e0e0"};
if (ie4) {document.all[lay].style.backgroundColor = color;}
if (ns4) {document.layers[lay].backgroundColor = color;}
if (ns6) {document.getElementById([lay]).style.backgroundColor = color;}

}

function resetColor(lay,color) {
if (color == ""){ myColor = "white"; } else { myColor = color; }
if (ie4) {document.all[lay].style.backgroundColor = myColor;}
if (ns4) {document.layers[lay].backgroundColor = myColor;}
if (ns6) {document.getElementById([lay]).style.backgroundColor = myColor;}

}


function writetolayer(lay,txt) {
if (ie4) {
document.all[lay].innerHTML = txt;
}
if (ns4) {
document[lay].document.write(txt);
document[lay].document.close();
}
if (ns6) {
over = document.getElementById([lay]);
range = document.createRange();
range.setStartBefore(over);
domfrag = range.createContextualFragment(txt);
while (over.hasChildNodes()) {
over.removeChild(over.lastChild);
}
over.appendChild(domfrag);
   }
}

function setClass(myID,myClass){
if (ie4) {document.all[myID].className = myClass;}
if (ns4) {document.layers[myID].className = myClass;}
if (ns6) {document.getElementById([myID]).className = myClass;}
}


function openSmWin(keyURL) {
window.open(keyURL,'500x400','toolbar=no,status=no,scrollbars=yes,location=no,menubar=no,directories=no,resizable=yes,width=500,height=400')}

/*
*	Used to limit the amount of characters in a textarea or multi-line server-control textbox
*	'lay' is the target output
*	'txtfield' is the target input
*/
function limitCharacter(lay,txtfield) {
	txt = txtfield.value.length
	if(txt > 255){
		alert("Please limit your answers to 255 characters");
		txtfield.value = txtfield.value.substring(0,255)
		return false;
	}
	myCountTxt = "character count: " + txt;
	if (ie4) {
		//document.all[lay].value = myCountTxt;
		return true;
	}
	if (ns4) {
		document[lay].document.write(myCountTxt);
		document[lay].document.close();
		return true;
	}
	if (ns6) {
		over = document.getElementById([lay]);
		range = document.createRange();
		range.setStartBefore(over);
		domfrag = range.createContextualFragment(myCountTxt);
		while (over.hasChildNodes()) {
			over.removeChild(over.lastChild);
		}
		over.appendChild(domfrag);
		return true;
	}
}