<!-- // Start of AdSubtract JavaScript block; you can ignore this.
     // It is used when AdSubtract blocks cookies or pop-up windows.
document.iMokie = "cookie blocked by AdSubtract";
document.iMferrer = "referrer blocked by AdSubtract";
function iMwin() {
	this.location = "";
	this.frames = new Array(9);
	this.frames[0] = this;
	this.frames[1] = this;
	this.frames[2] = this;
	this.frames[3] = this;
	this.frames[4] = this;
	this.frames[5] = this;
	this.frames[6] = this;
	this.frames[7] = this;
	this.frames[8] = this;
	this.length = 0;
}
// End of AdSubtract JavaScript block. -->
// TemplateName=utils.js
// $Header: /home/cvs/cvsroot/site_data/001/00000001/static_data/js/utils.js,v 1.29.2.1 2006/06/20 19:39:03 daveh Exp $

function addEvent (obj, evType, fn)
{
	if (obj.addEventListener) {
		obj.addEventListener (evType, fn, true);
		return true;
	}
	else if (obj.attachEvent) {
		return obj.attachEvent('on' + evType, fn);
	}
	else {
		return false;
	}
}

function addOnLoadHandler (_fn)
{
	addEvent (window, 'load', _fn);
}

function MM_swapImgRestore() { //v3.0
	var i,x,a = document.MM_sr;

	for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++)
		x.src = x.oSrc;
}

function MM_preloadImages() { //v3.0
	var d = document;

	if (d.images) {
		if (!d.MM_p)
			d.MM_p = new Array();
			var i,j = d.MM_p.length,a = MM_preloadImages.arguments;

		for(i = 0; i < a.length; i++) {
			if (a[i].indexOf("#") != 0) {
				d.MM_p[j] = new Image;
				d.MM_p[j++].src = a[i];
			}
		}
	}

	/* This has nothing to do with loading images but it needs to happen
		during the onload so preview windows will pop to the front. This
		is just too much of a kludge. */
	window.self.focus();
}

function MM_findObj(n, d) { //v4.01
	var p,i,x;

	if (!d)
		d = document;

	if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
		d = parent.frames[n.substring(p+1)].document;
		n = n.substring(0,p);
	}

	if (!(x = d[n]) && d.all)
		x = d.all[n];

	for (i = 0; !x && i < d.forms.length; i++)
		x = d.forms[i][n];

	for (i = 0; !x && d.layers && i < d.layers.length;i++)
		x = MM_findObj(n,d.layers[i].document);

	if (!x && d.getElementById)
		x = d.getElementById(n);

	return x;
}

function MM_swapImage() { //v3.0
	var i, j = 0, x, a = MM_swapImage.arguments;
	document.MM_sr = new Array;

	for (i = 0; i < (a.length - 2); i += 3) {
		if ((x = MM_findObj(a[i])) != null) {
			document.MM_sr[j++] = x;

			if (!x.oSrc)
				x.oSrc = x.src;

			x.src = a[i + 2];
		}
	}
}

function MM_openBrWindow (theURL, winName, features) { //v2.0
	window.open (theURL, winName, features);
}

/*
appends the given param/val pair to the given original url
*/

function appendToUrl (original, param, val)
{
	var newUrl = original;

	if (original && (typeof (original) == 'string')) {
		// Remove parameter if it is already in the URL
		var re = new RegExp ('([?&])' + param + '=[^&]*&*', 'g');
		original = original.replace (re, '$1');

		// Now append it with the desired value.
		var url = new String (original);
		var sep = (url.indexOf('?') == -1) ? '?' : '&';
		newUrl = url.valueOf() + sep + param + '=' + val;
	}

	return newUrl;
}

function loadXMLDoc(url)
{
	var rc = false;

	// branch for native XMLHttpRequest object
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
		req.open("GET", url, true);
		req.send(null);
		rc = true;
	}
	// branch for IE/Windows ActiveX version
	else if (window.ActiveXObject) {
		try {
			req = new ActiveXObject("Microsoft.XMLHTTP");

			if (req) {
				req.open("GET", url, true);
				req.send();
				rc = true;
			}
		}
		catch (ex) {
		}
	}

	return rc;
}

/**
 * Closes a window if it is found in an array on the current 'window' object.
 */
function closeDialog (_arrayName, _winName)
{
	var winArray = eval ('window.' + _arrayName);

	if (winArray) {
		var dlg = winArray[_winName];

		if (dlg && !dlg.closed) {
			dlg.close();
		}
	}
}

var Utils = new Object();

Utils.prompt = function (_prompt, _default)
{
	this.closeAllDialogs();
	return window.prompt (_prompt, _default);
}

Utils.closeAllDialogs = function()
{
	var winArray = eval ('window.cv_dialogs');

	if (winArray) {
		for (var dlgName in winArray) {
			var dlg = winArray[dlgName];

			if (dlg && !dlg.closed)
				dlg.close();
		}
	}
}

/**
 * Attaches a dialog window into an array on the current 'window' object.
 */
function attachDialog (_arrayName, _winName, _dialog)
{
	var winArray;

	try {
		winArray = eval ('window.' + _arrayName);
	}
	catch (e) {
	}

	if (!winArray) {
		eval ('window.' + _arrayName + ' = new Array();');
		winArray = eval ('window.' + _arrayName);
	}

	winArray[_winName] = _dialog;

	var fnBody = 'closeDialog("' + _arrayName + '", "' + _winName + '");';
	addEvent (window, 'unload', new Function (fnBody));
}

function popupDlgLoad()
{
	if (window.name.indexOf('.pop') > 0) {
		var name = window.name;
		changeLinksToStayInPopup (document.getElementsByTagName ('A'));
		changeLinksToStayInPopup (document.getElementsByTagName ('AREA'));

		// For every form, create a hidden input that preserves the 'mfc_popup' flag.
		var forms = document.getElementsByTagName ('FORM');

		for (var i = 0; (i < forms.length); i++) {
			if (!forms[i].target)
				forms[i].target = name;

			addHiddenInput (forms[i], 'mfc_popup', 't');
			// TODO: Remove test code:
			var val = forms[i].target + ', ' + window.name;
			addHiddenInput (forms[i], 'form_target', val);
		}
	}
}

function addHiddenInput (_form, _name, _value)
{
	var hid = document.getElementById (_name);

	if (!hid || !hid.form || (hid.form != _form)) {
		try {
			hid = document.createElement ('INPUT');
			hid.type = 'hidden';
			hid.name = _name;
			// caused unknown error in IE on link selector
			_form.appendChild (hid);
		}
		catch(e) {
		}
	}

	if (hid && (hid.tagName == 'INPUT'))
		hid.value = escape (_value);

	return hid;
}

/**
 * Changes a list of link elements so that their target is the current pop-up
 * window (unless they already have a target specified).  Necessary for IE modal
 * and modeless dialogs.
 * Also adds URL arguments to preserve the pop-up page wrapper.
 *
 * @param _links an Array of HTML elements to change.
 */
function changeLinksToStayInPopup (_links)
{
	for (var i = 0; (i < _links.length); i++) {
		if (!_links[i].target) {
			_links[i].target = name;

			if (_links[i].href && (_links[i].href.indexOf ('javascript:') < 0))
				_links[i].href = appendToUrl (_links[i].href, 'mfc_popup', 't');
		}
	}
}

// Bug#21558 - Make the links within the component frame submit
// the page so it remembers any changes.  This was a big deal when
// displaying links for messaging and repeating behavior.
function link_submit_redirect(_evt)
{
	var e = _evt ? _evt : event; // IE vs. Mozilla event model

	if (e) {
		// IE vs. Mozilla event model
		var anchor = e.target ? e.target : e.srcElement;
		anchor = findContainingLink (anchor);

		if (anchor && anchor.href) {
			var nextUrl = document.getElementById ('NEXTURL');

			if (nextUrl) {
				nextUrl.value = anchor.href;
				nextUrl.form.submit();
			}
		}
	}
	return false;
}

/**
 * Given an HTML element, finds a containing element (possibly itself) that is
 * a link.  A link can be an 'A' or 'AREA' element.
 * @param _el HTML element from which to start looking.
 * @return a link element or undefined if one is not found.
 * @type HTMLElement
 */
function findContainingLink (_el)
{
	var link;

	if (_el) {
		if ((_el.tagName == 'A') || (_el.tagName == 'AREA'))
			link = _el;
		else {
			_el = getAncestor ('A', _el);
			link = _el ? _el : getAncestor ('AREA', _el);
		}
	}

	return link;
}

function openModelessDialog (_url, _winName, _width, _height)
{
	var dlg;
	_url = appendToUrl (_url, 't', new Date().getTime());

	if (_winName.indexOf ('.pop') < 0)
		_winName += '.pop';

	if (window.showModelessDialog) {
		closeDialog ('cv_dialogs', _winName);
		var win_args = 'dialogLeft:5;dialogTop:5;resizable:yes;scroll:yes;dialogWidth:' + _width + 'px;dialogHeight:' + _height + 'px;';
		dlg = window.showModelessDialog (_url, null, win_args);
		dlg.name = _winName;
		dlg.opener = window;
		window.cvDialog = dlg;
		// Generally, this is ineffective because the handler seemed to get
		// detached when the dialog fetched the URL and reloaded its content.
		// That's why the popupDlgLoad handler is attached to all windows at
		// the bottom of this script.  But adding it back here in addition to
		// the other place seems to have fixed bug 21931 in which one user had
		// a problem with the handler not running, but only the first time that
		// it was supposed to after a test system was reloaded.
		addEvent (dlg, 'load', popupDlgLoad);
	}
	else {
		var win_args = 'alwaysRaised=yes,dependent=yes,resizable=yes,scrollbars=yes,left=5,top=5,width=' + _width + ',height=' + _height;
		dlg = window.open (_url, _winName, win_args);
	}

	if (dlg)
		attachDialog ('cv_dialogs', _winName, dlg);

	return dlg;
}

function openModalDialog (_url, _winName, _width, _height)
{
	var dlg;

	if (window.showModalDialog) {
		closeDialog ('cv_dialogs', _winName);
		var win_args = 'resizable:yes;scroll:yes;dialogWidth:' + _width + 'px;dialogHeight:' + _height + 'px;';
		dlg = window.showModalDialog (_url, null, win_args);
		dlg.name = _winName;
		dlg.opener = window;
		attachDialog ('cv_dialogs', _winName, dlg);
	}
	else {
		var win_args = 'alwaysRaised=yes,modal=yes,dependent=yes,resizable=yes,scrollbars=yes,width=' + _width + ',height=' + _height;
		dlg = window.open (_url, _winName, win_args);
	}

	if (dlg)
		attachDialog ('cv_dialogs', _winName, dlg);

	return dlg;
}

/*
Used to replace above functions in TeamRaiser links that open new windows. Netscape
does not understand URL replacement with "this.href=desired_url" (but FireFox does).
*/
function noNewWindow(gotoURL) {
	if ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) > 4) && (navigator.userAgent.indexOf("Firefox") == -1))
	{
		window.location = gotoURL;
	}
}

function reloadWindow (_win)
{
	if (_win && _win.document) {
		var loc = _win.document.location;

		if (loc && loc.reload)
			loc.reload (true);
	}
}

/*
	Tell if I'm being rendered in the browser I expect.
	If I spec a platform tell me that too (versionPlatform
	is optional). Platform values are Win32, Win16, Mac68k,
	MacPPC and various Unix.
*/
function isNS(versionNumber, versionPlatform) {
	if (versionPlatform) {
		return (navigator.appName.indexOf("Netscape") > -1)
						& (parseInt(navigator.appVersion) >= versionNumber)
						& (navigator.platform.indexOf(versionPlatform) > -1);
	}
	else {
		return (navigator.appName.indexOf("Netscape") > -1)
						& (parseInt(navigator.appVersion) >= versionNumber);
	}
}

function isIE(versionNumber, versionPlatform) {
	if (versionPlatform) {
		return (navigator.appName.indexOf("Microsoft") > -1)
					  & (parseInt(navigator.appVersion) >= versionNumber)
						& (navigator.platform.indexOf(versionPlatform) > -1);
	}
	else {
		return (navigator.appName.indexOf("Microsoft") > -1)
					  & (parseInt(navigator.appVersion) >= versionNumber);
	}
}

function closeWin() {
	var isIE = (navigator.appName.indexOf("Microsoft") != -1 && navigator.appName.indexOf("Mac") == -1);

	if (isIE)
		window.close();
	else
		self.close();
}

function set_display (_elName, _display)
{
	var _el = ((typeof _elName) == 'string') ? document.getElementById(_elName) : _elName;

	if (_el && _el.style) {
		if ((typeof _display) != 'string')
			_display = _display ? '' : 'none';

		_el.style.display = _display;
	}
}

function removeChildren (element) {
	if (element) {
		while (element.firstChild)
			element.removeChild (element.firstChild);
	}
}

/**
 * Gets the plain (non-HTML) text in an element.
 */
function getElementText (_el)
{
	var TEXT_NODE = 3; // == Node.TEXT_NODE in DOM, which IE does not know about.
	var text = '';

	if (_el) {
		if (_el.nodeType && (_el.nodeType == TEXT_NODE))
			text += _el.data;

		var ch = _el.childNodes;

		for (var c = 0; (c < ch.length); c++)
			text += getElementText (ch[c]);
	}

	return text;
}

function setElementText (_el, _text)
{
	removeChildren (_el);
	_el.appendChild (document.createTextNode (_text));
}

function set_visible (_elName, _visible)
{
	var _el = ((typeof _elName) == 'string') ? document.getElementById(_elName) : _elName;

	if (_el) {
		if ((typeof _visible) != 'string')
			_visible = _visible ? 'visible' : 'hidden';

		_el.style.visibility = _visible;
	}
}

function show_block_element (_elName)
{
	set_display (_elName, 'block');
}

function show_element (_elName)
{
	set_display (_elName, '');
}

function hide_element (_elName)
{
	set_display (_elName, 'none');
}

function parse_boolean(_b)
{
	return (_b && (_b != 'false'));
}

function disable_element (_elementName, _disable)
{
	var _el = document.getElementById (_elementName);

	if (_el) {
		_el.disabled = parse_boolean (_disable);

		// IE does a poor job of indicating that some kinds of input are disabled.
		// This is a work-around to make the field look gray when disabled.
		// Skip this for checkboxes, though, because setting a checkbox background
		// looks bad.
		if (_el.currentStyle && ((_el.tagName != 'INPUT') || (_el.type != 'checkbox'))) {

			// In case a style sheet specifies a non-default normal background,
			// remember it on the element so that the correct color is restored when
			// the element is enabled.
			if (_el.currentStyle.backgroundColor && !_el.originalBackground)
				_el.originalBackground = _el.currentStyle.backgroundColor;

			if (_el.disabled)
				_el.style.backgroundColor = '#ddd';
			else if (_el.originalBackground)
				_el.style.backgroundColor = _el.originalBackground;
			else
				_el.style.backgroundColor = 'transparent';
		}
	}
}

function reset_element (_elementName)
{
	var el = document.getElementById (_elementName);

	if (el)
		set_input_value (el, get_input_default_value (el));
}

function get_input_default_value (_element)
{
	var val;

	if (_element && (_element.tagName == 'INPUT')) {
		if ((_element.type == 'text') || (_element.type == 'password') || (_element.type == 'file'))
			val = _element.defaultValue;
		else if ((_element.type == 'radio') || (_element.type == 'checkbox'))
			val = _element.defaultChecked;
	}
	else if (_element && (_element.tagName == 'SELECT')) {
		for (var i = 0; (!val && (i < _element.options.length)); i++)
			if (_element.options[i].defaultSelected)
				val = _element.options[i].value;
	}
	else if (_element && (_element.tagName == 'TEXTAREA')) {
		val = _element.defaultValue;
	}

	return val;
}

function get_input_value (_element)
{
	var val;

	if (_element && (_element.tagName == 'INPUT')) {
		if ((_element.type == 'text') || (_element.type == 'password') || (_element.type == 'file'))
			val = _element.value;
		else if ((_element.type == 'radio') || (_element.type == 'checkbox'))
			val = _element.checked;
	}
	else if (_element && (_element.tagName == 'SELECT')) {
		for (var i = 0; (!val && (i < _element.options.length)); i++)
			if (_element.options[i].selected)
				val = _element.options[i].value;
	}
	else if (_element && (_element.tagName == 'TEXTAREA')) {
		val = _element.value;
	}

	return val;
}

function set_input_value (_element, _value)
{
	if (_element && (_element.tagName == 'INPUT')) {
		if ((_element.type == 'text') || (_element.type == 'password') || (_element.type == 'file'))
			_element.value = _value;
		else if ((_element.type == 'radio') || (_element.type == 'checkbox'))
			_element.checked = parse_boolean (_value);
	}
	else if (_element && (_element.tagName == 'SELECT')) {
		for (var i = 0; (i < _element.options.length); i++)
			_element.options[i].selected = (_element.options[i].value == _value);
	}
	else if (_element && (_element.tagName == 'TEXTAREA')) {
		_element.value = _value;
	}
}

/**
 * Given a radio button in a group, or the name of the buttons in a group,
 * returns the selected button (or undefined).
 */
function get_which_radio (_radio)
{
	var selBtn;
	var name = ((typeof _radio) == 'string') ? _radio : _radio.name;

	if (name) {
		var allBtns = document.getElementsByName (name);

		for (var b = 0; (!selBtn && (b < allBtns.length)); b++)
			if (allBtns[b].checked)
				selBtn = allBtns[b];
	}

	return selBtn;
}

function subclass(_sub, _parent)
{
	for (var property in _parent) {
		try {
			_sub[property] = _parent[property];
		}
		catch (excp) {
		}
	}
}

function getAncestor (tag, el)
{
	var anc;
	var lowTag = tag ? tag.toLowerCase() : tag;

	while (!anc && el && (el != document)) {
		if (!tag || (el.tagName && (el.tagName.toLowerCase() == lowTag)))
			anc = el;
		else
			el = el.parentNode;
	}

	return anc;
}

/**
 * Find a parent of a specific CSS class.
 */
function getAncestorByClass (_class, _el)
{
	var anc;

	if (_el) {
		var el = _el;

		while (el && !anc) {
			if (isOfClass (el, _class))
				anc = el;
			else
				el = el.parentNode;
		}
	}

	return anc;
}

/*
 * Finds all elements of a given class name and adds them to a list.
 * This needs to be optimized as much as possible and should only be
 * used if a faster method cannot be found.
 */
function findAllOfClass (_parent, _class, _list)
{
	if (isOfClass (_parent, _class))
		_list.push (_parent);

	var ch = _parent.childNodes;

	for (var c = 0; (c < ch.length); c++) {
		var node = ch.item(c);

		// Do not recurse if the node is a leaf (saves tens of thousands of
		// function calls on some pages).

		if (node.hasChildNodes())
			findAllOfClass (node, _class, _list);
		else if (isOfClass (node, _class))
			_list.push (node);
	}
}

function isOfClass (_el, _class)
{
	if (_el && _el.className) {
		// Checking this special case is a performance optimization: only use the
		// more costly reg. exp. if there are multiple class names.
		if (_el.className.indexOf (' ') > 0) {
			var re = new RegExp ('[\s^]*' + _class + '( |\s|$)');
			return (_el.className.search (re) >= 0);
		}
		else
			return (_el.className == _class);
	}
	else
		return false;
}

/*
 * Filters a list of elements to contain only those of a given class name.
 * The result is returned as a new array.

 * @param _nodeList a DOM NodeList of elements to filter.
 */
function filterByClass (_nodeList, _class)
{
	var list = new Array();

	if (_nodeList.length < 200) { // IE is VERY slow with large arrays
		for (var n = 0; (n < _nodeList.length); n++) {
			var node = _nodeList.item(n);

			if (isOfClass (node, _class))
				list.push (node);
		}
	}

	return list;
}

// Some functions for the help links:

/**
 * An event handler that invokes the source element's select() method.
 */
function self_select (_evt) {
	// IE vs. Mozilla event model
	_evt = _evt ? _evt : event;
	var el = _evt.target ? _evt.target : _evt.srcElement;

	if (el && el.select)
		el.select();
}

/**
 * Finds all text input fields and makes them highlight their contents when
 * they receive focus.
 */
function make_text_fields_auto_select()
{
	var inputs = document.getElementsByTagName ('INPUT');

	if (inputs.length < 200) { // IE is VERY slow with large arrays
		for (var i = 0; (i < inputs.length); i++) {
			if (inputs[i].type == 'text')
				addEvent (inputs[i], 'focus', self_select);
		}
	}

	inputs = document.getElementsByTagName ('TEXTAREA');

	if (inputs.length < 200) {
		for (var i = 0; (i < inputs.length); i++)
			addEvent (inputs[i], 'focus', self_select);
	}
}

/**
 * Shows the contents of the selected anchor in a 'Help' window.
 * Returns 'true' if successful.
 */
function cv_show_help (_evt)
{
	return cv_new_win_from_link (_evt, 'Help');
}

// This should only be used internally (consider it a private method).
function cv_new_win_from_link (_evt, _name, _width, _height, _isPopup)
{
	var rc = false;

	if (_evt) {
		// IE vs. Mozilla event model
		var anchor = _evt.target ? _evt.target : _evt.srcElement;
		anchor = findContainingLink (anchor);

		if (anchor && anchor.href) {
			if (!_name || (_name == 'null'))
				_name = getElementText (anchor);

			if (_name)
				_name = _name.replace (/\s*/g, '');

			rc = cv_new_win (anchor.href, _name, _width, _height, _isPopup);
		}
	}

	return rc;
}

function cv_new_win (_url, _name, _width, _height, _isPopup)
{
	var newWin;

	if (_name)
		_name = _name.replace (/\s*/g, '');

	_width = _width ? _width : 600;
	_height = _height ? _height : 600;

	if (_isPopup) {
		newWin = openModelessDialog (_url, _name, _width, _height)
	}
	else {
		var winArgs = 'toolbar=yes,scrollbars=yes,resizable=yes,width='
									+ _width + ',height=' + _height + ',left=5,top=5';
		newWin = window.open (_url, _name, winArgs);
		newWin.focus();

		try {
			addEvent (newWin, 'load', cv_win_focus);
		}
		catch (e) {
		}
	}

	return newWin ;
}

function cv_win_focus(_evt)
{
	var e = _evt ? _evt : event; // IE vs. Mozilla event model
	var win = e.target ? e.target : e.srcElement;

	if (win && win.focus)
		win.focus();
}

// Private method determines whether to handle the given event.
function cv_should_handle (e)
{
	var rc = false;

	if (e) {
		if (e.type && (e.type == 'keypress'))
			rc = ((e.keyCode == 13) || (e.keyCode == 32));
		else
			rc = true;
	}

	return rc;
}

/**
 * Examples:
 *  onclick="return cv_popup_from_link_handler(event, 'WinName', 500, 500)"
 * or
 *  document.getElementById('link_id').onclick = cv_popup_from_link_handler;
 */
function cv_popup_from_link_handler (_evt, _name, _width, _height)
{
	var e = _evt ? _evt : event; // IE vs. Mozilla event model

	if (cv_should_handle (e))
		return (cv_new_win_from_link (e, _name, _width, _height, true) == false);
	else
		return true;
}

/**
 * Examples:
 *  onclick="return cv_new_win_from_link_handler(event, 'WinName', 500, 500)"
 * or
 *  document.getElementById('link_id').onclick = cv_new_win_from_link_handler;
 */
function cv_new_win_from_link_handler (_evt, _name, _width, _height)
{
	var e = _evt ? _evt : event; // IE vs. Mozilla event model

	if (cv_should_handle (e))
		return (cv_new_win_from_link (e, _name, _width, _height) == false);
	else
		return true;
}

/**
 * Example:
 *  onclick="return cv_new_win_handler(event, 'http://...', 'WinName', 500, 500)"
 */
function cv_new_win_handler (_evt, _url, _name, _width, _height)
{
	var e = _evt ? _evt : event; // IE vs. Mozilla event model

	if (cv_should_handle (e))
		return (cv_new_win (_url, _name, _width, _height) == false);
	else
		return true;
}

// event handler for help links.
function cv_help_link_handler (_evt)
{
	var e = _evt ? _evt : event; // IE vs. Mozilla event model

	if (cv_should_handle (e))
		return (cv_show_help (e) == false);
	else
		return true;
}

// Find and enable help links.
function enable_help_links()
{
	var list = filterByClass (document.getElementsByTagName('A'), 'HelpLink');

	for (var i = 0; (i < list.length); i++) {
		list[i].onkeypress = cv_help_link_handler;
		list[i].onclick = cv_help_link_handler;
	}
}

/**
 * Shows the contents of the selected anchor in a 'Preview' window.
 * Returns 'true' if successful.
 */
function cv_show_preview (_evt)
{
	var rc = false;

	if (_evt) {
		// IE vs. Mozilla event model
		var anchor = _evt.target ? _evt.target : _evt.srcElement;

		if (anchor && (anchor.tagName != 'A'))
			anchor = getAncestor ('A', anchor);

		if (anchor && anchor.href)
			rc = cv_new_win (anchor.href, 'Preview', 670, 500, false);
	}

	return rc;
}

// event handler for preview links.
function cv_preview_link_handler (_evt)
{
	var e = _evt ? _evt : event; // IE vs. Mozilla event model

	if (cv_should_handle (e))
		return (cv_show_preview (e) == false);
	else
		return true;
}

function cv_launch_window_on_load(_url, _winName, _width, _height)
{
	_width = _width ? _width : 800;
	_height = _height ? _height : 600;

	if (_winName)
		_winName = _winName.replace (/\s*/g, '');

	var winArgs = 'scrollbars=yes,resizable=yes,left=5,top=5,alwaysRaised=yes,alwaysLowered=no,dependent=yes,width=' + _width + ',height=' + _height;
	var fnBody = 'window.open("' + _url + '","' + _winName + '","' + winArgs + '").focus();'
	addEvent (window, 'load', new Function (fnBody));
}

// Find and enable preview links.
function enable_preview_links()
{
	var list = filterByClass (document.getElementsByTagName('A'), 'PreviewLink');

	for (var i = 0; (i < list.length); i++) {
		list[i].onkeypress = cv_preview_link_handler;
		list[i].onclick = cv_preview_link_handler;
	}
}

/**
 * Use this function to copy text to the clipboard (only works in IE though).
 * @member Utils
 */
function copy_to_clip(text)
{

 	if (window.clipboardData) {
   		window.clipboardData.setData("Text", text);
		return true;
 	}
   	return false;
}

// After the page loads, enable help and preview links.
addOnLoadHandler (popupDlgLoad);
addOnLoadHandler (enable_help_links);
addOnLoadHandler (enable_preview_links);

