$("#modAR-cover, #modAR-close, .mymodal-submit").click(function() {
	//alert($(this).attr("id"));
	$("#modAR-container").fadeOut(600);
	$("#modAR-cover").delay(300).fadeOut(300);
});



$("#modAR-container").click(function(event) {
	event.stopPropagation();
});

function modal_start(tipus,param,valt){
	// ha nem váltás van, akkor csak tűnjön elő
	if($("#modAR-cover").css("display")=="none"){
		// háttér
		$("#modAR-cover").fadeIn(300);
		$.ajax({
			type: "POST",
			url: "/_includes/modal/"+tipus+".php",
			data: "ajax=true&"+param,
			success: function(response){
				//tartalom
				$("#modAR-cover").html(response);
				$('#modAR-container').hide();
				$('#modAR-container').fadeIn(300);
			}
		});
	} else {
	// ha váltás van
		var originalHeight = 0;
		var newHeight = 0;
		
		// eredeti magassag lekerdezes (20px a padding-top/bottom)
		var originalHeight = (parseInt( $('#modAR-box').height() ) - 20);
		$('#modAR-box .content #content_torzs,').animate({opacity: 0}, 400, 'easeInOutCirc', function() {
			$.ajax({
				type: "POST",
				url: "/_includes/modal/"+tipus+".php",
				data: "ajax=true&"+param,
				success: function(response){
					$("#modAR-cover").html(response);
					// uj tartalom marad lathatatlanul
					$('#modAR-box .content #content_torzs').animate({opacity: 0}, 0, function() {
						var newHeight = (parseInt( $('#modAR-box .content').height() ) - 20);	// uj magassag
						
						// eredeti magassag megadasa a divnek, majd uj magassagra animalas, kozben pedig uj tartalom befade-el
						$('#modAR-box .content').animate({height: originalHeight}, 0).animate({height: newHeight}, 400, 'easeInOutCirc');
						$('#modAR-box .content #content_torzs').animate({opacity: 1}, 400, 'easeInOutCirc');
					});
				}
			});
		});
	}

}
