/*
 * Initialises Searson Buck external link launcher.
 *
 * @author scampbell
 */


/**
 * Initialises the launcher by attaching event handlers
 * to the provided form.
 *
 * @param frm The form that is the external link launcher.
 */
function init_launcher(frm) {
	var frm = document.forms['external-links']
	var submit = frm.getElementsByTagName("a").item(0);

	submit.onclick = function() {
		var opts = frm.getElementsByTagName("option");
		var href = "";
		var idx = 0;
		for (var ii = 0; ii < opts.length; ii++) {
			if (opts[ii].selected) {
				href = opts[ii].value;
				idx = ii;
			}
		}
		if (href != "") {
			var w = window.open(href, "sb_ext_win_"+idx, "width=800,height=600,resizable=yes,menubar=yes,location=yes,status=yes,directories=yes,scrollbars=yes,toolbar=yes");
		} else {
			alert("Please select an external link.");
		}
		return false;
	}
}