/**
 * @author ichi
 */


$(function(){
	// Tabs
	//console.log($('#tabs').tabs('option', 'fx'));

	$('#tabs').tabs({
		selected: 0,
		//fx: { height: 'toggle', duration:400 },
		//fx: { height: 'show', duration:400},

		show: function(event,ui){
			$(ui.tab).parent().parent().children().each(function(i){
				$(this).find('a').bind('mouseenter', function(){
					$(this).find("img").eq(0).css({display:'none'});
					$(this).find("img").eq(1).css({display:'block'});
				});
				$(this).find('a').bind('mouseleave', function(){
					if($($(this).attr('href')).css('display') == 'none'){
						$(this).find("img").eq(1).css({display:'none'});
						$(this).find("img").eq(0).css({display:'block'});
					}
				});
			});
		},

		select: function(event, ui) {
			// Objects available in the function context:
			$(ui.tab).children().eq(0).css({display:'none'});
			$(ui.tab).children().eq(1).css({display:'block'});
			$(ui.tab).parent().parent().children().each(function(i){
				if(i != ui.index){
					$(this).children().find("img").eq(0).css({display:'block'});
					$(this).children().find("img").eq(1).css({display:'none'});
				}
			});
		}
	});
});


function InitDisplay(){
	//NEWS読み込み
	$(function(){
		$('#tabs-1').load('news.html');
	});
}


function ShowDivBlocks(divId){
	switch (divId){
		case "tabs-1":
			$(function(){
				$('#tabs-1').load('news.html');
			});
			document.getElementById("tabs-2").style.display = "none";
			document.getElementById("tabs-3").style.display = "none";
			document.getElementById("tabs-4").style.display = "none";
			document.getElementById("tabs-1").style.display = "block";
			break;

		case "tabs-2":
//			$(function(){
//				$('#tabs-2').load('disco.html');
//			});
			document.getElementById("tabs-1").style.display = "none";
			document.getElementById("tabs-3").style.display = "none";
			document.getElementById("tabs-4").style.display = "none";

			$('#tabs-2').load('disco.html','',function(){
				$(this).children('#content').children('#tabs_s').tabs({
					selected: 0,
					//fxShow: { height: 'show', opacity: 'show' },
//					fx: { duration:2000, opacity: 'show' },
					show: function(event,ui){
						//console.log("show");
						// console.log($(ui.tab).parent());
						
					$(ui.tab).parent().parent().children().each(function(i){
						$(this).find('a').bind('mouseenter', function(){
						$(this).find("img").eq(0).css({display:'none'});
						$(this).find("img").eq(1).css({display:'block'});
					});
					
					$(this).find('a').bind('mouseleave', function(){
					if($($(this).attr('href')).css('display') == 'none'){
						$(this).find("img").eq(1).css({display:'none'});
						$(this).find("img").eq(0).css({display:'block'});
					}
					});
						});
					},

					select: function(event, ui) {
						//console.log("select");
						// Objects available in the function context:
						$(ui.tab).children().eq(0).css({display:'none'});
						$(ui.tab).children().eq(1).css({display:'block'});
						$(ui.tab).parent().parent().children().each(function(i){
							if(i != ui.index){
								$(this).children().find("img").eq(0).css({display:'block'});
								$(this).children().find("img").eq(1).css({display:'none'});
							}
						});
					}
				});
			});
			document.getElementById("tabs-2").style.display = "block";
			break;

		case "tabs-3":
			//MEDIA読み込み
			$(function(){
				$('#tabs-3').load('media.html');
			});
			document.getElementById("tabs-1").style.display = "none";
			document.getElementById("tabs-2").style.display = "none";
			document.getElementById("tabs-4").style.display = "none";
			document.getElementById("tabs-3").style.display = "block";
			break;

		case "tabs-4":
			//LIVE読み込み
			$(function(){
				$('#tabs-4').load('live.html');
			});
			document.getElementById("tabs-1").style.display = "none";
			document.getElementById("tabs-2").style.display = "none";
			document.getElementById("tabs-3").style.display = "none";
			document.getElementById("tabs-4").style.display = "block";
			break;
	}
}
