function backToTop() {
    var x1 = x2 = x3 = 0;
    var y1 = y2 = y3 = 0;

    if (document.documentElement) {
        x1 = document.documentElement.scrollLeft || 0;
        y1 = document.documentElement.scrollTop || 0;
    }

    if (document.body) {
        x2 = document.body.scrollLeft || 0;
        y2 = document.body.scrollTop || 0;
    }

    x3 = window.scrollX || 0;
    y3 = window.scrollY || 0;

    var x = Math.max(x1, Math.max(x2, x3));
    var y = Math.max(y1, Math.max(y2, y3));

    window.scrollTo(Math.floor(x / 2), Math.floor(y / 2));

    if (x > 0 || y > 0) {
        window.setTimeout("backToTop()", 25);
    }
}

// #################################################################################################################################
function keypressed(e) {
  if (!e) var e = window.event;
  if (e.keyCode) code = e.keyCode;
	else if (e.which) code = e.which;
  if (code == 13) {
    document.login.submit();
  }
}

// #################################################################################################################################
function checkreturn() {
  var i,j,f,e;
  for (i=0; i<document.forms.length; i++){
    f = document.forms[i];
    for (j=0; j<f.elements.length; j++){
      e = f[j];
      e.onkeypress= keypressed;
    }
  }
}

// megnyit egy új ablakban egy képet ###############################################################################################
function OpenNewWindow(bigurl, width, height) {
  var newWindow = window.open("", "blank", "location=no, directories=no, resizable=yes, scrollbars=no, fullscreen=no, menubar=no, status=no, toolbar=no");

  newWindow.document.writeln("<html>");
  newWindow.document.writeln("<head>");
  newWindow.document.writeln("<script language='javascript'>"); 
  newWindow.document.writeln("function ResizeWin() {");
  newWindow.document.writeln("  iWidth = document.body.clientWidth;");
  newWindow.document.writeln("  iHeight = document.body.clientHeight;");
  newWindow.document.writeln("  iWidth = document.images[0].width - iWidth;");
  newWindow.document.writeln("  iHeight = document.images[0].height - iHeight;");
  newWindow.document.writeln("  window.resizeBy(iWidth+30, iHeight+40);");
  newWindow.document.writeln("  if (window.screen.width < document.body.clientWidth) window.resizeBy(window.screen.width-document.images[0].width, 0);");
  newWindow.document.writeln("  if (window.screen.height < document.body.clientHeight) window.resizeBy(0, window.screen.height-document.images[0].height-80);");
  newWindow.document.writeln("  self.focus();");
  newWindow.document.writeln("} ");
  newWindow.document.writeln("</script>");
  newWindow.document.writeln("</head>");
  newWindow.document.writeln("<body onload='ResizeWin();' style='margins: 0 0 0 0; padding: 0 0 0 0; background: #000000;'>");
/*  newWindow.document.writeln("<a href='javascript:window.close();'>");*/
  newWindow.document.writeln("<img border='0' align='left' src='" + bigurl + "' alt='Katt a bezáráshoz!' id='bigImage'/>");
/*  newWindow.document.writeln("</a>");*/
  newWindow.document.writeln("</body></html>");
  newWindow.document.close();
}

// oszlopok magassága ################################################################################################################
function resize_cols() {
  var maxheight;
  var t_height;
  var winy;

  d = document.getElementById('innercontentdiv');
  e = document.getElementById('menudiv');

  if (d.offsetHeight) {
    maxheight = d.offsetHeight;
  } else {
    if (d.style.pixelHeight) {
      maxheight = d.style.pixelHeight;
    }
  }

  if (e.offsetHeight) {
    maxheight2 = e.offsetHeight;
  } else {
    if (e.style.pixelHeight) {
      maxheight2 = e.style.pixelHeight;
    }
  }

  maxheight = maxheight + 330;
  maxheight2 = maxheight2 + 330;

  if (typeof(window.innerWidth) == 'number') {
    winy = window.innerHeight;
  } else if (document.documentElement && document.documentElement.clientHeight) {
    winy = document.documentElement.clientHeight;
  } else if( document.body && document.body.clientHeight) {
    winy = document.body.clientHeight;
  }

  if (maxheight2 > maxheight) {
    maxheight = maxheight2;
  }
  
  if (winy > maxheight) {
    maxheight = winy;
  }

  maxheight = maxheight - 10;

  document.getElementById('leftdiv').style.height = maxheight+'px';
  document.getElementById('rightdiv').style.height = maxheight+'px';
  document.getElementById('contentdiv').style.height = maxheight+'px';

}

// oszlopok magassága ################################################################################################################
function resize_admin_cols() {
  var maxheight;
  var winy;
  var d = document.getElementById('maindiv');

  if (d.offsetHeight) {
    maxheight = d.offsetHeight;
  } else {
    if (d.style.pixelHeight) {
      maxheight = d.style.pixelHeight;
    }
  }

  if (typeof(window.innerWidth) == 'number') {
    winy = window.innerHeight;
  } else if (document.documentElement && document.documentElement.clientHeight) {
    winy = document.documentElement.clientHeight;
  } else if( document.body && document.body.clientHeight) {
    winy = document.body.clientHeight;
  }

  if (winy > maxheight) maxheight = winy;

  document.getElementById('leftdiv').style.height = maxheight+'px';
  document.getElementById('rightdiv').style.height = maxheight+'px';
} 

