
$(function(){

	//画像上の右クリック禁止
	$('img, map').bind('contextmenu',function() {
		return false
	})
	
	//グローバルナビゲーション
	$('#header > ul a').css({opacity:0, background:'#000'}).hover(function(){
		$(this).css('opacity',0.4)
	},function(){
		$(this).css('opacity',0)
	})
	
	//ローカルナビゲーション
	$('#subnav a').css({opacity:0, background:'#659600'}).hover(function(){
		$(this).css('opacity',0.4)
	},function(){
		$(this).css('opacity',0)
	})

	//ページTOPにスクロールして戻るリンク
	$('p.pagetop a').click(function(){
		if ($('html').scrollTop() != 0 || $('body').scrollTop() != 0)
			$('html,body').animate({scrollTop:0}, 1000, 'easeOutQuart')
		return false
	})
	
	//スクロールバーのデザイン
	$('#hotnews p').jScrollPane()

	//条件にマッチするリンクは、別ウインドウで開くように
	$('#post a').each(function(){
		if (this.href.indexOf('flumpool.jp/news') == -1 && this.href.indexOf('flumpool.jp/media') == -1 && this.href.indexOf('flumpool.jp/live') == -1 && this.href.indexOf('flumpool.jp/discography') == -1 && this.href.indexOf('flumpool.jp/biography') == -1)
			$(this).attr('target','_blank')
	})
	
	//以下、ページ毎の処理
	if ($('body').is('#home')) {
		
		var flashplayer_ver = 0;
		if(navigator.plugins && navigator.mimeTypes['application/x-shockwave-flash']){
			var plugin = navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin;
			if (plugin)
				flashplayer_ver = parseInt(plugin.description.match(/\d+\.\d+/))
		} else {
			try{
				var flashOCX = new ActiveXObject("ShockwaveFlash.ShockwaveFlash").GetVariable("$version").match(/([0-9]+)/)
				if (flashOCX)
					flashplayer_ver = parseInt(flashOCX[0])
			} catch(e) {}
		}
		
		if (flashplayer_ver)
			$('#logo').html('<object width="260" height="86" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://fpdownload.adobe.com/pub/shockwave/cabs/flash/"><param name="movie" value="img/logo.swf" /><param name="wmode" value="transparent" /><embed src="img/logo.swf" wmode="transparent" width="260" height="86" pluginspage="http://www.adobe.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" /></object>')

		$('a > img','#contents').hover(function(){
			$(this).css('opacity',0.8)
		},function(){
			$(this).css('opacity',1)
		})
		$('#contents,address').fadeIn(1500)
	
	} else if ($('body').attr('id') == 'discography') {
		
		$('div.jk').each(function(){
			var $img = $(':first img',this)
			var $caption = $img.next().next()
			$img.data('src', $img.attr('src'))
			$caption.data('text', $caption.text())
			$('a',this).hover(function(){
				$img.attr('src', this.href)
				$caption.text($('img',this).attr('alt'))
			},function(){
				$img.attr('src', $img.data('src'))
				$caption.text($caption.data('text'))
			}).click(function(){
				return false
			})
		})
		$('td.youtube a').click(function(){
			youtube_open($(this).attr('href'))
			$('img',this).attr('src','img/movie.png')
			return false
		}).hover(function(){
			$('img',this).attr('src','img/movie_o.png')
		},function(){
			$('img',this).attr('src','img/movie.png')
		})
		$('#youtube_close').css('opacity',0.5).hover(function(){
			$(this).css('opacity',0.7)
		},function(){
			$(this).css('opacity',0.5)
		}).click(function(){
			youtube_close()
		})
	}
	
})


//YouTubeを開く関数
function youtube_open(id) {
	$('#youtube_me').html('<p><object width="640" height="385"><param name="movie" value="http://www.youtube.com/v/' + id + '&hl=ja_JP&fs=0&autoplay=1&egm=1&border=0&rel=0&showinfo=0&showsearch=0"></param><param name="wmode" value="transparent" /><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/' + id + '&hl=ja_JP&fs=0&autoplay=1&egm=1&border=0&rel=0&showinfo=0&showsearch=0" type="application/x-shockwave-flash" allowscriptaccess="always" wmode="transparent allowfullscreen="true" width="640" height="385"></embed></object></p>')
	$('#youtube').show().css('top',$(document).scrollTop()).height($(window).height())
	var i = Math.ceil($(document).height() / 2000)
	while (i--) {
		$('<div class="overlay"></div>').insertBefore('#youtube').css({ opacity : 0.7, top : i * 2000 })
	}
	$('#youtube_me p').fadeIn(1000)
}

//YouTubeを閉じる関数
function youtube_close() {
	$('#youtube_me').html('')
	$('#youtube').hide()
	$('div.overlay').remove()
}

