/***************************************************************************
           js/toggle.js  -  Javascript toggling functions
                             -------------------
    begin                : Fri Jun 09 2006
    copyright            : (C) 2006 by Filios Konstantinos
    email                : drcypher@mail.ntua.gr
    last modified        : Fri Jun 09 2006
    module version       : 1.0
 ***************************************************************************/

/***************************************************************************
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 ***************************************************************************/

/***************************************************************************
 *  Procedure: toggleField
 *  Purpose:   Toggles the desired field_branch. int_sel might be equal to
 *             'none', '1', '2', ...
 *  Called in: modules/main/panel/profile.tpl
 ***************************************************************************/
function toggleField(int_sel)
{
	html_hidden = $('selected_branch');
	int_prev= html_hidden.value;
	if (int_prev != int_sel) {
		$('fields_'+int_prev).style.display='none';
		$('fields_'+int_sel).style.display='block';
		html_hidden.value= int_sel;
	}
}

/***************************************************************************
 *  Procedure: toggle
 *  Purpose:   Enables/disables&clears the grade input box corresponding
 *             to a given subject checkbox.
 *  Called in: modules/main/subjects/index_input.tpl
 ***************************************************************************/
function toggle(dom_caller, str_target)
{
	dom_target = $('grade_' + str_target);

	// User checked it
	if (dom_caller.checked) {
		dom_target.disabled = false;
	} else {
		dom_target.disabled = true;
		dom_target.value = '';
	}
}

function tree_toggle(int_path)
{
	dom_div = $("path_" + int_path);
	dom_btn = $("btn_" + int_path);

	str_src = dom_btn.src;
	str_ext = str_src.substr(str_src.lastIndexOf('.'));
	str_path = str_src.substr(0, str_src.lastIndexOf('/') + 1);;

	// Path is wide open, contract it
	if (dom_div.style.display == "block") {
		dom_div.style.display = "none";
		dom_btn.src = str_path + 'expand' + str_ext;
	} else {
		dom_div.style.display = "block";
		dom_btn.src = str_path + 'contract' + str_ext;
	}

	return false;
}

