var lastObject = 'menu_4';

function updateHiddenFromCheckbox(object_id, subject_id, setvalue)
{
  var object_id_inst=document.getElementById(object_id);
  var subject_id_inst=document.getElementById(subject_id);
  var checboxnum = new Number(subject_id_inst.value);
	
  if (object_id_inst.checked == true)
  {
	var testing = (Math.floor(checboxnum / setvalue))%2
    if ((Math.floor(checboxnum / setvalue))%2 == 0) 
    {
		checboxnum = checboxnum + setvalue;
    subject_id_inst.value = checboxnum;
		
    }
  }
  if (object_id_inst.checked == false)
  {
	var testing = (Math.floor(checboxnum / setvalue))%2
	  if ((Math.floor(checboxnum / setvalue))%2 == 1) 
    {
		checboxnum = checboxnum - setvalue;
    subject_id_inst.value = checboxnum;
		
    }
  }
}

function updateHidden(subject_id, set_value)
{
  var subject_id_inst=document.getElementById(subject_id);

  subject_id_inst.value = set_value;

}

function incrementHidden(subject_id, max_value)
{
  var subject_id_inst=document.getElementById(subject_id);
  var new_value = Number(subject_id_inst.value) + 1;
  if (new_value>max_value)
  {
    new_value = max_value;
  }
  //if (new_value >= max_value)
  //{
	//document.getElementById('Alarms_inc').disabled = true;
  //}
	
  //document.getElementById('Alarms_dec').disabled = false;   
  subject_id_inst.value = new_value;
}

function decrementHidden(subject_id, min_value)
{
  var subject_id_inst=document.getElementById(subject_id);
  var new_value = Number(subject_id_inst.value) - 1;
  if (new_value<min_value)
  {
    new_value = min_value;
  }
  //if (new_value <= min_value)
  //{
  //  document.getElementById('Alarms_dec').disabled = true;
  //}
	
  //document.getElementById('Alarms_inc').disabled = false;    
  subject_id_inst.value = new_value;
}

  var edited_id_array = new Array();
  var edited_click_id_array = new Array();
function markChangeAsEdited(subject_id)
{
  var subject_id_inst=document.getElementById(subject_id);

  subject_id_inst.style.fontWeight = 'bold';
	edited_id_array.push(subject_id_inst);

}

function markClickAsEdited(subject_id)
{
  var subject_id_inst=document.getElementById(subject_id);

  subject_id_inst.style.backgroundColor = 'black';
  edited_click_id_array.push(subject_id_inst);
}


function unmarkFromEdited()
{
  var subject_id_inst;
  while (edited_id_array.length > 0)
  {
    subject_id_inst = edited_id_array.pop();
    subject_id_inst.style.fontWeight = 'normal';
  }
  while (edited_click_id_array.length > 0)
  {
    subject_id_inst = edited_click_id_array.pop();
    subject_id_inst.style.backgroundColor = 'white';
  }
}

function clearField(subject_id)
{
  var subject_id_inst=document.getElementById(subject_id);

  subject_id_inst.value = "";
  subject_id_inst.selectedIndex = 0;
}

function setField(subject_id, value)
{
  var subject_id_inst=document.getElementById(subject_id);

  subject_id_inst.value = value;
}

var current_section = 1;

function incrementIframe(frame_name, max_value)
{
  current_section = current_section + 1;
  if (current_section>max_value)
  {
    current_section = max_value;
  }
  if (current_section >= max_value)
  {
	document.getElementById('' + frame_name + '_inc').disabled = true;
  }
	else
	{
    document.getElementById('' + frame_name + '_dec').disabled = false;
    
  }
  document.getElementById('refresh_frame').src= 'web/refresh_' + frame_name + current_section + '.html';
}

function decrementIframe(frame_name, min_value)
{
  current_section = current_section - 1;
  if (current_section<min_value)
  {
    current_section = min_value;
  }
  if (current_section <= min_value)
  {
    document.getElementById('' + frame_name + '_dec').disabled = true;
  }
	else
	{
    document.getElementById('' + frame_name + '_inc').disabled = false;
	}    
	
	document.getElementById('refresh_frame').src= 'web/refresh_' + frame_name + current_section + '.html';
}