$(document).ready(function() {
	$(".mcBtnClose").hide();
	$(".mcTypeC").hide();
	var allTargets = $(".mcTypeA,.mcTypeB");
    $(".mcTypeA,.mcTypeB").each(function(){
		var target = this;
		var idname = $(this).attr("id");
        var pane = $("#"+idname+"List");
		$(this).find(".mcBtn.mcBtnOpen").click(function(){
			$(".mcBtnClose",allTargets).hide();
			$(".mcBtnOpen",allTargets).show();
			if($(".mcTypeC.opened").length > 0){
                $(".mcTypeC.opened").removeClass("opened").slideUp("normal", openPane);
            }else{
                openPane();
            }
            function openPane(){
                if(!pane.hasClass("opened")) {
					$(target).find(".mcBtnOpen").hide();
					$(target).find(".mcBtnClose").show();
                    pane.addClass("opened");
					pane.slideDown("normal");
				}
            }
			return false;
		});
        $(this).find(".mcBtn.mcBtnClose").click(function(){
            $(".mcBtnClose",allTargets).hide();
			$(".mcBtnOpen",allTargets).show();
            $(".mcTypeC.opened").removeClass("opened").slideUp("normal");
            return false;
        });
	});
	
	$(".mcTypeC").each(function(){
		var target = this;
		$(this).find(".mcClose").click(function(){
			if($(target).css("display") != "none") {
				$(target).slideUp();
			}
			$(target).parent().find(".mcBtnClose").hide();
			$(target).parent().find(".mcBtnOpen").show();
			return false;
		});
	});
	
	
});
