function showCompareButtons(source)
{
			if(source.is(':checked')){
				source.next('input').show();
			} else {
				source.next('input').hide();
			}
}

function Amount_OnChanged(source)
{
            var amount = source.val();

            var id = source.attr('id');

            $.ajax({
            type: "POST",
            url: "./index.php/winkelmandje/wijzigaantal/",
            data: "productId=" + id + '&amount=' + amount,
			success: function($html)
			{
				window.location.reload(true);
			}
			});
}

function Attribute_OnChanged(source, sFunction)
{
            var attribute = source.val();

            var id = source.attr('id');

            $.ajax({
            type: "POST",
            url: "./index.php/winkelmandje/" + sFunction,
            data: "productId=" + id + '&attribute=' + attribute,
			success: function($html)
			{
				window.location.reload(true);
			}
			});
}

function getAdressByZipcode(val)
{

			$.ajax({
						type: "POST",
						url: "./index.php/klanten/getstreet/",
						data: "zipcode=" + val,
						success: function($html)
						{
									if($html)
									$('#tbCity').val($html);
						}
			});
}

function handleFilter(source, postTo)
{
	var url = (postTo.split("?", 2))[0];
	
	var data = '';
	var count = false;

	$('.checkbox').each(
			function() {
				if ($(this).attr('type') == 'checkbox'
						&& $(this).is(':checked')) {
					data += $(this).attr('name') + '[]=' + $(this).val() + '&';
				}

				if ($(this).attr('type') == 'checkbox'
						&& $(this).attr('name') == source.attr('name')
						&& $(this).is(':checked')) {
					count = true;
				}
			});

	if (count == false) {
		data += source.attr('name') + '[]&';
	}

	if (data)
		window.location = url + '?' + data;
}

function AddToWinkelmandje($id)
{
	AddProductToWinkelmandje($id);
}

function AddProductToWinkelmandje($id)
{
			var $url = './index.php/winkelmandje/toevoegen/' + $id;
			$.ajax({
						type: "POST",
            url: $url,
						success: function($html)
						{
									$('#winkelmandjeWidget').fadeOut('100', function(){
												$(this).html($html);
												$(this).fadeIn();

												$('#dialogs').html('<div>Het product is aan uw winkelmandje toegevoegd</div>');
												$("#dialogs").find('div').each(function(){
															$(this).dialog({
																	bgiframe: true,
																	modal: true,
																	buttons: {
																		Ok: function() {
																			$(this).dialog('close');
																		}
																	}
															});
												});
									});
						}
			});
}

function AddToMoreWinkelmandje($url)
{
			$.ajax({
						type: "POST",
            url: $url,
						success: function($html)
						{
									$('#winkelmandjeWidget').fadeOut('1', function(){
												$(this).html($html);
												$(this).fadeIn(1);
									});
						}
			});
}
