single_r = new Array(10);
single_r[0] = 105;
single_r[1] = 130;
single_r[2] = 170;
single_r[3] = 135;
single_r[4] = 99;
single_r[5] = 75;
single_r[6] = 88;
single_r[7] = 79;
single_r[8] = 69;
single_r[9] = 40;

double_r = new Array(10);
double_r[0] = 120;
double_r[1] = 145;
double_r[2] = 190;
double_r[3] = 155;
double_r[4] = 119;
double_r[5] = 85;
double_r[6] = 96;
double_r[7] = 99;
double_r[8] = 79;
double_r[9] = 50;

// ******************* Szálloda árak értékei vége *************

function SzamolElso(member_info)	{
	//a variable that will hold the index number of the selected radio button
	document.form1.totalfee.value = 0;
	for (i = 0; i < document.form1.member.length; i++)	{
		if (document.form1.member[i].checked == true)	{
			document.form1.totalfee.value = eval(document.form1.totalfee.value) + (document.form1.member_amount.value * document.form1.member[i].value);
			if ((member_info != '') && (typeof(member_info) != "undefined"))	{
				document.form1.mitkattradio.value = member_info;
			}
		}
	}
	if (document.form1.accomp.checked == true)
		document.form1.totalfee.value = eval(document.form1.totalfee.value) + (document.form1.accomp_amount.value * document.form1.accomp.value);

	if (document.form1.gala_dinner.checked==true)
		document.form1.totalfee.value=eval(document.form1.totalfee.value)+(document.form1.gala_dinner_amount.value*document.form1.gala_dinner.value);

	document.form1.total_total.value = eval(document.form1.totalfee.value) + eval(document.form1.total_nights.value) + eval(document.form1.program_total.value);

	return true;
}	

function ElsoSzamol(member__info)	{
	if (document.form1.member_amount.value == 0)	{
		document.form1.member_amount.value = 1;
	}
	SzamolElso(member__info);
}

function ElsoAccompSzamol()	{
	if (document.form1.accomp_amount.value == 0){
		document.form1.accomp_amount.value = 1;
	}
	SzamolElso();
}

function SzamolMasodik()	{
	var szam=0;
	document.form1.total_nights.value = 0;
	for (i = 0; i < document.form1.hotel1st.length; i++)	{
		var ezaz = document.getElementById("amount" + (i + 1));
		if (document.form1.hotel1st[i].checked == true)	{
			if (document.form1.roomtype[0].checked == true)	{
				szam = ezaz.value;

				document.form1.total_nights.value = szam * single_r[document.form1.hotel1st[i].value - 1];
//				alert("felso"+szam+"   "+single_r[document.form1.hotel1st[i].value-1]);
			}
			if (document.form1.roomtype[1].checked == true)	{
				szam = ezaz.value;
				document.form1.total_nights.value = szam * double_r[document.form1.hotel1st[i].value - 1];
//				alert("also"+szam+"   "+double_r[document.form1.hotel1st[i].value-1]);
			}
		}
	}
	
	var masikradio = document.getElementById("metofpay1");
	var onsites = document.getElementById("metofpay3");
	if (((eval(document.form1.program_total.value) > 0) || (eval(document.form1.total_nights.value) > 0)) && (onsites.checked == true))	{
		alert("On-site payment is possible only in case of the registration fee.");
		masikradio.checked = true;
	}
	if (szam == 0) return false;
	else	return true;
}

function Szamol_hotel2(mezo){
	if ((mezo == "") || (mezo == 0))	{
		alert("You have to fill this field to continue!");
		return false;
	}	else	{
		var tizeuro = SzamolMasodik();
		document.form1.total_nights.value = (document.form1.total_nights.value * document.form1.nights.value);
		if (tizeuro)	document.form1.total_nights.value = parseInt(document.form1.total_nights.value) + 10;
		document.form1.total_total.value = eval(document.form1.totalfee.value) + eval(document.form1.total_nights.value) + eval(document.form1.program_total.value);
		return true;
	}
}

function MasodikEgyesSzamol(){

	for (i = 0; i < document.form1.hotel1st.length; i++)	{
		var ezaz = document.getElementById("amount" + (i + 1));
		ezaz.value = 0;
	}

	for (i = 0; i < document.form1.hotel1st.length; i++)	{
		var ezaz = document.getElementById("amount" + (i + 1));
		if (document.form1.hotel1st[i].checked == true)	{
			if (ezaz.value == 0)
				ezaz.value = 1;
			
			if (document.form1.nights.value == "" || document.form1.nights.value == 0)	{
				document.form1.nights.value = 1;
			}
		}
	}
	return true;
}

function reggeliszamol()	{
	if (document.form1.breakfast.checked == true)	{
		if (document.form1.amount_breakfast.value == 0)	document.form1.amount_breakfast.value = 1;
		Szamol_hotel2();
	}	else	{
		document.form1.amount_breakfast.value = 0;
		Szamol_hotel2();
	}
}

function ElsoGala_dinnerSzamol(){
	if (document.form1.gala_dinner_amount.value==0){
		document.form1.gala_dinner_amount.value=1;
	}
	SzamolElso();
	
	return true;
}

function daysbetweendates(d1, d2)	{
	var egynap = 1000 * 60 * 60 * 24;
	var dat1 = d1.split("-");
	var dat2 = d2.split("-");
	
	var datum1 = new Date(dat1[0]+"/"+dat1[1]+"/"+dat1[2]);
	var datum2 = new Date(dat2[0]+"/"+dat2[1]+"/"+dat2[2]);
	var datum1_ms = datum1.getTime();
	var datum2_ms = datum2.getTime();
	if (d1 != "" && d2 != "")	{
		if (datum1 >= datum2)	{
			alert("Arrival date must be earlier than departure date!");
		}	else	{
			var diff_ms = Math.abs(datum1_ms - datum2_ms)
			var diff = Math.ceil(diff_ms / egynap);
		}
		
		document.form1.nights.value = diff;
		Szamol_hotel2(diff);
	}
}

function resetvalues()	{
	for (i = 0; i < document.form1.hotel1st.length; i++)	{
		document.form1.hotel1st[i].checked = false;
		document.form1.hotel2nd[i].checked = false;
	}	
	document.form1.total_total.value = eval(document.form1.total_total.value) - eval(document.form1.total_nights.value);
	document.form1.nights.value = 0;
	document.form1.total_nights.value = 0;
	document.form1.arrival_date.value = "";
	document.form1.departure_date.value = "";
	MasodikEgyesSzamol();
}

function resetvalues_regfee()	{
	for (i = 0; i < document.form1.member.length; i++)	{
		document.form1.member[i].checked = false;
	}
	document.form1.accomp.checked = false;
	document.form1.gala_dinner.checked = false;
	document.form1.member_amount.value = 0;
	document.form1.accomp_amount.value = 0;
	document.form1.gala_dinner_amount.value = 0;
	document.form1.totalfee.value = 0;
	document.form1.total_total.value = eval(document.form1.total_total.value) - eval(document.form1.totalfee.value);
}

function Szamolharmadik()	{
	document.form1.program_total.value = 0;
	
	if (document.form1.optional1_sun.checked == true)	{
		if (document.form1.amount_program1.value == 0)	document.form1.amount_program1.value = 1;
		document.form1.program_total.value = parseInt(document.form1.program_total.value) + (parseInt(document.form1.optional1_sun.value) * parseInt(document.form1.amount_program1.value));
	}

	if (document.form1.optional2_wed.checked == true)	{
		if (document.form1.amount_program2.value == 0)	document.form1.amount_program2.value = 1;
		document.form1.program_total.value = parseInt(document.form1.program_total.value) + (parseInt(document.form1.optional2_wed.value) * parseInt(document.form1.amount_program2.value));
	}

	if (document.form1.optional3_thu.checked == true)	{
		if (document.form1.amount_program3.value == 0)	document.form1.amount_program3.value = 1;
		document.form1.program_total.value = parseInt(document.form1.program_total.value) + (parseInt(document.form1.optional3_thu.value) * parseInt(document.form1.amount_program3.value));
	}

	document.form1.total_total.value = eval(document.form1.totalfee.value) + eval(document.form1.total_nights.value) + eval(document.form1.program_total.value);
	var masikradio = document.getElementById("metofpay1");
	var onsites = document.getElementById("metofpay3");
	if (((eval(document.form1.program_total.value) > 0) || (eval(document.form1.total_nights.value) > 0)) && (onsites.checked == true))	{
		alert("On-site payment is possible only in case of the registration fee.");
		masikradio.checked = true;
	}
	
	return true;
}

function UresEll(mezoadat,meznev)	{
	if (mezoadat != "")	{
		return true;
	}	else	{
	   alert("All boxes must be completed!");
	   return false;
	} 
}

function SzemelyDarabEll()	{ 
	if (document.form1.member_amount.value == 1)	{
		document.form1.roomtype[1].checked = false;
		document.form1.roomtype[0].checked = true;
	}
}

function MM_validateForm() { //v4.0
	var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
	for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
		if (val) { nm=val.name; if ((val=val.value)!="") {
			if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
			if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
		} else if (test!='R') { num = parseFloat(val);
			if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
			if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
				min=test.substring(8,p); max=test.substring(p+1);
				if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
		} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' Must be filled in.\n'; }
	} 
	if (errors){ 
		// document.getElementById('first_name').focus();
		alert('Please fill in:\n'+errors);
		return false;
	}
	document.MM_returnValue = (errors == '');
}

function MM_findObj(n, d) { //v4.01
	var p,i,x;  if (!d) d=document; if ((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if (!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if (!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_setTextOfTextfield(objName,x,newText) { //v3.0
	var obj = MM_findObj(objName); if (obj) obj.value = newText;
}

function mailcheck(str) {
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){	return false	}
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){	return false	}
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){	return false	}
	if (str.indexOf(at,(lat+1))!=-1){	return false	}
	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){	return false	}
	if (str.indexOf(dot,(lat+2))==-1){	return false	}
	if (str.indexOf(" ")!=-1){	return false	}
	return true					
}

function Vizsgal()	{
	var masikradio = document.getElementById("metofpay1");
	if ((eval(document.form1.program_total.value) > 0) || (eval(document.form1.total_nights.value) > 0))	{
		alert("On-site payment is possible only in case of the registration fee.");
		masikradio.checked = true;
	}
}

