function select_topic(item_id){
	try {tree_item_old.background = "#F6F6F6";}catch(err){};
	try {
		tree_item = document.getElementById('tree_item_' + item_id);
		tree_item_id = item_id;
		tree_item_n = (document.layers)?tree_item:tree_item.style;
		tree_item_n.background = "#FFF0B8";
		tree_item_old_id = tree_item;
		tree_item_old = (document.layers)?tree_item_old_id:tree_item_old_id.style;
	}
	catch(err){
	};
}
function redirect(serv_req){
	try{link_url = serv_req + '&TID=' + tree_item_id;}catch(err){}finally{}
	try{document.location = link_url;}catch(err){}
}
function module_select(serv_req, id){
	try{link_url = serv_req}catch(err){};
	try{document.location = link_url;}catch(err){};
}
function ch_combo(combo_name, box_name){
	combo = document.getElementById(combo_name);
	last_val = combo.value
	edit_val = document.getElementById(box_name).value;
	combo.value = edit_val;
	if(combo.value == ''){combo.value = last_val;};
}
function ch_check_val(obj){
	obj.value = (obj.checked)?'1':'0';
}
function ch_color(obj){
	try{
		(document.layers)? obj.color="#FFF0B8" : obj.css="ddd";
	}catch(err){};
}
function xch_color(obj){
	try{
		(document.layers)? obj.color="#884400" : obj.css="bbb";
	}catch(err){};
}
function pop_img(RID, type){
	var dest = "pop.php?RID=" + RID + "&type=" + type;
	var features = "channelmode=0, toolbar=0, directories=0, location=0, status=0, menubar=0, scrollbars=0, resizible=0, height=250, width=300";
	kar = window.open(dest, "image", features);
}
function add_img(RID){
	str = "[|" + RID + "|]";
	return str;
}
function storeCaret (textEl) {
  if (textEl.createTextRange) 
    textEl.caretPos = document.selection.createRange().duplicate();
}
function insertAtCaret (textEl, text) {
  if (textEl.createTextRange && textEl.caretPos) {
    var caretPos = textEl.caretPos;
    caretPos.text =
      caretPos.text.charAt(caretPos.text.length - 1) == ' ' ?
        text + ' ' : text;
  }
  else
    textEl.value  = text;
}


