/* -------------------------------------------



------------------------------------------- */
(function()
{
var scrollBack = {
	init : function()
	{
		var _this = this;
		
		$('#pageTop').children('a').click(function( e )
		{
			_this.back();
			e.preventDefault();
		});
	},
	back : function()
	{
		var _this = this;
		var y,y1,y2,y3;
		var id;
		
		if( document.documentElement ) y1 = document.documentElement.scrollTop || 0;
		if( document.body ) y2 = document.body.scrollTop || 0;
		
		y3 = window.scrollY || 0;
	
		y = Math.max( y1, Math.max( y2, y3 ) );
		// 移動量調整
		window.scrollTo( 0, y / 1.2 );
			
		if( y > 0 )
		{
			id = setTimeout(function()
			{
				_this.back();
			
			}, 10); //リピート速度調整 msc
		}
		else
		{
			location.hash = '#';
			window.scrollTo( 0, 0 );// for ie7
			clearTimeout( id );
		}
	}
};
$(function()
{
	//scrollBack.init();
});
/* -------------------------------------------

	gNavi current

------------------------------------------- */
var gNaviCurrentFunc = {
	getURL : function()
	{
		var url = document.URL,
		link01 = document.getElementById('link01'),
		link02 = document.getElementById('link02'),
		link03 = document.getElementById('link03'),
		link04 = document.getElementById('link04'),
		link05 = document.getElementById('link05'),
		link06 = document.getElementById('link06'),
		link07 = document.getElementById('link07'),
		link08 = document.getElementById('link08');
		
		// url と 適用するCSSの値をセットしている
		if( url.indexOf('about/') > -1 ){ this.changeNavi( link01, '0 100%' ); return false; }
		if( url.indexOf('case/') > -1 ){ this.changeNavi( link02, '-116px 100%' ); return false; }
		if( url.indexOf('photo_collage/') > -1 ){ this.changeNavi( link03, '-281px 100%' ); return false; }
		if( url.indexOf('servise/') > -1 ){ this.changeNavi( link04, '-421px 100%' ); return false; }
		if( url.indexOf('guide/') > -1 ){ this.changeNavi( link05, '-526px 100%' ); return false; }
		if( url.indexOf('contact/') > -1 ){ this.changeNavi( link06, '-651px 100%' ); return false; }
		if( url.indexOf('corprate/') > -1 ){ this.changeNavi( link07, '-746px 100%' ); return false; }
		if( url.indexOf('sitemap.html') > -1 ){ this.changeNavi( link08, '-822px 100%' ); return false; }
	},
	changeNavi : function( val, position )
	{
		val.style.backgroundPosition = position;
	}
};
/* -------------------------------------------

	gNavi for IE
	
	// hideFocus

------------------------------------------- */
var hideForcusForIE = {
	manager : function()
	{
		var UA = navigator.userAgent;
		if( UA.indexOf('MSIE') > -1 ) this.get();
	},
	get : function()
	{
		var target = document.getElementById('gNavi');
		var a = target.getElementsByTagName('a');
		
		for( var i = 0; i < a.length; i++ )
		{
			a[i].setAttribute( 'hideFocus', 'true' );
		}
	}
};
/* -------------------------------------------

	fire!

------------------------------------------- */
window.onload = function()
{
	gNaviCurrentFunc.getURL();
	hideForcusForIE.manager();
};
/* --------------------------------------


	roll over


-------------------------------------- */
$(function()
{
	/* -------------------------------------
	
	imgタグにsrc属性がある場合の処理。
	
	------------------------------------- */
	function autoRollover()
	{
		var imageTags = document.getElementsByTagName("img");
		
		for(var i=0; i < imageTags.length; i++)
		{
			if(imageTags[i].getAttribute("src").match("_off."))
			{
				imageTags[i].onmouseover = function()
				{
					this.setAttribute("src", this.getAttribute("src").replace("_off.", "_on."));
				}
				
				imageTags[i].onmouseout = function()
				{
					this.setAttribute("src", this.getAttribute("src").replace("_on.", "_off."));
				}
			}// end if
		}// end for
	}// func

	if(window.addEventListener)
	{
		window.addEventListener("load", autoRollover, false);
	}
	else if(window.attachEvent)
	{
		window.attachEvent("onload", autoRollover);
	}
});

})();// capsule





