//初期設定JavaScript[script.js]
//------------------------------------------------------------------------------


//ロールオーバーで「○○○.***」を「○○○_on.***」に変更
//<img src="image/●.gif" class="rollover" />

$(function(){
	//img内にクラス「rollover」が指定されているファイルに対して
	$("img.rollover").mouseover(function(){
	//ロールオーバーで「ファイル名」＋「_on」＋「.拡張子」に変更
		$(this).attr("src",$(this).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_on$2"))
	}).mouseout(function(){
	//ロールアウトで「ファイル名」＋「.拡張子」に変更
		$(this).attr("src",$(this).attr("src").replace(/^(.+)_on(\.[a-z]+)$/, "$1$2"));
	}).each(function(){
	//プリロード設定
		$("<img>").attr("src",$(this).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_on$2"))
	})
})





//指定したページ内リンクをスクロールで移動
//<a href="#" class="pagelink_bt">サンプル1へ</a>
//<div class="content">サンプル1</div>
//<a href="#" class="pagetop_bt">ページ上部へ</a>

$(function() {
	//ページ内スクロール
	$(".pagelink_bt").click(function () {
		var i = $(".pagelink_bt").index(this)
		var p = $(".content").eq(i).offset().top;
		$('html,body').animate({ scrollTop: p }, 'fast');
		return false;
	});
	//ページ上部へ戻る
	$(".pagetop_bt").click(function () {
		$('html,body').animate({ scrollTop: 0 }, 'fast');
		return false;
	});
});





//ロールオーバーで不透明度操作
//<img src="image/●.gif" class="opacity" />

$(function(){
	//img内にクラス「opacity」が指定されているファイルに対して
	$("img.opacity").mouseover(function(){
			//ロールオーバーで不透明度70％に変更
		$(this).css('opacity', '0.7');
	}).mouseout(function(){
	//ロールアウトで不透明度60％に変更
				$(this).css('opacity', '1');
	})
})





//ロード時に外部テキストを読み込む
//<div class="loadtext"></div>

$(function(){
//div要素「loadtext」に「load.txt」を読み込む
	$("div.loadtext").load("http://www.nishi-designoffice.jp/load.txt");
})






