function show_cal(year,month) {

	//var akt_date = $("selected_date").value;
	var akt_date = "";
	new Ajax.Request('/ajaxhelper.php?type=show_cal', {
		parameters: {year: year, month: month, akt_date: akt_date},
		onSuccess: function(data){
				$("calholder").innerHTML = data;
			}
		}
	);
}

function select_day(date) {
	var akt_date = $("#selected_date").val();
	if(akt_date != ''){
		document.getElementById(akt_date).className = "szabad";
	}
	if(akt_date == date){
		$("#selected_date").val('');
		document.getElementById(date).className = "szabad";		
	}else{
		$("#selected_date").val(date);
		document.getElementById(date).className = "foglalt";		
	}
}

function submit_cal() {
	var akt_date = $("#selected_date").val();
	if(akt_date == ''){
		alert("Kérjük válasszon érkezési dátumot!");
	}else{
		document.location.href="/ajanlatok?datum="+akt_date;
	}
}

function showAjanlom()
{
	$("#ajanlom_kont").show('fast')
}

function hideAjanlom()
{
	$("#ajanlom_kont").hide('fast')
	$("#ajanlom_error_email").hide()
	$("#ajanlom_error_snev").hide()
	$("#ajanlom_error_semail").hide()
	$("#ajanlomform input[type='text']").each(function(){
		$(this).val('')
	})
}

function ajanlomExec()
{
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	var jo = true;

	if ($("#ajanlom_snev").val() == '')
	{
		jo = false;
		$("#ajanlom_error_snev").show()
	} else {
		$("#ajanlom_error_snev").hide()
	}

	if ($("#ajanlom_semail").val() == '')
	{
		jo = false;
		$("#ajanlom_error_semail").show()
	} else {
		$("#ajanlom_error_semail").hide()
		if (!filter.test($("#ajanlom_semail").val()))
		{
			jo = false;
			$("#ajanlom_error_semail").show()
		} else {
			$("#ajanlom_error_semail").hide()
		}
	}


	if ($("#ajanlom_email").val() == '')
	{
		jo = false;
		$("#ajanlom_error_email").show()
	} else {
		$("#ajanlom_error_email").hide()
		if (!filter.test($("#ajanlom_email").val()))
		{
			jo = false;
			$("#ajanlom_error_email").show()
		} else {
			$("#ajanlom_error_email").hide()
		}
	}

	if (jo)
	{
		$.post('/ajaxhelper.php?type=send_ajanlom', $("#ajanlomform").serialize(),
			function(data){
				$("#normalform").hide();
				if(data == 'ok'){
					$("#elkuldveform_data").html("Ön sikeresen elküldte az ajánlatot a megadott címre!<br>Köszönjük, hogy a Confhotel Travel ajánlatát továbbította!");
					$("#elkuldveform").show()
				}else if(data == 'error'){
					$("#elkuldveform_data").html("Hiba");
					$("#elkuldveform").show()
				}
				setTimeout("restoreDivs()", 5000)
			}
		);
	}
	
}

function restoreDivs()
{
	$("#ajanlom_kont").hide('fast')
	$("#normalform").show();
	$("#elkuldveform").hide()
	$("#ajanlomform input[type='text']").each(function(){
		$(this).val('')
	})
}

function changeFilter(sel,subt,orszag)
{
	var filter = "";
	var orszagtxt = "";
	if (sel >-1)
	{
		filter = "&filter="+sel
	}
	if (orszag > -1)
	{
		orszagtxt = "&orszag="+orszag
	}
	document.location.href='?p=20&subtype='+subt+orszagtxt+filter
}

function changeOrszag(sel,subt,filter,facebook)
{
	var orszag = "";
	var filtertxt = "";
	var facebooktxt = "";
	if (sel >-1)
	{
		orszag = "&orszag="+sel
	}

	if (filter > -1)
	{
		filtertxt = "&filter="+filter
	}
	if (facebook > 0)
	{
		facebooktxt = "&facebook="+facebook
	}
	document.location.href='?p=20&subtype='+subt+orszag+filtertxt+facebooktxt
}
