/**
 * @version 1.0
 * @author John Noel <john.noel@irisassociates.com>
 */

/* Title */
showOtherField = function() {
	if($F("formTitle") == "Other")
	{
		$("formTitleOther").show().select();
	}
	else
	{
		$("formTitleOther").hide();
	}
};

$("formTitleOther").hide();
$("formTitle").observe("change", showOtherField);
showOtherField();

/* Talk description */
countWords = function() {
	var matches = $F("formAbout").match(/[\s\W]+/g);
	if(matches !== null)
	{
		$("wordCounter").update(matches.size() + " word" + ((matches.size() != 1) ? "s" : ""));
	}
	else
	{
		$("wordCounter").update("0 words");
	}
};

var counterElem = $(document.createElement("span"));
counterElem.writeAttribute({id: "wordCounter"});
$("formAbout").observe("keyup", countWords).insert({after: counterElem});
countWords();

/* STEM ambassador */
$("stemAmbassador").hide();
$$(".stemAmbassador").invoke("observe", "click", function(evt) {
	if(evt.findElement("input").readAttribute("value") == "no")
	{
		$("stemAmbassador").show();
	}
	else
	{
		$("stemAmbassador").hide();
	}
});
