<!--
	// ユーザーフォントサイズ ユーティリティ JavaScript
	// for www.ehealthyrecipe.com
	//

	// 変数定義 ----------------------------------------------------------------

	// サーバホスト名
	var ServerHostName = "www.ehealthyrecipe.com";

	// フォントCSSファイルリストの定義
	var fontCssFiles = new Array();
	fontCssFiles["l"] = "fontsizel.css";
	fontCssFiles["m"] = "fontsizem.css";
	fontCssFiles["s"] = "fontsizes.css";

	// フォントIFRAME URLリストの定義
	var fontIframeUrls = new Array();
	var fontIframeUrlBase = "http://www.daiichisankyo.co.jp/ehr/userfont_iframe-ds.php?";
	fontIframeUrls["l"] = fontIframeUrlBase + "font=l";
	fontIframeUrls["m"] = fontIframeUrlBase + "font=m";
	fontIframeUrls["s"] = fontIframeUrlBase + "font=s";

	// ブランクページURL
	var blankIframeUrl = "http://www.ehealthyrecipe.com/blank.html";

	// 現在のフォントサイズの読込
	var userFontSize = defUserFontSize(getCookie("ehruserfontsize"));

	// フォントサイズ変更状態の読込
	var changeFontSizeFlag = getCookie("fontsizechange");
	clearChangeFontSizeFlagFromCookie();

	// ブラウザ判別
	var thisBrowserType;
	var thisBrowserVersion;
	diagBrowser(navigator.userAgent);
	var isTargetBrowser = 0;
	if (	// 対応ブラウザ: MSIE5up, Netscape6up, Firefox, Opera
		(thisBrowserType == "MSIE" && thisBrowserVersion >= 5) ||
		(thisBrowserType == "Netscape" && thisBrowserVersion >= 5) ||
		(thisBrowserType == "Firefox") ||
		(thisBrowserType == "Opera")
	) {
		isTargetBrowser = 1;
	}
	
	// Header利用関数 ----------------------------------------------------------
	function clearText(obj) {
		if(obj.value==obj.defaultValue){
			obj.value="";
			obj.style.color="#000000";  
		}
	}

	function defaultText(obj) {
		if(obj.value==""){
			obj.value=obj.defaultValue;
			obj.style.color="#cccccc";  
		}
	}
	
	function replaceHankakuNum(str){ //半角数字変換
		var replacenum = new Array("1","2","3","4","5","6","7","8","9","0")
		var num = new Array("１","２","３","４","５","６","７","８","９","０");
	
		for(i=0; i<str.length;i++){
			for(x = 0; x < num.length; x++){
				if(num[x] == str.charAt(i)){
					str = str.replace(num[x],replacenum[x]);
				}
			}
		}
		return str;
	}

	function headwordsrch() {
		var wsrch = document.wordsrch;
		var srchword = wsrch.srchword.value;
		var wsrchtype = wsrch.srchtype;
		var wtype = 0;
		var srchpgm;
		
		if (wsrch.srchtype[0].checked == true) {
			wtype = 1;
		} else if (wsrch.srchtype[1].checked == true) {
			wtype = 2;
		}
		if (wtype == 1) {
			setHeadWordSrchTypeCookie(wtype);
			srchpgm = "/recipe-webapp/IpnMenuNameGrepServ.php";
			wsrch.todo.value = "exec";
			wsrch.MENUKEYWORD.value = srchword;
			wsrch.action = srchpgm;
			wsrch.submit();
		}
		else if (wtype == 2) {
			setHeadWordSrchTypeCookie(wtype);
			srchpgm = "/recipe-webapp/IpnSgRcpServ.php?menuCd=";
			srchpgm += replaceHankakuNum(srchword);
			wsrch.action = srchpgm;
			wsrch.submit();
		}
	}

	// 検索タイプをcookieへの永続化
	function setHeadWordSrchTypeCookie(val) {
		// 既存cookie削除
		document.cookie = "lastsrchtype=; domain=" + ServerHostName + "; path=/; expires=Mon, 1-Jan-1990 00:00:00 GMT;";
		// cookie書き込み
		document.cookie = "lastsrchtype=" + escape(val) + "; domain=" + ServerHostName + "; path=/;";
	}



	// 機能関数 ----------------------------------------------------------------

	// フォントサイズの変更
	function changeUserFontSize (fmobj) {
		if (fmobj.options[fmobj.selectedIndex].value) {
			userFontSizeVal = defUserFontSize(fmobj.options[fmobj.selectedIndex].value);
			setUserFontSizeToCookie(userFontSizeVal);
			setChangeFontSizeFlagToCookie();

			window.location.reload();
		}
	}

	// フォントサイズのチェックと取得
	function defUserFontSize (val) {
		if (val == "l" || val == "m" || val == "s") {
			return val;
		}
		else {
			return "m";
		}
	}

	// フォントサイズをcookieへの永続化
	function setUserFontSizeToCookie(val) {
		// 既存cookie削除
		document.cookie = "ehruserfontsize=; domain=" + ServerHostName + "; path=/; expires=Mon, 1-Jan-1990 00:00:00 GMT;";
		// cookie書き込み
		document.cookie = "ehruserfontsize=" + escape(val) + "; domain=" + ServerHostName + "; path=/;";
	}

	// フォントサイズ変更フラグをcookieへの永続化
	function setChangeFontSizeFlagToCookie() {
		// 既存cookie削除
		clearChangeFontSizeFlagFromCookie();
		// cookie書き込み
		document.cookie = "fontsizechange=1; path=/;";
	}

	// フォントサイズ変更フラグをcookieから削除
	function clearChangeFontSizeFlagFromCookie() {
		document.cookie = "fontsizechange=; path=/; expires=Mon, 1-Jan-1990 00:00:00 GMT;";
	}

	// 汎用Cookie取得関数
	function getCookie (key) {
		var tmp = document.cookie + ";";
		var index1 = tmp.indexOf(key, 0);
		if(index1 != -1) {
			tmp = tmp.substring(index1, tmp.length);
			var index2 = tmp.indexOf("=", 0) + 1;
			var index3 = tmp.indexOf(";", index2);
			return(unescape(tmp.substring(index2,index3)));
		}
		return("");
	}

	//ブラウザとバージョン判別
	function diagBrowser (ua) {
		thisBrowserType = "Unknown";
		thisBrowserVersion = 0;

		if (ua.indexOf("Opera") >= 0) {
			thisBrowserType = "Opera";
			thisBrowserVersion = ua.split("Opera ")[1].split(" ")[0];
			if(isNaN(thisBrowserVersion)){
				thisBrowserVersion = ua.split("Opera/")[1].split(" ")[0];
			}
		}
		else if(ua.indexOf("Safari") >= 0) {
			thisBrowserType = "Safari";
			thisBrowserVersion = ua.split("Safari/")[1].split(" ")[0];
		}
		else if(ua.indexOf("Firefox") >= 0) {
			thisBrowserType = "Firefox";
			thisBrowserVersion = ua.split("Firefox/")[1].split(" ")[0];
		}
		else if(ua.indexOf("MSIE") >= 0) {
			thisBrowserType = "MSIE";
			thisBrowserVersion = ua.split("MSIE ")[1].split(";")[0];
		}
		else if(ua.indexOf("Netscape/") >= 0) {
			thisBrowserType = "Netscape";
			thisBrowserVersion = ua.split("Netscape/")[1].split(" ")[0];
		}
		else if(ua.indexOf("Netscape6/") >= 0) {
			thisBrowserType = "Netscape";
			thisBrowserVersion = ua.split("Netscape6/")[1].split(" ")[0];
		}
		else {
			thisBrowserType = "Netscape";
			thisBrowserVersion = ua.split("Mozilla/")[1].split(" ")[0];
		}
		return true;
	}

	// 文字サイズ変更ボタン挿入
	function docwriteChangeFontSizeSelector () {
		if (isTargetBrowser == 1) {
			document.write('<div id="mojisize">');
			document.write('<p>');
			// document.write('文字サイズ');
			document.write('<select name="fontsizeselect" id="fontsizeselect" onchange="changeUserFontSize(document.getElementById(this.id))">');
			if (userFontSize == "l") {
				document.write('<option value="l" selected="selected">大</option>');
				document.write('<option value="m">中</option>');
				document.write('<option value="s">小</option>');
			}
			else if (userFontSize == "s") {
				document.write('<option value="l">大</option>');
				document.write('<option value="m">中</option>');
				document.write('<option value="s" selected="selected">小</option>');
			}
			else {
				document.write('<option value="l">大</option>');
				document.write('<option value="m" selected="selected">中</option>');
				document.write('<option value="s">小</option>');
			}
			document.write('</select>');
			document.write('</p>');
			document.write('</div>');
		}
	}

	// フォントサイズスタイルシート読込
	function docwriteIncludeFontCss () {
		var cssFileName = '/ehr/' + fontCssFiles[userFontSize];
		document.write('<style type="text/css" media="all">');
		document.write('<!' + '--');
		document.write('@import "' + cssFileName + '";');
		document.write('--' + '>');
		document.write('</style>');
	}

	// IFRAME読込
	function docwriteFontIframe () {
		if (isTargetBrowser == 1) {
			document.write('<iframe src="' + blankIframeUrl + '" height="5" width="5" marginheight="0" marginwidth="0" frameborder="0" scrolling="no" name="iiffrraammee"></iframe>');
			if (changeFontSizeFlag == 1) {
				window.iiffrraammee.location.href = fontIframeUrls[userFontSize];
			}
		}
	}

	// IFRAME読込
	function docwriteFontIframeDs () {
		docwriteFontIframe();
	}
// -->
