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)
{
			var url = (document.location.href.split("?", 2))[0];

			data = '';

			$('.checkbox').each(function() {

						if($(this).attr('type') == 'checkbox' && $(this).is(':checked'))
									data += $(this).attr('name') + '[]=' + $(this).val() + '&';
			});

			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)
						{
									$('#winkelmandje').fadeOut('10', 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)
						{
									$('#winkelmandje').fadeOut('1', function(){
												$(this).html($html);
												$(this).fadeIn(1);
									});
						}
			});
}