/* ================================================================================
* Title: Jquery Function
*
* Copyright (c) 2010 Astra The Studio Inc.
* http://www.studio.co.jp/
* Date: Mar.26, 2010
* @author: Chihiro Mori
* @version: 1.0.4
*
* jQuery 1.4.2
*
* 確認済ブラウザ: [Mac] FireFox3.0, Safari3.1.2 [Win] IE6.0, 7.0, 8.0
* Macで作業するときの注意：バックスラッシュ\を入力するときはoptionを押しながらエンマーク
================================================================================ */
/* 目次
selfLink():
自ページリンク（ハッシュは除外）にcurrentクラスを付与し、href属性を削除。
※スラッシュ（/）とファイル名を省略したアクセスの場合は、/index.htmlを補完して評価

selfScroll(): 
ページ内リンクのスムーススクロール。href属性にハッシュ（#）を指定したAタグを評価。
※ファイル名とhashの組み合わせ（hoge.html#hoge）は評価しない。

menuRollover():
透明効果を使った画像のマウスオーバー。IDに#cNavを指定した、DIV等のブロック要素の子タグのみ評価。
※imgの親のAタグがcurrentだったら透明度0になり背景画像が表示される。

btnRollover():
透明効果を使った画像のマウスオーバー。class="btn"を指定したimgタグを評価。
※imgの親のAタグがcurrentだったら透明度0.7になる。

headerScroll():
positionにfixを指定した要素も、横スクロールに対応できるようにする。
IDに#headerWrapを指定した、DIV等のブロック要素のみ評価。

*/
(function($)
{
//---------------------------------------------------------------------
	$(function()
	{
		$.ASconf.selfLink();
		//$.ASconf.selfScroll();
		$.ASconf.menuRollover();
		$.ASconf.btnRollover();
	});
//---------------------------------------------------------------------
	$.ASconf =
	{
	//---------------------------------------------------------------------
		selfLink: function ()
		{
			var selfLinkClass = 'current';
			
			var theUrl = location.href.replace(location.hash, '').replace(/(\/|\#)$/, '/index.html');
			
			$('a[href]').each(function()
			{
				var i = document.createElement('span');
				i.innerHTML = '<a href="' + $(this).attr('href') + '" />';
				var absolutePath = i.firstChild.href;
				if(absolutePath == theUrl)
					$(this).addClass(selfLinkClass).removeAttr('href');
			});
		}
		,
		//-----------------------------------------------------------------
		selfScroll: function()
		{//^は初めの文字が#だった場合。*にするとhoge.html#hogeもマッチ
			$('a[href^=#]').click(function()
			{
				var hash = this.hash;
				if(!hash || hash == "#")
					return false;
				$($.browser.safari ? 'body' : 'html')
				.animate({scrollTop: $(hash).offset().top}, 300, "swing");
				return false;
			});
		}
		,
		//-----------------------------------------------------------------
		menuRollover: function()
		{
			var parentClass = 'current';
			
			$('#cNav img, #sideCont img').each(function()
			{
				if($(this).parent().attr('class') == parentClass)
					$(this).fadeTo(0, 0.7);
				else
				{
					$(this).hover(function(){
						$(this).not(':animated').fadeTo('fast', 0.6);}
					,function(){
						$(this).fadeTo('fast', 1);});
				};
			});
		}
		,
		//-----------------------------------------------------------------
		btnRollover: function()
		{
			var parentClass = 'current';
			
			$('img.btn, #indexTable .photoLink img').each(function()
			{
				$(this).hover(function(){
					$(this).not(':animated').fadeTo('fast', 0.6);}
				,function(){
					$(this).fadeTo('fast', 1);});
			});
		}
	//-----------------------------------------------------------------
	};
//---------------------------------------------------------------------
})(jQuery);
