$(document).ready(function() {

	$('#imprimirLote').click(function() {
		window.open($(this).attr('href'), "dddd", "width = 600,scrollbars = yes");
		return false;
	});
	$('#imprimirLista').click(function() {
		window.open($(this).attr('href'),"asd", "width = 600,scrollbars = yes");
		return false;
	});

	$('#adi-lista').click(function () {
		if ($(this).attr('checked')) {
			$.ajax({
	            url: baseUrl+'minhalista/adicionar',
	            data: {
	            	lote_id:$('#lote_id').val()
	            },
	            type: 'POST',
	            dataType: 'html',
	        	cache: false,
	        	async: false,
	            beforeSend: function () {

	            },
	        	success: function(data) {
	        		alert(data);
	        	}
	    	});
		} else {
			$.ajax({
	            url: baseUrl+'minhalista/remover',
	            data: {
	            	lote_id:$('#lote_id').val()
	            },
	            type: 'POST',
	            dataType: 'html',
	        	cache: false,
	        	async: false,
	            beforeSend: function () {

	            },
	        	success: function(data) {
	        		alert(data);
	        	}
	    	});
		}
	});

	$('.minhaLista').click(function () {
		idLote = $(this).val();
		if ($(this).attr('checked')) {
			$.ajax({
	            url: baseUrl+'minhalista/adicionar',
	            data: {
	            	lote_id:idLote
	            },
	            type: 'POST',
	            dataType: 'html',
	        	cache: false,
	        	async: false,
	            beforeSend: function () {

	            },
	        	success: function(data) {
	        		alert(data);
	        	}
	    	});
		} else {
			$.ajax({
	            url: baseUrl+'minhalista/remover',
	            data: {
	            	lote_id:idLote
	            },
	            type: 'POST',
	            dataType: 'html',
	        	cache: false,
	        	async: false,
	            beforeSend: function () {

	            },
	        	success: function(data) {
	        		alert(data);
	        	}
	    	});
		}
	});

});