// Copyright (C) 2008 Efficient IP - all rights reserved
// $Id: form.js,v 1.107.2.2 2009-05-28 11:58:36 eippkg Exp $

/*
if (typeof console == "object")
{
  alert('please disable firebug');
}
*/

var ipm_use_old_ie_iframe = 0;
var ipm_page_is_loaded=0;
var IP6_BIN_ONE='00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001';
var IP6_BIN_ZERO='00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';

ipm_init_form();

Array.prototype.search = function(value) { 

  var i = this.length;

  while (i--) if (this[i] == value) return i;
  return -1;
}

function ipm_init_form()
{
  var browser=navigator.appName;
  var b_version=navigator.appVersion;
  var version=parseFloat(b_version);
  if (browser=="Microsoft Internet Explorer" && version < 7)
    ipm_use_old_ie_iframe = 1;
}

function enter_submit(myform,event)
{
  if ((window.event && window.event.keyCode == 13) ||
      (event && event.which == 13))
    {
      myform.submit();
      return false;
    }
  else
    return true;
}

function enter_submit_disabled(myform,event)
{
  if ((window.event && window.event.keyCode == 13) ||
      (event && event.which == 13))
    {
      return false;
    }
  else
    return true;
}

function release_search_column(thisform)
{
  var len = thisform.elements.length;	
  while (len--)
    if (thisform.elements[len].is_seachable)
      thisform.elements[len].value = '';
}


function pretty_macaddr(it)
{
  var str = it.value;
  str = str.replace(/ /g, ':');
  str = str.replace(/\-/g, ':');
  str = str.replace(/\./g, ':');
  str = str.replace(/([a-zA-Z0-9])([a-zA-Z0-9])([a-zA-Z0-9])/g, '$1$2:$3');
  str = str.replace(/:([a-zA-Z0-9]):/g, ':0$1:');
  str = str.replace(/^([a-zA-Z0-9]):/g, '0$1:');
  str = str.replace(/^::/g, '00:00:');
  str = str.replace(/::/g, ':00:');

  if (it.value != str)
    it.value = str;
}



function move_all_list(fromlist,tolist,accesslist)
{
  var i = fromlist.options.length;

  while (i--)
    {
      if ((accesslist && accesslist.search(fromlist.options[i].value) > 0) || accesslist == null)
	{

	  tolist[tolist.length] = new Option(fromlist.options[i].text,
					       fromlist.options[i].value);
	    fromlist.options[i] = null;
	}

    }
  sort_list(tolist);
}


function apply_template(tl,list_a,list_b)
{
  var all_access = 0;
  var i = 0;
  var tv;
  if (tl.selectedIndex < 0 || tl.options[tl.selectedIndex].value == '')
    return;
  var tlv = tl.options[tl.selectedIndex].value;
  

  
  if (tlv == "*")
    {
      move_all_list(list_b,list_a,null);
      return;
    }
  
  move_all_list(list_a,list_b,null);
  
  if (tlv == "#")
    return;
  

  var tla = tlv.split(","); 

  move_all_list(list_b,list_a,tla);
}






function search_option_value(tlist,value)
{
  var i = tlist.length;
  while (i--)
    if (tlist.options[i].value == value)
      return i;
  return false;
}


function apply_template2(template_list,list_a,list_b)
{
  var i;
  var b;
  var a;
  var all_access;

  all_access = 0;

  if (template_list.value == '')
    return;

  var txt = template_list.value;

  if (txt == "*")
    {
      txt = "";
      all_access = 1;
    }
  else
    if (txt == "#")
      {
	txt = "";
      }

  var tab_auth = txt.split(",");

  dstlist = new Array();
  newlist_a = new Array();
  newlist_b = new Array();

  a = 0;
  b = 0;
  i = 0;
  
  while (i != list_a.options.length)
    {
      newlist_b[b] = list_a.options[i];
      i ++;
      b ++;
    }
  
  i = 0;
  while (i != list_b.options.length)
    {
      newlist_b[b] = list_b.options[i];
      i ++;
      b ++;
    }

  if (all_access == 1)
    {
      i = 0;
      while (i != newlist_b.length)
	{
	  tab_auth[i] = newlist_b[i].value;
	  i ++;
	}
    }

  i = 0;
  while (i != tab_auth.length)
    {
      b = 0;
      while (b != newlist_b.length && newlist_b[b].value != tab_auth[i])
	b ++;
      
      if (b != newlist_b.length)
	{
	  newlist_a[a] = newlist_b[b];
	  while (b != newlist_b.length-1)
	    {
	      newlist_b[b] = newlist_b[b+1];
	      b ++;
	    }
	  newlist_b.length --;
	  a ++;
	}
      i ++;
    }

  newlist_a.sort(option_text_strcmp);
  newlist_b.sort(option_text_strcmp);

  i = 0;
  while (i != newlist_a.length)
    {
      list_a.options[i] = newlist_a[i];
      i ++;
    }
  list_a.length = newlist_a.length;

  i = 0;
  while (i != newlist_b.length)
    {
      list_b.options[i] = newlist_b[i];
      i ++;
    }
  list_b.length = newlist_b.length;
}






function add_input2list_simple(thislist,thisinput,thishidden)
{
  if (!thisinput.value)
    return;
  if (!checkType_validate_alert(thisinput))
    return;
  if (exists_list(thislist, 
		  thisinput.value, 
		  thisinput.value)) 
    {
      alert(error_mesg['js/This entry already exists']);
      return;
    }
  add_list(thislist, 
	   thisinput.value, 
	   thisinput.value);
  thisinput.value = '';
  sort_list(thislist);
  serialize_list(thislist,thishidden);
}


function option_value_strcmp(a,b)
{
  if (a.value < b.value)
    return(-1);
  if (a.value > b.value)
    return(1);
  return(0);
}

function option_text_strcmp(a,b)
{
  if (a.text < b.text)
    return(-1);
  if (a.text > b.text)
    return(1);
  return(0);
}


function set_selected(list, value)
{
  var i;
  if (!list || !list.options || !list.options.length)
    return;
  i = list.options.length;
  while (i--)
    if (list.options[i].value == value)
      return list.selectedIndex = i;
}


function move_to_list(from,to)
{
  return _move_to_list(from,to,true,true)
}

function move_to_list_nosort(from,to)
{
  return _move_to_list(from,to,false,true)
}

function copy_to_list(from,to)
{
  return _move_to_list(from,to,true,false)
}

function copy_to_list_nosort(from,to)
{
  return _move_to_list(from,to,false,false)
}

function _move_to_list(from,to,with_sort,delete_source)
{
  var savedIndexFrom;
  
  if (from.selectedIndex < 0)
    return;
  
  savedIndexFrom = from.selectedIndex;	

  if (to && to.options)
    {
      to.options[to.options.length] = new Option(from.options[from.selectedIndex].text, 
						 from.options[from.selectedIndex].value);
      if (with_sort)
	sort_list(to);

      to.selectedIndex = to.options.length - 1;
    }

  if (delete_source)
    {
      from.options[from.selectedIndex] = null;
      if (savedIndexFrom < from.options.length)
	from.selectedIndex = savedIndexFrom;
      else
	from.selectedIndex = from.options.length - 1;
    }

  return;
}

function text_move_to_list(from,to, separator)
{
  return _text_move_to_list(from,to,true, separator)
}

function text_move_to_list_nosort(from,to, separator)
{
  return _text_move_to_list(from,to,false, separator)
}

function _text_move_to_list(from,to,with_sort, separator)
{
  if (from.value == '')
    return;
  
  if (to)
    {
      var i = to.options.length;

      if (separator != '')
	{
	  splited_str_array = from.value.split(separator);
	  splited_str = splited_str_array[0];
	  while (i != 0 && to.options[i-1].text != splited_str)
	    {
	      i --;
	    }
	}
      else
	{
	  while (i != 0 && to.options[i-1].value != from.value)
	    {
	      i --;
	    }
	}

      if (i == 0)
	{
	  if (separator != '')
	    {
	      to.options[to.options.length] = new Option(splited_str,from.value);
	    }
	  else
	    {
	      to.options[to.options.length] = new Option(from.value,from.value);
	    }
	
	  
	  if (with_sort)
	    sort_list(to);
	  else
	    to.selectedIndex = to.options.length - 1;
	}
    }

  from.value = '';
  return;
}

function add_list(thislist, text, value)
{
  thislist.options[thislist.options.length] = new Option(text,value);
  thislist.selectedIndex = thislist.options.length - 1;
}

function incr_selected(thislist)
{

  if (thislist.selectedIndex < (thislist.options.length - 1))
    thislist.selectedIndex ++;
}


function copy_to_list(srclist,trglist)
{
  if (srclist.selectedIndex < 0)
    return;
  srctext = srclist.options[srclist.selectedIndex].text;
  srcvalue = srclist.options[srclist.selectedIndex].value;

  if (exists_list(trglist, srctext, srcvalue))
    {
      alert(d('js/This entry already exists'));
      return;
    }
  add_list(trglist,srctext,srcvalue);
  incr_selected(srclist);
}


function go_search(thisform)
{
  if (ipm_page_is_loaded == 1)
    {
      if (thisform.record_offset)
	thisform.record_offset.value = 0;
      unselect_record();
      thisform.submit();
    }
}	

function go_abc(thischar,thisform)
{

  thisform.record_offset.value = 0;
  if (thisform && thisform.search_abc)
    {
      thisform.search_abc.value = thischar;
      if (thisform.search_type && thisform.search_text)
	{
	  var i = thisform.search_type.options.length;
	  while (i--)
	    if (thisform.search_type.options[i].value == 'beginby')
	      thisform.search_type.options[i].selected = true;
	  thisform.search_text.value = thischar;
	} 
      unselect_record();
      thisform.submit();
    }
}


function exists_list(list, text, value)
{	
  var i = list.options.length;

  if (arguments.length > 3 && arguments[3])
    or_exclusion = false;
  else
    or_exclusion = true;
  while (i--)
    if (or_exclusion && (list.options[i].value == value || list.options[i].text == text) ||
	!or_exclusion && list.options[i].value == value && list.options[i].text == text)
      return true;
  return false;
}	





function notexists_list_mesg(list,text,value,input_text)
{
  if (exists_list(list,text,value))
    {
      alert(d('js/This entry already exists'));
      if (input_text)
	{
	  input_text.focus();
	  input_text.select();  
	}
      return false;
    }
  return true;
}

function delete_all_list(list)
{
  if (list && list.options)
    while (list.options.length)
      list.options[0] = null;
}	

function extract_intersect_list(from, to) /* from list must sorted */
{
  var hashtab = new Array();
  var i;
  var buffer = new String();
  
  if (!to || !from)
      return;
  
  i = to.options.length;
  while (i-- > 0)
    {
      hashtab[to.options[i].value] = ++hashtab.length;
    }

  i = from.options.length;
  while (i-- > 0)
    {
      if (hashtab[from.options[i].value])
	{
	  from.options[i] = null;
	}
    }
}



function sort_list(list)
{
  var tab = new Array();
  var i = 0;
  while (list.options.length)
    {
      tab[tab.length] = new Option(list.options[0].text,list.options[0].value);
      list.options[0] = null;
    }
  tab.sort(option_text_strcmp);
  
  while (i < tab.length)
    {
      list.options[list.options.length] = new Option(tab[i].text,tab[i].value);
      i++;
    }
}


function delete_list(list)
{
  var pos;
  pos = list.selectedIndex;
  if (pos == -1)
    return;

  if (list.options[pos].value)
    {
      list.options[pos] = null;
      if (pos == 0)
	list.selectedIndex = 0;
      else
	list.selectedIndex = pos-1;
    }
}


function delete_choosed_option(tlist)
{
  var i = tlist.length;
  while (i--)
    if (tlist.options[i].value == '#???#')
      {
	tlist.options[i] = null;
	return;
      }
}


function update_twins_list(l1, l2)
{
  var i = 0;
  
  delete_all_list(l2);
  while (i < l1.options.length)
    {
      if (!l1.options[i].selected)
	add_list(l2, l1.options[i].text, l1.options[i].value);
      i++;
    }
}

function up_list(list)
{
  var current_option;
  var cov,cot,pov,pot,sindex;
  sindex = list.selectedIndex;
    
  if (sindex == 0 || sindex == -1 || !list.options[sindex].value)
    return;

  cov = list.options[sindex].value;
  cot = list.options[sindex].text;
  list.options[sindex].value = list.options[sindex - 1].value;
  list.options[sindex].text = list.options[sindex - 1].text;
  list.options[sindex - 1].value = cov;
  list.options[sindex - 1].text = cot;
  list.options[sindex - 1].selected = true;
}


function down_list(list)
{
  var current_option;
  var cov,cot,nov,not,sindex;
  sindex = list.selectedIndex;
  
  if (sindex >= list.length - 1 ||
      !list.options[sindex+1].value)
    return;

  cov = list.options[sindex].value;
  cot = list.options[sindex].text;
  list.options[sindex].value = list.options[sindex + 1].value;
  list.options[sindex].text = list.options[sindex + 1].text;
  list.options[sindex + 1].value = cov;
  list.options[sindex + 1].text = cot;
  
  list.options[sindex + 1].selected = true;

}


function serialize_list(list,hidden_text)
{	
  serialize_list_separator(list,hidden_text,';');
}


function unserialize_list(list,hidden_text)
{	
  unserialize_list_separator(list,hidden_text,';');
}



function serialize_list_separator(list,hidden_text,separator)
{
  var i = 0;
  var buff="";
  var trailer = "";

  if (arguments.length == 4)
    trailer = arguments[3];  
  while (i < list.length)
    {
      if (list.options[i].value)
        {
          if (buff)
	    buff += separator;
	  buff += list.options[i].value;
        }
      i++;
    }
  if (buff && trailer)
    buff += trailer;
  hidden_text.value = buff;
}


function unserialize_list_separator(list,hidden_text,separator, label_separator)
{	
  var i = 0;
  var trailer = "";

  txt = hidden_text.value.trim();

  if (arguments.length == 4 &&   // remove trailer
      arguments[3].length == 1 &&
      txt.lastIndexOf(arguments[3]) == txt.length -1)
    txt = txt.substr(0,txt.length -1);
  
  tab = txt.split(separator);
  
  while (i < tab.length)
    {
      str = tab[i].trim();
      if (label_separator != '')
	{
	  tmp_str = str.split(label_separator);
	  if (str.length > 0)
	    {
	      add_list(list,tmp_str[0],str);
	    }
	}
      else
	if (str.length > 0)
	  {
	    add_list(list,str,str);
	  }
      i++;
    } 
}


function serialize_full_list(list,hidden_text)
{	
  var i = 0;
  var buff="";
  while (i < list.length)
    {
      if (list.options[i].value)
	buff += list.options[i].text + '#' + list.options[i].value + ';';
      i++;
    } 

  hidden_text.value = buff;
}

function unserialize_full_list(list,hidden_text)
{	
  var i = 0;
  tab = hidden_text.value.split(';');
  while (i < tab.length)
    {
      if (tab[i])
	{
	  tab2 = tab[i].split('#');
	  add_list(list,tab2[0],tab2[1]);
	}
      i++;
    } 
}

function unserialize_list_from_list_separator(to_list,from_list,hidden_text,separator)
{	
  var i;
  var tab_from_list = new Array();

  i = 0;
  while (i < from_list.length)
    {
      if (from_list.options[i].value)
	tab_from_list[from_list.options[i].value] = from_list.options[i].text;
      i++;
    } 

  i = 0;
  tab = hidden_text.value.split(separator);
  while (i < tab.length)
    {
      if (tab[i])
	{
	  if (tab_from_list[tab[i]])
	    {
	      add_list(to_list,tab_from_list[tab[i]],tab[i]);
	    }
	}
      i++;
    } 
}

function unserialize_list_from_list(to_list,from_list,hidden_text)
{
  unserialize_list_from_list_separator(to_list,from_list,hidden_text,';');
}

function set_order(list)     
{
  if (document.forms[0] && document.forms[0].order_column)
    {
      if (document.forms[0].order_column.value == list)
	{
	  if (document.forms[0].order_dir.value == "ASC")
	    document.forms[0].order_dir.value = "DESC";
	  else
	    document.forms[0].order_dir.value = "ASC";
	}
      else
	document.forms[0].order_dir.value = "ASC";

      document.forms[0].order_column.value = list;      
      document.forms[0].record_offset.value = 0;
      unselect_record();
      document.forms[0].submit();
    }

}

function next_page()
{
//  document.forms[0].record_browse.value = "next";

  if (document.forms[0] && 
      document.forms[0].record_limit &&
      document.forms[0].record_offset)
    {
      if (!document.forms[0].record_offset.value)
	document.forms[0].record_offset.value = 0;

      document.forms[0].record_offset.value = document.forms[0].record_limit.value * 1 + document.forms[0].record_offset.value * 1;
      unselect_record();
      document.forms[0].submit();
    }


}


function prev_page()
{
//  document.forms[0].record_browse.value = "prev";
  if (document.forms[0] && 
      document.forms[0].record_offset &&  
      document.forms[0].record_limit)
    {
         if (!document.forms[0].record_offset.value)
	document.forms[0].record_offset.value = 0;

      document.forms[0].record_offset.value = document.forms[0].record_offset.value * 1 - document.forms[0].record_limit.value * 1;
      unselect_record();
      document.forms[0].submit();
    }
}

function goto_page(pos)
{
//  document.forms[0].record_browse.value = "goto";

  if (document.forms[0]
      && document.forms[0].record_offset
//    && document.forms[0].record_limit
//    && document.forms[0].hidden_record_count
      )
    {
      document.forms[0].record_offset.value = pos;
      unselect_record();
      document.forms[0].submit();
    }
}



function nowhere()
{
  return;
}

function checkall(checked,thisform)
{
  var i=0;
  var len = thisform.elements.length;
  if (thisform.select_all_bottom)
    thisform.select_all_bottom.checked = checked;
  if (thisform.select_all_top)
    thisform.select_all_top.checked = checked;

  //re = /(ckbx_[a-zA-Z0-9 \._-]+)/i;
  re = /(ckbx_.*)/i;
  for( i=0; i<len; i++)
    {
      if (thisform.elements[i].name.match(re))
	thisform.elements[i].checked=checked;
    }
}

function checkallonpage(checked,thisform)
{
  var i=0;
  var len = thisform.elements.length;
  if (thisform.select_allonpage_bottom)
    thisform.select_allonpage_bottom.checked = checked;
  if (thisform.select_allonpage_top)
    thisform.select_allonpage_top.checked = checked;

  if (thisform.select_all_bottom)
    thisform.select_all_bottom.checked = false;
  if (thisform.select_all_top)
    thisform.select_all_top.checked = false;

  re = /^(ckbx_.*)$/i;
  for( i=0; i<len; i++)
    {
      if (thisform.elements[i].name.match(re))
	thisform.elements[i].checked=checked;
    }
}

function checkallpages(checked,thisform)
{
  var i=0;
  var len = thisform.elements.length;
  if (thisform.select_allonpage_bottom)
    thisform.select_allonpage_bottom.checked = false;
  if (thisform.select_allonpage_top)
    thisform.select_allonpage_top.checked = false;

  if (thisform.select_all_bottom)
    thisform.select_all_bottom.checked = checked;
  if (thisform.select_all_top)
    thisform.select_all_top.checked = checked;

  re = /^(ckbx_.*)$/i;
  for( i=0; i<len; i++)
    {
      if (thisform.elements[i].name.match(re))
	thisform.elements[i].checked=checked;
    }
}

function uncheck_all(thisform)
{
  if (thisform.select_allonpage_bottom)
    thisform.select_allonpage_bottom.checked = false;
  if (thisform.select_allonpage_top)
    thisform.select_allonpage_top.checked = false;
  if (thisform.select_all_bottom)
    thisform.select_all_bottom.checked = false;
  if (thisform.select_all_top)
    thisform.select_all_top.checked = false;
}


function serialize_cron(obj)
{
  var form = obj.form;
  var search = 'notregistered_cron_' + obj.name;
  var i = 0;
  obj.value = '';

  select_obj = document.getElementById(search + '_wday');
  if (select_obj)
    obj.value += select_obj.options[select_obj.selectedIndex].value;
  else
    obj.value += '.*';
  
  obj.value += ":";
  select_obj = document.getElementById(search + '_mday');
  if (select_obj)
    obj.value += select_obj.options[select_obj.selectedIndex].value;
  else
    obj.value += '.*';

  obj.value += ":";
  select_obj = document.getElementById(search + '_month');
  if (select_obj)
    obj.value += select_obj.options[select_obj.selectedIndex].value;
  else
    obj.value += '.*';

  obj.value += ':.*';

  obj.value += ":";
  select_obj = document.getElementById(search + '_hour');
  if (select_obj)
    obj.value += select_obj.options[select_obj.selectedIndex].value;
  else
    obj.value += '.*';

  obj.value += ":";
  select_obj = document.getElementById(search + '_min');
  if (select_obj)
    obj.value += select_obj.options[select_obj.selectedIndex].value;
  else
    obj.value += '.*';
	      
  obj.value += ':.*';
}

function unserialize_cron(obj)
{
  var form = obj.form;
  var search = obj.name;
  var i = 0;
  var tab = new Array();

  tab = obj.value.split(':');

  if (obj.value == '' || tab.length == 7)
    {
      unserialize_cron_set_options(search + '_wday',tab[0]);
      unserialize_cron_set_options(search + '_mday',tab[1]);
      unserialize_cron_set_options(search + '_month',tab[2]);
      unserialize_cron_set_options(search + '_hour',tab[4]);
      unserialize_cron_set_options(search + '_min',tab[5]);
    }
  else
    {
      alert(obj.value + ' ---- ' + tab.length);
    }
}

function unserialize_cron_set_options(select_name,select_value)
{
  thisform = document.forms[0];
  var i = thisform.elements.length;

  select_name = 'notregistered_cron_' + select_name;

  while (i -- )
    {
      if (thisform.elements[i].name == select_name)
	{
	  select_obj = thisform.elements[i];
	  if (select_obj && select_obj.options)
	    {
	      var optpos = select_obj.options.length;
	      
	      while (optpos--)
		if (select_obj.options[optpos].value == select_value)
		  select_obj.selectedIndex = optpos;
	    }
	}
    }
}


function serialize_cron_old(obj)
{
  var form = obj.form;
  var search = 'notregistered_cron_' + obj.name;
  var i = 0;
  obj.value = '';

  select_obj = document.getElementById(search + '_min');
  if (select_obj)
    obj.value += select_obj.options[select_obj.selectedIndex].value;
  else
    obj.value += '.*';
  
  obj.value += ":";
  select_obj = document.getElementById(search + '_hour');
  if (select_obj)
    obj.value += select_obj.options[select_obj.selectedIndex].value;
  else
    obj.value += '.*';

  obj.value += ":";
  select_obj = document.getElementById(search + '_mday');
  if (select_obj)
    obj.value += select_obj.options[select_obj.selectedIndex].value;
  else
    obj.value += '.*';

  obj.value += ":";
  select_obj = document.getElementById(search + '_month');
  if (select_obj)
    obj.value += select_obj.options[select_obj.selectedIndex].value;
  else
    obj.value += '.*';

  obj.value += ":";
  select_obj = document.getElementById(search + '_wday');
  if (select_obj)
    obj.value += select_obj.options[select_obj.selectedIndex].value;
  else
    obj.value += '.*';
}

function unselect_record()
{
  var thisform = document.forms[0];
  var i = thisform.elements.length;

  re = /^ckbx_(.*)$/i;
  while (i --)
    if (thisform.elements[i].name.match(re) &&
	thisform.elements[i].checked == true)
      thisform.elements[i].checked = false;
}


function submit_record()
{
  var thisform = document.forms[0];
  
  unselect_record();
  thisform.submit();
}

function generic_record_confirm(id_list,type)
{
  var i = id_list.length;
  var buff;

  if (i > 1)
    buff = d("js/Do you really want to " + type + " those following entries ?") + "\n\n";
  else
    buff = d("js/Do you really want to " + type + " this following entry ?") + "\n\n";

  if (i > 10)
    i = 10;

  while (i--)
    {
      var j = PK_records.length;
      while (j--)
	if (id_list[i] == PK_records[j][0])
	  {
	    buff +=  PK_records[j][1] + "\n";
	  }
    }

  if (id_list.length > 10)
    buff += "...";

  return confirm(buff);
}

function delete_record(id)
{
  var thisid = [id];

  if (generic_record_confirm(thisid,'delete'))
   {
     window.document.forms[0].record_delete.value = thisid.join(" ");
     unselect_record();
     window.document.forms[0].submit();
    }
}

function generic_call_service_args(type,message,args)
{	
  var thisform = document.forms[0];
  var buff = d(message) + "\n\n";
  
  if (confirm(buff))
    {
      thisform.selected_action.value = type;
      thisform.service_args.value = args;
      thisform.submit();
    }
}	

function generic_call_service(type,message)
{	
  var thisform = document.forms[0];
  var buff = d(message) + "\n\n";
  
  if (confirm(buff))
    {
      thisform.selected_action.value = type;
      thisform.submit();
    }
}	

function generic_selected_records(type,label)
{
  var thisform = document.forms[0];
  var i = thisform.elements.length;
  var id_tab = new Array;
  var j = 0;
  var hidden_obj;
  var msg1;
  var msg2;
  var confirm_result;
  var buff;

  re = /^ckbx_(.*)$/i;
  re_address = /ckbx_A_[0-9]+/i;
  while (i --)
    if (thisform.elements[i].name.match(re) &&
	thisform.elements[i].checked == true &&
	!(type == 'delete' && thisform.elements[i].name.match(re_address)))
      id_tab[j++] = RegExp.$1;

  if (label == '')
    label = type;

  if (thisform && j)
    {
      if (thisform.select_all_top.checked == true)
	{
	  buff = d("js/Do you really want to " + label + " all entries using the current filters ?") + "\n\n";

	  if (thisform.hidden_record_count.value <= 1)
	    buff += thisform.hidden_record_count.value + " " + d("js/entry") + "\n\n";
	  else
	    buff += thisform.hidden_record_count.value + " " + d("js/entries") + "\n\n";

	  confirm_result = confirm(buff);
	}
      else
	confirm_result = generic_record_confirm(id_tab,label);
      
      if (confirm_result)
	{
	  thisform.selected_action.value = type;
	  thisform.selected_records.value = id_tab.join(" ");
	  submit_record();
	}
    }
  else
    alert(d("js/No selection,\nplease select the rows before"));  
}

function open_execute_macro(page_name,url,php_id,no_export_format)
{
  var obj = new Object();

  obj.page_name = page_name;
  obj.url = url;
  obj.php_id = php_id;
  obj.no_export_format = no_export_format;
  return open_execute_obj(obj);

  // return _open_execute(page_name,url,php_id,'',no_export_format,'','');
}

function open_execute_service(php_name,title,php_params)
{
  var obj = new Object();

  obj.url = '/mod/system/script/wizzard_script.php';
  obj.php_name = php_name;
  obj.no_export_format = 1;
  obj.title = title;
  obj.php_params = php_params;
  return open_execute_obj(obj);

  // return _open_execute('', '/mod/system/script/wizzard_script.php', '', php_name,1,title,php_params);
}

function open_execute_service_params(page_name,php_name,no_export_format,php_params)
{
  var obj = new Object();

  obj.page_name = page_name;
  obj.url = '/mod/system/script/wizzard_script.php';
  obj.php_name = php_name;
  obj.no_export_format = no_export_format;
  obj.php_params = php_params;
  obj.min_selected = 1;
  return open_execute_obj(obj);

  // return _open_execute(page_name, '/mod/system/script/wizzard_script.php', '', php_name, no_export_format,php_name,php_params);
}

function open_execute_service_export(php_name,title,php_params)
{
  var obj = new Object();

  obj.url = '/mod/system/script/wizzard_script.php';
  obj.php_name = php_name;
  obj.php_params = php_params;
  obj.title = title;
  return open_execute_obj(obj);

  // return _open_execute('', '/mod/system/script/wizzard_script.php', '', php_name,'',title,php_params);
}

function open_execute_report(report_php_name)
{
  return _open_execute('', '/mod/generic/wizzard_report.php', '', 'report_generate.php', 1, '', 'wizzard_action=ok&report_format=html&no_sql=1&report_type_php_name='+report_php_name);
}

function open_wizzard_report(url, need_selection, php_params)
{
  var thisform = document.forms[0];
  var i = thisform.elements.length;
  var j = 0;

  // alert('obsolete open_wizzard_report');

  sel = '';
  querysel = '';

  re = /^ckbx_(.*)$/i;
  while (i --)
    {
      if (thisform.elements[i].name.match(re) &&
	  thisform.elements[i].checked == true)
	{
	  if (sel != '')
	    sel = sel + ',';
	  sel = sel + RegExp.$1;
	  j ++;
	}
    }

  if (j == 0 && !thisform.history_back && need_selection == '1')
    {
      alert(d('js/No selection,\nplease select the rows before'));
    }
  else
    {
      var the_date = new Date();

      if (thisform.history_back)
	sel = thisform.selected_records.value;
      else
	{
	  if (thisform.select_all_top)
	    {
	      if (thisform.select_all_top.checked == true)
		querysel = thisform.selected_query.value;
	      else
		{
		  if (thisform.search_object_id.value != '')
		    {
		      filter = /^(.*)\+.*$/;
		      if (tab_re = filter.exec(thisform.selected_query.value))
			{
			  querysel = tab_re[1];
			}
		      else
			querysel = thisform.selected_query.value;

		      if (j != 0)
			querysel += ' ' + 'WHERE=' + encodeURI(thisform.search_object_id.value + ' in (' + sel + ')');
		      querysel = encodeURIComponent(querysel);
		    }
		}
	    }
	}

      winname = 'macro' + the_date.getHours() + '_' + the_date.getMinutes() + '_' + the_date.getSeconds() + '_' + the_date.getDate() + '_' + the_date.getMonth();

      if (php_params)
	php_params = '&' + php_params;
      else
	php_params = '';
      eip_open_wizzard(url + '?selected_query=' + querysel + '&selected_oids=' + sel + php_params,500,350);
    }
}

function _open_execute(page_name,url,php_id,php_name,no_export_format,title,php_params)
{
  var thisform = document.forms[0];
  var i = thisform.elements.length;
  var j = 0;

  // alert('obsolete _open_execute');

  sel = '';
  querysel = '';

  re = /^ckbx_(.*)$/i;
  while (i --)
    {
      if (thisform.elements[i].name.match(re) &&
	  thisform.elements[i].checked == true)
	{
	  if (sel != '')
	    sel = sel + ',';
	  sel = sel + RegExp.$1;

	  j ++;
	}
    }

  if ((j == 0 && (php_id != '' || php_name != '')) && !thisform.history_back && !php_params)
    {
      alert(d('js/No selection,\nplease select the rows before'));
    }
  else
    {
      var the_date = new Date();

      if (thisform.history_back)
	sel = thisform.selected_records.value;
      else
	{
	  if (thisform.select_all_top)
	    {
	      if (thisform.select_all_top.checked == true)
		querysel = thisform.selected_query.value;
	      else
		{
		  if (thisform.search_object_id.value != '')
		    {
		      filter = /^(.*)\+.*$/;
		      if (tab_re = filter.exec(thisform.selected_query.value))
			{
			  querysel = tab_re[1];
			}
		      else
			querysel = thisform.selected_query.value;

		      querysel += ' ' + 'WHERE=' + encodeURI(thisform.search_object_id.value + ' in (' + sel + ')');
		      querysel = encodeURIComponent(querysel);
		    }
		}
	    }
	}

      winname = 'macro' + the_date.getHours() + '_' + the_date.getMinutes() + '_' + the_date.getSeconds() + '_' + the_date.getDate() + '_' + the_date.getMonth();
      
      if (php_params)
	php_params = '&' + php_params;
      else
	php_params = '';
	
      eip_open_wizzard(url + '?php_name='+ php_name +'&title=' + title + '&php_id=' + php_id + '&no_export_format=' + no_export_format + '&calling_page=' + page_name + '&selected_query=' + querysel + '&selected_oids=' + sel + php_params,500,350);
      // winwiz=window.open(url + '?php_name='+ php_name +'&title=' + title + '&php_id=' + php_id + '&no_export_format=' + no_export_format + '&calling_page=' + page_name + '&selected_query=' + querysel + '&selected_oids=' + sel + php_params,winname,'width=500,height=350,scrollbars=no,locationbar=yes,resizable=yes');
      // winwiz.focus();
    }
}

function open_execute_obj(obj)
{
  var thisform = document.forms[0];
  var i = thisform.elements.length;
  var j = 0;
  var page_name = '';
  var url = '/mod/system/script/wizzard_script.php';
  var php_id = '';
  var php_name = '';
  var ending_report = '';
  var title = '';
  var php_params = '';
  var min_selected = 0;
  var max_selected = 0;

  if (obj.page_name)
    page_name = obj.page_name;

  if (obj.php_name)
    php_name = obj.php_name;

  if (obj.url)
    url = obj.url;

  if (obj.php_id)
    php_id = obj.php_id;

  if (obj.ending_report)
    ending_report = obj.ending_report;

  if (obj.title)
    title = obj.title;

  if (obj.php_params)
    php_params = obj.php_params;

  if (obj.min_selected)
    min_selected = obj.min_selected;

  if (obj.max_selected)
    max_selected = obj.max_selected;

  sel = '';
  sel_txt = '';
  querysel = '';
  querysel_txt = '';

  re = /ckbx_(.*)/i;
  re_txt = /^ckbx_A_(.*)$/i;
  while (i --)
    {
      if (thisform.elements[i].checked == true)
	{
	  if (thisform.elements[i].name.match(re_txt))
	    {
	      if (sel_txt != '')
		sel_txt = sel_txt + ',';
	      sel_txt = sel_txt + RegExp.$1;

	      j ++;
	    }
	  else
	    if (thisform.elements[i].name.match(re))
	      {
		if (sel != '')
		  sel = sel + ',';
		sel = sel + RegExp.$1;
		
		j ++;
	      }
	}
    }

  if (thisform.select_all_top && thisform.select_all_top.checked == true)
    j = thisform.hidden_record_count.value;
  
  var msg_min_select_rows = 'js/No selection,\nplease select the rows before';
  var msg_max_select_rows = 'js/Too many selection,\nplease select less rows';

  if (obj.msg_min_select_rows)
    msg_min_select_rows = obj.msg_min_select_rows;

  if (obj.msg_max_select_rows)
    msg_max_select_rows = obj.msg_max_select_rows;

  if (thisform.history_back)
    {
      sel = thisform.selected_records.value;
      j = 1;
    }

  if (min_selected && j < min_selected)
    {
      alert(d(msg_min_select_rows));
      return;
    }
  if (max_selected && j > max_selected)
    {
      alert(d(msg_max_select_rows));
      return;
    }

  var the_date = new Date();
  
  if (thisform.select_all_top)
    {
      if (thisform.select_all_top.checked == true)
	querysel = thisform.selected_query.value;
      else
	{
	  if (sel != '')
	    {
	      if (thisform.search_object_id.value != '')
		{
		  filter = /^(.*)\+.*$/;
		  if (tab_re = filter.exec(thisform.selected_query.value))
		    querysel = tab_re[1];
		  else
		    querysel = thisform.selected_query.value;
		  
		  querysel += ' ' + 'WHERE=' + encodeURI(thisform.search_object_id.value + ' in (' + sel + ')');
		  querysel = encodeURIComponent(querysel);
		}
	    }
	}
    }

  winname = 'macro' + the_date.getHours() + '_' + the_date.getMinutes() + '_' + the_date.getSeconds() + '_' + the_date.getDate() + '_' + the_date.getMonth();
  
  url += '?';

  if (title)
    url += '&title=' + encodeURIComponent(title);

  if (php_id)
    url += '&php_id=' + encodeURIComponent(php_id);

  if (ending_report)
    url += '&no_export_format=' + encodeURIComponent(ending_report);
  else
    {
      if (obj.no_export_format)
	url += '&no_export_format=1';
    }

  if (php_name)
    url += '&php_name=' + encodeURIComponent(php_name);

  if (page_name)
    url += '&calling_page=' + encodeURIComponent(page_name);

  if (querysel)
    url += '&selected_query=' + querysel;

  if (sel)
    url += '&selected_oids=' + encodeURIComponent(sel);

  if (sel_txt)
    url += '&selected_txt=' + encodeURIComponent(sel_txt);

  if (php_params)
    url += '&' + php_params;

  eip_open_wizzard(url,500,350);
}

function eip_upload_click(file_obj,text_obj)
{
  file_obj.click();
  text_obj.value = file_obj.value;
}

var _address_is_valid = true;


function eip_subnet_address_change(subnet_addr,subnet_mask,subnet_prefix,subnet_info,force_prefix)
{
  var laddr, netclass, prefix, cidr;
  _address_is_valid = true;


  if (!subnet_addr)
    {
      alert('eip_subnet_address_change is null');
      return;
    }

  if (!subnet_prefix.options && force_prefix)
    subnet_prefix.value = force_prefix;

  if (!subnet_mask.options && force_prefix)
    subnet_mask.value = prefix2netmask(force_prefix);

  if (!subnet_addr.value)
    return;
  
  if (!/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/i.exec(subnet_addr.value))
    return;
  
  laddr = netaddr2long(subnet_addr.value);

  if (!subnet_prefix.options && force_prefix)
    {
      update_netinfo(subnet_info,laddr,force_prefix);
      if (laddr & ((1 << (32 - force_prefix)) - 1))
	{
	  if (subnet_info != null)
	    {
	      subnet_info.value = d("This subnet address does not match the subnet size");
	      subnet_info.value += ' ' + force_prefix;
	      subnet_addr.EIP.alert = 1;
	    }
	}
      else
	subnet_addr.EIP.alert = null;
      return;
    }


  if (!force_prefix)
    {
      delete_all_list(subnet_mask);
      delete_all_list(subnet_prefix);
    }
  

  if (laddr)
    {
      if (!force_prefix)
	{
	  if (!is_subnet_address(laddr))
	    return;
	  netclass = network_class(laddr);
	  cidr =1;
	  prefix = probable_prefix(laddr,1);
	  if (prefix < 8)
	    prefix = 8;

	  update_prefix(subnet_prefix,laddr,null);
	  update_netmask(subnet_mask,laddr,null);

	  if (subnet_info != null)
	    update_netinfo(subnet_info,laddr,prefix);
	}
      else
	{
	  if (laddr & ((1 << (32 - force_prefix)) - 1))
	    {
	      _address_is_valid = false;

	      if (subnet_info != null)
		{
		  subnet_info.value = d("This subnet address do not match the prefix");
		  subnet_info.value += ' ' + force_prefix;
		}
	      callError(subnet_addr,0,0);
	    }
	  else
	    {
	      if (subnet_info != null)
		update_netinfo(subnet_info,laddr,force_prefix);
	    }
	}
    }
}


function eip_subnet_address_changeold(subnet_addr,subnet_mask,subnet_prefix,subnet_info,force_prefix)
{
  var laddr, netclass, prefix, cidr;
  _address_is_valid = true;

  if (!subnet_addr)
    {
      alert('eip_subnet_address_change is null');
      return;
    }
  
  if (!force_prefix)
    {
      delete_all_list(subnet_mask);
      delete_all_list(subnet_prefix);
    }

  if (subnet_addr.value)
    {
      if (!/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/i.exec(subnet_addr.value))
	{
	  return;
	}
      
      laddr = netaddr2long(subnet_addr.value);
      if (!force_prefix)
	{
	  if (!is_subnet_address(laddr))
	    return;
	  netclass = network_class(laddr);
	  cidr =1;
	  prefix = probable_prefix(laddr,1);
	  if (prefix < 8)
	    prefix = 8;

	  update_prefix(subnet_prefix,laddr,null);
	  update_netmask(subnet_mask,laddr,null);

	  if (subnet_info != null)
	    update_netinfo(subnet_info,laddr,prefix);
	}
      else
	{
	  if (laddr & ((1 << (32 - force_prefix)) - 1))
	    {
	      _address_is_valid = false;

	      if (subnet_info != null)
		{
		  subnet_info.value = d("This subnet address do not match the prefix");
		  subnet_info.value += ' ' + force_prefix;
		}
	      callError(subnet_addr,0,0);
	    }
	  else
	    {
	      if (subnet_info != null)
		update_netinfo(subnet_info,laddr,force_prefix);
	    }
	}
    }
}

function eip_subnet6_address_change(subnet_addr,subnet_prefix,subnet_info)
{
  var laddr, netclass, min_prefix, cidr;
  _address_is_valid = true;
  var force_prefix = 0;
  var tab_bits;
  
//  if (!force_prefix)
    {
      delete_all_list(subnet_prefix);
    }
  
  if (subnet_addr.value)
    {
      ip6_addr = hostaddr6_to_ip6_addr(subnet_addr.value);

      min_prefix = probable_prefix6(ip6_addr);
      // tab_bits = ip6_addr_to_tab_bits(ip6_addr);

      // check ip_addr is valid
      
      if (!force_prefix)
	{
	  // if (prefix < 8)
	  // prefix = 8;
	  
	  update_prefix6(subnet_prefix,min_prefix,null);

	  // if (subnet_info != null)
	  // update_netinfo(subnet_info,laddr,prefix);
	}
      else
	{
	  if (laddr & ((1 << (32 - force_prefix)) - 1))
	    {
	      _address_is_valid = false;

	      if (subnet_info != null)
		{
		  subnet_info.value = d("This subnet address do not match the prefix");
		  subnet_info.value += ' ' + force_prefix;
		}
	      callError(subnet_addr,0,0);
	    }
	  else
	    {
	      if (subnet_info != null)
		update_netinfo(subnet_info,laddr,force_prefix);
	    }
	}
    }
}

function eip_subnet_netmask_change(subnet_addr,subnet_mask,subnet_prefix,subnet_info)
{
  if (subnet_addr && subnet_info)
    {
      laddr = netaddr2long(subnet_addr.value);
      prefix = subnet_prefix.options[subnet_mask.selectedIndex].value;
      update_netinfo(subnet_info, laddr, prefix);
    }
  subnet_prefix.selectedIndex = subnet_mask.selectedIndex;
}


function eip_subnet_prefix_change(subnet_addr,subnet_mask,subnet_prefix,subnet_info)
{
  if (subnet_addr && subnet_info)
    {
      laddr = netaddr2long(subnet_addr.value);
      prefix = subnet_prefix.options[subnet_prefix.selectedIndex].value;
      update_netinfo(subnet_info,laddr,prefix);      
    }
  subnet_mask.selectedIndex = subnet_prefix.selectedIndex;
}

function eip_range_start_address_change(start_addr,end_addr,range_size)
{
  sladdr = netaddr2long(start_addr.value);
  if (sladdr == false)
    return;

  eladdr = netaddr2long(end_addr.value);
  if (eladdr)
    if (eladdr >= sladdr)
      range_size.value = eladdr - sladdr + 0x1;
    else
      range_size.value = 0;
  else if (/^\d+$/i.exec(range_size.value))
    end_addr.value = netlong2addr(sladdr + parseInt(range_size.value,10) - 1);
}

function eip_range6_start_address_change(start_addr,end_addr,range_size)
{
  return;

  sladdr = netaddr2long(start_addr.value);
  if (sladdr == false)
    return;

  eladdr = netaddr2long(end_addr.value);
  if (eladdr)
    if (eladdr >= sladdr)
      range_size.value = eladdr - sladdr + 0x1;
    else
      range_size.value = 0;
  else if (/^\d+$/i.exec(range_size.value))
    end_addr.value = netlong2addr(sladdr + parseInt(range_size.value,10) - 1);
}

function eip_range_end_address_change(start_addr,end_addr,range_size)
{
 eladdr = netaddr2long(end_addr.value);
  if (eladdr == false)
    return;
  
  sladdr = netaddr2long(start_addr.value);

  if (sladdr)
    if (eladdr >= sladdr)
      range_size.value = parseFloat(eladdr) - parseFloat(sladdr) + 1;
    else
      range_size.value = 0;
  else if (/^\d+$/i.exec(range_size.value))
    start_addr.value = netlong2addr(eladdr - parseInt(range_size.value,10) + 1);  
}

function eip_range6_end_address_change(start_addr,end_addr,range_size)
{
  return;

  eladdr = netaddr2long(end_addr.value);
  if (eladdr == false)
    return;
  
  sladdr = netaddr2long(start_addr.value);

  if (sladdr)
    if (eladdr >= sladdr)
      range_size.value = parseFloat(eladdr) - parseFloat(sladdr) + 1;
    else
      range_size.value = 0;
  else if (/^\d+$/i.exec(range_size.value))
    start_addr.value = netlong2addr(eladdr - parseInt(range_size.value,10) + 1);  
}

function eip_range_size_change(start_addr,end_addr,range_size)
{
  if (!/^\d+$/i.exec(range_size.value))
    return;
  
  sladdr = netaddr2long(start_addr.value);
  eladdr = netaddr2long(end_addr.value);
  if (sladdr)
    {
      eladdr = sladdr + parseInt(range_size.value,10) - 1;
      end_addr.value = netlong2addr(eladdr);
    }
  else
    if (eladdr)
      {
	start_addr.value = netlong2addr(eladdr - parseInt(range_size.value,10) + 1);
      }
}

function eip_range6_size_change(start_addr,end_addr,range_size)
{
  if (!/^\d+$/i.exec(range_size.value))
    return;
  
  size_bin = int_to_ip6_bin(parseInt(range_size.value,10));

  if (size_bin == IP6_BIN_ZERO)
    return;

  if (start_addr.value)
    {
      start_bin = ip6_addr_to_ip6_bin(hostaddr6_to_ip6_addr(start_addr.value));
      end_bin = ip6_bin_add(start_bin,size_bin);
      end_bin = ip6_bin_sub(end_bin,IP6_BIN_ONE);
      end_addr.value = ip6_addr_to_hostaddr6(ip6_bin_to_ip6_addr(end_bin));
    }
  else
    if (end_addr.value)
      {
	end_bin = ip6_addr_to_ip6_bin(hostaddr6_to_ip6_addr(end_addr.value));
	
	start_bin = ip6_bin_sub(end_bin,size_bin);
	start_addr.value = ip6_addr_to_hostaddr6(ip6_bin_to_ip6_addr(start_bin));
      }
}

function eip_subnet_size_number_change(subnet_size,subnet_mask,subnet_prefix)
{
  if (subnet_prefix != null)
    subnet_prefix.selectedIndex = 24 - subnet_size.selectedIndex;
  if (subnet_mask != null)
    subnet_mask.selectedIndex = 24 - subnet_size.selectedIndex;
}

function eip_subnet_size_prefix_change(subnet_size,subnet_mask,subnet_prefix)
{
  if (subnet_size != null)
    subnet_size.selectedIndex = 24 - subnet_prefix.selectedIndex;
  if (subnet_mask != null)
  subnet_mask.selectedIndex = subnet_prefix.selectedIndex;
}


function eip_subnet_size_netmask_change(subnet_size,subnet_mask,subnet_prefix)
{
  if (subnet_prefix != null)
    subnet_prefix.selectedIndex = subnet_mask.selectedIndex;
  if (subnet_size != null)
  subnet_size.selectedIndex = 24 - subnet_mask.selectedIndex;
}




function dhcp_acl_update_preview(acl_list)
{
  var i=0, buff='';
  
  while (i < document.forms[0].allow_list.length)
    {
      if (document.forms[0].allow_list[i].value)
	buff += document.forms[0].allow_list[i].text + '; '; 
      i++;
    }

  acl_list.value = buff;
}

function dhcp_acl_add_general(acl_list)
{
  var name = '', rname = '';
  var value, ts;
  
  ts = document.forms[0];
  
  if (document.forms[0].negative_general_acl[1].checked)
    {
      name += "deny ";
      rname += "allow ";
    }
  else
    {
      name += "allow ";
      rname += "deny ";
    }

  name += ts.general_acl.options[ts.general_acl.selectedIndex].value;
  rname += ts.general_acl.options[ts.general_acl.selectedIndex].value;

  value = name + '@*';
  rvalue = rname + '@*';
  if (exists_list(document.forms[0].allow_list, name, value))
    {
      alert(d('js/This ACL already exists.'));
      return;
    }
  
  if (exists_list(document.forms[0].allow_list, rname, rvalue))
    {
      alert(d('js/Warning: Another ACL disable this entry.'));
      return;
    }
  add_list(document.forms[0].allow_list, name, value);
  dhcp_acl_update_preview(acl_list);
}

function dhcp_acl_add_specific(acl_list)
{
  var name = '', rname = '';
  var value, ts;
  
  ts = document.forms[0];
  if (document.forms[0].negative_specific_acl[1].checked)	
    {
      name += "deny ";
      rname += "allow ";
    }
  else
    {
      name += "allow ";
      rname += "deny ";
    }
	
  name += 'members of "' + ts.specific_acl.options[ts.specific_acl.selectedIndex].text + '"';
  rname += 'members of "' + ts.specific_acl.options[ts.specific_acl.selectedIndex].text + '"';

  value = name + '@*';
  rvalue = rname + '@*';
  if (exists_list(document.forms[0].allow_list, name, value))
    {
      alert(d('js/This ACL already exists.'));
      return;
    }

  if (exists_list(document.forms[0].allow_list, rname, rvalue))
    {
      alert(d('js/Warning: Another ACL disable this entry.'));
      return;
    }
  add_list(document.forms[0].allow_list,name,value);
  dhcp_acl_update_preview(acl_list);
}

function initAjaxFileContent(div_name,url,timeout)
{
  fillFileContent(div_name,url,timeout);
}

function fillFileContent(div_name,url,timeout)
{
  var rand_val = (new Date()).getTime();
  buildAndSendRequestAsync(url,'fillFileContent_div(txt,\'' + div_name + '\',\'' + url + '\',' + timeout + ')');
  /* buildAndSendRequest(url + '&rand_val=' + rand_val,'fillFileContent_div(xhr.responseText,\'' + div_name + '\',\'' + url + '\')'); */
}

function fillFileContent_div(txt,div_name,url,timeout)
{
  div_obj = document.getElementById(div_name);
  if (div_obj)
    {
      re = /<script>(.*)<\/script>/i;
      if (txt.match(re))
	{
	  eval(RegExp.$1);
	}
      
      if (div_obj.nodeName != 'DIV')
	div_obj.value = txt;
      else
	div_obj.innerHTML = txt;
    }

  /* window.setTimeout('fillFileContent(\'' + div_name + '\',\'' + url + '\')',50); */
  
  if (timeout > 0)
    window.setTimeout('fillFileContent(\'' + div_name + '\',\'' + url + '\',' + timeout + ')',timeout);
}

function buildAndSendRequest(url,fcnt)
{
  xhr = ipmGetXMLHTTP();

  xhr.open('get',url,false);
  try {
    xhr.send(null);
  }
  catch(e) {
    // return 'Internal server error';
    return '';
  }

  if (xhr.status == 200)
    {
      if (fcnt != null)
	{
	  eval(fcnt);
	}
      else
	return '' + xhr.responseText + '';
    }

  xhr = null;

  return '';
  //  else if (xhr.status == 404)
  // return 'file not found';
  // else
  // return 'error found';
}

function callInProgress (xmlhttp) {
  switch (xmlhttp.readyState) {
  case 1: case 2: case 3:
    return true;
    break;
    // Case 4 and 0
  default:
    return false;
    break;
  }
}

function buildAndSendRequestAsync(url,fcnt)
{
  var xhr = null;
  var timeoutid = null;
  var txt; 
  
  txt = '';

  xhr = ipmGetXMLHTTP();

  if (!xhr)
    {
      alert('ipmGetXMLHTTP error');
      return;
    }

  timeoutid = setTimeout( function()
      {
	if (callInProgress(xhr))
	{
	  xhr.onreadystatechange = null;
	  xhr.abort();
	  xhr = new Object();
	  xhr.responseText = '';
	  eval(fcnt);
	  xhr = null;
	}
      }
  , 5000
  );

  var rand_val = (new Date()).getTime();

  xhr.open('POST',url + '&rand_val=' + rand_val,true);

  xhr.onreadystatechange = 
    function() {
      if (xhr.readyState == 4 && xhr.status == 200)
      {
	clearTimeout(timeoutid); 
	txt = xhr.responseText; 
	
	if (!document.all)
	xhr.onreadystatechange=null;
	xhr=null; 
	eval(fcnt); 
      } 
    };
  
  try {
    xhr.send('');
  }
  catch(e) {
    alert('Internal server error');
  }
}

function ipmGetXMLHTTP()
{
  var xhr=null;

  if(window.XMLHttpRequest)
    xhr = new XMLHttpRequest();
  else if(window.ActiveXObject)
    {
      try
	{
	  xhr = new ActiveXObject("Msxml2.XMLHTTP");
	}
      catch (e)
	{
	  try
	    {
	      xhr = new ActiveXObject("Microsoft.XMLHTTP");
	    }
	  catch (e1)
	    {
	      xhr = null;
	    }
	}
    }
  else
    {
      alert("NO XMLHTTPRequest support");
    }

  return xhr;
}

function eip_upload_loaded(hidden_name,tmpname,realname)
{
  var hidden_obj = parent.document.forms[0][hidden_name];

  if (hidden_obj == null)
    {
      alert('can\'t find parent ' + hidden_name);
      return;
    }
	
  var hidden_local_obj = parent.document.forms[0][hidden_name + '_local_name'];

  if (hidden_local_obj == null)
    {
      alert('can\'t find parent ' + hidden_name);
      return;
    }

  hidden_obj.value = tmpname;
  hidden_local_obj.value = realname;

  if (hidden_obj.onchange)
    hidden_obj.onchange();

  if (hidden_local_obj.onchange)
    hidden_local_obj.onchange();
}

function eip_upload_file(this_obj)
{
  var images = document.getElementById('progress_indicator');
  images.style.visibility = 'visible';

  document.forms[0].submit();
}

function eip_close_wizzard(do_submit)
{
  if (opener)
    {
      if (do_submit == 1)
	opener.document.forms[0].submit();
      else
	if (do_submit != '')
	  opener.document.location = do_submit;
      self.close();
    }
  else
    {
      var wizzard_iframe = parent.document.getElementById('wizzard_iframe');
      if (!wizzard_iframe)
	{
	  alert('can\' find wizzard_iframe (1)');
	  return;
	}
      else
	{
	  wizzard_iframe.src = '/about_blank.html';
	  wizzard_iframe.style.width = '0px';
	  wizzard_iframe.style.height = '0px';
	  wizzard_iframe.style.left = '0px';
	  wizzard_iframe.style.top = '0px';
	  wizzard_iframe.style.visibility = 'hidden';
	}

      eip_close_wait_iframe_wizzard();

      /*
      var wizzard_wait_iframe = parent.document.getElementById('wizzard_wait_iframe');
      if (!wizzard_wait_iframe)
	{
	  alert('can\' find wizzard_wait_iframe');
	  return;
	}
      else
	{
	  wizzard_wait_iframe.src = '/about_blank.html';
	  wizzard_wait_iframe.style.width = '0px';
	  wizzard_wait_iframe.style.height = '0px';
	  wizzard_wait_iframe.style.left = '0px';
	  wizzard_wait_iframe.style.top = '0px';
	  wizzard_wait_iframe.style.visibility = 'hidden';
	}
      */

      var grey_iframe = parent.document.getElementById('grey_iframe');
      if (!grey_iframe)
	{
	  alert('can\' find grey_iframe');
	  return;
	}
      else
	{
	  grey_iframe.style.visibility = 'hidden';
	  grey_iframe.style.width = '0px';
	  grey_iframe.style.height = '0px';
	}

      if (ipm_use_old_ie_iframe)
	{
	  var ie6_grey_iframe = parent.document.getElementById('ie6_grey_iframe');
	  if (!ie6_grey_iframe)
	    {
	      alert('can\' find ie6_grey_iframe');
	      return;
	    }
	  else
	    {
	      ie6_grey_iframe.style.visibility = 'hidden';
	      ie6_grey_iframe.style.width = '0px';
	      ie6_grey_iframe.style.height = '0px';
	    }
	}

      if (do_submit == 1)
	parent.document.forms[0].submit();
      else
	if (do_submit != '')
	  parent.document.location = do_submit;
    }
}

function eip_close_wait_iframe_wizzard()
{
  if (opener)
    {
    }
  else
    {
      var wizzard_wait_iframe = parent.document.getElementById('wizzard_wait_iframe');
      if (!wizzard_wait_iframe)
	{
	  alert('can\' find wizzard_wait_iframe');
	  return;
	}
      else
	{
	  wizzard_wait_iframe.style.visibility = 'hidden';
	}
    }
}

function eip_open_wait_iframe_wizzard()
{
  if (opener)
    return;

  var wizzard_iframe = document.getElementById('wizzard_iframe');

  if (!wizzard_iframe)
    wizzard_iframe = parent.document.getElementById('wizzard_iframe');

  var wizzard_wait_iframe = document.getElementById('wizzard_wait_iframe');

  if (!wizzard_wait_iframe)
    wizzard_wait_iframe = parent.document.getElementById('wizzard_wait_iframe');

  if (!wizzard_iframe)
    {
      alert('can\' find wizzard_iframe (2)');
      return;
    }
  else
    {
      wizzard_wait_iframe.style.width = wizzard_iframe.offsetWidth -8 + 'px';
      wizzard_wait_iframe.style.height = wizzard_iframe.offsetHeight -8 + 'px';
      wizzard_wait_iframe.style.left = wizzard_iframe.offsetLeft + 'px';
      wizzard_wait_iframe.style.top = wizzard_iframe.offsetTop + 'px';

      wizzard_wait_iframe.src = '/wizzard_wait.html';
      wizzard_wait_iframe.style.visibility = 'visible';
    }
}

function eip_resize_bottom_scroll_div(height)
{
  var bottom_scroll_div = document.getElementById('bottom_scroll_div');
  var win_height;

  if (document.all)
    {
      if (document.documentElement.clientHeight)
	win_height = document.documentElement.clientHeight;
      else
	win_height = document.body.offsetHeight;
    }
  else
    {
      win_height = window.innerHeight;
    }

  win_height = win_height - height;
  if (win_height > 0)
    bottom_scroll_div.style.height = win_height + 'px';
}

function eip_check_resize_wizzard()
{
  var wizzard_iframe = document.getElementById('wizzard_iframe');
  var wizzard_wait_iframe = document.getElementById('wizzard_wait_iframe');
  if (wizzard_iframe)
    {
      if (wizzard_iframe.style.visibility == 'visible')
	{
	  if (document.all)
	    {
	      if (document.documentElement.clientHeight)
		{
		  win_width = document.documentElement.clientWidth;
		  win_height = document.documentElement.clientHeight;
		}
	      else
		{
		  win_width = document.body.offsetWidth;
		  win_height = document.body.offsetHeight;
		}
	      
	      iframe_width = wizzard_iframe.offsetWidth;
	      iframe_height = wizzard_iframe.offsetHeight;

	      scroll_left = document.body.scrollLeft;
	      scroll_top = document.body.scrollTop;
	    }
	  else
	    {
	      win_width = window.innerWidth;
	      win_height = window.innerHeight;
	      iframe_width = wizzard_iframe.offsetWidth;
	      iframe_height = wizzard_iframe.offsetHeight;

	      if (window.pageXOffset)
		{
		  scroll_left = window.pageXOffset;
		  scroll_top = window.pageYOffset;
		}
	      else
		{
		  if (window.scrollLeft)
		    {
		      scroll_left = window.scrollLeft;
		      scroll_top = window.scrollTop;
		    }
		  else
		    {
		      scroll_left = 0;
		      scroll_top = 0;
		    }
		}
	    }

	  var pos_x = scroll_left + (win_width-iframe_width)/2;
	  var pos_y = scroll_top + (win_height-iframe_height)/2;

	  if (pos_x < 0)
	    pos_x = 0;

	  if (pos_y < 0)
	    pos_y = 0;

	  wizzard_iframe.style.left = pos_x + 'px';
	  wizzard_iframe.style.top = pos_y + 'px';

	  wizzard_wait_iframe.style.left = pos_x + 'px';
	  wizzard_wait_iframe.style.top = pos_y + 'px';
	  
	  var grey_iframe = document.getElementById('grey_iframe');
	  if (grey_iframe)
	    {
	      grey_iframe.style.width = '100%';
	      grey_iframe.style.height = '100%';
/*
	      grey_iframe.style.left = scroll_left + 'px';
	      grey_iframe.style.top = scroll_top + 'px';
*/
	      grey_iframe.style.left = 0;
	      grey_iframe.style.top = 0;
	    }

	  if (ipm_use_old_ie_iframe)
	    {
	      var ie6_grey_iframe = document.getElementById('ie6_grey_iframe');
	      if (ie6_grey_iframe)
		{
		  ie6_grey_iframe.style.width = '100%';
		  ie6_grey_iframe.style.height = '100%';
/*
		  ie6_grey_iframe.style.left = scroll_left + 'px';
		  ie6_grey_iframe.style.top = scroll_top + 'px';
*/
		  ie6_grey_iframe.style.left = 0 + 'px';
		  ie6_grey_iframe.style.top = 0 + 'px';
		}
	    }
	}
    }
}

function eip_open_wizzard(url,iframe_width,iframe_height)
{
  var in_parent = 0;
  var wizzard_iframe = document.getElementById('wizzard_iframe');

  if (!wizzard_iframe)
    {
      wizzard_iframe = parent.document.getElementById('wizzard_iframe');
      in_parent = 1;
    }

  if (!wizzard_iframe)
    {
      alert('can\'t find wizzard_iframe (3)');
      return;
    }

  if (document.all)
    {
      if (in_parent)
	{
	  win_width = parent.document.body.offsetWidth;
	  win_height = parent.document.body.offsetHeight;
	  scroll_left = parent.document.body.scrollLeft;
	  scroll_top = parent.document.body.scrollTop;
	}
      else
	{
	  if (document.documentElement.clientHeight)
	    {
	      win_width = document.documentElement.clientWidth;
	      win_height = document.documentElement.clientHeight;
	    }
	  else
	    {
	      win_width = document.body.offsetWidth;
	      win_height = document.body.offsetHeight;
	    }

	  scroll_left = document.body.scrollLeft;
	  scroll_top = document.body.scrollTop;
	}
    }
  else
    {
      if (in_parent)
	{
	  win_width = parent.window.innerWidth;
	  win_height = parent.window.innerHeight;
	}
      else
	{
	  win_width = window.innerWidth;
	  win_height = window.innerHeight;
	}

      if (window.pageXOffset)
	{
	  if (in_parent)
	    {
	      scroll_left = parent.window.pageXOffset;
	      scroll_top = parent.window.pageYOffset;	      
	    }
	  else
	    {
	      scroll_left = window.pageXOffset;
	      scroll_top = window.pageYOffset;
	    }
	}
      else
	{
	  if (window.scrollLeft)
	    {
	      if (in_parent)
		{
		  scroll_left = parent.window.scrollLeft;
		  scroll_top = parent.window.scrollTop;
		}
	      else
		{
		  scroll_left = window.scrollLeft;
		  scroll_top = window.scrollTop;
		}
	    }
	  else
	    {
	      scroll_left = 0;
	      scroll_top = 0;
	    }
	}
    }

  var grey_iframe = document.getElementById('grey_iframe');

  if (!grey_iframe)
    var grey_iframe = parent.document.getElementById('grey_iframe');

  if (!grey_iframe)
    {
      alert('can\'t find grey_iframe');
      return;
    }

  var pos_x = scroll_left + (win_width-iframe_width)/2;
  var pos_y = scroll_top + (win_height-iframe_height)/2;
  
  if (pos_x < 0)
    pos_x = 0;
  
  if (pos_y < 0)
    pos_y = 0;

  wizzard_iframe.style.width = iframe_width + 'px';
  wizzard_iframe.style.height = iframe_height + 'px';
  wizzard_iframe.style.left = pos_x + 'px';
  wizzard_iframe.style.top = pos_y + 'px';

  eip_open_wait_iframe_wizzard();

  wizzard_iframe.src = url;
  wizzard_iframe.style.visibility = 'visible';

  if (ipm_use_old_ie_iframe)
    {
      var ie6_grey_iframe = document.getElementById('ie6_grey_iframe');

      if (!ie6_grey_iframe)
	ie6_grey_iframe = parent.document.getElementById('ie6_grey_iframe');

      if (!ie6_grey_iframe)
	{
	  alert('can\'t find ie6_grey_iframe');
	  return;
	}

      ie6_grey_iframe.style.width = '100%';
      ie6_grey_iframe.style.height = '100%';
/*
      ie6_grey_iframe.style.left = scroll_left + 'px';
      ie6_grey_iframe.style.top = scroll_top + 'px';
*/
      ie6_grey_iframe.style.left = 0 + 'px';
      ie6_grey_iframe.style.top = 0 + 'px';

      ie6_grey_iframe.style.visibility = 'visible';
    }

  grey_iframe.style.width = '100%';
  grey_iframe.style.height = '100%'
/*
  grey_iframe.style.left = scroll_left + 'px';
  grey_iframe.style.top = scroll_top + 'px';
*/
  grey_iframe.style.left = 0 + 'px';
  grey_iframe.style.top = 0 + 'px';

  grey_iframe.style.visibility = 'visible';
}

function ocm(name)
{
  var obj = document.getElementById(name);
  if (obj)
    {
      obj.oncontextmenu = function() {open_menudrop(obj,1,'0',name); return false;}
      obj.onmouseout = function() {leave_menudrop(obj,1,'0');}
    }
}

function cmfilt(name,value)
{
  document.getElementById(name).value = value;
  document.forms[0].submit();;
}

var winwiz = 0;
var winsel = 0;

function EFIP_unloadPage()
{
  if (winwiz!=0&&!winwiz.closed) winwiz.close();
  if (winsel!=0&&!winsel.closed) winsel.close();
}

function	openFrame(inside)
{
  if (inside.getAttribute('valFrame') == 'openFrame')
  {
    inside.src = '/img/button18/iconext.png';
    inside.setAttribute('valFrame', 'closeFrame');
    parent.document.body.cols="0,\*";
  }
  else
  {
    inside.src = '/img/button18/icoprev.png';
    inside.setAttribute('valFrame', 'openFrame');
    parent.document.body.cols="15%,\*";
  }
}
function enter_global_search(event)
{
  if ((window.event && window.event.keyCode == 13) ||
      (event && event.which == 13))
    return go_global_search();
  else 
    return true;
}

function go_global_search()
{
  var global_search_iframe = document.getElementById('global_search_iframe');
  var global_search_popup = document.getElementById('global_search_popup');
  var global_search = document.getElementById('global_search');
  if (global_search_iframe)
    {
      global_search_iframe.src = '/mod/generic/popup_search_result.php?search=' + encodeURI(global_search.value);
      
      global_search_popup.style.height = 0;
      global_search_popup.style.visibility = 'visible';
      eip_progressive_resize_div_height('global_search_popup',0,0,220);
    }
  return false;
}



function changeStatBox(obj,idBox, no, yes)
{
  targetBox = document.getElementById(idBox);

  if (targetBox.value == no)
    targetBox.value = yes;
  else
    targetBox.value = no;
}

var eip_report_div_is_open = 0;

function eip_open_close_report_div(cmd)
{
  // var report_button;
  var running_report_popup;
	 
  // report_button = document.getElementById('report_button');
  running_report_popup = document.getElementById('running_report_popup');

  if (eip_report_div_is_open == 0)
    {
      eip_report_div_is_open = 1;

      // report_button.className = 'button_close_report';
      running_report_popup.style.height = 0;
      running_report_popup.style.visibility = 'visible';
      eip_progressive_resize_div_height('running_report_popup',0,0,220);
    }
  else
    if (eip_report_div_is_open == 1)
      {
	eip_report_div_is_open = 0;
	
	// report_button.className = 'button_open_report';
	eip_progressive_resize_div_height('running_report_popup',220,220,0);
	// running_report_popup.style.visibility = 'hidden';
      }
}

function eip_progressive_resize_div_height(div_name,height,start_height,end_height)
{
  div_obj = document.getElementById(div_name);

  if (div_obj == null)
    alert('can\'t find ' + div_name);

  if (start_height < end_height)
    {
      height += 10;

      if (height < end_height)
	{
	  div_obj.style.height = height + 'px';
	  window.setTimeout('eip_progressive_resize_div_height(\'' + div_name + '\',' + height + ',' + start_height + ',' + end_height + ')',10);
	}
      else
	div_obj.style.height = end_height + 'px';
    }
  else
    {
      height -= 10;

      if (height > end_height)
	{
	  div_obj.style.height = height + 'px';
	  window.setTimeout('eip_progressive_resize_div_height(\'' + div_name + '\',' + height + ',' + start_height + ',' + end_height + ')',10);
	}
      else
	{
	  if (end_height == 0)
	    div_obj.style.visibility = 'hidden';
	  else
	    div_obj.style.height = end_height + 'px';
	}
    }
}

function eip_progressive_resize_div_width(div_obj,width,start_width,end_width)
{
  if (start_width < end_width)
    {
      width += 10;

      if (width < end_width)
	{
	  div_obj.style.width = width + 'px';
	  window.setTimeout('eip_progressive_resize_div_width(div_obj,' + width + ',' + start_width + ',' + end_width + ')',10);
	}
      else
	div_obj.style.width = end_width + 'px';
    }
  else
    {
      width -= 10;

      if (width > end_width)
	{
	  div_obj.style.width = width + 'px';
	  window.setTimeout('eip_progressive_resize_div_width(div_obj,' + width + ',' + start_width + ',' + end_width + ')',10);
	}
      else
	{
	  if (end_width == 0)
	    div_obj.style.visibility = 'hidden';
	  else
	    div_obj.style.width = end_width + 'px';
	}
    }
}

var eip_tab_running_report = new Array();
var last_time_report_check = 0;

function initAjaxRunningReportCheck()
{
  buildAndSendRequestAsync('/mod/generic/ajax_json_running_report.php?a=1&last_time=' + last_time_report_check,'ajaxRunningReportCheck(txt)');
}

function eip_get_tab_running_report_by_id(id)
{
  var x = 0;
  var ret_id = -1;

  while (x != eip_tab_running_report.length)
    {
      if (eip_tab_running_report[x] != null)
	{
	  if (eip_tab_running_report[x].id == id)
	    {
	      return(x);
	    }
	}
      else
	ret_id = id;

      x ++;
    }
  if (ret_id != -1)
    return(ret_id);
  else
    return(x);
}

function ajaxRunningReportCheck(txt)
{
  if (txt != '')
    {
      var tmp_tab;
      var running_report;
      var icon_running_report;

      running_report = document.getElementById('running_report');
      icon_running_report = document.getElementById('icon_running_report');

      tmp_tab = eval('(' + txt + ')');

      last_time_report_check = tmp_tab.time;

      var do_open = 0;
      var have_busy = 0;
      var notify_html = '';
      var pos_report;

      var x = 0;

      while (x != eip_tab_running_report.length)
	{
	  if (eip_tab_running_report[x] != null)
	    eip_tab_running_report[x].to_delete = 1;
	  x ++;
	}
  
      x = 0;
      while (report = tmp_tab.reports[x])
	{
	  id = report.id;

	  if (report.status == 'BUSY')
	    have_busy = 1;

	  report_pos = eip_get_tab_running_report_by_id(id);
      
	  if (eip_tab_running_report[report_pos] == null)
	    {
	      var divTag;

	      divTag = document.createElement("div");
	      divTag.id = 'report_' + id;
	      divTag.className ="running_report_line";
	      divTag.innerHTML = report.html;

	      var first_child;

	      first_child = running_report.firstChild;
	      if (first_child)
		running_report.insertBefore(divTag,first_child);
	      else
		running_report.appendChild(divTag);

	      eip_tab_running_report[report_pos] = report;
	      eip_tab_running_report[report_pos].div = divTag;

	      /* create line */
	    }
	  else
	    {
	      old_report = eip_tab_running_report[report_pos];
	      if (old_report.html != report.html)
		{
		  if (report.status == 'OK' && old_report.status != 'OK')
		    {
		      do_open = 1;
		      notify_html += '<div style="cursor:pointer"';
		      
		      notify_html += ' onclick="javascript:o=new Object();o.url=\'/mod/generic/wizzard_show_report.php\';o.php_params=\'report_id=' + report.id + '\';open_execute_obj(o);x"';

		      notify_html += '>';

		      notify_html += '<div>' + report.name + '</div>';

		      if (report.nb_error && report.nb_error > 0)
			notify_html += '<div><img src="/img/icomod/misc_error_rw.png">' + report.nb_error + ' errors</div>';
		      
		      if (report.nb_warning && report.nb_warning > 0)
			notify_html += '<div><img src="/img/icomod/misc_warning_yw.png">' + report.nb_warning + ' warnings</div>';
		      		    
		      notify_html += '</div>';
		    }
	      
		  report.div = old_report.div;
		  old_report.div.innerHTML = report.html;
		  eip_tab_running_report[report_pos] = report;
		}
	    }

	  eip_tab_running_report[report_pos].to_delete = 0;

	  x ++;
	}

      /* check div to destroy */

      var len = eip_tab_running_report.length;
      x = 0;
      while (x != len)
	{
	  if (eip_tab_running_report[x] != null)
	    {
	      if (eip_tab_running_report[x].to_delete == 1)
		{
		  running_report.removeChild(eip_tab_running_report[x].div);
		  eip_tab_running_report[x] = null;
		}
	    }
	  x ++;
	}

      if (do_open == 1)
	{
	  /* eip_open_close_report_div('open'); */
      
	  var notify_report = document.getElementById('notify_report_div');

	  notify_report.innerHTML = notify_html;

	  eip_open_close_notify_report_div('open');
	  window.setTimeout('eip_open_close_notify_report_div("close")',10000);
	}

      if (have_busy == 1)
	icon_running_report.className = 'icon_running_report_on';
      else
	icon_running_report.className = 'icon_running_report_off';
    }

  window.setTimeout('initAjaxRunningReportCheck()',2000);
}

function eip_open_close_notify_report_div(cmd)
{
  var notify_report;
	 
  notify_report = document.getElementById('notify_report');

  if (cmd != 'close')
    {
      notify_report.style.height = 0;
      notify_report.style.visibility = 'visible';
      eip_progressive_resize_div_height('notify_report',0,0,100);
    }
  else
    if (cmd != 'open')
      {
	eip_progressive_resize_div_height('notify_report',100,100,0);
	// notify_report.style.visibility = 'hidden';
      }
}

function eip_init_over_global_search()
{
  var obj_input;

  obj_input = document.getElementById('global_search');

  if (obj_input && 0)
    {
      obj_input.onmouseover = function() { this.className = 'menu_search_input_in'; }
      obj_input.onmouseout = function()	{ this.className = 'menu_search_input_out'; }
    }
}


function eip_selectText(thisdiv)
{
  if (document.selection)
    {
      var div = document.body.createTextRange();
      div.moveToElementText(thisdiv);
      div.select();
    }
  else
    {
      var div = document.createRange();
      div.setStartBefore(thisdiv);
      div.setEndAfter(thisdiv);	
      window.getSelection().addRange(div);
    }
}

function eip_delete_running_report(report_id)
{
  var len = eip_tab_running_report.length;
  x = 0;
  while (x != len)
    {
      if (eip_tab_running_report[x] != null &&
	  eip_tab_running_report[x].id == report_id)
	{
	  running_report.removeChild(eip_tab_running_report[x].div);
	  eip_tab_running_report[x] = null;

	  buildAndSendRequest('/mod/generic/ajax_delete_report.php?report_id=' + report_id,null);
	  return;
	}
      x ++;
    }
}

