$(document).ready(function() {

/*
	$(".block").wrapInner('<div class="block_tl"><div class="block_tr"><div class="block_bl"><div class="block_br"><div class="block_pad"></div></div></div></div></div>');
*/
	var sameHeightMax = 0;

	$(".same_height").each(function(){
		var h = $(this).height();
	
		if(h > sameHeightMax){
			sameHeightMax = h;
		}
	});

	$(".same_height").css("height", sameHeightMax + "px");
	
	$(".controller").click(function(){
		var slave = $("#" + $(this).attr("slave"));
		slave.toggle();
	});

	$(".controller_slow").click(function(){
		var slave = $("#" + $(this).attr("slave"));
		slave.toggle("slow");
		$(this).css("display", "none");
	});

	$(".tab_controller").click(function(){
		var tab_slave = $("#" + $(this).attr("slave"));

		$(".tab_controller").each(function(){
			var slave = $("#" + $(this).attr("slave"));
			
			if(slave != tab_slave && slave.css("display") == "block"){
				slave.hide("slow");
			}

			$(this).removeClass("sel");
		});
		
		$(this).addClass("sel");
		tab_slave.show("slow");
	});

	$(".dd_master").hover(function(){
		var master = $(this);
		if(master.attr("slave") in hoverTimer){
			clearTimeout(hoverTimer[master.attr("slave")]);
		}

		var slave = $("#" + master.attr("slave"));
		slave.slideDown("fast");
	}, function(){
		var master = $(this);
		hoverTimer[master.attr("slave")] = setTimeout(function(){
			var slave = $("#" + master.attr("slave"));
			slave.slideUp("fast");
		}, 200);
	});


	$(".dd_master").click(function(){
		var tab_slave = $("#" + $(this).attr("slave"));
		tab_slave.slideToggle("fast");
	});


});

var hoverTimer = new Array();

