/* ◆スムーズスクロール */
function util_scroll(){
	$('a[href*=#]').click(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
			
			var $target = $(this.hash);
			$target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
			
		   if ($target.length) {
		   		var targetOffset = $target.offset().top;
		   		
		   		$('html,body').animate({scrollTop: targetOffset},1000);
				return false;
			}
		}
	});
}


/* ◆ロールオーバー */
function util_rollover(){
	// gif
	$('img.rollover[src$=".gif"]').hover(
		function() {
			this.src = this.src.replace(".gif","_o.gif");
		},
		function() {
			this.src = this.src.replace("_o.gif",".gif");
		}
	);
	
}

/* IEのcssセレクタ補助 */
function custom_programList(){
	$.browser.version < 7 ? $(".aboutEvent .program ul").css("height","1em") : $(".aboutEvent .program ul").css("min-height","1em")
	$(".aboutEvent .program ul li:nth-child(odd)").css("float", "left");
	$(".aboutEvent .program ul li:nth-child(even)").css("float", "right");
	$(".date ul li:first-child").css("margin-left","0px");
}

/* 日程カレンダー */
function custom_schedule(){
	if(!($.browser.msie && ($.browser.version < 7))){
		$("#schedule li").wrapInner('<div></div>');
		$("#schedule li[id!=jul_2]>div").prepend('<span class="up"></span>');
		$("#jul_2>div").prepend('<span id="jul_2_18" class="down"></span><span id="jul_2_19" class="down"></span>');
	}else{
		$("#schedule li").wrapInner('<span></span>');
		$("#schedule li[id!=jul_2][class!=right]").prepend('↑');
		$("#schedule li[id!=jul_2][class=right] span").after('↑');
		$("#schedule #jul_2").prepend('↓').css('padding-right','0px');
		$("#schedule #jul_2note").css('left','90px');
		$("#schedule #jul_2 span").after('↓');
	}
}

/* 追従ナビ */
function custom_footer(){
	
	$("#topOfPage").hide();	// 先頭にいるときは、ページの先頭へを非表示
		
	var obj = $("#utilNavigation");		// 追従するナビ
	var detail = $("#footer");			// 最初のナビ
	
	if($(window).height() < detail.offset().top) obj.addClass("move");
	
	if ($.browser.msie && ($.browser.version < 7)){	// IE6用
		
		// position:fixのかわり
		obj.css("position","absolute");
		var base = obj.offset().top;
		
		$(window).scroll(function () {
			$(document,'html,body').scrollTop() < 1 ? $("#topOfPage").hide() : $("#topOfPage").show();
			
			var tPosition = base + $(this).scrollTop();
			obj.css("top" , tPosition).addClass("move");
		});
		// リサイズ
		$(window).bind("resize", function (){
			var tPosition = $(window).height() - obj.height();
			obj.css("top" , tPosition);
		});
	}
	else {	// IE6以外
		$(window).scroll(function () {
			$(document,'html,body').scrollTop() < 1 ? $("#topOfPage").hide() : $("#topOfPage").show();
			
			var h = $(window).height();
			h += $(document,'html,body').scrollTop();
			h > detail.offset().top ? obj.removeClass("move").css("position","relative") : obj.addClass("move").css("position","fixed");
		});
	}
}

/* モーダルウィンドウ */
function custom_modal(){
	
	var body = $("body");
	var screen = $("#screen");
	var detail = $("#mobile_detail");
	
	// 開く（#detail_kobegakuin で神戸学院大学のみに絞ってある）
	$("#detail_kobegakuin dl.mobile a , #detail_kobegakuin dl.mobile img").click(function() {
		var h = $(window).height();
		var t = h / 2 - detail.height();
		var l = ($(window).width() - detail.width()) / 2;
		
		if ($.browser.msie && ($.browser.version < 7)) screen.css("height",$(document,'html,body').height()).show();
		else screen.css("height",h).show();
		detail.css({"top":t,"left":l}).show();
	});
		
	// 閉じる
	$("#screen , #close")
	.click(function() {
		var h = $(document,'html,body').height();
		//body.css({"height":h,"overflow":"scroll"})
		screen.hide();
		detail.hide();
	});
	
	// リサイズ
	$(window).bind("resize", function(){
		var h = $(window).height();
		var t = h / 2 - detail.height();
		var l = ($(window).width() - detail.width()) / 2;
		
		screen.css("height",h);
		detail.css({"top":t,"left":l});
	});
}


/* ◆読み込み完了後に実行 */
$(document).ready(function(){
	util_scroll();
	util_rollover();
	if($.browser.msie) custom_programList();
	custom_schedule();
	custom_footer();
	custom_modal();
});
$(window).resize(function(){
});

/* 
 * 【メモ】「IE6以外」の条件
 * 
 * if(!($.browser.msie && ($.browser.version < 7)))
 */
