/**
 * @requires jquery.js
 */
/* ----------------------------------------------------------------------------------- */

/**
 * @namespace 
 */
var MARUZENSHOWALIB = {};


MARUZENSHOWALIB.COMMON_DIR_NAME = "common";




/* ----------------------------------------------------------------------------------- */
MARUZENSHOWALIB.SmoothScroll = function () {
	this.selector      = $('a[href^=#], area[href^=#]');
	this.goToPageTop   = "#pageContainer";
	this.speed         = 600;
	this.easing        = "easeOutExpo";
	this.noScrollCName = "no-scroll";

	if (this.selector.length) {
		this.init();
	}
}

MARUZENSHOWALIB.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/'など。
 * 
*/

MARUZENSHOWALIB.getCommonDir = function() {
	var dirName = arguments.length? arguments[0] : MARUZENSHOWALIB.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 MARUZENSHOWALIB) {
		var obj = MARUZENSHOWALIB[module];
		if (obj && typeof obj == "function") {
			new MARUZENSHOWALIB[module]();
		}
	}
});


/* ----------------------------------------------------------------------------------- */
/**
 * @requires jquery.js, styleswitcher.js, rollover.js
 * 
 */

FONTSIZE_SELECTOR_ENABLED = true;
FONTSIZE_SELECTOR         = null;


if (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")
		};

		FONTSIZE_SELECTOR = new FontSizeSelector(config);
	});

	// 
	document.write(''
	+ '<style  type="text/css" media="screen,print">'
	+ '#fontsize-selector {display: block !important;}'
	+ '</style>');
}





/* ----------------------------------------------------------------------------------- */
/**
 * 	
 * 
*/

$(window).load(function(){

	var targetClass = $('.fixColumnWidth');
	
	if(targetClass.length){
		
		targetClass.each(function(){
			
			imgArr = [];
			targetImg = $('img',this);
			
			targetImg.each(function(){ //画像の数だけ画像幅を格納
				
				tmpWidth = $(this).width();
				imgArr.push(tmpWidth);
				
			});
			
			imgArr.sort();
			maxWidth = imgArr[imgArr.length - 1]; //配列の中から一番大きいものを取り出す
			$(this).width(maxWidth);
		
		});

	};
});





/* ----------------------------------------------------------------------------------- */
/**
 * 	 printBtn
 * 
*/


$(function() {
		   
	$('.printBtn').css('cursor','pointer');
		   
	$('.printBtn').click(function(){
		funcPrint();
	});
	
});


function funcPrint(){
	print();
}

