jQuery(function(){
	try{
		if (jQuery.cookie('fsize')) {
			jQuery("body").css("font-size",jQuery.cookie('fsize'));jQuery("div.function").show();
		}
	} catch(e){}

	/* ------------------------------------------------------------------------------
		フォントサイズ変更。
	------------------------------------------------------------------------------ */
	jQuery("#magnifier button").each(function(){
		var i=jQuery(this).attr("class");
		if (i == "large" ) {
			jQuery(this).click(function(){font('140%');});
		} else if (i == "middle" ) {
			jQuery(this).click(function(){font('100%');});
		} else if (i == "small" ) {
			jQuery(this).click(function(){font('85%');});
		}
	});

	/* ------------------------------------------------------------------------------
		必須機能。
	------------------------------------------------------------------------------ */
	jQuery("#dialogue img").click(function () {
		jQuery(this).hide("slide", { direction: "up" }, 200).show("slide", { direction: "up" }, 500);
	});

	/* ------------------------------------------------------------------------------
		ライトボックス系機能。
	------------------------------------------------------------------------------ */
	try{
		jQuery.fn.colorbox.settings.bgOpacity = "0.9";
		jQuery.fn.colorbox.settings.contentCurrent = "{current} / {total}";
		jQuery("a[rel='lb']").colorbox({transition:"fade"});
	} catch(e){}

	/* ------------------------------------------------------------------------------
		フォーム整形。
	------------------------------------------------------------------------------ */
	try{
		//jQuery('#inquiry form').jqTransform({imgPath:'jqtransformplugin/img/'});
	} catch(e){}

});
function font(size){jQuery("body").css("font-size",size);jQuery.cookie("fsize",size,{expires:30,path:'/'});}

/* ------------------------------------------------------------------------------
	スクロール処理。
------------------------------------------------------------------------------ */
var eventTimer;	//タイマー変数
var restScroll=0;	//スクロール残量

function Scroll(base,move){

	//移動元(base)要素＆オブジェクトを取得
	var obj_base  = getElemPosition(base);

	//移動先(move)要素＆オブジェクトを取得
	var elem_move = document.getElementById(move);
	var obj_move  = getElemPosition(elem_move);

	restScroll = obj_move.y-obj_base.y;
	eventTimer = setInterval(setScrollPosition,10);
}
//スクロール処理をする
function setScrollPosition() {

	var moveValue=0;

	//スクロール残量が60以上の場合、スクロール量を変える
	//Math.abs()では値の絶対値を取得
	if(Math.abs(restScroll)>60){
		//moveValue = (restScroll>0)?30:-30;
		moveValue = Math.round(restScroll/15);
	}else{
		moveValue = Math.round(restScroll/2);
	}
	//スクロールを処理
	parent.scrollBy(0,moveValue);

	//スクロール残量を計算して、残りが無ければタイマー解除
	restScroll = (restScroll>0)?restScroll-moveValue:restScroll-moveValue;

	if(moveValue==0){clearInterval(eventTimer);restScroll=0;}
}

//要素の位置を取得し、オブジェクトとして返す
function getElemPosition(elem) {
	var obj = new Object();obj.x = elem.offsetLeft;obj.y = elem.offsetTop;

	//親要素を取得して位置情報を修正する
	while(elem.offsetParent) {
		elem = elem.offsetParent;obj.x += elem.offsetLeft;obj.y += elem.offsetTop;
	}
	return obj;
}

