var gMaxTopicsSelected = 3;function validateEmailAddress(email){	// check . exists and is not last character	var dotPos = email.lastIndexOf(".");	var addrLen = email.length;	if (dotPos == -1 || dotPos == (addrLen - 1)) return false;		// check @ exists and is not first character	var atPos = email.indexOf("@");	if (atPos == -1 || atPos == 0) return false;		// ensure @ comes before .	if (atPos > dotPos) return false;		// ensure @. aren't together	if (dotPos - atPos == 1) return false;		return true;}// load selected topics into display <select>function loadSelectedTopicsOptions(language){	var topicsField = document.forms[0].elements.namedItem("SelectedTopics");	if ((topicsField == null) || (topicsField.value == "")) return;		var topics = topicsField.value.split(";");		var destSelect = document.forms[0].elements.namedItem("SelectedTopicsDisp");	if (!destSelect) return;		var topicNameIndex = (language == "fr" ? 1 : 0);		for (var i = 0; i < topics.length; i++)	{		var topicComponents = topics[i].split("~");		var newOption = document.createElement("option");		newOption.text = trimSpaces(topicComponents[topicNameIndex]);		newOption.value = topics[i];			try		{			// standards compliant; doesn't work in IE			destSelect.add(newOption, null);		}		catch (ex)		{			destSelect.add(newOption); // IE only		}	}}// capture selected topics before submitting formfunction captureSelectedTopics(){	var topicsSelect = document.forms[0].elements.namedItem("SelectedTopicsDisp");	var topicsString = "";	var option;	for (var i = 0; i < topicsSelect.length; i++)	{		option = topicsSelect.options[i];		topicsString += option.value;				// separate values by semicolons		if (i < topicsSelect.length - 1)		{			topicsString += ";"		}	}	var topicsField = document.forms[0].elements.namedItem("SelectedTopics");	topicsField.value = topicsString;}// selecting topics, selecting is true if selecting a topic, false if deselectingfunction selectTopic(selecting, language){	if (selecting)	{/* 		2007-10-26: should not use getElementById(), */		//var destSelect = document.getElementById("SelectedTopicsDisp");		var destSelect = document.forms[0].elements.namedItem("SelectedTopicsDisp");		if (destSelect.length >= gMaxTopicsSelected)		{			 if (language == "en")                         {                                 alert("You have already reached the maximum of three topics.");                         }                         else                         {                                 alert("Vous avez d\u00E9j\u00E0 choisi trois domaines (le maximum).");                         }                                 return;		}			var sourceSelect = document.forms[0].elements.namedItem("AvailableTopics");	}	else	{		var destSelect = document.forms[0].elements.namedItem("AvailableTopics");		var sourceSelect = document.forms[0].elements.namedItem("SelectedTopicsDisp");	}	var option;	var toRemove = new Object();		for (var i = 0; i < sourceSelect.length; i++)	{		option = sourceSelect.options[i];		if (option.selected)		{			// add to destination <select>			var newOption = document.createElement("option");			newOption.value = option.value;			newOption.text = option.text;			try			{				// standards compliant; doesn't work in IE    				destSelect.add(newOption, null);			}			catch (ex)			{				destSelect.add(newOption); // IE only			}						// mark for removal			toRemove[option.value] = "1";			if (selecting && destSelect.length >= gMaxTopicsSelected) break;		}	}	// remove options from source	var noRemoval = false;		while (!noRemoval)	{		noRemoval = true;		for (i = 0; i < sourceSelect.length; i++)		{			option = sourceSelect.options[i];			if (toRemove[option.value] == "1")			{				sourceSelect.remove(i);				noRemoval = false;			}		}			}	}function rankTopic(direction){	var slct = document.forms[0].elements.namedItem("SelectedTopicsDisp");	var options;	var option, tempValue, tempText;		options = slct.options;	for (var i = 0; i < options.length; i++)	{		option = options[i];		if (option.selected)		{			if (direction == "up" && i > 0)			{				tempValue = options[i - 1].value;				tempText = options[i - 1].text;				options[i - 1].value = option.value;				options[i - 1].text = option.text;				options[i].value = tempValue;				options[i].text = tempText;								options[i].selected = false;				options[i - 1].selected = true;			}			else if (direction == "down" && (i < options.length - 1))			{				tempValue = options[i + 1].value;				tempText = options[i + 1].text;				options[i + 1].value = option.value;				options[i + 1].text = option.text;				options[i].value = tempValue;				options[i].text = tempText;								options[i].selected = false;				options[i + 1].selected = true;			}						break;		}	}}function trimSpaces(s){	while (s.substr(0, 1) == " ") s = s.substr(1);	return s;}function manageAddressFields(inOnLoad){	// depending on country selected, enable, disable fields and	// update province/state options		/* 2007-10-26: should not use this to get Form fields where "Country" is just name, not ID: 								document.getElementById("Country")  */	// var countrySlct = document.getElementById("Country");	var countrySlct = document.forms[0].elements.namedItem("Country");		var country = countrySlct.options[countrySlct.selectedIndex].value;		// enable/disable other country and other province fields		/* 2007-10-26: should not use this to get Form fields where "Country" is just name, not ID: 					all changed to use form elements collection	*/	var otherCountryField = document.forms[0].elements.namedItem("OtherCountry");	var otherProvinceField = document.forms[0].elements.namedItem("OtherProvince");	var provinceSlct = document.forms[0].elements.namedItem("Province");	if (country != "other")	{		otherCountryField.value = "";		otherCountryField.disabled = true;		otherProvinceField.value = "";		otherProvinceField.disabled = true;	}	else	{		otherCountryField.disabled = false;		otherProvinceField.disabled = false;	}		// if not in onLoad() event, refresh province combo box options	if (!inOnLoad)	{		// clear out current options		while (provinceSlct.options.length > 0) provinceSlct.remove(0);				if (country != "other")		{			provinceSlct.disabled = false;						var optionsField = (country == "CA" ? "provinces" : "states");						/* 2007-10-26: it is not correct to use getElementById() to access form fields by name - IE only */			// var values = document.getElementById(optionsField).value.split(";");			var values = document.forms[0].elements.namedItem(optionsField).value.split(";");						for (i = 0; i < values.length; i++)			{				var newOption = document.createElement("option");				newOption.value = values[i];				newOption.text = values[i];				try				{					// standards compliant; doesn't work in IE	    				provinceSlct.add(newOption, null);				}				catch (ex)				{					provinceSlct.add(newOption); // IE only				}			}					}		else		{			provinceSlct.disabled = true;			// do nothing for other country, checkbox disabled above		}	}	else	{		// correct options already loaded server-side by Domino	}}
