/*
 * contents.js
 * 背景画像の全画面表示、AJAXでのページ繊維など
*/

jQuery(function(){
	/*
	 * 初期設定
	 */
	 
	 
	//背景全画面処理
	_maximage.maxImage({
		isBackground: true,
		overflow: 'auto',
		verticalAlign:'bottom',
		onImageShow: function () {
			_maximage
				.css({"opacity": 0})
				.animate({"opacity": 1}, 1500 , function () {
						
					});

		}
	});
	 
	//背景画像の読み込み
	jQuery.preloadImages = function()
	{
		for(var i = 0; i<arguments.length; i++)
		{
			$('#imageArea').append(jQuery("<img>").attr("src", arguments[i]));
		}
	};

	// Usage
	jQuery.preloadImages(
		"/renew_images/bg/speciality.jpg",
		"/renew_images/bg/recruit.jpg",
		"/renew_images/bg/contact.jpg",
		"/renew_images/bg/company.jpg",
		"/renew_images/bg/apartments.jpg",
		"/renew_images/bg/information.jpg",
		"/renew_images/bg/sitemap.jpg",
		"/renew_images/bg/top.jpg"
	);

	//aタグの書き換え
	$('a[target != "_blank"]').each(function() {
	  $(this)
	    .filter(function() {
	      return this.href.indexOf(domain) != -1;
	    })
	    .attr('href', $(this).attr('href').match(/^\./)
	      ? $(this).attr('href')
	        .replace(domain, '')
	        .replace(/^\./, '#')
	      : '#' + $(this).attr('href').replace(domain, ''))
	});

	// ページにアクセスしたら /# に置き換えたURLへリダイレクトする
	if ( location.href != domain ) {
		var goHash = location.href.replace(domain, '');
		if ( !/^\#/.test(goHash)) {
			location.href = domain + '#/' + goHash;
			return false;
		}
	}


	//戻る、進むボタンの対応
	$(window)
	  .hashchange(function() {
	    location.hash.replace('#', '');
	  });

	$(window).hashchange(); // Windowロード時に実行

	$(window).bind('hashchange', function() {
		if ( !location.hash ) {
			pageMove(domain);
		} else {
			if (location.hash == '#/') {
				//TOPページへの移動の時
				pageMove(location.hash.replace('#', ''));
			} else {
				//他のページ
				pageMove(location.hash.replace('#', ''));
			}

		}
	});
	

	if ( location.hash && location.hash != '#/' ) $(window).trigger('hashchange');


	
	
	_header
		.css({"opacity": 0})
		.animate({"opacity": 1}, 2000 );
	
	_newsBox
		.css({"opacity": 0})
		.animate({"opacity": 1}, 2000 );
	
	$('#bnrBoxInner').find('ul')
		.css({"opacity": 0})
		.animate({"opacity": 1}, 3000 );
	
	_bnrBox.innerfade({
		speed: bnrSpeed,
		timeout: bnrTimeout,
		type: 'sequence',
		containerheight: '462px'
	});
	

	
	
	
	
	//リサイズ時のコンテンツセンター
	$(window).bind("resize", function () {
		contentsCenter('realtive');
	});
});
