// FUNCTION TO ATTACH FADE OUTS
// $("#container a").fadeOutLink();
$.fn.fadeOutLink = function(){
  $foo = $(this);
  return this.each(function(){
      $this = $(this);
      $(this).click(function(){
        $foo.not($(this)).fadeTo(400,0.001);
        $(this).fadeTo(1000,0.001);
      });
  });
};

// FUNCTION TO ANIMATE HOVER IMAGES
// $(".offClassName").animationHoverImages("offClassName","onClassName");
$.fn.animateHoverImages = function(offClass,onClass){
  
   return this.each(function(){
      $this = $(this);
      $this.removeClass(offClass)
           .append("<span class=\"JSHover "+onClass+"\" ></span>")
           .each(function(){
              var $span = $('> span.JSHover', this).css('opacity', 0);
              $span.css("backgroundImage",$(this).css("backgroundImage"));
      
              // when the user hovers in and out of the anchor
              $(this).hover(function () {
                // on hover
                // stop any animations currently running, and fade to opacity: 1
                $span.stop().fadeTo(500, 1);
              }, function () {
                // off hover 
                // again, stop any animations currently running, and fade out
                $span.stop().fadeTo(500, 0);
              }); // end hover
           }); // end each
   }); // end each
} // end function
function doNothing(){}
function shopmain_functions(){
	// fade in the shop brand images
	// note currently, images are offset in css... if JS doesn't work, then it will load from CSS and not see the image.
	$("#cartContent").hide();//fadeIn(2000);
	$("#cartContent a").fadeOutLink();
	$(".Box_off").animateHoverImages("Box_off","Box_on");
	$("a").not(".Image_matic, .Image_gw, .Image_monsters, .faded").click(function(){
		$("#cartContent").fadeTo(500,0.001);
	});
	$(window).load(function(){
                $("#cartContent").fadeIn(2000);
        });
}
function shopbrowse_functions(){
	// fade in the one div instead of each product item
	$("#cartContent").hide();
	$(".BrowsedItem a").fadeOutLink();
	$(".BrowsedItem a img").hover(function(){
		$(this).css("opacity","0.8");
	},function(){
		$(this).css("opacity","1");
	});
	$("a").not(".faded").click(function(){
		$("#cartContent").fadeTo(500,0.001);
	});
	$(window).load(function(){
                $("#cartContent").fadeIn(2000);
        });
}
function shopitem_functions(){
	$("#pGallery").hide();//.fadeIn(1000);
	$("#pDetails").hide();//.fadeIn(2000);
	$("a").not(".faded").click(function(){
		$("#pGallery").fadeTo(500,0.001);
		$("#pDetails").fadeTo(1000,0.001);
	});
	$(window).load(function(){
                $("#pGallery").fadeIn(1000);
		$("#pDetails").fadeIn(2000);
        });

}
function blog_functions(){
	$(".post").hide();//.fadeIn(2000);
	$(".blognavigation").hide();//.fadeIn(4000);
	$("#respond").hide();//.fadeIn(4000);
	$("#commentform").hide();//.fadeIn(4000);
	$(window).load(function(){
                $(".post").fadeIn(1500);
		$(".blognavigation").fadeIn(2000);
	        $("#respond").fadeIn(2000);
	        $("#commentform").fadeIn(2000);
        });

	$("a").not(".faded").click(function(){
		$("#content").fadeTo(500,0.001);
	});
	$("#commentsBox").hide();
	$(".CommentExpand").click(function(){
		state = document.getElementById("commentsBox").style.display;
		if(state != 'block'){
			$("#commentsBox").slideDown(1000);
		}else{
			$("#commentsBox").slideUp(1000);
		}
	});
}
function checkout_functions(){
	$("#checkout_login_box").hide();
	$("#content").hide();
	$("a").not(".faded").click(function(){
		$("#content").fadeTo(500,0.001);
	});
	$(window).load(function(){
		$("#content").fadeIn(500);
	});
}
function profile_functions(){
	$("#profile").hide();//.fadeIn(500);
	$("a").click(function(){      
                $("#profile").fadeTo(500,0.001);
        });
	$(window).load(function(){
                $("#profile").fadeIn(500);
        });
}
function contact_functions(){
	$("#contact").hide();//.fadeIn(500);
	$("a").click(function(){      
                $("#contact").fadeTo(500,0.001);    
        });
	$(window).load(function(){
                $("#contact").fadeIn(500);
        });
}
function home_functions(){
	$("#homeContent").hide();//.fadeIn(500);
	$("a").click(function(){      
                $("#homeContent").fadeTo(500,0.001);
        });
	$(window).load(function(){
                $("#homeContent").fadeIn(500);
        });
}
