/**
 * Guess what?
 */
function fadeOutAlert(id)
{
	if(document.getElementById(id)) {
    setTimeout("new Effect.Fade('" + id + "')", 5000);
  }
}

/**
 * JSON multi AJAX updater
 */
function update_divs(request)
{
	var divs = eval('(' + request.responseText + ')');
	for (var div_id in divs) {
		if ($(div_id)) {
			$(div_id).innerHTML = divs[div_id];
		}
	}
}

/**
 * copy input field from hidden template
 *
 * ::: OPTIMIZABLE TO 1 FUNCTION :::
 */
function add_input(name, name_pl)
{
  template = document.getElementById("new_"+name);
  copy = template.cloneNode(true);
  copy.style.display = "";
  
  // get first unused id
  id = 1;
	input_x = document.getElementById(name + "_" + id);
  while(input_x) {
    id++;
    input_x = document.getElementById(name + "_" + id);
  }
  copy.id = name + "_" + id;
  input = copy.getElementsByTagName("input")[0];
  input.id = name + "_" + input.name + "_" + id;
  input.name = name_pl + "[" + id + "][" + input.name + "]";
  template.parentNode.insertBefore(copy, template);
  return id;
}

function add_input_company(name, name_pl)
{
  template = document.getElementById("new_"+name);
  copy = template.cloneNode(true);
  copy.style.display = "";
  
  // get first unused id
	id = 1;
	input_x = document.getElementById(name + "_" + id);
  while(input_x) {
    id++;
    input_x = document.getElementById(name + "_" + id);
  }
  copy.id = name + "_" + id;
  input = copy.getElementsByTagName("input")[0];
  input.id = name + "_" + id + "_" + input.name;
  input.name = name_pl + "[" + id + "][" + input.name + "]";
  autocomplete = copy.getElementsByTagName("div")[0];
  autocomplete.id = input.id + "_auto_complete";
  template.parentNode.insertBefore(copy, template);
  new Ajax.Autocompleter('company_name_' + id + '_name', 'company_name_' + id + '_name_auto_complete', '/auto_complete/goal_company/desire', {callback:function(element, value) { return 'complete=' + $('company_name_' + id + '_name').value } });
  return id;
}

/**
 *
 */
function set_select(id, value)
{
  sel = $(id);
  for ( i=0; i < sel.options.length; i++ ) {
    if ( sel.options[i].value == value ) {
      sel.options[i].selected = true;
    }
  }
}

/**
 * slider2range
 *
 * calculate km range from slider position ( 25 .. 205 )
 * this function is repeated in ruby (search_value)
 */
function slider2range(n, unit, unlimited)
{
	if(!unit) {
		unit = 'km';
	}
	
	if(!unlimited) {
		unlimited = 'unbegrenzt';
	}
	
	if ( unit == 'km' ) {
		if ( n < 100 ) { n = ( Math.round( n / 5 ) * 5 ); return (n < 100 ? "&nbsp;" : "" ) + n.toString() + " km"; }
		if ( n <= 200 ) { return ( Math.round( ( 100 + 2 * (n-100) ) / 5 ) * 5 ).toString() + " km" }
	}
	else {
		if ( n < 100 ) { n = ( Math.round( n / 5 ) * 5 ); return (n < 100 ? "&nbsp;" : "" ) + n.toString() + " mi"; }
	if ( n <= 200 ) { return ( Math.round( ( 100 + 2 * (n-100) ) / 5 ) * 5 ).toString() + " mi" }
	}
	return unlimited;
}

/**
 *
 */
function days2date(days)
{
	days = Math.round(days);
  if ( days == 0 ) {
    return "heute";
  }
  date = new Date(new Date().getTime() - Math.round(days) * 24 * 3600 * 1000 );
  return "" + date.getDate() + "." + (date.getMonth()+1) + "." + date.getFullYear();
}

/**
 * ::: OPTIMIZABLE TO 1 FUNCTION :::
 */
function expSlider(n, labels)
{
	n = Math.round(n);
	if ( n >= 1 && n <= 4 ) {
		return labels[n];
	}
	else {
		return "--";
	}
}

function languageSkillSlider(n, labels)
{
	n = Math.round(n);
	if ( n >= 2 && n <= 4 ) {
		return labels[n];
	}
	return ''
}

/**
 * Toggle to skip the value of the input field
 */
function valFieldToggle(r, b, v)
{
	if (b) {
		if (r.value == v) {
			r.style.color="#525B65";
			r.value = "";
		}
	}
	else {
		if (r.value == "") {
			r.style.color="#8796AB";
			r.value = v;
		}
	}
}

/**
 * Image Preloader
 *
 * ::: OPTIMIZABLE - BETTER IMAGE HANDLING :::
 */
var preloadToggle = false;

function preloadImage()
{
	if (document.images) {
		careerActive = newImage("/images/icoCareer_a.gif");
		careerInactive = newImage("/images/icoCareer.gif");
		recruitingActive = newImage("/images/icoRecruiting_a.gif");
		recruitingInactive = newImage("/images/icoRecruiting.gif");
		bgProfilheadView_a1 = newImage("/images/bgProfilheadView_a1.gif");
		bgProfilheadView_a2 = newImage("/images/bgProfilheadView_a2.gif");
		bgProfilheadView_a3 = newImage("/images/bgProfilheadView_a3.gif");
		bgProfilheadView_i1 = newImage("/images/bgProfilheadView_i1.gif");
		bgProfilheadView_i2 = newImage("/images/bgProfilheadView_i2.gif");
		bgProfilheadView_i3 = newImage("/images/bgProfilheadView_i3.gif");
		personalmarkt = newImage("/images/ga_knopf_over.jpg");
		preloadToggle  = true;
	}
}

/**
 * Image Toggle
 */
function newImage(arg)
{
	if (document.images) {
		rslt        = new Image();
		rslt.src    = arg;
		return rslt;
	}
}

function changeImage()
{
	if (document.images && (preloadToggle == true)) {    
		for (var i=0; i< changeImage.arguments.length; i+=2) {
			document.images[changeImage.arguments[i]].src = changeImage.arguments[i+1];
		}
	}
}

/**
 * Display toggler
 *
 * ::: OPTIMIZABLE TO 1 FUNCTION :::
 */
function toggleDisplayExt(id, arr, partner_sufix, scrollto)
{
	elb = $(id);
	var display = elb.style.display ? '' : 'none';
	elb.style.display = display;
	
	els = $(id + '_collapse_sign');
	
	if (elb.style.display == 'none') {
		if (partner_sufix) {
			els.src = '/images/shorty/' + partner_sufix + '/icoTriClosed.gif';
		} else {
			els.src = '/images/icoTriClosed.gif';
		}
	} else {
		if (partner_sufix) {
			els.src = '/images/shorty/' + partner_sufix + '/icoTriOpen.gif';
		} else {
			els.src = '/images/icoTriOpen.gif';
		}
	}
	
	if (arr.length > 0) {
		for (i = 0; i < arr.length; i++) {
			if ($(arr[i]) != null) {
				$(arr[i]).style.display = 'none';
				if ($(arr[i] + '_collapse_sign') != null) {
					if (partner_sufix) {
						$(arr[i] + '_collapse_sign').src = '/images/shorty/' + partner_sufix + '/icoTriClosed.gif';
					} else {
						$(arr[i] + '_collapse_sign').src = '/images/icoTriClosed.gif';
					}
				}
			}
		}
	}
	
	if (scrollto) {
		var elbParent = Element.ancestors(elb)[0];
		Element.scrollTo( elbParent );
	}
}

function toggleDisplay(id, cid, partner_sufix)
{
	elo = $(id + 'Wrapper');
	var display = elo.style.display ? '' : 'none';
	elo.style.display = display;
	
	elf = $(id + 'CollapseFlag');
	els = $(id + 'CollapseSign');
	if (elf.value == '0' || elf.value == '') {
		elf.value = '1';
		if (partner_sufix) {
			els.src = '/images/shorty/' + partner_sufix + '/icoTriOpen.gif';
		} else {
			els.src = '/images/icoTriOpen.gif';
		}
	} else {
		elf.value = '0';
		if (partner_sufix) {
			els.src = '/images/shorty/' + partner_sufix + '/icoTriClosed.gif';
		} else {
			els.src = '/images/icoTriClosed.gif';
		}
	}
	
	if(cid) {
		elc = $(cid + 'Wrapper');
		elc.style.display = 'none';
		
		elf = $(cid + 'CollapseFlag');
		els = $(cid + 'CollapseSign');
		
		elf.value = '0';
		if (partner_sufix) {
			els.src = '/images/shorty/' + partner_sufix + '/icoTriClosed.gif';
		} else {
			els.src = '/images/icoTriClosed.gif';
		}
	}

	/*
	elo = $(id + 'Wrapper');
	var display = elo.style.display ? '' : 'none';
	if (display == "") {
		Effect.SlideDown(elo);
	} else {
		Effect.SlideUp(elo);
	}
	
	elf = $(id + 'CollapseFlag');
	els = $(id + 'CollapseSign');
	if (elf.value == '0' || elf.value == '') {
		elf.value = '1';
		els.src = '/images/icoTriOpen.gif';
	} else {
		elf.value = '0';
		els.src = '/images/icoTriClosed.gif';
	}
	
	if(cid) {
		elc = $(cid + 'Wrapper');
		var display = elc.style.display ? '' : 'none';
		
		if (display != "") {
			Effect.SlideUp(elc);
		
			elf = $(cid + 'CollapseFlag');
			els = $(cid + 'CollapseSign');
		
			elf.value = '0';
			els.src = '/images/icoTriClosed.gif';
		}
	}
	*/
}

function cbToggleDisplay(id, cid, partner_image_path, teaser_toggle)
{
	
	elo = $(id + 'Wrapper');
	var display = elo.style.display ? '' : 'none';
	
	var tri_open = 'ico_tri_open';
	var tri_closed = 'ico_tri_closed';
	
	elo.style.display = display;
	
	elf = $(id + 'CollapseFlag');
	els = $(id + 'CollapseSign');
	
	if (elf.value == '0' || elf.value == '') {
		elf.value = '1';
		els.src = partner_image_path + tri_open + '.gif';
		
		if(teaser_toggle) {
			$('visual_teaser_container').style.display='none';
		}
	} else {
		elf.value = '0';
		els.src = partner_image_path + tri_closed + '.gif';
		
		if(teaser_toggle) {
			$('visual_teaser_container').style.display='';
		}
	}
	
	if(cid) {
		elc = $(cid + 'Wrapper');
		elc.style.display = 'none';
		
		elf = $(cid + 'CollapseFlag');
		els = $(cid + 'CollapseSign');
		
		elf.value = '0';
		els.src = partner_image_path + tri_closed + '.gif';
	}
}

function toggleHelpDisplay(id)
{
	elo = $(id);

	var display = elo.style.display ? '' : 'none';
	elo.style.display = display;
}

/**
 * show/hide toggle
 */
function action(_element, _action)
{
  var tbl = _element + "_tbl";
  var btn = _element + "_btn";
  
  var thisTable = document.getElementById(tbl);
  var thisButton = document.getElementById(btn);
  
  if (_action == "hide") { 
    thisTable.style.display = "none";
    thisButton.firstChild.nodeValue = "+";
    thisButton.setAttribute("href", "javascript:action('" + _element + "','show');");
  } else {
    thisTable.style.display = "block";
    thisButton.firstChild.nodeValue = "-";
    thisButton.setAttribute("href", "javascript:action('" + _element + "','hide');");
  }
}

/**
 * 24.03.2006 - mow
 *
 * toggle visibilty of element
 */
function toggleVisibility(element)
{
  current = $(element).style.display;
  if ( current == 'none' ) {
    $(element).style.display = '';
  }
  else {
    $(element).style.display = 'none';
  }
}

/**
 * used in recruiting/add_position
 */
function reset_and_toggle(field_name)
{
  if (field_name == 'industry') {
    if ($('job[industry_id]')) {
      $('job[industry_id]').value = '';
    }
    if ($('job_industry_id')) {
      $('job_industry_id').value = '';
    }
    $('selected_industry').style.display = 'none';
    $('job_industry').style.display = '';
  } else if (field_name == 'geocode') {
    if ($('job[geocode_id]')) {
      $('job[geocode_id]').value = '';
    }
    if ($('job_geocode_id')) {
      $('job_geocode_id').value = '';
    }
    $('selected_geocode').style.display = 'none';
    $('job_geocode').style.display = '';
  } else if (field_name == 'company') {
    if ($('job[company_id]')) {
      $('job[company_id]').value = '';
    }
    if ($('job[company_name]')) {
      $('job[company_name]').value = '';
    }
    $('selected_company').style.display = 'none';
    $('job_company').style.display = '';
  }
}

/**
 * 
 */
function show_selection(sect, prefix, id, text)
{
	if ( $(prefix + '_' + id).checked ) {
		current =  $(sect).innerHTML;
		$(sect).innerHTML = current + (current=='' ? '' : '<span id="' + prefix + '_sep_' + id + '"> | </span>') + '<span id="' + prefix + '_sel_' + id + '">' + text + '</span>';
	} 
	else {
		parentx = $(sect);
		childx = $(prefix + '_sel_' + id);
		sep = $(prefix + '_sep_' + id);
		parentx.removeChild(childx);
		if(sep) {
			parentx.removeChild(sep);
		}
		else if ( parentx.firstChild ) {
			parentx.removeChild(parentx.firstChild);
		}
	}
}

function updateSearchSortValue(arg)
{
	el=document.getElementById('search_sort');
	el.value=arg;
	
	ajaxUpdater();
}
  
function remove_list_item(item_id, list_id)
{
  if ($(list_id).hasChildNodes) {
    $(list_id).removeChild($(item_id));
  }
}

function check_double_selected(item_id, list_id)
{
  var selected_items = $(list_id)
  var found = false;

  if (selected_items.hasChildNodes) {
    var children = selected_items.childNodes;
    for(var i=0; i < children.length; i++){
      if (children[i].id == item_id) {
        found = true;
      }
    }
  }
  return found;
}

/**
 * Get X and Y position of an element
 */
function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	
	return curtop;
}

/**
 * Help functionality
 *
 * ::: OPTIMIZABLE TO 1 FUNCTION :::
 */
function posHelp(obj, top, content, txtmove, offset)
{
	var newContainerX = findPosX($(top)) + $(top).offsetWidth + 20;
	var newContainerY = findPosY($(top));
	
	var helpBox = $('helpBox');
	
	helpBox.style.top = newContainerY + 'px';
	helpBox.style.left = newContainerX + 'px';
	helpBox.style.height = $(top).offsetHeight + 'px';
	helpBox.style.display = 'block';
	
	var newThumbX = newContainerX - 9;
	var newThumbY = findPosY(obj);
	
	$('helpThumb').style.top = newThumbY + 'px';
	$('helpThumb').style.left = newThumbX + 'px';
	$('helpThumb').style.display = 'block';
	
	$('helpTxt').innerHTML = $(content).innerHTML;
	
	if (txtmove != null) {
		if (offset != null) {
			offset = 23 + offset;
		} else {
			offset = 23;
		}
		$('helpTxt').style.top = (newThumbY - newContainerY - offset) + 'px';
	} else {
		$('helpTxt').style.top = '6px';
	}
	
	$('helpTxt').style.display = 'block';
}

function posHelpShort(obj, top, content, txtmove, offset)
{
	var newContainerX = findPosX($(top));
	var newContainerY = findPosY(obj) + 20;
	
	var helpBox = $('helpBox');
	
	helpBox.style.top = newContainerY + 'px';
	helpBox.style.left = newContainerX + 'px';
	helpBox.style.width =  '492px';
	helpBox.style.zIndex =  '1000';
	helpBox.style.display = 'block';
	
	$('helpTxt').innerHTML = $(content).innerHTML;
	
	$('helpTxt').style.display = 'block';
}

function posHelpCatalogue(obj, top, content, txtmove, offset)
{
	var newContainerX = findPosX($(top)) + $(top).offsetWidth + 20;
	var newContainerY = findPosY($(top));
	
	var helpBox = $('helpBox');
	
	helpBox.style.top = newContainerY + 'px';
	helpBox.style.left = (newContainerX - 605) + 'px';
	helpBox.style.height = $(top).offsetHeight + 'px';
	helpBox.style.display = 'block';
	
	var newThumbX = newContainerX - 9;
	var newThumbY = findPosY(obj);
	
	$('helpThumb').style.top = newThumbY + 'px';
	$('helpThumb').style.left = (newThumbX-366) + 'px';
	$('helpThumb').style.display = 'block';
	
	$('helpTxt').innerHTML = $(content).innerHTML;
	
	if (txtmove != null) {
		if (offset != null) {
			offset = 23 + offset;
		} else {
			offset = 23;
		}
		$('helpTxt').style.top = (newThumbY - newContainerY - offset) + 'px';
	} else {
		$('helpTxt').style.top = '6px';
	}
	
	$('helpTxt').style.display = 'block';
}

function hideHelp()
{
	var helpBox = $('helpBox');
	
	helpBox.style.display = 'none';
	if ($('helpThumb')) {
		$('helpThumb').style.display = 'none';
	}
	$('helpTxt').style.display = 'none';
}

/**
 * Tooltip
 *
 * ::: OPTIMIZABLE TO 1 FUNCTION :::
 */
function displayTooltip(el1, el2, y, x, offset)
{
	if (!document.getElementById) return;
	
	var objX = findPosX(el1);
	var objY = findPosY(el1);
	
	var tt = $(el2);
	
	if (tt) {
		tt.style.top = (objY-y) + 'px';
		tt.style.left = (objX+x) + 'px';
		tt.style.display = 'block';
	}
	
	return false;
}

function displayTooltipShort(el1, el2, y, x, offset)
{
	if (!document.getElementById) return;
	
	var objX = findPosX(el1);
	var objY = findPosY(el1);
	
	if (navigator.appName=="Microsoft Internet Explorer" && offset) {
		objX -= 263;
	}
	
	var tt = $(el2);
	
	if (tt) {
		tt.style.top = (objY-y) + 'px';
		tt.style.left = (objX+x) + 'px';
		tt.style.display = 'block';
	}
	
	return false;
}

function hideTooltip(el)
{
  if (!document.getElementById) return;
  
  var tt = $(el);
  
  if (tt) {
    tt.style.display = 'none';
  }
  
  return false;
}

/**
 * 10.03.2006 - mow
 *
 * set completenes indicator for some profile input section  
 */
function update_profile_completeness(section, complete)
{
	elem1 = $('profile_complete_wiz_' + section)
	
	if (elem1) {
		$('profile_complete_wiz_' + section).innerHTML = complete ? '<img alt="" src="/images/icoProfileComplete.gif" />' : '<img alt="" src="/images/icoProfileUncomplete.gif" />';
	}
	
}

/**
 * 16.03.2006 - mow
 *
 * update function for edit_positions in job desire input
 */
function insert_edit_job_desire(request, sliderPosition, unit, unlimited)
{
	var txt = request.responseText;

  $('desire_main').innerHTML = txt.stripScripts();
  setTimeout(function() {txt.evalScripts()}, 10);

  var distance_slider = new Control.Slider('distance_slider_handle','distance_slider_track', {
    sliderValue:sliderPosition,
	range:$R(25,205),
	restricted:true,
    onSlide:function(v){$('distance_range').innerHTML=slider2range(v, unit, unlimited)},
	onChange:function(v){$('distance_range').innerHTML=slider2range(v, unit, unlimited); 
			     $('position_distance').value = v; 
      } } );
  $('distance_range').innerHTML=slider2range(sliderPosition, unit, unlimited);
}

/**
 * unselect all selected options in a 
 * multi-select selection box
 */
function unselect_multiselect(id)
{
  sel = $(id);
  for ( i=0; i < sel.options.length; i++ ) {
    if ( sel.options[i].selected ) {
      changed = true;
    }
    sel.options[i].selected = false;
  }
}

/**
 * popup content
 */
function popContent(file, w, h)
{
	var sb = "scrollbars=no";
	
	if(arguments.length > 3) sb = arguments[3];
	
	var top = ((screen.height - h) / 2);
	var left = ((screen.width - w) / 2);
	var ref = window.open(file, "popcontent", "status=no,"+sb+",scrolling=0,resizable=no,width="+w+",height="+h+",top="+top+",left="+left+",locationbar=no");
}

/**
 * used to set a status string while ajaxing, e.g.
 * ... :loading => "ajax_status('added_tag_msg','Updating...')" ...
 */
function ajax_status(node, status_string, replace)
{
  if (!node) return false;
  if (typeof node == 'string') node = document.getElementById(node);
  if (node) {
    if (replace)
      node.innerHTML = status_string
    else
      node.innerHTML = status_string + node.innerHTML 
  }
}

/**
 * check if some text might be a complete zipcode
 * 16.10.2006 - mow
 */
function checkZip(country_id, zip)
{
	var pattern4 = /^\d{4}$/; /* CH, BE, DK, NL, NO, AT */
	var patternl4 = /^L-\d{4}$/; /* LU */
	var pattern5 = /^\d{5}$/; /* FR, ES, FI, IT, SE, DE */
	/* no check for UK; sorry, postal codes are to irregular */
	return ( ( ( country_id == 23 || country_id == 43 || country_id == 158 || country_id == 164 || country_id == 166 || country_id == 191 ) && pattern4.test(zip) ) || ( ( country_id == 44 || country_id == 55 || country_id == 56 || country_id == 88 || country_id == 190 || country_id == 200 ) && pattern5.test(zip) ) || ( country_id == 126 && patternl4.test(zip) ) );
}

/**
 * Equal Column Height, accepts a Class name and tag
 */
function equalColHeightClass(classn, tag)
{
	var mx=0;
	var theval;
	var theeles = new Array();
	if(document.getElementById){
		theeles =getElementsByTagClass(tag, classn);
		var numa= theeles.length;
		for(var a=0; a < numa; a++){
			if(theeles[a].offsetHeight){
				theval=parseInt(theeles[a].offsetHeight);
				if(theval > mx){
					mx=theval;
				}
			}
			else{
				return false;
			}
		} 
		for(var n=0; n < numa; n++){
			theeles[n].style.height=mx+'px';
		}
	}
}
 
/**
 * returns an array of elements of a given tag and classname
 */
function getElementsByTagClass(tag, classn)
{
	var allElements = document.getElementsByTagName(tag);
	var classed = new Array();
	var i, j, c;
  
	for (i=0, j=0; i < allElements.length; i++){
		c = " " + allElements[i].className + " "; 
		if (c.indexOf(" " + classname + " ") != -1){
			classed[j++] = allElements[i];
		}
	}
  return classed;
}

/*###########################################################################
#
# NEED TO BE CHECKED IF THIS FUNCTIONS ARE STILL IN USE
#
###########################################################################*/

/**
 * select/deselect all checkboxes
 */
function checkBox(b)
{
  for (i = 0; i < document.forms.length; i++) {
    if (document.forms[i].name.substr(0,6) == "choose") {
      for (j = 0; j   < document.forms[i].elements.length; j++) {
        if (b == "true") {
          document.forms[i].elements[j].checked = true;
        } else {
          document.forms[i].elements[j].checked = false;
        }
      }
    }
  }
}

/**
 * another show/hide toggle: 
 * show: id from the element you want to show
 * hide: id from the element you want to hide 
 */
function toggle( show, hide )
{
	var show = ( document.layers ) ? document.show : document.getElementById( show ).style;
	var hide = ( document.layers ) ? document.hide : document.getElementById( hide ).style;
	show.display = "block";
	hide.display = "none";
}

function add_input2(name, name_pl)
{
  template = document.getElementById("new_"+name);
  copy = template.cloneNode(true);
  copy.style.display = "";
  
  // get first unused id
  id = 1
    input_x = document.getElementById(name + "_" + id);
  while ( input_x ) {
    id++;
    input_x = document.getElementById(name + "_" + id);
  }
  copy.id = name + "_" + id;
  input = copy.getElementsByTagName("input")[0];
  input.id = name + "_" + input.name + "_" + id;
  input.name = name_pl + "[]";
  template.parentNode.insertBefore(copy, template);
  return id;
}

function unselect_select(id, form_id, update, url, update_hint)
{
  changed = false;
  sel = $(id);
  for ( i=0; i < sel.options.length; i++ ) {
    if ( sel.options[i].selected ) {
      changed = true;
    }
    sel.options[i].selected = false;
  }
  
  if ( changed ) {
    if ( update_hint ) {
      $(update_hint).style.visibility = 'visible';
    }
    
    new Ajax.Updater(update, url, {asynchronous:true, evalScripts:true, parameters:Form.serialize($(form_id))});
  }
}

function selection_add_counts(id, values)
{
  selection = $(id)
  for ( i=0; i<selection.options.length; i++ ) {
    count = 0;
    option = selection.options[i]
    value = option.value;
    if ( value != '' ) {
      value = Number(value);
      if ( value < values.length ) {
	count = values[value]
      }
      sel = option.selected // MSIE forgets selection state when changing text
      if ( option.text.search(/\([0-9]*\)/) >= 0 ) {
	option.text = option.text.replace(/\([0-9]*\)/,"(" + count + ")");
      }
      else {
	option.text += " (" + count + ")";
      }
      option.selected = sel
    }
  }
}

/* obsolete: 10.07.2007 - mow 
function salary(n)
{
	n = Math.round(n);
	if ( n == 160 ) {
		n = "> 150";
	}
  return n;
}*/

/**
 * This function will not return until (at least)
 * the specified number of milliseconds have passed.
 * NOTE: It does a busy-wait loop.
 */
function pause(numberMillis)
{
	var now = new Date();
	var exitTime = now.getTime() + numberMillis;
	while(true) {
		now = new Date();
		if(now.getTime() > exitTime)
			return;
	}
}

/**
 * obsolete: 2008-01-07 - sfr
 */
/*function posContainer(obj, hlp, xDelay, yDelay, width)
{
	if (xDelay == null) {
		xDelay = 0;
	}
	
	if (yDelay == null) {
		yDelay = 0;
	}
	
	var newX = findPosX(obj);
	var newY = findPosY(obj);
	
	$(hlp).style.top = newY + yDelay + 'px';
	$(hlp).style.left = newX + xDelay + 'px';
	
	if (width != null) {
		$(hlp).style.width = width + 'px';
	}
	
	$(hlp).style.display = 'block';
}

function hideContainer(hlp)
{
	$(hlp).style.display = 'none';
}*/

/**
 * obsolete: 2008-01-07 - sfr
 */
/*function pop_content_w_scrollbar(file, w, h)
{
	var top = ((screen.height - h) / 2);
	var left = ((screen.width - w) / 2);
	var ref = window.open(file, "popcontent", "status=no,scrollbars=yes,scrolling=0,resizable=no,width="+w+",height="+h+",top="+top+",left="+left+",locationbar=no");
}*/
