$(function(){
	
	//$(".rolllist").roll({
	//	auto: true
	//});

	function maxHeight(h1,h2,h3) {
		if(h1>h2 && h1>h3) { return h1; }
		if(h2>h1 && h2>h3) { return h2; }
		if(h3>h1 && h3>h2) { return h3; }
	}
	var $menu_height = $("#menuBar").height();
	var $list_height = $("#listBox").height();
	var $comm_height = $("#commBar").height();
	var $main_height = $("#main").height();
	var $main2_height = $("#main2").height();
	var $tsly_height = $("#main_tsly").height();
	var $tslybox_height = $("#tslyBox").height();
	
	if($("#menuBar").length>0 && $("#listBox").length>0 && $("#commBar").length>0) {
		mh = maxHeight($menu_height,$list_height,$comm_height);
		$("#menuBar").height(mh);
		$("#listBox").height(mh);
		$("#commBar").height(mh);	
	}
	
	if($("#menuBar").length>0 && $("#tslyBox").length>0 && $("#commBar").length>0) {
		mh = maxHeight($menu_height,$tslybox_height,$comm_height);
		$("#menuBar").height(mh);
		$("#tslyBox").height(mh);
		$("#commBar").height(mh);	
	}
	
	if($("#main").length>0 && $("#commBar").length>0) {
		mh = maxHeight($main_height,$comm_height,0);
		$("#main").height(mh);
		$("#commBar").height(mh);	
	}
	
	if($("#main2").length>0 && $("#menuBar").length>0) {
		mh = maxHeight($main2_height,$menu_height,0);
		$("#main2").height(mh);
		$("#menuBar").height(mh);	
	}
	
	if($("#main_tsly").length>0 && $("#commBar").length>0) {
		mh = maxHeight($tsly_height,$comm_height,0);
		$("#main_tsly").height(mh);
		$("#commBar").height(mh-15);	
	}
	
	
	var $div_li =$(".tab li");
	$div_li.hover(function(){
		$(this).addClass("current") 
			   .siblings().removeClass("current");
		var index =  $div_li.index(this);
		$(".tabContent > div") 
				.eq(index).fadeIn() 
				.siblings().hide();
	}).hover(function(){
		$(this).addClass("hover");
	},function(){
		$(this).removeClass("hover");
	});
	
	var $news =$(".newsTab li");
	$news.click(function(){
		$(this).addClass("current") 
			   .siblings().removeClass("current");
		var index =  $news.index(this);
		$(".newsContent > div") 
				.eq(index).fadeIn() 
				.siblings().hide();
	}).hover(function(){
		$(this).addClass("hover");
	},function(){
		$(this).removeClass("hover");
	});
	
	var $mail =$(".mailTab li");
	$mail.click(function(){
		$(this).addClass("current") 
			   .siblings().removeClass("current");
		var index =  $mail.index(this);
		if(index > 0) { $(this).css("border-left-width","0") }
		$(".mailContent > div") 
				.eq(index).fadeIn() 
				.siblings().hide();
	}).hover(function(){
		$(this).addClass("hover");
	},function(){
		$(this).removeClass("hover");
	});
	
	var $bs =$(".t li");
	$bs.hover(function(){
		$(this).addClass("current") 
			   .siblings().removeClass("current");
		var index =  $bs.index(this);
		if(index > 0) { $(this).css("border-left-width","0") }
		$(".bsContent > div") 
				.eq(index).fadeIn() 
				.siblings().hide();
	}).hover(function(){
		$(this).addClass("hover");
	},function(){
		$(this).removeClass("hover");
	});
	
})

