
	function TrimString(strInput){
		// Remove whitespace and apostrophe characters  
		return strInput.replace(/^\s*/,'').replace(/\s*$/,'').replace(/\'/g,'').replace(/,/g,'');		
	}
	
	function CheckStatus(ChkBox){
	if (ChkBox.checked) {
		hL(ChkBox);
	}else{
		if (ie){
			if (!ChkBox.parentElement.parentElement.children[0].children[0].checked && !ChkBox.parentElement.parentElement.children[1].children[0].checked)
				dL(ChkBox);
			}else{
				Data = ChkBox.name.split(/:/);
				if (!frm['1'].checked && !frm['2'].checked && !frm['4'].checked)
				dL(ChkBox);
			}
		}
	}

	function hL(E){
		if (ie){
			while (E.tagName!="TR"){
				E=E.parentElement;
			}
		}else{
			while (E.tagName!="TR"){E=E.parentNode;}
		}
			E.className = "Selected";
	}

	function dL(E){
		if (ie){
			while (E.tagName!="TR"){
				E=E.parentElement;
			}
		}else{
			while (E.tagName!="TR"){
				E=E.parentNode;}
			}
		E.className = "DeSelected";
	}	

function toggleRadio(radioButtonId) {

	var radioButton;
	var checked;

	radioButton = document.getElementById(radioButtonId);
	checked = radioButton.checked;

	radioButton.checked = 1 - checked;
}


function setGroupCellBorderStyle(groupName) {

	var allControlsInGroup;
	var controlIndex;
	var controlCount;
	var control;

	var cell;
	var cellStyle;
	var control;
	var checked;

	allControlsInGroup = document.getElementsByName(groupName);

	controlCount = allControlsInGroup.length;

	for (controlIndex = 0; controlIndex < controlCount; controlIndex++) {
		control = allControlsInGroup[controlIndex];
		checked = control.checked;
		setCellBorderStyle(control.id)
	}
	return true;
}


function setCellBorderStyle(controlId) {

	var cell;
	var cellStyle;
	var control;
	var checked;

	control = document.getElementById(controlId);

	if (control.checked) {
		cellStyle = 'solid';
	}
	else {
		cellStyle = 'none';
	}

	cell = document.getElementById('td' + controlId);
	cell.style.borderStyle = cellStyle;
	return true;
}

function toggleControl(controlId) {

	var control;
	var checked;

	control = document.getElementById(controlId);
	checked = (! control.checked);
	control.checked = checked;

	setCellBorderStyle(controlId);
	return true;
}


function selectControl(controlId) {

	var control;

	control = document.getElementById(controlId);
	control.checked = true;

	setGroupCellBorderStyle(control.name);
	return true;
}

function alertRadio(radioButtonId) {

	var radioButton;
	var checked;
	var radValue;

	radioButton = document.getElementById(radioButtonId);
	checked = radioButton.checked;
	radValue = radioButton.value;

	alert(radioButtonId + ' : ' + checked + ' : ' + radValue);
	return (checked);
}

function aRadioValue(radioButtonId) {

	var radioButton;
	var checked;
	var radValue;

	radioButton = document.getElementById(radioButtonId);
	checked = radioButton.checked;
	radValue = radioButton.value;

	return (radioButtonId + ' : ' + checked + ' : ' + radValue);
}

function showRadioValues() {

	var radioValues;

	radioValues = aRadioValue('radtkTiger1') + '\n' +
						aRadioValue('radtkWhirlWind1') + '\n' +
						aRadioValue('radtkWhirlWind2') + '\n' +
						aRadioValue('radtkWhirlWind3') + '\n' +
						aRadioValue('radWhiteAndBlack') + '\n' +
						aRadioValue('CheckIt')
	alert(radioValues);
}

function selectAll(groupName, state) {

	var allControlsInGroup;
	var controlIndex;
	var controlCount;
	var control;

	allControlsInGroup = document.getElementsByName(groupName);

	controlCount = allControlsInGroup.length;

//	alert('There are ' + controlCount + ' controls in the group')

	for (controlIndex = 0; controlIndex < controlCount; controlIndex++) {

		control = allControlsInGroup[controlIndex];
//		alert('Name:' + control.name + ':Id:' + control.id + ':Checked:' + control.checked + ':')

		control.checked = state;
	}
}


function setAllControls(groupName, state) {

	var allControlsInGroup;
	var controlIndex;
	var controlCount;
	var control;

	allControlsInGroup = document.getElementsByName(groupName);

	controlCount = allControlsInGroup.length;

	for (controlIndex = 0; controlIndex < controlCount; controlIndex++) {
		control = allControlsInGroup[controlIndex];
		control.checked = state;
	}
}


function setAllImageSelectors(groupName, state) {

	var allControlsInGroup;
	var controlIndex;
	var controlCount;
	var control;

	allControlsInGroup = document.getElementsByName(groupName);

	controlCount = allControlsInGroup.length;

	for (controlIndex = 0; controlIndex < controlCount; controlIndex++) {
		control = allControlsInGroup[controlIndex];
		control.checked = state;
		setCellBorderStyle(control.id)
	}
}


function SetAllStatesThemes(groupName, state) {
	setAllImageSelectors(groupName, state);
}

function SetAllStatesEditors(groupName, state) {
	setAllControls(groupName, state);
}

function SetAllStatesIconSets(groupName, state) {
	setAllControls(groupName, state);
}

function SetAllStatesFontSizes(groupName, state) {
	setAllControls(groupName, state);
}



/******************************************************************/
/*                                                                */
/* Author:       CWilson                                          */
/*                                                                */
/* Date:         December 2004                                    */
/*                                                                */
/* Description:  These functions are used to start and stop usage */
/*               stats when items are launched in a new window.   */
/*                                                                */
/******************************************************************/

function DetermineParameters(URL)
{
    var parameters;
    var position;

    // Assume the URL is invalid.
    parameters = "";

    // Force the URL to a string.
    try
    {
        URL = String(URL);
    }
    catch (e)
    {
        URL = "";
    }

    // Convert the URL into parameters.
    if (URL != "")
    {
        position = URL.indexOf("?");

        if (position != -1)
        {
            parameters = "&URL=" + encodeURIComponent(URL.substr(0, position));

            if (URL.length > position + 1)
            {
                parameters += "&" + URL.substr(position + 1);
            }
        }
        else
        {
            parameters = "&URL=" + encodeURIComponent(URL);
        }
    }

    return parameters;
}

function StopUsageFromWindow(URL,Package,BcMenuLevel)
{
    try
    {
        opener.parent.PortalRelease.document.location ='/LearningSystem/eView/Usage/StopRecordUsage.asp?InWindow=1' + DetermineParameters(URL);
		if (Package != '')
		{
			opener.parent.PortalBottom.StopUsageFromWindow_RefreshMenu(Package,BcMenuLevel);
		}
    }
    catch (e)
    {
        // Do nothing.
    }
}
