$(function(){
	$('.roll').each(function(){
		this.originalSrc = $(this).attr('src');
		this.rolloverSrc = this.originalSrc.replace(/(\.gif|\.jpg|\.png)$/, '_on'+"$1");
		this.rolloverImg = new Image();
		this.rolloverImg.src = this.rolloverSrc;
		}).hover(function(){
		$(this).attr('src',this.rolloverSrc);
	},function(){
		$(this).attr('src',this.originalSrc);
	});

	var num = 1;
	var mact;
	var tabno;

	$("#tab li").click(function() {
		num = $("#tab li").index(this);
		if(num == 2){
			$(document).ready(function(){
				$(".pmessage").colorbox({width:"840px", height:"560px", iframe:true,scrolling:true});
				//Example of preserving a JavaScript event for inline calls.
				$("#click").click(function(){
					$('#click').css({"background-color":"#f00", "color":"#fff", "cursor":"inherit"}).text("Open this window again and this message will still be here.");
					return false;
				});
			});
		}else{
//			$(".content_wrap").addClass('disnon');
//			$(".content_wrap").removeClass('mod');
//			$(".content_wrap").eq(num).removeClass('disnon');
//			$(".content_wrap").eq(num).addClass('mod');
			$("#tab li").removeClass('nselect1');
			$("#tab li").removeClass('nselect2');
			$("#tab li").removeClass('nselect3');
			tabno = "nselect" + ++num;
			$(this).addClass(tabno)
		}
	});
	$("#tab li").mouseover(function() {
		mact = $("#tab li").index(this);
		tabno = "nselect" + ++mact;
		$(this).addClass(tabno)
	});
	$("#tab li").mouseout(function() {
		mact = $("#tab li").index(this);
		tabno = "nselect" + ++mact;
		if(num != mact){
			$(this).removeClass(tabno)
		}
	});

	var newsnum = 1;
	var newsmact;
	var newstabno;

	$("#newstab li").click(function() {
		newsnum = $("#newstab li").index(this);
//		$(".news_wrap").addClass('disnon');
//		$(".news_wrap").eq(newsnum).removeClass('disnon');
		$("#newstab li").removeClass('newsselect1');
		$("#newstab li").removeClass('newsselect2');
		$("#newstab li").removeClass('newsselect3');
		newstabno = "newsselect" + ++newsnum;
		$(this).addClass(newstabno)
	});
	$("#newstab li").mouseover(function() {
		newsmact = $("#newstab li").index(this);
		newstabno = "newsselect" + ++newsmact;
		$(this).addClass(newstabno)
	});
	$("#newstab li").mouseout(function() {
		newsmact = $("#newstab li").index(this);
		newstabno = "newsselect" + ++newsmact;
		if(newsnum != newsmact){
			$(this).removeClass(newstabno)
		}
	});

	$(document).ready(function(){
		// ポップアップ動作セット
		$(".searchmenu").colorbox({width:"600px", height:"498px", iframe:true,scrolling:true});
		$(".requestmenu").colorbox({width:"840px", height:"560px", iframe:true,scrolling:true});
		$(".smessage").colorbox({width:"840px", height:"560px", iframe:true,scrolling:true});
		
		// timetable曜日タブセット
		dayweek = new Array('Mon','Tue','Wed','Thu','Fri','Sat','Sun');
		gToday = new Date();

		// 現在時刻がAM0時-5時台なら前日とする
		nowhour = gToday.getHours();
		if(nowhour>=0&&nowhour<6) {
			gToday.setDate(gToday.getDate()-1);
		}
		
		gYoubi = gToday.getDay();
		
		if(gYoubi == 0){
			daynum = 6;
		}else{
			daynum = gYoubi - 1;
		}
		
		$("#daytab li:eq("+daynum+")").addClass('Today'+dayweek[daynum]);
		
		var daymact;
		var daytabno;
		
		$("#daytab li").click(function() {
			daynum = $("#daytab li").index(this);
			ycnt = 0;
			while(ycnt <= 6 ) {
			    rmclass= 'Today'+dayweek[ycnt];
			    $("#daytab li").removeClass(rmclass);
			    ycnt = ycnt + 1;
			}
			addclass = 'Today'+dayweek[daynum];
			$(this).addClass(addclass)
		});
		$("#daytab li").mouseover(function() {
			daymact = $("#daytab li").index(this);
			addclass = 'Today'+dayweek[daymact];
			$(this).addClass(addclass)
		});
		$("#daytab li").mouseout(function() {
			daymact = $("#daytab li").index(this);
			addclass = 'Today'+dayweek[daymact];
			if(daynum != daymact){
				$(this).removeClass(addclass)
			}
		});

		// 2011.05.16 ADD
		$('#ecnext').hide(); //Hide/close all containers

		$('#ec_more').click(function(){
			$('#ecnext').slideDown();
			$('#ec_more').hide();
			$('#ec_close').show();
		});

		$('#ec_close').click(function(){
			$('#ecnext').slideUp();
			$('#ec_more').show();
			$('#ec_close').hide();
		});
		
	});
	
});



