function fillCats(value){
	$.post('/index.php/products/getCatsByManu/'+value,function(data){
										   $('#cats').html("<option value=\"null\">Categories</option>");
										   $('#cats').append(data);
										   $('#cats').css('visibility','visible');
										   });
}

function showProducts(value){
	
	$("#product_parts").html("<center><img src='/system/application/images/loading.gif'/></center>");
	$.post('/index.php/products/getProductsByProductCode/'+value,function(data){
										   $('#product_parts').html(data);										   
										   });
	
	
}

function showProducts2(value){	
	$("#product_parts").html("<center><img src=\"/system/application/images/loading.gif\"/></center>");
	$.post('/index.php/products/getProducts/'+value,function(data){
										   $('#product_parts').html(data);										   
										   });	
	return false;
}

function addToCart(itemcode, mfg){
	qty = $('#'+itemcode+'_qty').val();
	avail = $('#'+itemcode+'_avail').html();
	if(qty <= 0){
		alert("Please enter a quantity.");
		return false;
	}
	/*if(Number(avail) < qty){
		alert("Currently, we do not have that many in stock. Please lower your quantity.");
		return false;	
	}*/
	var price = "";
	
	mfg = mfg.replace(",","c");
		mfg = mfg.replace(".","d");
	$.post('/index.php/products/getProductDiscountPrice/'+itemcode+'/'+mfg+'/true',function(data){
			price = data;
			price = price.replace(".","d");
		$.post('/index.php/products/addToCart/'+qty+'/'+itemcode+'/'+price,function(data){
																	   
																	   
																	   });
		});
	

}
function showUpdate(id){
	$('#'+id+'_update').show();	
}
function updateItemQtyCart(id){
	new_qty = $('#'+id+'_qty').val();
	if(new_qty > 0){
	$.post('/index.php/products/updateQty',{'itemid':id,'qty':$('#'+id+'_qty').val()},function(){
													   $('#'+id+'_update').hide();
													   calcTotal();
													   });
	}else{
		removeFromCart(id);		
	}
}

