/* *********************************************************
script.js
サイト全体で共有するJS
Last Modified: 2011-03-22
********************************************************* */
jQuery(function($){

	/* ==================================================
	 * 外部リンクを別ウィンドウで開く
	 * Copyright (c) 2009 Kyosuke Nakamura (kyosuke.jp)
	 * Licensed under the MIT License:
	 * http://www.opensource.org/licenses/mit-license.php
	 ================================================== */
	var siteUri = 'http://www.nitrochiral.com';
	var windowOpen = true;
	var externalClass = 'externalLink';
	
	var externalLinks = $('a[href^="http"]').not('a[href^="' + siteUri + '"]');
	if (windowOpen) {
		externalLinks.click(function(){
			window.open($(this).attr('href'), '_blank');
			return false;
		});
	}
	externalLinks.addClass(externalClass);

	/* ==================================================
	 * 画像ロールオーバー
	 * @author AkiraNISHIJIMA(http://nishiaki.probo.jp/)
	 * Licensed under the MIT License:
	 * http://www.opensource.org/licenses/mit-license.php
	 ================================================== */
	var img_cache = new Object();
	$('img.over').not('[src*="_on"]').each(function(){
		var imgsrc = this.src;
		var imgsrc_non_filetype = this.src.lastIndexOf('.');
		var imgsrc_over = this.src.substr(0,imgsrc_non_filetype)+'_on'+this.src.substr(imgsrc_non_filetype,4);
		img_cache[this.src] = new Image();
		img_cache[this.src].src = imgsrc_over;
		$(this).hover(
			function(){ this.src = imgsrc_over; },
			function(){ this.src = imgsrc; }
		);
	});

	/* ==================================================
	/* CSS3を擬似実装
	 * Copyright (c) 2007 Kyosuke Nakamura (kyosuke.jp)
	 * Licensed under the MIT License:
	 * http://www.opensource.org/licenses/mit-license.php
	 ================================================== */
	/* :nth-child, :first-child, :last-child
	--------------------------------------------------- */
	$('li:nth-child(odd)').addClass('odd');
	$('li:nth-child(even)').addClass('even');
	$('li:first-child').addClass('firstChild');
	$('li:last-child').addClass('lastChild');
	$('tr:nth-child(odd)').addClass('odd');
	$('tr:nth-child(even)').addClass('even');
	$('tr:first-child').addClass('firstChild');
	$('tr:last-child').addClass('lastChild');

	/* display:box;
	--------------------------------------------------- */

	/* boxの高さを統一*/
	$('.column2').each(function(){
			$('li',this).each(function(i){
		$(this).addClass('nth'+(i+1));
		});
	});
	var a = [];
	var max = 0;
	var col = 2;//ここまで連番CSS付け
	

	$(window).load(function(){$('#pg-event ul.column2,#pg-game ul.column2').each(function(){		
			var lastIndex = $(this).find("li").length;//要素の中のliの数を把握
			$('li',this).each(function(i){
			var li = $(this);
			var index = i + 1;
			a.push(li);
	
	
			if (li.height() > max){
				max = li.height();	
			}
			if (index % col === 0 || index === lastIndex){
				$.each(a, function(i, li){
					li.height(max);
				});
				a = [];
				max = 0;
			}
			});
		});	
	});

	
		
	/* ==================================================
	/* 追記スクリプト　 @author:4403 scrolltoTop//モダンブラウザのみ対応
	 ================================================== */
	 
	if (!jQuery.support.checkOn || jQuery.browser.webkit || jQuery.browser.mozilla){
		$("p.pageTop").click(function (e){
			$('html,body').animate({//eventDelegate
				scrollTop : $($(e.target).attr("href")).offset().top 
			},
			'slow', 'swing');
			return false;
		});
	}

});




