
// コンフリクトを回避
jQuery.noConflict();

(function($) {

	$.fn.alignheight = function(options){
		var settings = {
			target:">div",
			alignheightClass:"alignHeight"
		}
		if(options){
			$.extend(settings, options);
		}
		var height_array = new Array();
		this.each(function(){
			target = $(settings.target,this);
			target.each(function(i){
				$(this).addClass(settings.alignheightClass);
				height_array.push(Number($(this).height()));
			});
		});
		var Height = height_array.sort(function(a,b){return (a-b);}).pop();
		this.each(function(i){
			target = $(settings.target,this);
			target.height(Height);
		});
		return this;
	}

	$.fn.blocklink = function(options){
		var settings = {
			hoverClass:"bl-hover",
			nth:1,
			wraplinks:1	//内包するa要素個別のリンクを有効にするか（0で無効）
		}
		if(options){
			$.extend(settings, options);
		}
		$(this).each(function(){
			var Link = $("a:eq("+(settings.nth-1)+")",this);
			var Href = Link.attr("href");
			if(Href!=undefined){
				var Target = Link.attr("target");
				$(this).mouseover(function(){
					$(this).addClass(settings.hoverClass);
				}).mouseout(function(){
					$(this).removeClass(settings.hoverClass);
				}).click(function(){
						if(Target==""){
							Target="_self";
						}
						if(!bAnchorHover){
						window.open(Href,Target);
						}
				}).css("cursor","pointer");
				var bAnchorHover=false;
				$("a",this).hover(
					function(){bAnchorHover=true},
					function(){bAnchorHover=false}
				);
				if(!settings.wraplinks){
					$("a",this).click(function(){
						window.open(Href,Target);
						return false;
					});
				}
			}
		});
		return this;
	}

	$(function(){

		//アクティブハイライト処理
		switch($("body").attr("class")){
			case "home" :
				var menu = $("#menu0 a");
				break;
			case "about" :
				var menu = $("#menu1 a");
				break;
			case "event" :
				var menu = $("#menu2 a");
				break;
			case "guide" :
				var menu = $("#menu3 a");
				break;
			case "ikiiki" :
				var menu = $("#menu4 a");
				break;
			case "group" :
				var menu = $("#menu5 a");
				break;
		}
		if(menu!=undefined){
			menu.addClass("over");
		}

		//ロールオーバー
		$("img.over").mouseover(function(){
			$(this).attr("src",$(this).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_o$2").replace("_o_o","_o"));
		}).mouseout(function(){
			$(this).attr("src",$(this).attr("src").replace(/^(.+)_o(\.[a-z]+)$/, "$1$2"));
		}).each(function(){
			$("<img>").attr("src",$(this).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_o$2"));
		}).click(function(){
			$(this).attr("src",$(this).attr("src").replace(/^(.+)_o(\.[a-z]+)$/, "$1$2"));
		});

		//アンカーリンク
		if(location.href.indexOf("file")==0){
			var url = "file://" + location.hostname + location.pathname + location.search;
		}else if(location.href.indexOf("https")==0){
			var url = "https://" + location.hostname + location.pathname + location.search;
		}else{
			var url = "http://" + location.hostname + location.pathname + location.search;
		}
		$("a[href*=#],area[href*=#]").click(function() {
			var id = this.href.substring(this.href.indexOf('#'),this.href.length);
			var hrefUrl = this.href.split(id);
			if(String(hrefUrl[0]) == String(url)) {
				var hash = this.hash;
				if(!hash || hash == "#")
					return false;
				if(id == '#inbox') { 
					$($.browser.safari ? 'body' : 'html')  
						.animate({scrollTop: 0}, 500, "easeInOutCubic");
					return false;
				}else if(id != "#"){
					$($.browser.safari ? 'body' : 'html')  
						.animate({scrollTop: $(hash).offset().top}, 500, "easeInOutCubic");
					return false;
				}
			}
		});

		$(".side-bnrs a img, .lucent a img, img.highlight, ul.bnrs li a img, ul.programlist img, #program-list a, img.links").hover(function(){
			$(this).animate({
				opacity: .8
			},{
				duration: 200,
				queue: false
			})
		}, function(){
			$(this).animate({
				opacity: 1
			}, {
				duration: 200,
				queue: false
			})
		});

		// boxの高さを揃える
		$("#event-craft .craft-inner").alignheight({
			target:">div",
			alignheightClass:"alignHeight"
		})
		

		// blocklink
		/*$(".wrap div").blocklink({
			hoverClass:"bl-hover",
			nth:1,	//何番目のリンクを有効にするか
			wraplinks:1	//内包するa要素個別のリンクを有効にするか（0で無効）
		})*/

		$("a.external").append('<span class="icon-nw"><img src="/images/icon/icon_nw.gif" alt="" width="10" height="9" /></span>');
		$("#home .space-theater th:even, #home .space-theater td:even").css("background-color","#eeeeee");

        //テーブルの背景色を1行置きに変更する
        $(function() {
           $(".stripe tr:even").addClass("even");
		});
		
		//jQuery.corner
		$('.roundtop').corner("top");
		
	});

})(jQuery);







