$(document).ready(function() {

	
	/**  Megrendelés, vagy ajánlatkérés az űrlapnél  **/
	$("#mode_1").click(function() {
		if ($('#mode_1').attr('checked')) {
		    $("#order_send_pay_data").show();
		}
		else {
		    $("#order_send_pay_data").hide();
		}
	});
	
	$("#mode_2").click(function() {
		if ($('#mode_2').attr('checked')) {
		    $("#order_send_pay_data").hide();
		}
		else {
		    $("#order_send_pay_data").show();
		}
	});
	
	
	/**  Megrendelés, vagy ajánlatkérés az űrlapnél  **/
	$("#bill_1").click(function() {
		if ($('#bill_1').attr('checked')) {
		    $(".bill_data").show();
		} else {
		    $(".bill_data").hide();
		}
	});
	
	$("#bill_2").click(function() {
		if ($('#bill_2').attr('checked')) {
		    $(".bill_data").hide();
		} else {
		    $(".bill_data").show();
		}
	});
	
	
	
	/**  Kosárból törlés  **/
	del_from_basket = function(id) {

		var data = 'id=' + id;
		
		$.ajax({
			
			url : "ajaxLoader.php?pg=delBasket",
			type : "POST",
			data : data,
			cache : false,

			success : function(html) {
				$('.order_product_list').html(html);
				
				$(".order_del_basket").bind('click', function() {
					del_from_basket($(this).attr('name'));
				});
				
				$('#cart_product_sum').load('ajaxLoader.php?pg=getProductSum');
			}
		
		});

	}
	
	
	
	
	$(".order_del_basket").click( del_from_basket($(this).attr('name')) );
	
	
	$('#cart_product_sum').load('ajaxLoader.php?pg=getProductSum');
	
	
	
	/**  Kosárba tétel  **/
	$(".order_to_basket").click(function() {
		
		var id = $(this).attr('name');
		
		var name = $(".product_name_" + id).text();

		var data = 'id=' + id + '&name=' + name;
		
		$.ajax({
			
			url : "ajaxLoader.php?pg=toBasket",
			type : "POST",
			data : data,
			cache : false,

			success : function(html) {
				$('.order_product_list').html(html);
				
				$("#order_to_basket_div_" + id).html('');

				/**  Kosárból törlés  **/
				$(".order_del_basket").bind('click', function() {
					del_from_basket($(this).attr('name'));
				});
				
				$('#cart_product_sum').load('ajaxLoader.php?pg=getProductSum');
			}
		
		});
		
	});

	
	/**  Kosárba tétel médiatárból  **/
	$(".oltozekbt_media_order_link").click(function() {
		
		var id_ = $(this).attr('id');
		
		var id = id_.replace('oltozekbt_media_order_', '');
		
		var name = $(".product_name_media_" + id).text();

		var data = 'id=' + id + '&name=' + name;
		
		$.ajax({
			
			url : "ajaxLoader.php?pg=toBasket",
			type : "POST",
			data : data,
			cache : false,

			success : function(html) {
				$("#oltozekbt_media_order_" + id).html('');
				
				$('#cart_product_sum').load('ajaxLoader.php?pg=getProductSum');
			}
		
		});
		
	});
	
});

