function jumpMax(from, max, to) {
  if ( (from.value.length == max) && (to != '') ) {
    document.getElementById(to).select();
    document.getElementById(to).focus();

  }

}

function copyField(from, to) {
  document.getElementById(to).value = document.getElementById(from).value;
}

function copyaddress() {
  copyField('tdl2', 'tdl');

  document.getElementById().value = document.getElementById('tdl').value;
  document.getElementById('country2').value = document.getElementById('country').value;
  document.getElementById('zip2').value = document.getElementById('zip').value;
  document.getElementById('shire2').value = document.getElementById('shire').value;
  document.getElementById('city2').value = document.getElementById('city').value;
  document.getElementById('address2').value = document.getElementById('address').value;
  document.getElementById('district2').value = document.getElementById('district').value;
}

function checkAttributes(formname) {

  o = document.getElementById(formname);
  l = o.elements.length;
  for (i=0; i<l; i++) {

    if ( o.elements[i].getAttribute('needed') == "1" ) {
      o.elements[i].onfocus = check;
      o.elements[i].onblur = check;
      o.elements[i].onkeydown = check;

    } else if ( o.elements[i].getAttribute('filter') ) {
      f = o.elements[i].getAttribute('filter');
      o.elements[i].onkeypress = new Function('editKeyBoard(this,'+f+')');

    }

  }
}


function popup(url,name,width,height,position,wplus,hplus,focus,left,top,menubar,status,toolbar,scrollbar,resizable,scrx,scry,directories,loc) {
	if ( !url ) return false;
	if ( !name ) name = 'popupWin';
	if ( !width ) width = '';
	if ( !height ) height = '';
	if ( !directories ) directories = 'no';
	if ( !loc ) loc = 'no';
	if ( !menubar ) menubar = 'no';
	if ( !status ) status = 'no';
	if ( !toolbar ) toolbar = 'no';
	if ( !scrollbar ) scrollbar = 'no';
	if ( !resizable ) resizable = 'no';
	if ( !scrx ) scrx = '100';
	if ( !scry ) scry = '100';
	if ( !left ) left = '100';
	if ( !top ) top = '100';
	if ( wplus ) width  += wplus;
	if ( hplus ) height += hplus;

	if ( position == '1' ) {
		var winleft = (screen.width - width) / 2;
		var wintop = (screen.height -  height) / 2;
	} else {
		var winleft = left;
		var wintop = top;
	}

    var popupWin = window.open(url,name,'width='+width+'px,height='+height+'px,left='+winleft+',top='+wintop+',menubar='+menubar+',status='+status+',toolbar='+toolbar+',scrollbars='+scrollbar+',resizable='+resizable+',screenX='+scrx+',screenY='+scry+'directories='+directories+',location='+loc);

	if ( focus ) popupWin.focus();
}

