/* *********************************************************
common.js
Last Modified: 2011-03-08
********************************************************* */
$(function(){

	/* ==================================================
	 * Lightbox風効果「colorbox」
	 * http://colorpowered.com/colorbox/
	 * Copyright (c) 2010 Jack Moore - jack@colorpowered.com
	 * Licensed under the MIT license:
	 * http://www.opensource.org/licenses/mit-license.php
	 ================================================== */
	$('a[rel="gallery"]').colorbox();

	/* ==================================================
	 * 外部リンクを別ウィンドウで開く
	 * Copyright (c) 2009 Kyosuke Nakamura (kyosuke.jp)
	 * Licensed under the MIT License:
	 * http://www.opensource.org/licenses/mit-license.php
	 ================================================== */
	var siteUri = 'http://steinsgate.jp/';
	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: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');

});

