function setFocus(controlId)
{
	var oControl = document.getElementById(controlId);
	if(oControl)
		oControl.focus();
}
function confirmAction(message)
{
	if(confirm(message))
		return true;
	return false;
}
function goOn(formId)
{
	var form = document.getElementById(formId);
	if(form)
		form.submit();
}
function goTo(goUrl)
{
	//document.location.href = goUrl;
	location.replace(url);
}
function goToSelected(obj, url)
{
    var val = obj.value;
	url += val;
    location.replace(url);
}
function setControlValue(controlId, value)
{
	var oControl = document.getElementById(controlId);
	if(oControl)
		oControl.value = value;
}
function setControlValueFromSelect(controlId, selectId, strSep)
{
	var value = '';
	var sep = '';
	var oControl = document.getElementById(controlId);
	var oSelect = document.getElementById(selectId);
	for (i=0; i<oSelect.options.length; i++)
	{
		var option = oSelect.options[i];
    	if (option.selected)
		{
			value += sep + option.value;
			sep = strSep;
    	}
    }	
	if(oControl)
		oControl.value = value;
}
function checkAll(formId, baseId)
{
	var oForm = document.getElementById(formId);
    var totLen = oForm.elements.length;
    var dObj, tmpObj;
    var i = 0;
    var check_all, all_value;
    var trObj, chObj, tr_id;
    check_all = document.getElementById('check_all_' + baseId);
    all_value = check_all.checked;
    var name = baseId + '[';//]';
    var len = name.length;
    while(i<totLen)
    {
        tmpObj = oForm.elements[i];
        tmpName = tmpObj.name;
        tmpName = tmpName.substring(0,len);
        if(tmpName == name)
        {
            tr_id = 'tr_'+tmpObj.value;
            //trObj = document.getElementById(tr_id);         
            if(all_value)
            {           
                tmpObj.checked = true;
                //trObj.bgColor = '#FF0000';
            }
            else
            {
                tmpObj.checked = false;
                //trObj.bgColor = '';
            }
        }
        i++;
    }
}
function setRichTextData(baseId)
{
	var editorId = 'editor' + baseId;
	var hiddenId = baseId;
	var oEditor = document.getElementById(editorId);
	var oHidden = document.getElementById(hiddenId);
	oEditor.EscapeUnicode = true;
	oHidden.value = oEditor.value;
}
function setCheckboxes(checkId, checkboxesIds)
{
	var oCheck = document.getElementById(checkId);
	var isChecked = oCheck.checked;
	for(var i=0; i<checkboxesIds.length; i++)
	{
		var tmpObj = document.getElementById(checkboxesIds[i]);
        if(isChecked)
        {           
            tmpObj.checked = true;
        }
        else
        {
            tmpObj.checked = false;
        }		
	}
}
function toggleEditor(id)
{
	var elm = document.getElementById(id);
	if (tinyMCE.getInstanceById(id) == null)
		tinyMCE.execCommand('mceAddControl', false, id);
	else
		tinyMCE.execCommand('mceRemoveControl', false, id);
}
function activateEditor(id)
{
    for(var j=0; j<aEditors.length ; j++)
    {
    	var editorId = aEditors[j];
    	if(editorId == id)
    	{
    		tinyMCE.execCommand('mceAddControl', false, editorId);
    	}
    	else
    	{
    		if( !(tinyMCE.getInstanceById(editorId) == null) )
    		{
    			tinyMCE.execCommand('mceRemoveControl', false, editorId);
    		}
    	}
    }	
}
function showElement(id)
{
	var elm = document.getElementById(id);
	elm.style.display = '';
}
function hideElement(id)
{
	var elm = document.getElementById(id);
	elm.style.display = 'none';
}
