/* ================================================================================
* Title: Jquery Function
*
* Copyright (c) 2010 Astra The Studio Inc.
* http://www.studio.co.jp/
* Date: Feb.15, 2011
* @author: Chihiro Mori
* @version: 1.0.5
*
* jQuery 1.5
*
* 確認済ブラウザ: [Mac] FireFox3.0, Safari3.1.2 [Win] IE6.0, 7.0, 8.0
* Macで作業するときの注意：バックスラッシュ\を入力するときはoptionを押しながらエンマーク
================================================================================ */

(function($)
{
//---------------------------------------------------------------------
	$(function()
	{
		$.ASconf.selfLink();
		$.ASconf.btnRollover();
		$.ASconf.homeScript();
		$.ASconf.belatedPNG();
	});
//---------------------------------------------------------------------
	$.ASconf =
	{
	//---------------------------------------------------------------------
		selfLink: function ()
		{
			var selfLinkClass = 'current';
			var pdfLinkClass = 'pdf';
			var blankLinkClass = 'blank';

			$.ASconf.theUrl = location.href.replace(location.hash, '').replace(/(\/|\#)$/, '/index.html');
			$.ASconf.shrUrl = document.getElementById('baseCSS').href.replace('css/base.css', '');
			$('a').each(function()
			{
				var i = document.createElement('span');
				var path = $(this).attr('href');
				i.innerHTML = '<a href="' + path + '" />';
				var absolutePath = i.firstChild.href;
				var host = i.firstChild.hostname;
				if(absolutePath == $.ASconf.theUrl)
				{
					$(this).addClass(selfLinkClass).removeAttr('href');
				}
				else if(path.match(/pdf$/))
				{
					$(this).append(' <img alt="pdf" src="' + $.ASconf.shrUrl + 'img/icon_pdf.gif' + '" />').addClass(pdfLinkClass);
				}
				else if(path.match(/^http/))
				{
					$(this).filter(function (i)
					{
						return !($(this).find('img')[0]);
					})
					.attr('target', '_blank').append(' <img alt="blank" src="' + $.ASconf.shrUrl + 'img/icon_blank.gif' + '" />').addClass(blankLinkClass);
				}
			});
		}
		,
		//-----------------------------------------------------------------
		btnRollover: function()
		{
			var parentClass = 'current';
			
			$('a img').each(function()
			{
				if($(this).parent().attr('class') == parentClass)
				{
					if(!$('body').hasClass('home'))
					{
						$(this).fadeTo(0, 0.6);
					}
				}
				else
				{
					$(this).hover(function()
					{
						$(this).not(':animated').fadeTo('fast', 0.6);
					}
					,function()
					{
						$(this).fadeTo('fast', 1);
					});
				};
			});
		}
		,
		//-----------------------------------------------------------------
		homeScript: function()
		{
			$('body.home').each(function()
			{
//				$('#videoPlayer').flash(
//				{
//					swf: 'shr/video/video_player.swf',
//					width: 200,
//					height: 147,
//					wmode: 'transparent',
//					hasVersion: 8, // requires Flash 9,
//					flashvars: {
//						flv: 'video_demo.flv',
//						showvolume: 1,
//						showopen: 0,
//						playercolor: '7A5F51',
//						playeralpha: '75',
//						margin: 2,
//						bgcolor1 :'A3958E',
//						bgcolor2 :'A3958E',
//						buffermessage: 'ロード中…',
//						startimage: 'shr/video/video_demo.jpg'
//					},
//					hasVersionFail: function (options) { return false; }
//				});
				
				
				$('#main div.scroll').jScrollPane({showArrows:true});
			});
		}
		,
		//-----------------------------------------------------------------
		belatedPNG: function()
		{
			if (typeof document.documentElement.style.maxHeight == "undefined") 
			{//for IE6 PNG
				$('#contents, #mainWrap, #main').fixPng();
			}
		}
	//-----------------------------------------------------------------
	};
//---------------------------------------------------------------------
})(jQuery);
