/******
 * Copyright: Bernardini & Schnyder GmbH
 * Author: Sebastian Haller
 * Date: 2005
 * javascript
 * Example   <input type="text" onkeypress="return goodchars(event, '0123456789')" /> - only numbers
 */

// allow only numbers to be entered in sone fields
function goodchars(e, chars)
{
	var key, keychar;

	if (window.event)
		key = window.event.keyCode;
	else if (e)
		key = e.which;
	else
		return true;

	keychar = String.fromCharCode(key);
	keychar = keychar.toLowerCase();
	chars = chars.toLowerCase();

	if (chars.indexOf(keychar) != -1)
		return true;

	// control keys
	if ( key==null || key==0 || key==8 || key==9 || key==13 || key==27 )
		return true;

	return false;
}

// new window
function newwindow(url, name, w, h, features) {
/*	if(screen.width)
	{
		var winl = (screen.width-w)/2;
		var wint = (screen.height-h)/2;
	}
	else
	{
		winl = 0;
		wint = 0;
	}
	if (winl < 0)
		winl = 0;
	if (wint < 0)
		wint = 0; */
	//var settings = 'scrollbars=yes, resizable=yes, ';
	var settings = '';
	settings += 'height=' + h + ', ';
	settings += 'width=' + w + ', ';
	//settings += 'top=' + wint + ', ';
	//settings += 'left=' + winl + ', ';
	settings += features;
	win = window.open(url, name, settings);
	win.resizeTo(w, h);
	win.focus();
	// do not uncomment this. it is used in links containing
	// a href for users without javascript and an onclick="return newwindow(...);" for users with javascript
	// we do not want the href action to be excuted on success!
	return false;
}

  function ValidateNumeric()
  {
    var keyCode = window.event.keyCode;
    if (keyCode > 57 || keyCode < 48)
      window.event.returnValue = false;
  }
  
  function CheckJump(fieldFromId, fieldTargetId, charLength) {
    
      if(document.getElementById(fieldFromId).value.length == charLength) {
      
            document.getElementById(fieldTargetId).focus();
      }
}

