function showInCart(init) {

	try{

		$('cartListTablePlace').innerHTML = '';
		var src = "<table id='cartListTable' class='cart_data_table3'>";
		var img ="";

		new Ajax.Request("ajaxGetCartList", {
			method: 'post',
			parameters: "",
			onSuccess: function(req) {
				try {
					eval("obj=" + req.responseText);

					if( obj.Product.length != 0 ){

						$A(obj.Product).each(function(Product, index) {
							var product = Product.Product;

							src += "<tr id='cart_row_" + product.id + "'>";
							if( product.image_id != null ) {
								img = $F('image_path') + product.image_id;
							}else if( product.line_middle_image_id != null ){
								img = $F('image_path') + product.line_middle_image_id;
							}else if( product.line_small_image_id != null ){
								img = $F('image_path') + product.line_small_image_id;
							}else if( product.line_image_id != null ){
								img = $F('image_path') + product.line_image_id;
							} else {
								img = $F('content_path') + "/img/" + "100-100.jpg";
							}
							src += "<td class='cart_pict2'><img src='" + img + "' width='100' height='100' class='cart_pict_border'></td>";
							src += "<td class='cart_name2'>" + product.name + "</td>";
							src += "<td class='cart_capacity_header2'>" + null2ZeroString(product.content_amount) + "</td>";
							src += "<td class='cart_size_header2'>" + null2ZeroString(product.size_height) + "/" + null2ZeroString(product.size_width) + "/" + null2ZeroString(product.size_depth) + "</td>";
							src += "<td class='cart_material_header2'>" + null2ZeroString(product.material) + "</td>";
							src += "<td class='cart_into_header2'>" + null2ZeroString(product.number) + "</td>";
							src += "<td class='cart_weight_header2'>" + null2ZeroString(product.weight) + "</td>";
							src += "<td class='cart_del_header2'><a href='javascript:void(0);' onclick='removeProduct(" + product.id + ")'>取消</a></td></td></tr>";
						});
						src += "</table>";

						$('cartListTablePlace').innerHTML = src;
						$('jumpToSampleRequestVisible').style.display = "";

						if( init == true ){
							jQuery(function($) {
								$.blockUI({ message: $('#cartDialogFormArea'), css: { top: '20px', left: '100px', width: '900px' }});
							});
						}

					}else{

						$('cartListTablePlace').innerHTML = "<table id='cartListTable' class='cart_data_table3'><tr><td><div style='width:780px;padding-bottom:20px;text-align:center;'>現在カートに製品はありません。</div></td></tr></table>";
						$('jumpToSampleRequestVisible').style.display = "none";

						if( init == true ){
							jQuery(function($) {
								$.blockUI({ message: $('#cartDialogFormArea'), css: { top: '20px', left: '100px', width: '900px' }});
							});
						}

					}

				} catch(e) {
					alert(e.toString());
				}
			},
			onFailure: function(req) {
				alert("通信エラーが発生しました。");
				return;
			}
		});

	}catch( e ){

	}

}

function removeProduct(productId) {

	if( confirm("カートから削除してもよろしいですか？") ) {

		$('deleteProductId').value = productId;

		new Ajax.Request("ajaxRemoveCartList", {
			method: 'post',
			parameters: "productId="+productId,
			onSuccess: function(req) {
				try {

					var tObj = $("cartListTable");
					for (var i = 0; i < tObj.rows.length; i++ ) {
			            if(tObj.rows[i]!=null){
			                if( tObj.rows[i] == $("cart_row_" + $F('deleteProductId')) ){
			                	tObj.deleteRow(i);
			                	break;
			                }
			            }
			        }

			        objNodeList = tObj.getElementsByTagName( "tr" );

			    	// 行数
			    	nLength = objNodeList.length;

			        if( nLength == 0 ) {
						$('cartListTablePlace').innerHTML = "<table class='cart_data_table3' id='cartListTable'><tr><td><div style='width:780px;padding-bottom:20px;text-align:center;'>現在カートに製品はありません。</div></td></tr></table>";
						$('jumpToSampleRequestVisible').style.display = "none";
			        }

			        if(typeof productIdsInCart != "undefined" && productIdsInCart != null ){

			        	for(i = 0; i < productIdsInCart.length; i++){
			        		 if( productIdsInCart[i] == productId ){
			        			 productIdsInCart.splice(i,1);
			        		 }
			        	}
			        	removeProductRowClass(productId);
			        }
					//showInCart(false);

				} catch(e) {
					alert(e.toString());
				}
			},
			onFailure: function(req) {
				alert("通信エラーが発生しました。");
				return;
			}
		});

	}

}

function jumpToSampleRequest() {

	location.href = $F('content_path') + "/sample_request/login";

}

