// JavaScript Document

function onBodyLoad() 

{

  initFormHandlers();

}



function NVL(value, defaultValue) 

{

  if(typeof(value) == "undefined" || value == null) {

    return defaultValue;

  }

  return value;

}



function show_div(div_id) 

{

	document.getElementById(div_id).style.display = 'block';

}

function hide_div(div_id) 

{

	document.getElementById(div_id).style.display = 'none';

}



function showWithdraw(record) 

{

	var y ='withdraw_form'+record[record.selectedIndex].value;

	var tmp = new String;

	for (var i=0; i < record.length; i++) {

		tmp='withdraw_form'+record[i].value;

		document.getElementById(tmp).style.display = 'none';

	}

	document.getElementById(y).style.display = 'block';



}

function manageGroup(groupListId) 

{

    if (document.getElementById) {

	    var el = document.getElementById (groupListId);

        var groupId = el.options[el.selectedIndex].value;

        window.location = "groups.php#" + groupId;

    }

    return;

}





function checkForm(form, action, subaction) {

	var res = true;

	eval("res = check_" + form + "()");

	if (res && NVL(action, false)) {

		document.forms[form].elements['action'].value = action;

	}

	if (res && NVL(subaction, false)) {

		document.forms[form].elements['subaction'].value = subaction;

	}	

	return res;

}



function setFormAction(action, form) 

{

    document.forms[form].elements['action'].value = action;

}



function setFormSubAction(action, form) 

{

    document.forms[form].elements['subaction'].value = action;

}





function highlightFormsElement() {

    var h_elem_ids = new Array; 

    h_elem_ids  = getHighlightElementsId();    

    if (h_elem_ids != null) {

        for (var i=0; i<h_elem_ids.length; i++) {

          selectElementBackgroundById(h_elem_ids[i]); 

        }

    }

}



function getHighlightElementsId() { 

    get = new String(window.location);

    var res = null;

    var x = get.indexOf('?');

    if(x!=-1) {

        var tmp = get.substr(x+1, get.length-x);  

        var getparam = tmp.split('&');

        for(var i=0; i<getparam.length; i++)

        {

          tmp = getparam[i].split('=');

          if (tmp[0]=='highlight') 

          {

            res = tmp[1].split(":");

          }

        }



    }

    return res;    

}



function selectElementBackgroundById(element_id, bgcolor) {

   var element = document.getElementById(element_id);

   if (element != null) {

        element.className = "highlight";   

        element.title = "Please modify this option";

   }

   return;



}