//font size を指定するjavascript
function fontSizeLoad(fontStyle){

	var url = retHost();
	
	var img_s = '<img src="'+url+'common/images/text-size-s.gif" width="20" height="28" onclick="fontSizeCookie(\'small\')" />';
	var img_s_on = '<img src="'+url+'common/images/text-size-s-on.gif" width="20" height="28" onclick="fontSizeCookie(\'small\')" />';
	var img_m = '<img src="'+url+'common/images/text-size-m.gif" width="21" height="28" onclick="fontSizeCookie(\'medium\')" />';
	var img_m_on = '<img src="'+url+'common/images/text-size-m-on.gif" width="21" height="28" onclick="fontSizeCookie(\'medium\')" />';
	var img_l = '<img src="'+url+'common/images/text-size-l.gif" width="23" height="28" onclick="fontSizeCookie(\'large\')" />';
	var img_l_on = '<img src="'+url+'common/images/text-size-l-on.gif" width="23" height="28" onclick="fontSizeCookie(\'large\')" />';
	//text-size-s.m.l
	$("body").removeClass("textsize-s textsize-m textsize-l");
	switch (fontStyle){
		case "small":
			$("#small").html(img_s_on);
			$("#large").html(img_l);
			$("#medium").html(img_m);
			$("body").addClass("textsize-s");
			break;
		case "large":
			$("#small").html(img_s);
			$("#large").html(img_l_on);
			$("#medium").html(img_m);
			$("body").addClass("textsize-l");
			break;
		case "medium":
		default:
			$("#small").html(img_s);
			$("#large").html(img_l);
			$("#medium").html(img_m_on);
			$("body").addClass("textsize-m");
			break;
	}
}
//ホスト名をリターン
function retHost(){
		var pro = location.protocol;
		var host= location.hostname;
		var url = pro + "//" + host + "/kidsdesignjp/";
		return url;
}
//クリック時
function fontSizeCookie(fontStyle){
	$.cookie('fontSize', fontStyle, {path:'/'});
	fontSizeLoad( fontStyle);
}
//ロード時
$(document).ready(function(){
	var fontStyle = $.cookie('fontSize');
	if( fontStyle == null){ fontStyle = "medium";}
	fontSizeLoad( fontStyle);
});

//ページ分割プラグインの設定
$(document).ready(function(){
	$(".multiple-pages li:first").css("border", "none");
});

//角丸
$(function() {
  $(".mes-ico").corner("7px");
});


/**
 * 文字数制限
 * @id  対象タグのID
 * @len 制限文字数
 */
function str_replace( id, len){
	var txt = $("#"+id).text();
	if( len < txt.length){
		txt = txt.substr(0,len);
		txt = nl2br(txt);
		$("#"+id).html( txt+"...");
	}
}
/**
 * 改行コードを<br>に変換
 */
function nl2br( txt){
	var ret_txt = "";
	var br = '<br />';
	var arr_txt = txt.split('\n');
	for( var i in arr_txt){
		if( trim(arr_txt[i]) != ""){
			ret_txt += arr_txt[i] + br + "\n";
		}
	}
	ret_txt = ret_txt.substr( 0, (ret_txt.length-(br.length+1)));
	return ret_txt;
}
/**
 * 空白を削除
 */
function trim( txt){
	return txt.replace(/^\s+|\s+$/g, "");
}


function limitChars(target,maxlength) {
    if ( target.value.length > maxlength ) {
        alert("入力制限 : "+maxlength+"文字までです。");
        target.value = target.value.substr(0,maxlength);
    }

    target.focus();
}
