single_r = new Array(19);
single_r[0] = 175;
single_r[1] = 205;
single_r[2] = 235;
single_r[3] = 179;
single_r[4] = 159;
single_r[5] = 144;
single_r[6] = 130;
single_r[7] = 150;
single_r[8] = 125;
single_r[9] = 155;
single_r[10] = 100;
single_r[11] = 110;
single_r[12] = 110;
single_r[13] = 110;
single_r[14] = 75;
single_r[15] = 79;
single_r[16] = 75;
single_r[17] = 105;
single_r[18] = 62;

double_r = new Array(19);
double_r[0] = 195;
double_r[1] = 225;
double_r[2] = 255;
double_r[3] = 194;
double_r[4] = 174;
double_r[5] = 159;
double_r[6] = 150;
double_r[7] = 170;
double_r[8] = 145;
double_r[9] = 175;
double_r[10] = 114;
double_r[11] = 124;
double_r[12] = 130;
double_r[13] = 130;
double_r[14] = 85;
double_r[15] = 99;
double_r[16] = 95;
double_r[17] = 115;
double_r[18] = 77;

// ******************* 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 ev1 = d1.substring(0, 4);
	var ho1 = d1.substring(5, 7);
	var nap1 = d1.substring(8, 10);

	var ev2 = d2.substring(0, 4);
	var ho2 = d2.substring(5, 7);
	var nap2 = d2.substring(8, 10);
	
	var datum1 = new Date(ev1, ho1, nap1);
	var datum2 = new Date(ev2, ho2, nap2);
	
	if (d1 != "" && d2 != "")	{
		if (datum1 >= datum2)	{
			alert("Arrival date must be earlier than departure date!");
		}	else	{
			diff = Math.ceil((datum2.getTime() - datum1.getTime()) / 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_mon.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_mon.value) * parseInt(document.form1.amount_program1.value));
	}
	if (document.form1.optional1_tue.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_tue.value) * parseInt(document.form1.amount_program1.value));
	}
	if (document.form1.optional1_thu.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_thu.value) * parseInt(document.form1.amount_program1.value));
	}

	if (document.form1.optional2_sun.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_sun.value) * parseInt(document.form1.amount_program2.value));
	}
	if (document.form1.optional2_mon.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_mon.value) * parseInt(document.form1.amount_program2.value));
	}
	if (document.form1.optional2_tue.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_tue.value) * parseInt(document.form1.amount_program2.value));
	}
	if (document.form1.optional2_thu.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_thu.value) * parseInt(document.form1.amount_program2.value));
	}

	if (document.form1.optional3_mon.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_mon.value) * parseInt(document.form1.amount_program3.value));
	}
	if (document.form1.optional3_tue.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_tue.value) * parseInt(document.form1.amount_program3.value));
	}
	if (document.form1.optional3_wed.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_wed.value) * parseInt(document.form1.amount_program3.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));
	}

	if (document.form1.optional4_sun.checked == true)	{
		if (document.form1.amount_program4.value == 0)	document.form1.amount_program4.value = 1;
		document.form1.program_total.value = parseInt(document.form1.program_total.value) + (parseInt(document.form1.optional4_sun.value) * parseInt(document.form1.amount_program4.value));
	}
	if (document.form1.optional4_mon.checked == true)	{
		if (document.form1.amount_program4.value == 0)	document.form1.amount_program4.value = 1;
		document.form1.program_total.value = parseInt(document.form1.program_total.value) + (parseInt(document.form1.optional4_mon.value) * parseInt(document.form1.amount_program4.value));
	}
	if (document.form1.optional4_tue.checked == true)	{
		if (document.form1.amount_program4.value == 0)	document.form1.amount_program4.value = 1;
		document.form1.program_total.value = parseInt(document.form1.program_total.value) + (parseInt(document.form1.optional4_tue.value) * parseInt(document.form1.amount_program4.value));
	}
	if (document.form1.optional4_wed.checked == true)	{
		if (document.form1.amount_program4.value == 0)	document.form1.amount_program4.value = 1;
		document.form1.program_total.value = parseInt(document.form1.program_total.value) + (parseInt(document.form1.optional4_wed.value) * parseInt(document.form1.amount_program4.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;
	}
}
