﻿var np=0;	// nobel page...
var fl=0;	// almenu

function wlink(ezt) {
  vissza = '';
  if ( ezt == 1 ) {                             // menu_fent
    vissza = '&wd=140';
  }
  if ( ezt == 2 ) {                             // lent
    vissza = '&lk=www.zalaifogorvos.hu';
  }
  return vissza;
}

function nobel_page() {
  np = 1;
  fl = 1;
  oldal(null,404,2,0,1);
  document.getElementById('mp202').style.backgroundColor=MO_BG;
  window.scrollTo(0,0);
  m=202;
  am=404;
}

function altatas_page() {
  fl = 1;
  oldal(null,409,2,0,1);
  document.getElementById('mp202').style.backgroundColor=MO_BG;
  window.scrollTo(0,0);
  m=202;
  am=409;
}

function fogszab_page() {
  fl = 1;
  oldal(null,402,2,0,1);
  document.getElementById('mp202').style.backgroundColor=MO_BG;
  window.scrollTo(0,0);
  m=202;
  am=402;
}

function fogfeh_page() {
  fl = 1;
  oldal(null,403,2,0,1);
  document.getElementById('mp202').style.backgroundColor=MO_BG;
  window.scrollTo(0,0);
  m=202;
  am=403;
}

function eset_page() {
  oldal(null,205,0,0,1);
  window.scrollTo(0,0);
}

function oldal(obj,ezt,alm,alal,nyelv) {

  if ( ezt == 102 ) {
    window.location = "mailto:info@zalaifogorvos.hu?subject=honlap";
    return; 
  }

  document.getElementById('tartalom').style.visibility='hidden';
  document.getElementById('menu_bal').style.visibility='hidden';
  if ( fl == 0 ) {
    document.getElementById('almenu').style.visibility='hidden';
  }

/*

  if ( alal == 0 ) { 
    if ( m == ezt ) { return; }
  } else {
    if ( am == ezt ) { return; }
  }

*/

// -----------------------------------------------------------------------

  szelesseg = 150;                              // az almenük szélessége
  if ( alm == 2 ) { szelesseg = 110; }

  if ( ezt == 104 || ezt == 202 ) {
    mch(obj,ezt,"mp");
    if ( ezt == 104 ) { oldal(obj,301,alm,1,nyelv); }
    if ( ezt == 202 ) { oldal(obj,401,alm,1,nyelv); }
    return;
  }

  bjv = 0;

  if ( ezt == 103 || ( ezt >= 301 && ezt <= 303) ) {                                             // munkatársaink
    document.getElementById("banner_jobb").style.display='none';
  } else {
    bjv= 1;
  }

// -----------------------------------------------------------------------

  if ( alal == 0 ) {
    mch(obj,ezt,"mp");
    am = 0;
  } else {
    amch(obj,ezt,"amp");
  }

  xmlhttp=GetXmlHttpObject();
  if (xmlhttp==null) {
    alert ("Your browser does not support AJAX!");
    return;
  }

  xm=ezt;

  if ( nyelv == 1 ) { lang = 'hu'; }
  if ( nyelv == 2 ) { lang = 'gb'; }
  if ( nyelv == 3 ) { lang = 'de'; }

  home = lang + '/';

  var url=home+"main.php";
  url=url+"?p="+ezt;
  url=url+"&n="+np;
  url=url+"&sid="+Math.random();
  xmlhttp.onreadystatechange=stateChanged;

  if ( np == 1 ) {
    np = 0;
  }

  if ( fl == 0 ) {
    if ( alal == 0 || alm == 1 ) {
      document.getElementById("almenu").innerHTML='';
    }
  }

  fl = 0;

  if ( alm != 1 ) {
    document.getElementById("menu_bal").innerHTML='';
  }

  xmlhttp.open("GET",url,true);
  xmlhttp.send(null);
  if ( alm != 0 ) {
    var url="menuk.php";
    url=url+"?lg="+nyelv;
    url=url+"&lh="+lang;
    url=url+"&al="+alm;
    xmlhttp2=GetXmlHttpObject();
    if ( alm != 1 ) {
      url=url+"&fn=almenu";
      url=url+"&wd="+szelesseg;
      xmlhttp2.onreadystatechange=stateChangedA;
      document.getElementById("menu_bal").style.display='none';
    } else {
      url=url+"&fn=menu_bal";
      xmlhttp2.onreadystatechange=stateChangedB;
      document.getElementById("menu_bal").style.display='block';
    }
    xmlhttp2.open("GET",url,true);
    xmlhttp2.send(null);
  }
}

function vrend(ezt) {
  vrnd = window.open('hu/page/vrendelo.php?r='+ezt,'VRendelo','width=800,height=500,location=no,menubar=no,resizable=no,scrollbars=yes,status=no,titlebar=no,toolbar=no');
  vrnd.focus();
}

function vrend2(ezt) {
  vrnd2 = window.open('hu/page/vrendelo.php?r='+ezt,'VRendelo2','width=800,height=800,location=no,menubar=no,resizable=no,scrollbars=yes,status=no,titlebar=no,toolbar=no');
  vrnd2.focus();
}

function kep() {
  nev = window.open('hu/page/ujsag.html','Újságcikk','location=no,menubar=no,resizable=no,scrollbars=yes,status=no,titlebar=no,toolbar=no');
  nev.focus();
}

function trim(str) {
  str = str.replace(/^\s+/, '');
  for (var i = str.length - 1; i >= 0; i--) {
    if (/\S/.test(str.charAt(i))) {
      str = str.substring(0, i + 1);
      break;
    }
  }
  return str;
}

function kuldes() {

  var url="hu/kuldes.php";
  url += "?nev="+document.form1.nev.value;
  url += "&email="+document.form1.email.value;
  url += "&uzenet="+document.form1.uzenet.value;
  url += "&sid="+Math.random();

  xmlhttpKM = GetXmlHttpObject();
  xmlhttpKM.onreadystatechange = stateChangedKM;
  xmlhttpKM.open("GET",url,true);
  xmlhttpKM.send(null);

}

function stateChangedKM() {
  var vissza = '';
  if (xmlhttpKM.readyState==4) {
    if ( xmlhttpKM.responseText != null ) {
      vissza = trim(xmlhttpKM.responseText);
      document.getElementById('vissza').innerHTML = vissza;
    }
  }
}

function loadpage(ffeh) {

  var url = 'hu/page/';

  if ( ffeh == 1 ) { url += 'fogfeheritesrol_altalaban.php'; }
  if ( ffeh == 2 ) { url += 'otthoni_fogfeherites.php'; }
  if ( ffeh == 3 ) { url += 'rendeloi_fogfeherites.php'; }
  if ( ffeh == 4 ) { url += 'egyfogfeherites.php'; }
  if ( ffeh == 7 ) { url += 'nobel_guide.php'; }
  if ( ffeh == 8 ) { url += 'implantacio_hogyan.php'; }
  if ( ffeh == 9 ) { url += 'implantacio_elony.php'; }

  url += "?sid="+Math.random();

  xmlhttpFF = GetXmlHttpObject();
  xmlhttpFF.onreadystatechange = stateChangedFF;
  xmlhttpFF.open("GET",url,true);
  xmlhttpFF.send(null);

}

function stateChangedFF() {
  if (xmlhttpFF.readyState==4) {
      document.getElementById('tartalom').innerHTML = xmlhttpFF.responseText;
  }
}

