$(document)
		.ready(
				function() {

					/* Right Accordion Menu */
					$(".right ul.navigation ul").hide();

					/*
					 * $(".right ul.navigation li a.slide").click(function(){
					 * $(".right ul.navigation li ul").slideUp("slow");
					 * $(".right ul.navigation li a").removeClass("active");
					 * $(this).next("ul").slideToggle("slow");
					 * $(this).toggleClass("active");
					 * $(this).siblings("ul.navigation
					 * ul").removeClass("active"); return false; });
					 */
					$(".right ul.navigation li a.slide").click(
							function() {
								$(this).next("ul").slideToggle("slow");
								$(this).toggleClass("active");
								$(this).siblings("ul.navigation ul")
										.removeClass("active");
								return false;
							}

					);

					/* Drop Down Menu */
					$('#top .nav ul ul').hide();
					$('#top .nav ul li').hover(function() {
						$(this).find('ul').slideDown();
					}, function() {
						$(this).removeClass("active");
						$(this).find('ul').slideUp('slow');
					});

					/* Cart remove */
					$(".delete").click(deleteGood);

					function deleteGood() {
						$(".cart_item_line").parent().parent().attr("disabled",
								"disabled");

						$
								.getJSON(
										BaseUrl + "/user/jsonadeletecart",
										{
											id : $(this).attr("alt"),
											ajax : 'true'
										},
										function(j) {
											var item = '<span class="mini_cart_item">Items : $' + j.qty + '</span>';
											var summ = '<span class="mini_cart_price">Subtotal : $' + j.summ + '</span>';

											$(".mini_cart_item").replaceWith(
													item);
											$(".mini_cart_price").replaceWith(
													summ);
										})

						removeTr($(this));
					}

					function removeTr(obj) {
						var link = obj.parent().parent();
						link.css('background-color', '#ff6666');
						link.fadeOut();
					}
					/* Order history slide */
					$(".history_item_line_hidden").hide();

					$(".history_item_line").click(
							function() {
								$(this).next(".history_item_line_hidden")
										.slideToggle("slow");
							});

					$(".history_item_plus").click(
							function() {
								$(this).parent().next(
										".history_item_line_hidden")
										.slideToggle("slow");
								return false;

							});

					/* Reviews slide */
					$(".reviews_item_line_hidden").hide();

					$(".reviews_read").click(
							function() {
								$(this).parent().parent().next(
										".reviews_item_line_hidden")
										.slideToggle("slow");
								return false;

							});

					/* Comment slide */
					$(".product_reviews_comm_line").hide();

					$(".reviews_item_line_product_comm").click(
							function() {
								$(this).parent().parent().parent().next(
										".product_reviews_comm_line")
										.slideToggle("slow");
								return false;

							});

/*					$(".add_cart")
							.click(
									function() {

										$
												.getJSON(
														BaseUrl
																+ "/user/jsonaddcart",
														{
															id : $(this).attr(
																	"alt"),
															ajax : 'true'
														},
														function(j) {
															var item = '<span class="mini_cart_item">Items :' + j.qty + '</span>';
															var summ = '<span class="mini_cart_price">Price :' + j.summ + '</span>';

															$(".mini_cart_item")
																	.replaceWith(
																			item);
															$(
																	".mini_cart_price")
																	.replaceWith(
																			summ);
															// $(".cart_but_subtotal").replaceWith(summ);

															$(this)
																	.attr(
																			"alt",
																			BaseUrl
																					+ "/images/but/shopcartapply_48x48.png");
														})
									},
									function() {
										$(this)
												.attr(
														"src",
														BaseUrl
																+ "/images/but/002.gif");
									});

					$(".add_cart")
							.click(
									function() {
										$(this)
												.attr(
														"src",
														BaseUrl
																+ "/images/but/shopcartapply_48x48.png");
										$(this).css("cursor", "default");

									});*/ // hover ends

					$(".delete").hover(function() {
						$(".delete").css("cursor", "pointer");
						$(this).attr("src", BaseUrl + "/images/but/002.gif");

					}, function() {
						$(".delete").css("cursor", "default");
						$(this).attr("src", BaseUrl + "/images/but/002b.gif");
					}); // hover ends

					$("#popupClose").click(function() {
						disablePopup();
					});
					$(".eproduct_det_below").click(function() {
						centerPopup();
						loadPopup();
					});
					$("#backgroundPopup").click(function() {
						disablePopup();
						// centerPopup();
							// loadPopup();
						});
					// Press Escape event!
					$(document).keypress(function(e) {
						if (e.keyCode == 27 && popupStatus == 1) {
							disablePopup();
						}
					});
					$("#cart_select_all").toggle(function() {
						//var checked_status = this.checked;						
						$("#formCart .remove_cart").each(function() {
							$(this).attr('checked',true);
						});
						$(this).val('Unselect All');
					},
					function() {
						//var checked_status = this.checked;						
						$("#formCart .remove_cart").each(function() {							
							$(this).attr('checked',false);
						});
						$(this).val('Select All');
					});
				});
