/*==画像切り替え関数郡==*/
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
/*==Cookie情報取得==*/
function getCookie(k, c, v, x, y, z) {
	c = " " + document.cookie + ";";
	x = y = 0;
	l = c.length;
	while(x < l) {
		y = c.indexOf(";", x);
		v = c.substring(x + 1, y);
		z = v.indexOf("=");
		if(v.substring(0, z) == k) {
			return(unescape(v.substring(z + 1, y - x - 1)));
		}
		x = y + 1;
	}
	return("");
}
/*==Cookie設定==*/
function setCookie(k, v, t) {
	var n = calcDate(10);	// COOKIE残存期間は10日を設定
	var e = n["wd"]+", "+n["dd"]+"-"+n["mn"]+"-"+n["yy"]+" "+n["hh"]+":"+n["mm"]+":"+n["ss"];
	t = k + "=" + escape(v) + "; expires=" + e + "; path=/";
	document.cookie = t;
}
/*==Cookieｸﾘｱ==*/
function clearCookie(k) {
	document.cookie = k + "=" + "xx; expires=Tue, 1-Jan-1980 00:00:00;";
}
/*==N日後・前の日付算出==*/
function calcDate(nissu) {
	var w = new Array("Sun","Mon","Tue","Wed","The","Fri","Sat");
	var m = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
	var d = new Array();
	var o = new Date();
	o.setTime(o.getTime() + (nissu * 1000 * 60 * 60 * 24));
	d["yy"] = (o.getYear() < 2000) ? o.getYear()+1900 : o.getYear();
	d["mm"] = (o.getMonth()+1 < 10) ? "0"+(o.getMonth()+1) : (o.getMonth()+1);
	d["mn"] = m[o.getMonth()];
	d["dd"] = (o.getDate() < 10) ? "0"+o.getDate() : o.getDate();
	d["wd"] = w[o.getDay()];
	d["hh"] = (o.getHours() < 10) ? "0"+o.getHours() : o.getHours();
	d["mm"] = (o.getMinutes() < 10) ? "0"+o.getMinutes() : o.getMinutes();
	d["ss"] = (o.getSeconds() < 10) ? "0"+o.getSeconds() : o.getSeconds();
	d["ms"] = o.getMilliseconds();
	return(d);
}

/*=================================*/
/*==検索実行==*/
function goOralStudioKeywordSearch() {
	//ｷｰﾜｰﾄﾞﾁｪｯｸ
	keyword = document.oralstudioSearch.key.value;
	if(keyword =="")			{ alert("検索キーワードを入力して下さい。");			return false; }
	if(keyword.length < 2)		{ alert("検索キーワードは2文字以上を入力して下さい。");	return false; }
	if(keyword.match("<|>"))	{ alert("検索キーワードに禁止文字が含まれています。");	return false; }
	
	//ﾗｼﾞｵﾎﾞﾀﾝ選択ﾁｪｯｸ
	option = "";
	for (i = 0; i < document.oralstudioSearch.stype.length; i++) {
		if (document.oralstudioSearch.stype[i].checked) {
			option = document.oralstudioSearch.stype[i].value;
		}
	}
	
	//googleｻｲﾄ内検索
	if(option == 1 || option == "") {
		document.oralstudioSearch.q.value=keyword;
		document.oralstudioSearch.action="http://www.google.co.jp/search";
		document.oralstudioSearch.method="GET";

	}
	//辞書用語検索
	else if(option == 2) {
		document.oralstudioSearch.keyword.value=keyword;
		document.oralstudioSearch.action="/stepup/jisho/jis_s_result.php";
		document.oralstudioSearch.method="POST";
	}
	//商品情報検索
	else if(option == 3) {
		document.oralstudioSearch.keyword.value=keyword;
		document.oralstudioSearch.action="/maker/item/itemlist.php";
		document.oralstudioSearch.method="POST";
	}
	document.oralstudioSearch.submit();
}
/*==popｳｨﾝﾄﾞｳを開く(ｻｲｽﾞ変更有り)==*/
function openResizeWindow(url, win_name, win_width, win_height) {
  window.open(url,win_name,"toolbar=no,menubar=no,status=no,location=no,scrollbars=yes,directories=no,resizable=yes,width=" + win_width + ",height=" + win_height );
}
/*==popｳｨﾝﾄﾞｳを開く(ｻｲｽﾞ変更有り・POST送信)==*/
function openResizeWindowSendPostInfo(url, win_name, win_width, win_height) {
	 var win = window.open("", win_name,"toolbar=no,menubar=yes,status=no,location=no,scrollbars=yes,directories=no,resizable=yes,width=" + win_width + ",height=" + win_height );
	if(win != null)  {
    	if(win.opener == null){ win.opener = self; }
		document.form.target = win_name;
		document.form.action = url;
		document.form.submit();
	}
	return false;
}
/*==popｳｨﾝﾄﾞｳを開く(ｻｲｽﾞ変更なし)==*/
function openNoresizeWindow(url, win_name, win_width, win_height) {
  window.open(url,win_name,"toolbar=no,menubar=no,status=no,location=no,scrollbars=yes,directories=no,resizable=no,width=" + win_width + ",height=" + win_height );
}
/*==印刷ﾌﾟﾚﾋﾞｭｰ表示==*/
function printPreview() {
    if(window.ActiveXObject == null || document.body.insertAdjacentHTML == null) return;
    var sWebBrowserCode = '<object width="0" height="0" classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></object>'; 
    document.body.insertAdjacentHTML('beforeEnd', sWebBrowserCode); 
    var objWebBrowser = document.body.lastChild;
    if(objWebBrowser == null) return;
    objWebBrowser.ExecWB(7, 1);
    document.body.removeChild(objWebBrowser);
}
/*==承認ﾎﾞﾀﾝｸﾘｯｸ==*/
function clickApprovalButton(flg) {
	//承認
	if(flg == 1) {
		var n = calcDate(0);
		var v = n["wd"]+", "+n["dd"]+"-"+n["mn"]+"-"+n["yy"]+" "+n["hh"]+":"+n["mm"]+":"+n["ss"];
		setCookie("agreement", v);
	}
	document.getElementById("approvalPannel").style.display = "none";
	return false;
}