
// Translations /////////////////////////////////////////////////
var keremvarjon = new Array();
keremvarjon["hun.conf"] = "Kérem várjon..."
keremvarjon["eng.conf"] = "Please wait..."
keremvarjon["ger.conf"] = "Bitte warten..."
keremvarjon["fr.conf" ] = "Attendez, s'il vous plait!"
keremvarjon["ita.conf"] = "Kérem várjon... (I)"

var err_datum = new Array();
err_datum["hun.conf"] = "A záró dátum megelőzi a kezdő dátumot, kérem adja meg újra!"
err_datum["eng.conf"] = "Start date is greater than end date, please re-enter it!"
err_datum["ger.conf"] = "Das Abreisedatum liegt vor dem Anreisedatum, bitte richtig eingeben!"
err_datum["fr.conf" ] = "La date de départ doit préc?de la date d'arrivée, donnez la nouveau svp.!"
err_datum["ita.conf"] = "La data di partenza non é piú presto di quella di arrivo! Per favore controllateli!"

var err_datum_2 = new Array();
err_datum_2["hun.conf"] = "Legfeljebb 7 napot adhat meg!"
err_datum_2["eng.conf"] = "Legfeljebb 7 napot adhat meg! (E)"
err_datum_2["ger.conf"] = "Legfeljebb 7 napot adhat meg! (G)"
err_datum_2["fr.conf" ] = "Legfeljebb 7 napot adhat meg! (F)"
err_datum_2["ita.conf"] = "Legfeljebb 7 napot adhat meg! (I)"

var err_datum_3 = new Array();
err_datum_3["hun.conf"] = "Múltbéli időpontot adott meg!"
err_datum_3["eng.conf"] = "The specified date is in the past! (E)"
err_datum_3["ger.conf"] = "Múltbéli időpontot adott meg! (G)"
err_datum_3["fr.conf" ] = "Múltbéli időpontot adott meg! (F)"
err_datum_3["ita.conf"] = "Múltbéli időpontot adott meg! (I)"

var err_nincsar = new Array();
err_nincsar["hun.conf"] = "Az alábbiakra nem adott meg árat:"
err_nincsar["eng.conf"] = "You have not entered price for the next fields:"
err_nincsar["ger.conf"] = "Für folgende Dienstleistungen haben Sie keinen Preis angegeben:"
err_nincsar["fr.conf" ] = "Vous n'avez pas donner la prix ci-dessous:"
err_nincsar["ita.conf"] = "Az alábbiakra nem adott meg árat: (I)"

var szoba = new Array();
szoba["hun.conf"] = "szoba"
szoba["eng.conf"] = "room"
szoba["ger.conf"] = "zimmer"
szoba["fr.conf" ] = "chambre"
szoba["ita.conf"] = "camera"

var garazs = new Array();
garazs["hun.conf"] = "garázs"
garazs["eng.conf"] = "garage"
garazs["ger.conf"] = "garage"
garazs["fr.conf" ] = "garage"
garazs["ita.conf"] = "garázs (I)"

var err_nincsertek = new Array();
err_nincsertek["hun.conf"] = "Az alábbi mezőkre nem adott meg érvényes értéket:"
err_nincsertek["eng.conf"] = "You have not entered a valid value for the next fields:"
err_nincsertek["ger.conf"] = "Folgende Felder haben Sie nicht richtig ausgefüllt:"
err_nincsertek["fr.conf" ] = "Vous n'avez pas donner veleurs valable ci- dessous:"
err_nincsertek["ita.conf"] = "Az alábbi mezőkre nem adott meg érvényes értéket: (I)"

var vezeteknev = new Array();
vezeteknev["hun.conf"] = "Vezetéknév"
vezeteknev["eng.conf"] = "Last name"
vezeteknev["ger.conf"] = "Familiennahme"
vezeteknev["fr.conf" ] = "Nom"
vezeteknev["ita.conf"] = "Vezetéknév (I)"

var keresztnev = new Array();
keresztnev["hun.conf"] = "Keresztnév"
keresztnev["eng.conf"] = "First name"
keresztnev["ger.conf"] = "Vorname"
keresztnev["fr.conf" ] = "Prénom"
keresztnev["ita.conf"] = "Keresztnév (I)"

var email = new Array();
email["hun.conf"] = "E-mail cím"
email["eng.conf"] = "E-mail address"
email["ger.conf"] = "E-Mail Adresse"
email["fr.conf" ] = "E-mail"
email["ita.conf"] = "E-mail cím (I)"

var email_ervenytelen = new Array();
email_ervenytelen["hun.conf"] = "E-mail cím (érvénytelen)"
email_ervenytelen["eng.conf"] = "E-mail address (invalid)"
email_ervenytelen["ger.conf"] = "E-Mail Adresse (ungültig)"
email_ervenytelen["fr.conf" ] = "E-mail (non valable)"
email_ervenytelen["ita.conf"] = "E-mail cím (I)"

var tel = new Array();
tel["hun.conf"] = "Telefonszám"
tel["eng.conf"] = "Phone number"
tel["ger.conf"] = "Telefonnummer"
tel["fr.conf" ] = "Téléphone"
tel["ita.conf"] = "Telefonszám (I)"

var cim = new Array();
cim["hun.conf"] = "Cím"
cim["eng.conf"] = "Address"
cim["ger.conf"] = "Adresse"
cim["fr.conf" ] = "Adresse"
cim["ita.conf"] = "Cím (I)"

var nemzet = new Array();
nemzet["hun.conf"] = "Nemzetiség"
nemzet["eng.conf"] = "Nationality"
nemzet["ger.conf"] = "Nationalität"
nemzet["fr.conf" ] = "Nationalité"
nemzet["ita.conf"] = "Nemzetiség (I)"

var szabalyzatelfog = new Array();
szabalyzatelfog["hun.conf"] = "Szabályzat nincs elfogadva"
szabalyzatelfog["eng.conf"] = "Conditions are not accepted"
szabalyzatelfog["ger.conf"] = "Regeln wurden nicht akzeptiert"
szabalyzatelfog["fr.conf" ] = "Le réglement n'est pas accepter"
szabalyzatelfog["ita.conf"] = "Szabályzat nincs elfogadva (I)"
// Translations /////////////////////////////////////////////////











// Functions ////////////////////////////////////////////////////
function selectBoxGo(box)
{
    destination = box.options[box.selectedIndex].value;

    if (destination)
    {
        location.href = destination;
    }
}

function popUp(url, width, height)
{
    new_window = window.open(url, 'name',
                                  'width=' + width + ',height=' + height +
                                  ',toolbar=no,scrollbars=no');

    if (window.focus)
    {
        new_window.focus();
    }

    return false;
}

function submitProtect(langfile, submit_button, inprogress_input)
{

    var warn = new String();
    warn = "";
/*
    switch(langfile)
    {
        case "hun.conf": { warn = "Kérem várjon..."; break }
        case "eng.conf": { warn = "Please wait..."; break }
        case "ger.conf": { warn = "DEUTSCH"; break }
        default:         { warn = "Kérem várjon..."; break }
    }
*/

	warn = keremvarjon[langfile];

    if (inprogress_input.value == "")
    {
        submit_button.value = warn;
        inprogress_input.value = "w8";
        return true;
    }
    else
    {
        return false;
    }
}

function checkMail(str)
{
   filter = new RegExp(/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i);

   if (filter.exec(str))
      testresults=true
   else
   {
        testresults=false;
   }
   return (testresults)
}

function changeDate(d1,d2)
{
    select1 = document.getElementById(d1);
    select2 = document.getElementById(d2);
    select2.selectedIndex = select1.selectedIndex;
}

function checkDate(langfile,ye1,ye2,mo1,mo2,da1,da2)
{

    var warn = new String();
    warn = "";

    y1 = document.getElementById(ye1);
    y2 = document.getElementById(ye2);
    m1 = document.getElementById(mo1);
    m2 = document.getElementById(mo2);
    d1 = document.getElementById(da1);
    d2 = document.getElementById(da2);

    date1 = new Date(y1.options[y1.selectedIndex].text, m1.options[m1.selectedIndex].value, parseInt(d1.options[d1.selectedIndex].value)+1);
    date2 = new Date(y2.options[y2.selectedIndex].text, m2.options[m2.selectedIndex].value, parseInt(d2.options[d2.selectedIndex].value)+1);
	plus7days=new Date()
    plus7days.setYear(date1.getYear())
    plus7days.setMonth(date1.getMonth())
	plus7days.setDate(date1.getDate())
	plus7days.setDate(date1.getDate()+6)

	today=new Date()
	today.setHours(0)
	today.setMinutes(0)
	today.setSeconds(0)
	today.setMilliseconds(0)

	//alert(date1.getFullYear()+"/"+date1.getMonth()+"/"+date1.getDate()+","+date2.getFullYear()+"/"+date2.getMonth()+"/"+date2.getDate()+","+plus7days.getFullYear()+"/"+plus7days.getMonth()+"/"+plus7days.getDate())

	if (date1 < date2 && date2 <= plus7days && date1 >= today && date2 >= today)
    {
        return true;
    }
    else if(date2 > plus7days)
	{
		warn = err_datum_2[langfile];

        alert(warn);
        return false;
	}
    else if(date1 < today || date2 < today)
	{
		warn = err_datum_3[langfile];

        alert(warn);
        return false;
	}
	else
    {
		warn = err_datum[langfile];

        alert(warn);
        return false;
    }
}

function checkDate2(langfile,ye1,ye2,mo1,mo2,da1,da2)
{

    var warn = new String();
    warn = "";

    y1 = document.getElementById(ye1);
    y2 = document.getElementById(ye2);
    m1 = document.getElementById(mo1);
    m2 = document.getElementById(mo2);
    d1 = document.getElementById(da1);
    d2 = document.getElementById(da2);

	//alert("date1="+y1.options[y1.selectedIndex].text+", "+m1.options[m1.selectedIndex].value+", "+parseInt(d1.options[d1.selectedIndex].value)+1)
	//alert("date2="+y2.options[y2.selectedIndex].text+", "+m2.options[m2.selectedIndex].value+", "+parseInt(d2.options[d2.selectedIndex].value)+1)

    date1 = new Date(y1.options[y1.selectedIndex].text, m1.options[m1.selectedIndex].value, parseInt(d1.options[d1.selectedIndex].value)+1);
    date2 = new Date(y2.options[y2.selectedIndex].text, m2.options[m2.selectedIndex].value, parseInt(d2.options[d2.selectedIndex].value)+1);
	plus7days=new Date()
    plus7days.setYear(date1.getYear())
    plus7days.setMonth(date1.getMonth())
	plus7days.setDate(date1.getDate())
	plus7days.setDate(date1.getDate()+6)

	today=new Date()
	today.setHours(0)
	today.setMinutes(0)
	today.setSeconds(0)
	today.setMilliseconds(0)

	//alert(date1.getFullYear()+"/"+date1.getMonth()+"/"+date1.getDate()+","+date2.getFullYear()+"/"+date2.getMonth()+"/"+date2.getDate()+","+plus7days.getFullYear()+"/"+plus7days.getMonth()+"/"+plus7days.getDate())


	if (date1 <= date2 && date2 <= plus7days && date1 >= today && date2 >= today)
    {
		alert("2   "+today+"   "+date1+"   "+date2)
		return true;
    }
    else if(date2 > plus7days)
	{
		warn = err_datum_2[langfile];
        warn += ": " + date2 + " > " + plus7days;
        alert(warn);
        return false;
	}
    else if(date1 < today || date2 < today)
	{
		warn = err_datum_3[langfile];

        alert(warn);
        return false;
	}
	else
    {
		warn = err_datum[langfile];

        alert(warn);
        return false;
    }

}

function checkPrice(langfile)
{

    var warn = new String();
    warn = "";
    err = false;

    gp = document.getElementById("garage_price");

/*    switch(langfile)
    {
        case "hun.conf": { warn = "Az alábbiakra nem adott meg árat:"; break }
        case "eng.conf": { warn = "You haven't entered price for the next fields:"; break }
        case "ger.conf": { warn = "(D) Az alábbiakra nem adott meg árat:"; break }
        default:         { warn = "Az alábbiakra nem adott meg árat:"; break }
    }*/

	warn = err_nincsar[langfile ];

    for(i = 1; i <= 5; i++)
    {
     t = "room" + i + "twin";
     d = "room" + i + "double";
     tp = document.getElementById(t);
     dp = document.getElementById(d);

     if(!(tp.disabled) && (tp.value == "" || dp.value == ""))
     {
        err = true;
        warn += "\n" + i + ". " + szoba[langfile ];
     }
    }

    if(!gp.disabled && gp.value == "")
    {
        err = true;
        warn += "\n" + garazs[langfile ];
    }

    if(err)
    {
        alert(warn);
        return false;
    }
    else
    {
        return true;
    }

}

function checkFeltolt(langfile,p1,p2)
{
    if(checkDate(langfile,'year1','year2','month1','month2','day1','day2') && checkPrice(langfile))
    {
         return submitProtect(langfile,p1,p2);
         return true;
    }
    else
    {
         return false;
    }
}

function checkFeltolt2(langfile,p1,p2)
{
    if(checkDate2(langfile,'year1','year2','month1','month2','day1','day2') && checkPrice(langfile))
    {
         return submitProtect(langfile,p1,p2);
         return true;
    }
    else
    {
         return false;
    }
}

function checkFoglal2(langfile, p1, p2, checktag)
{
    v = document.getElementById("vezeteknev").value;
    k = document.getElementById("keresztnev").value;
    m = document.getElementById("mail").value;
    t = document.getElementById("telefon").value;
    c = document.getElementById("cim").value;
	n = document.getElementById("nemzetiseg").value;
	
    var warn = new String();
    warn = "";
    err = false;
    
/*    switch(langfile)
    {
        case "hun.conf":
        {
          warn = "Az alábbi mezőkre nem adott meg érvényes értéket:";
          if(v == "") { err = true; warn += "\n" + "- Vezetéknév" }
          if(k == "") { err = true; warn += "\n" + "- Keresztnév" }
          if(m == "") { err = true; warn += "\n" + "- E-mail cím" } else { if(!checkMail(m)) { err = true; warn += "\n" + "- E-mail cím (érvénytelen)" } }
          if(t == "") { err = true; warn += "\n" + "- Telefonszám" }
          if(c == "") { err = true; warn += "\n" + "- Cím" }
		  if(n == 0) { err = true; warn += "\n" + "- Nemzetiség" }
          break;
        }

        case "eng.conf":
        {
          warn = "You haven't entered a valid value for the next fields:";
          if(v == "") { err = true; warn += "\n" + "- Last name" }
          if(k == "") { err = true; warn += "\n" + "- First name" }
          if(m == "") { err = true; warn += "\n" + "- E-mail address" } else { if(!checkMail(m)) { err = true; warn += "\n" + "- E-mail cím (érvénytelen)" } }
          if(t == "") { err = true; warn += "\n" + "- Phone number" }
          if(c == "") { err = true; warn += "\n" + "- Address" }
		  if(n == 0) { err = true; warn += "\n" + "- Nationality" }
          break;
        }

        case "ger.conf":
        {
          warn = "(D) Az alábbi mezőkre nem adott meg érvényes értéket:";
          if(v == "") { err = true; warn += "\n" + "- (D) Vezetéknév" }
          if(k == "") { err = true; warn += "\n" + "- (D) Keresztnév" }
          if(m == "") { err = true; warn += "\n" + "- (D) E-mail cím" } else { if(!checkMail(m)) { err = true; warn += "\n" + "- (D) E-mail cím (érvénytelen)" } }
          if(t == "") { err = true; warn += "\n" + "- (D) Telefonszám" }
          if(c == "") { err = true; warn += "\n" + "- (D) Cím" }
		  if(n == 0) { err = true; warn += "\n" + "- (D) Nemzetiség" }
          break;
        }

        default:
        {
          warn = "Az alábbi mezőkre nem adott meg érvényes értéket:";
          if(v == "") { err = true; warn += "\n" + "- Vezetéknév" }
          if(k == "") { err = true; warn += "\n" + "- Keresztnév" }
          if(m == "") { err = true; warn += "\n" + "- E-mail cím" } else { if(!checkMail(m)) { err = true; warn += "\n" + "- E-mail cím (érvénytelen)" } }
          if(t == "") { err = true; warn += "\n" + "- Telefonszám" }
          if(c == "") { err = true; warn += "\n" + "- Cím" }
		  if(n == 0) { err = true; warn += "\n" + "- Nemzetiség" }
          break;
        }
    }*/

  warn = err_nincsertek[langfile ];
  if(v == "") { err = true; warn += "\n" + "- " + vezeteknev[langfile ] }
  if(k == "") { err = true; warn += "\n" + "- " + keresztnev[langfile ] }
  if(m == "") { err = true; warn += "\n" + "- " + email[langfile ] } else { if(!checkMail(m)) { err = true; warn += "\n" + "- " + email_ervenytelen[langfile ] } }
  if(t == "") { err = true; warn += "\n" + "- " + tel[langfile ] }
  if(c == "") { err = true; warn += "\n" + "- " + cim[langfile ] }
  if(n == 0) { err = true; warn += "\n" + "- " + nemzet[langfile ] }
	
	if( checktag.checked == false ) {
		warn += "\n" + "- " + szabalyzatelfog[langfile ]
		err = true;
	}

    if(!err)
    {
         return submitProtect(langfile,p1,p2);
         return true;
    }
    else
    {
         alert(warn);
         return false;
    }
}

function setPriceText(txt)
{
    r = document.getElementById(txt);
    pcs = parseInt(r.options[r.selectedIndex].value) + 1;

    switch(txt)
    {
      case "room":
      {
        for(i = 1; i <= 5; i++)
        {
         t = "room" + i + "twin";
         d = "room" + i + "double";
         tp = document.getElementById(t);
         dp = document.getElementById(d);

         if(i <= pcs)
         {
            tp.disabled = false;
            dp.disabled = false;
         }
         else
         {
            tp.disabled = true;
            dp.disabled = true;
         }
        }
       break
      }

      case "garage_pcs":
      {
       if((pcs - 1) > 0)
       {
        gp = document.getElementById("garage_price");
        gp.disabled = false;
       }
       else
       {
        gp.disabled = true;
       }
       break
      }
    }

    return true;
}

function setParamText(txt)
{
    r = document.getElementById(txt);
    pcs = parseInt(r.options[r.selectedIndex].value) + 1;

    for(i = 1; i <= 5; i++)
    {
     a = "agy" + i;
     t = "td" + i;
     d = "dohanyzo" + i;
     f = "felpanzio" + i;
     agy = document.getElementById(a);
     td = document.getElementById(t);
     doh = document.getElementById(d);
     fp = document.getElementById(f);

     if(i <= pcs)
     {
        agy.disabled = false;
        td.disabled = false;
        doh.disabled = false;
        fp.disabled = false;
     }
     else
     {
        agy.disabled = true;
        td.disabled = true;
        doh.disabled = true;
        fp.disabled = true;
     }
    }
    return true;
}

function hetiNezetDelete2( id ) {
	value = window.confirm( "Biztosan törölni szeretnéd?" );
	if( value ) {
		this.location = "torles.php?tip=sz&id=" + id;
	}
}

function hetiNezetDelete( id ) {
	value = window.confirm( "Biztosan törölni szeretnéd?" );
	if( value ) {
		this.location = "torles.php?tip=sz&id=" + id;
	}
}

function veglegDelete( id ) {
	value = window.confirm( "Véglegesen törölni szeretnéd?" );
	if( value ) {
		this.location = "vegleg_torol.php?tip=sz&id=" + id;
	}
}

function veglegDelete2( id ) {
	value = window.confirm( "Véglegesen törölni szeretnéd?" );
	if( value ) {
		this.location = "vegleg_torol_nv.php?tip=sz&id=" + id;
	}
}

function veglegDelete3() {
	value = window.confirm( "Véglegesen törölni szeretnéd az összes visszaigazolatlan foglalást?" );
	if( value ) {
		this.location = "vegleg_torol_osszes_nv.php";
	}
}

function changeMonth( ml, dl, ml2, dl2 )
{
	ar = new Array(1, 3, 5, 7, 8, 10, 12);
	m = document.getElementById(ml);
	d = document.getElementById(dl);
	h = document.getElementById("month_changed");
	mi = m.selectedIndex;
	di = d.selectedIndex;

	h.value = "1";
	
	while (d.childNodes.length > 0)
	{
		d.removeChild(d.childNodes[0]);
	}	
	
	if(inArray(++mi, ar)) x = 31; else x = 30;

	for( i = 0; i <= x; ++i )
	{
		j = i;
		if(i>0) d.options.add(new Option(i,++j));
	}
	if(d.childNodes.length == 30 && di == 30) di = 29;
	d.selectedIndex = di;

	changeDay( ml, dl, ml2, dl2 );

	return true;
}

function changeMonth2( ml, dl, ml2, dl2 )
{
	ar = new Array(1, 3, 5, 7, 8, 10, 12);
	m = document.getElementById(ml);
	d = document.getElementById(dl);
	h = document.getElementById("month_changed");
	mi = m.selectedIndex;
	di = d.selectedIndex;

	h.value = "1";
	
	while (d.childNodes.length > 0)
	{
		d.removeChild(d.childNodes[0]);
	}	
	
	if(inArray(++mi, ar)) x = 31; else x = 30;

	for( i = 0; i <= x; ++i )
	{
		j = i;
		if(i>0) d.options.add(new Option(i,++j));
	}
	if(d.childNodes.length == 30 && di == 30) di = 29;
	d.selectedIndex = di;

	return true;
}

function changeDay( ml, dl, ml2, dl2 )
{
	ar = new Array(1, 3, 5, 7, 8, 10, 12);
	m = document.getElementById(ml);
	d = document.getElementById(dl);
	m2 = document.getElementById(ml2);
	d2 = document.getElementById(dl2);
	mi = m.selectedIndex;
	mi22 = m2.selectedIndex;
	mi2 = ++mi22;
	di = d.selectedIndex;

	if(di == 30) // 31
	{
		if(inArray(mi2,ar)) di = 30;	
		if(!inArray(mi2,ar)) di = 29;	
	}
	else if(di == 29) // 30
	{
		if(inArray(mi2,ar)) di = 30;	
		if(!inArray(mi2,ar)) di = 29;	
	}
	else ++di;
	
//	m2.selectedIndex = mi;
	d2.selectedIndex = di;

	return true;
}

function inArray( e, a )
{
	inarr = false;
	for( i = 0; i < a.length; ++i )
	{
		if( e == a[i] ) inarr = true;
	}
	return inarr;
}

function dispList()
{
	m1 = document.getElementById("month1");
	d1 = document.getElementById("day1");
	m2 = document.getElementById("month2");
	d2 = document.getElementById("day2");
	mi1 = m1.selectedIndex;
	di1 = d1.selectedIndex;
	mi2 = m2.selectedIndex;
	di2 = d2.selectedIndex;

	alert(m1+":"+mi1+","+d1+":"+di1+"\n"+m2+":"+mi2+","+d2+":"+di2);

	return true;
}
