$(document).ready(function(){

	var loadingimage = "<center><br /><img src='/images/loading2.gif' /></center>";
	
  $(".expandcat").click(function(){
  	var parentid = $(this).attr("alt");
	  $("#boxSubCat"+parentid).slideToggle("normal");	  
	});



	$(".CategoryLink").click(function() {
  	var parentid = $(this).attr("cat");
    var pathname = window.location.pathname;
		
		if (pathname == "/cart.php" || pathname == "/authcart.php" || pathname == "/thanks.php") {
			window.location = "/categories.php?cat="+parentid;
		}
		
	  $("#boxSubCat"+parentid+":hidden").slideDown("normal");	    
  	$("#ContentBody").fadeOut("fast");

		$.ajax({
			type: "GET",
			url: "/include/catdetail.php",
			data: "cat="+parentid,
			success: function(data){
      	$("#ContentBody").html(data);
        $("#ContentBody").fadeIn("normal");
			},
			error: function(data, status, error) {
        $("#ContentBody").html("<div class='boxError'>Error: "+error+"</div>"+data);
        $("#ContentBody").fadeIn("normal");
			}
		});

    
  });
  
	/*
	$(".TeaCatBox").click(function() {
  	var parentid = $(this).attr("cat");
    var pathname = window.location.pathname;
		
		if (pathname == "/cart.php" || pathname == "/authcart.php" || pathname == "/thanks.php") {
			window.location = "/categories.php?cat="+parentid;
		}
    
	  $("#boxSubCat"+parentid+":hidden").slideDown("normal");	    
  	$("#ContentBody").fadeOut("fast");

		$.ajax({
			type: "GET",
			url: "/include/catdetail.php",
			data: "cat="+parentid,
			success: function(data){
      	$("#ContentBody").html(data);
        $("#ContentBody").fadeIn("normal");
			},
			error: function(data, status, error) {
        $("#ContentBody").html("<div class='boxError'>Error: "+error+"</div>"+data);
        $("#ContentBody").fadeIn("normal");
			}
		});

    
  });  
	*/
  
	$(".SubCategoryLink").click(function() {
  	var parentid = $(this).attr("id");
    var pathname = window.location.pathname;
		
		if (pathname == "/cart.php" || pathname == "/authcart.php" || pathname == "/thanks.php") {
			window.location = "/categories.php?cat="+parentid;
		}

$("#ContentBody").fadeOut("fast");

		$.ajax({
			type: "GET",
			url: "/include/catdetail.php",
			data: "cat="+parentid,
			success: function(data){
      	$("#ContentBody").html(data);
        $("#ContentBody").fadeIn("normal");
			},
			error: function(data, status, error) {
        $("#ContentBody").html("<div class='boxError'>Error: "+error+"</div>"+data);
        $("#ContentBody").fadeIn("normal");
			}
		});

    
  });  
	
});	
