// JavaScript Document
function menu_on(id)
{
	
document.getElementById(id).style.background = "#FEC643";
document.getElementById(id).style.color = "#7e1718";
	}
	
function menu_off(id)
{
	
document.getElementById(id).style.background = "";
document.getElementById(id).style.color = "";
	}	
	

function window_open(url_address,window_width,window_height,framename) {
	
  sx = (screen.availWidth - window_width) / 2;
  sy = (screen.availHeight - window_height) / 2;
  params = "width="+window_width+",height="+window_height+",Left="+sx+",Top="+sy+",screenX="+sx+",screenY="+sy;
  additional = 'resizable=no,controls=yes,menubar=no,toolbar=no,scrollbars=no';
  params += "," + additional;
  nw = window.open(url_address, framename, params);
  nw.document.open();
  nw.document.write("<html><head><title>Aranypatkó Panzió és Étterem - Képek</title></head>\n");
  nw.document.write("<body marginwidth='0' marginheight='0' topmargin='0' leftmargin='0'>\n");
  nw.document.write("<center><img src='"+url_address+"' ></center>\n");
  nw.document.write("</body>\n");
  nw.document.write("</html>\n");
  nw.document.close();
  nw.focus();
}	

function kosar_tartalma()
{
	
	window_open_resizeable('rendeles_tartalma.php?kosar='+document.form1.kosar.value,530,300,'Aranypatko')
	
	}
	
function window_open_resizeable(url_address,window_width,window_height,framename) {
  sx = (screen.availWidth - window_width) / 2;
  sy = (screen.availHeight - window_height) / 2;
  params = "width="+window_width+",height="+window_height+",Left="+sx+",Top="+sy+",screenX="+sx+",screenY="+sy;
  additional = 'resizable=yes,controls=no,menubar=no,toolbar=no,scrollbars=yes';
  params += "," + additional;
  nw = window.open(url_address, framename, params);
  nw.focus();
}	

function kosar_szinkron()
{
	window.opener.document.form1.kosar.value = document.form1.kosar.value;
	
	}
	
function kosarba_tesz(id)
{

	document.getElementById('kosar').value += id+"|"+document.getElementById('db_'+id).value + "@";
	document.form1.submit();

}

function torol_kosar(id_)
{
    if (confirm('Biztos, hogy törli ezt a rendelési tételt?'))
	{
	document.getElementById('torolt_id').value = id_;	
	document.form1.submit();
	}
}	

function vissza_termekkategoria()
{
	
	document.form1.action = "online-rendeles.php";
	document.form1.submit();
	}

function vissza_termekkategoria_()
{
	window.close();
	}	
	
function belep_termekkategoria(id)
{
	document.form1.id.value = id;
	document.form1.submit();
	
	}	
	
function megrendel()
{
	
	document.form1.action = "etel-megrendelo.php";
	document.form1.submit();
	}	

function megrendel_()
{

	opener.window.document.form1.action = "etel-megrendelo.php";
	opener.window.document.form1.submit();
	window.close();

	}	

function tetel_rendben()
{
	if (document.getElementById('check_').checked == true) document.getElementById('rendel_gomb').disabled = false;
	else document.getElementById('rendel_gomb').disabled = true;
	
	}
	
function rendel_kuld()
{
	
		document.form1.submit();
	}

function szall_cim_()
{
	
	if (document.getElementById('sz_cim_checked').checked == false)
	{
		document.getElementById('uj_sz_cim').style.display='block';
		}
		else 		document.getElementById('uj_sz_cim').style.display='none';
	}
	
function email_check(text)
{
	if (text.indexOf('@') == -1) return 'Az e-mail címben szerepelni kell a @ karakternek!';
    	else  if (text.indexOf('.') == -1) return 'Az e-mail címben szerepelni kell a . karakternek!';
              else if ((text.length-text.lastIndexOf('.'))>4 || (text.length-text.lastIndexOf('.'))<2)  return 'Hibás e-mail cím!';
      				else  if (text.indexOf('.')==text.indexOf('@')+1)  return 'Hibás e-mail cím!';
						else return 'ok';	
	
}


function reg_check()	
{
	var hiba = '';
var email = document.form2.email.value;
result = email_check(email);
if (result != 'ok') hiba = result + "\n";
if (document.form2.nev.value == '') hiba += "Kérem töltse ki a név mezot!\n"	;
if (document.form2.telefon.value == '') hiba += "Kérem töltse ki a telefon mezot!\n"	;
if (document.form2.cim.value == '') hiba += "Kérem adja meg címét!\n"	;

if (hiba == '')
{
document.form2.submit();
}
else alert(hiba);
	}
	
	
function password_check()
{

 hiba = '';	
	if (document.form1.password.value != document.form1.password2.value)
	{
		hiba = 'A két jelszó nem egyezik!';
		document.form1.password.value = "";
		document.form1.password2.value = "";			
		}
	if (document.form1.temp_password.value == "")
		hiba += 'Adja meg az elküldött ideiglenes jelszót!';

	if (hiba != "")
		alert(hiba);
	else document.form1.submit();		
}
	
function foglalas1()
{

if (document.form1.ketagyas.value == 0)
	alert('Adja meg a szobák számát!');
		else 
		{
			document.form1.erk_datum.value = document.form1.erk_ev_ho.value + "-" + document.form1.erk_nap.value;
			document.form1.tav_datum.value = document.form1.tav_ev_ho.value + "-" + document.form1.tav_nap.value;			
			document.form1.szoba_db.value = document.form1.ketagyas.value;
			document.form1.submit();
			}
}

function letszam_check(id)
{

id_potagy = 'potagy_'+id;
	if (document.getElementById(id).value == 3)
				document.getElementById(id_potagy).style.display = "block";
		else 		document.getElementById(id_potagy).style.display = "none"; 
	
	}

function foglalas2()
{
document.form1.submit();
}

function foglalas2_back()
{
	document.form1.action = "szobafoglalas.php";
	document.form1.submit();
	}

function foglalas3()
{

hiba = 0;
	if (document.form1.vezeteknev.value == "") hiba = 1;
	if (document.form1.keresztnev.value == "") hiba = 1;
	if (document.form1.email.value == "") hiba = 1;
	if (document.form1.tel.value == "") hiba = 1;
	if (hiba == 1) alert('Kérem adja meg valamennyi kötelezo adatot!');
	else {
	document.form1.action = "szobafoglalas4.php";
	document.form1.submit();
	}
}

function foglalas3_back()
{
	
	document.form1.action = "szobafoglalas2.php";
	document.form1.submit();
	
	}
	
function foglalas4_back()
{
	document.form1.action = "szobafoglalas3.php";
	document.form1.submit();
	}	
	
	

function checkDate() {
	var start = document.form1.erk_ev_ho.value+'-'+document.form1.erk_nap.value;
	var end = document.form1.tav_ev_ho.value+'-'+document.form1.tav_nap.value;
	if (start>=end) {
		var DayIndex = document.form1.erk_nap.selectedIndex;
		var YearIndex = document.form1.erk_ev_ho.selectedIndex;
		if ((DayIndex+1)>30){
			if (YearIndex==document.form1.erk_ev_ho.options.length-1){
				var newDayIndex = DayIndex;
				var newYearIndex = YearIndex;
			}else{
				var newDayIndex = 0;
				var newYearIndex = YearIndex+1;
			}
		}else{
			var newDayIndex = DayIndex+1;
			var newYearIndex = YearIndex;
		}
		document.form1.tav_nap.selectedIndex = newDayIndex;
		document.form1.tav_ev_ho.selectedIndex = newYearIndex;
	}
}

function foglalas_elkuld()
{
	document.form1.submit();
	}
	
function arajanlat_kuld()
{
hiba = 0;

if (document.form1.f_szam.value == "") hiba = 1;
if (document.form1.gy_szam.value == "") hiba = 1;
if (document.form1.no_ifa1.value == "") hiba = 1;
if (document.form1.no_ifa2.value == "") hiba = 1;
if (document.form1.vezeteknev.value == "") hiba = 1;
if (document.form1.keresztnev.value == "") hiba = 1;
if (document.form1.email.value == "") hiba = 1;
if (document.form1.tel.value == "") hiba = 1;

if (hiba == 1) alert('Kérjük töltse ki valamennyi adatot!');
else {
	
	document.form1.erk_datum.value = document.form1.erk_ev_ho.value + "-" + document.form1.erk_nap.value;
	document.form1.tav_datum.value = document.form1.tav_ev_ho.value + "-" + document.form1.tav_nap.value;	
	document.form1.submit();
	}	

	
	
	}
	
	
/* cookie construct start */
function Cookie(document,name,hours,path,domain,secure) {
  // any VAR in "this" that does not start with a "$" will
  // be written into the cookie (read from also)
  this.$doc  = document
  this.$name = name
  if (hours)  this.$expiration=new Date((new Date()).getTime()+1000*60*10); else this.$expiration = null
  if (path)   this.$path   = path;                                             else this.$path       = null
  if (domain) this.$domain = domain;                                           else this.$domain     = null
  if (secure) this.$secure = true;                                             else this.$secure     = false
}

function CookieWrite() {
  var cookieval=""
  for(var prop in this) {
    if ((prop.charAt(0) == '$') || ((typeof this[prop]) == 'function') || prop == '') continue
	if (cookieval != "") cookieval += '&'
	cookieval+=prop+":"+escape(this[prop])
  }
  var cookie=this.$name+"="+cookieval
  if (this.$expiration) cookie+='; expires=' + this.$expiration.toGMTString()
  if (this.$path)       cookie+='; path='    + this.$path
  if (this.$domain)     cookie+='; domain='  + this.$domain
  if (this.$secure)     cookie+='; secure'
  this.$doc.cookie=cookie
}

function CookieRead() {
  var allcookies=this.$doc.cookie
  if (allcookies=="") {
    return false
  }
  var start= allcookies.indexOf(this.$name+'=')
  if (start== -1) {
    return false
  }
  start += this.$name.length+1
  var end=allcookies.indexOf(';',start)
  if (end == -1) end=allcookies.length
  var cookieval = allcookies.substring(start,end)
  var a = cookieval.split('&')
  for (var i=0;i < a.length;i++) a[i]=a[i].split(':')
  for (var i=0;i < a.length;i++) this[a[i][0]]=unescape(a[i][1])
  return true
}

function CookieDelete() {
  var cookie = this.$name+'='
  if (this.$path)   cookie+='; path='+this.$path
  if (this.$domain) cookie+='; domain='+this.$domain
  cookie+='; expires=Fri, 02-Jan-1970 00:00:00 GMT'  // MAKE IT EXPIRE!
  this.$doc.cookie=cookie
}

new Cookie()
Cookie.prototype.write = CookieWrite
Cookie.prototype.del   = CookieDelete
Cookie.prototype.read  = CookieRead
/* cookie construct end */

var myCookie=new Cookie(document,"visit_counterx",1);
    myCookie.read();
var count=myCookie.count;
if(count!=parseInt(count))count=0;
var FIRST_VISIT=(!count)?true:false;
count++;
myCookie.count=count;
myCookie.write();

function runOnce()
{
/*if (FIRST_VISIT){
 sx = (screen.availWidth - 530) / 2;
  sy = (screen.availHeight - 225) / 2;
  params = "width=530,height=225,resizable=no,controls=no,menubar=no,toolbar=no,scrollbars=no,Left="+sx+",Top="+sy+",screenX="+sx+",screenY="+sy;
 window.open('szilveszter-popup.htm','popup',params);
}*/
 
}	
