/**
 * @requires jquery.js
 * @requires styleswitcher.js
 * @requires rollover.js
 */
/* ----------------------------------------------------------------------------------- */

/**
 * @namespace 
 */
var SMFLLIB = {};


SMFLLIB.COMMON_DIR_NAME = "common";



/* ----------------------------------------------------------------------------------- */
SMFLLIB.SmoothScroll = function () {
	this.selector      = $('a[href^=#], area[href^=#]');
	this.goToPageTop   = "#headContainer";
	this.speed         = 600;
	this.easing        = "easeOutExpo";
	this.noScrollCName = "no-scroll";

	if (this.selector.length) {
		this.init();
	}
}

SMFLLIB.SmoothScroll.prototype.init = function () {
	var _this = this;
	this.selector.each(function () {
		if (!$(this).hasClass(_this.noScrollCName)) {
			var fi = $(this).attr("href");
			if (fi == "#") return;//return false;
			var el = ($(fi).length) ? $(fi) : $("a[name="+fi.replace(/#/,"")+"]");
			if (el.length) {
				$(this).click(function(e) {
//					e.preventDefault();
					var target = el[0];
					$.scrollTo(target, {
						speed: _this.speed,
						easing: _this.easing,
						onAfter: function() {
							location.hash = "#"+fi.split("#")[1];;
						}
					});
					return false;
				});
			}
		}
	});
}


/* ----------------------------------------------------------------------------------- */
/**
 * @returns {String} 相対パスを返す。'../../common/'など。
 * 
*/

SMFLLIB.getCommonDir = function() {
	var dirName = arguments.length? arguments[0] : SMFLLIB.COMMON_DIR_NAME;
	var links   = document.getElementsByTagName('LINK');
	var reg = new RegExp( "(.*\/?" + dirName + "\/).+$" );
	if( links ){
		for( var i=0; i<links.length; i++ ){
			if( links[i].getAttribute("rel") && links[i].getAttribute("rel").indexOf("stylesheet") != -1 ) {
				if( links[i].href && links[i].href.match( reg ) )
					return RegExp.$1;
			}
		}
	}
	return '/'+ dirName +'/';
}


/* ----------------------------------------------------------------------------------- */
/**
 * 
 * 
*/

$(function() {

	if (jQuery.browser.msie && jQuery.browser.version == 6) {
		try {
			document.execCommand("BackgroundImageCache", false, true);
		} catch(err) {}
	}

	var roi = new RolloverImages('rollover', 'on');

	for (module in SMFLLIB) {
		var obj = SMFLLIB[module];
		if (obj && typeof obj == "function") {
			new SMFLLIB[module]();
		}
	}
});


/* ----------------------------------------------------------------------------------- */
/**
 * 
 * 
 */

SMFLLIB.FONTSIZE_SELECTOR_ENABLED = true;
SMFLLIB.FONTSIZE_SELECTOR         = null;


if (SMFLLIB.FONTSIZE_SELECTOR_ENABLED) {

	$(function() {
		var config = {
			className      : "fontsize",
			blockId        : "fontsize-selector",
			buttonsSetting : {
					"medium" : {
								styleId       : "fontsize-medium",
								buttonId      : "fontsize-btn-medium",
								title         : "文字サイズを「標準」に変更します",
								titleSelected : "現在選択中の文字サイズは「標準」です"
					},
					"large" : {
								styleId       : "fontsize-large",
								buttonId      : "fontsize-btn-large",
								title         : "文字サイズを「大」に変更します",
								titleSelected : "現在選択中の文字サイズは「大」です"
					}
			}
			,rollover : new RolloverImages("rollover-fs", "on", "on")
		};

		SMFLLIB.FONTSIZE_SELECTOR = new FontSizeSelector(config);
	});

	// 
	document.write(''
	+ '<style  type="text/css" media="screen,print">'
	+ '#fontsize-selector {display: block !important;}'
	+ '</style>');
}


/* ----------------------------------------------------------------------------------- */
/**
 * 
 * 
 */

$(function() {
	$(".innerNavi .navi01 a").hover(
		function(){
			$(this).parent().parent(".innerNavi").addClass("naviOn01");
		},
		function(){
			$(this).parent().parent(".innerNavi").removeClass("naviOn01");
		}
	);
	$(".innerNavi .navi02 a").hover(
		function(){
			$(this).parent().parent(".innerNavi").addClass("naviOn02");
		},
		function(){
			$(this).parent().parent(".innerNavi").removeClass("naviOn02");
		}
	);
	$(".innerNavi .navi03 a").hover(
		function(){
			$(this).parent().parent(".innerNavi").addClass("naviOn03");
		},
		function(){
			$(this).parent().parent(".innerNavi").removeClass("naviOn03");
		}
	);
});










