
	function open_popup(varTrgt) {
		help=window.open(varTrgt,"popup", "status=no,toolbar=no,scrollbars=no,resizable=no,location=no,width=410,height=440"); 
		help.focus();
	}

	//window.onError = null;


	// File Attachment Clone

	//number of forms currently in <span id="attachments"> tree
	var form_count = 0;

	//add file attachment form and associated elements
	function addattachment()
	{
		//create new <img> element
		var new_img = document.createElement('img');
		//give element an id
		new_img.setAttribute('id', 'child_attachment_img_' + form_count);
		//set image source
		new_img.setAttribute('src','file.png');
		//set image alternative text
		new_img.setAttribute('alt',' ');
		//set image stylings
		new_img.setAttribute('style', 'float: left;');
		//append newly created element to <span id="attachments"> tree
		document.getElementById('attachments').appendChild(new_img);

		//create new <input> element
		var new_attachment = document.createElement('input');
		//give element an name
		new_attachment.setAttribute('name', 'attachments[]');
		//give element an id
		new_attachment.setAttribute('id', 'child_attachment_' + form_count);
		//set element type
		new_attachment.setAttribute('type', 'file');
		//set element size
		new_attachment.setAttribute('size', '48');
		//append newly created element to <span id="attachments"> tree
		document.getElementById('attachments').appendChild(new_attachment);

		//create new <span> element
		var new_text = document.createElement('span');
		//give element an id
		new_text.setAttribute('id','child_attachment_text_' + form_count);
		//set element HTML to produce 'remove' text link
		new_text.innerHTML = ' <span class="remove" onclick="removeattachment(' + form_count + ');"> remove</span><br />';
		//append newly created element to <span id="attachments"> tree
		document.getElementById('attachments').appendChild(new_text);

		//increase the form count
		form_count++;

		//if an attachment has been added, change text to "Attach another file"
		document.getElementById('more').innerHTML = 'Attach another file';
	}

	//remove file attachment form and associated elements
	function removeattachment(remove_form_num)
	{
		//decrease the form count
		form_count--;

		//remove <input> element attachment
		document.getElementById('attachments').removeChild(document.getElementById('child_attachment_' + remove_form_num));
		//remove <span> element text
		document.getElementById('attachments').removeChild(document.getElementById('child_attachment_text_' + remove_form_num));
		//remove <img> element image
		document.getElementById('attachments').removeChild(document.getElementById('child_attachment_img_' + remove_form_num));

		//if all forms are removed, change text back to "Attach a file"
		if (form_count == 0)
		{
        	document.getElementById('more').innerHTML = 'Attach a file';
		}
	}

	// END of File attachment clone



	// Add multiple users javascript

	//number of forms currently in <span id="attachments"> tree
	var user_form_count = 0;

	//add file attachment form and associated elements
	function addadditionaluser()
	{
		//create new <img> element
		//var new_img = document.createElement('img');
		//give element an id
		//new_img.setAttribute('id', 'child_attachment_img_' + user_form_count);
		//set image source
		//new_img.setAttribute('src','file.png');
		//set image alternative text
		//new_img.setAttribute('alt',' ');
		//set image stylings
		//new_img.setAttribute('style', 'float: left;');
		//append newly created element to <span id="additionalusers"> tree
		//document.getElementById('additionalusers').appendChild(new_img);

		//create new <input> element
		var new_attachment = document.createElement('select');
		//give element an name
		new_attachment.setAttribute('name', 'additionalusers[]');
		//give element an id
		new_attachment.setAttribute('id', 'child_additionaluser_' + user_form_count);
		//set element type
		//new_attachment.setAttribute('type', 'file');
		//set element size
		//new_attachment.setAttribute('size', '48');
		//append newly created element to <span id="attachments"> tree
		document.getElementById('additionalusers').appendChild(new_attachment);
		copyOptions(document.getElementById('myUserID'),new_attachment);
		copyOptions($('myUserID').up('form')['tfUserID'],new_attachment);

		//create new <span> element
		var new_text = document.createElement('span');
		//give element an id
		new_text.setAttribute('id','child_additionaluser_text_' + user_form_count);
		//set element HTML to produce 'remove' text link
		new_text.innerHTML = ' <span class="remove" onclick="removeadditionaluser(' + user_form_count + ');">&nbsp;Remove</span><br />';
		//append newly created element to <span id="additionalusers"> tree
		document.getElementById('additionalusers').appendChild(new_text);

		//increase the form count
		user_form_count++;

		//if an attachment has been added, change text to "Attach another file"
		document.getElementById('moreusers').innerHTML = 'Add another user';
	}

	//remove additional user and associated elements
	function removeadditionaluser(remove_form_num)
	{
		//decrease the form count
		user_form_count--;

		//remove <input> element additionaluser
		document.getElementById('additionalusers').removeChild(document.getElementById('child_additionaluser_' + remove_form_num));
		//remove <span> element text
		document.getElementById('additionalusers').removeChild(document.getElementById('child_additionaluser_text_' + remove_form_num));
		//remove <img> element image
		//document.getElementById('additionalusers').removeChild(document.getElementById('child_additionaluser_img_' + remove_form_num));

		//if all forms are removed, change text back to "Attach a file"
		if (user_form_count == 0)
		{
        		document.getElementById('moreusers').innerHTML = 'Add another user';
		}
	}

	function copyOptions(from,to) {

		var options = new Object();

		if (hasOptions(to)) {
			for (var i=0; i<to.options.length; i++) {
				options[to.options[i].value] = to.options[i].text;
			}
		}

		if (!hasOptions(from)) { return; }

		for (var i=0; i<from.options.length; i++) {
			var o = from.options[i];
			if (!o.selected) {
				if (options[o.value] == null || options[o.value] == "undefined" || options[o.value]!=o.text) {
					if (!hasOptions(to)) { 
						var index = 0;
					} else {
						var index=to.options.length;
					}
					to.options[index] = new Option( o.text, o.value, false, false);
				}
			}
		}

		//if ((arguments.length<3) || (arguments[2]==true)) { sortSelect(to); }
		
		//from.selectedIndex = -1;
		to.selectedIndex = -1;
		

	}

	function hasOptions(obj) {
		if (obj!=null && obj.options!=null) { return true; }
		return false;
	}



function copyit(theField) {

	// copies selected text into a control

	var selectedText = document.selection;
	if (selectedText.type == 'Text') {
		var newRange = selectedText.createRange();
		theField.focus();
		theField.value = newRange.text;
	} else {
		alert('select a text in the page and then press this button');
	}
}
