/*
 * This file is part of EC-CUBE
 *
 * Copyright(c) 2000-2010 LOCKON CO.,LTD. All Rights Reserved.
 *
 * http://www.lockon.co.jp/
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
/****************************************
 css.js
*****************************************/

gCssUA = navigator.userAgent.toUpperCase();
gCssBrw = navigator.appName.toUpperCase();

with (document) {
		write("<style type=\"text/css\"><!--");


//WIN-IE
	if (gCssUA.indexOf("WIN") != -1 && gCssUA.indexOf("MSIE") != -1) {
		write(".fs10 {font-size: 62.5%; line-height: 150%; letter-spacing:1px;}");
		write(".fs12 {font-size: 75%; line-height: 150%; letter-spacing:1.5px;}");
		write(".fs14 {font-size: 87.5%; line-height: 150%; letter-spacing:2px;}");
		write(".fs18 {font-size: 117.5%; line-height: 130%; letter-spacing:2.5px;}");
		write(".fs22 {font-size: 137.5%; line-height: 130%; letter-spacing:3px;}");
		write(".fs24 {font-size: 150%; line-height: 130%; letter-spacing:3px;}");
		write(".fs30 {font-size: 187.5%; line-height: 125%; letter-spacing:3.5px;}");
		write(".fs10n {font-size: 62.5%; letter-spacing:1px;}");
		write(".fs12n {font-size: 75%; letter-spacing:1.5px;}");
		write(".fs14n {font-size: 87.5%; letter-spacing:2px;}");
		write(".fs18n {font-size: 117.5%; letter-spacing:2.5px;}");
		write(".fs22n {font-size: 137.5%; letter-spacing:1px;}");
		write(".fs24n {font-size: 150%; letter-spacing:1px;}");
		write(".fs30n {font-size: 187.5%; letter-spacing:1px;}");
		write(".fs12st {font-size: 75%; line-height: 150%; letter-spacing:1.5px; font-weight: bold;}");
	}

//WIN-NN
	if (gCssUA.indexOf("WIN") != -1 && gCssBrw.indexOf("NETSCAPE") != -1) {
		write(".fs10 {font-size:72%; line-height:130%;}");
		write(".fs12 {font-size: 75%; line-height: 150%;}");
		write(".fs14 {font-size: 87.5%; line-height: 140%;}");
		write(".fs18 {font-size: 117.5%; line-height: 130%;}");
		write(".fs22 {font-size: 137.5%; line-height: 130%;}");
		write(".fs24 {font-size: 150%; line-height: 130%;}");
		write(".fs30 {font-size: 187.5%; line-height: 120%;}");
		write(".fs10n {font-size:72%;}");
		write(".fs12n {font-size: 75%;}");
		write(".fs14n {font-size: 87.5%;}");
		write(".fs18n {font-size: 117.5%;}");
		write(".fs22n {font-size: 137.5%;}");
		write(".fs24n {font-size: 150%;}");
		write(".fs30n {font-size: 187.5%;}");
		write(".fs12st {font-size: 75%; line-height: 150%; font-weight: bold;}");
	}

//WIN-NN4.x
	if ( navigator.appName == "Netscape" && navigator.appVersion.substr(0,2) == "4." ) {
		write(".fs10 {font-size:90%; line-height: 130%;}");
		write(".fs12 {font-size: 100%; line-height: 140%;}");
		write(".fs14 {font-size: 110%; line-height: 135%;}");
		write(".fs18 {font-size: 130%; line-height: 175%;}");
		write(".fs24 {font-size: 190%; line-height: 240%;}");
		write(".fs30 {font-size: 240%; line-height: 285%;}");
		write(".fs10n {font-size:90%;}");
		write(".fs12n {font-size: 100%;}");
		write(".fs14n {font-size: 110%;}");
		write(".fs18n {font-size: 130%;}");
		write(".fs24n {font-size: 190%;}");
		write(".fs30n {font-size: 240%;}");
		write(".fs12st {font-size: 100%; line-height: 140%; font-weight: bold;}");
	}

//MAC
	if (gCssUA.indexOf("MAC") != -1) {
		write(".fs10 {font-size: 10px; line-height: 14px;}");
		write(".fs12 {font-size: 12px; line-height: 18px;}");
		write(".fs14 {font-size: 14px; line-height: 18px;}");
		write(".fs18 {font-size: 18px; line-height: 23px;}");
		write(".fs22 {font-size: 22px; line-height: 27px;}");
		write(".fs24 {font-size: 24px; line-height: 30px;}");
		write(".fs30 {font-size: 30px; line-height: 35px;}");
		write(".fs10n {font-size: 10px;}");
		write(".fs12n {font-size: 12px;}");
		write(".fs14n {font-size: 14px;}");
		write(".fs18n {font-size: 18px;}");
		write(".fs22n {font-size: 22px;}");
		write(".fs24n {font-size: 24px;}");
		write(".fs30n {font-size: 30px;}");
		write(".fs12st {font-size: 12px; line-height: 18px; font-weight: bold;}");
	}

	write("--></style>");
}

/****************************************
 navi.js
*****************************************/

	var preLoadFlag = "false";

	function preLoadImg(URL){

		arrImgList = new Array (
			URL+"img/header/basis_on.jpg",URL+"img/header/product_on.jpg",URL+"img/header/customer_on.jpg",URL+"img/header/order_on.jpg",
			URL+"img/header/sales_on.jpg",URL+"img/header/mail_on.jpg",URL+"img/header/contents_on.jpg",
			URL+"img/header/mainpage_on.gif",URL+"img/header/sitecheck_on.gif",URL+"img/header/logout.gif",
			URL+"img/contents/btn_search_on.jpg",URL+"img/contents/btn_regist_on.jpg",
			URL+"img/contents/btn_csv_on.jpg",URL+"img/contents/arrow_left.jpg",URL+"img/contents/arrow_right.jpg",
			URL+"img/products/b_detail_on.gif", URL+"img/products/b_cartin_on.gif",
			URL+"img/side/button_cartin_on.gif", URL+"img/login/b_login_on.gif",
			URL+"img/cart/b_contn_on.gif", URL+"img/cart/b_todokesaki_on.gif",
			URL+"img/cart/b_contn_on.gif", URL+"img/side/contact2_on.gif"
		);
		arrPreLoad = new Array();
		for (i in arrImgList) {
			arrPreLoad[i] = new Image();
			arrPreLoad[i].src = arrImgList[i];
		}
		preLoadFlag = "true";
	}

	function chgImg(fileName,imgName){
		if (preLoadFlag == "true") {
			document.images[imgName].src = fileName;
		}
	}
	
	function chgImgImageSubmit(fileName,imgObj){
	imgObj.src = fileName;
	}
	
	// サブナビの表示切替
	function naviStyleChange(ids, bcColor, color){
		document.getElementById(ids).style.backgroundColor = bcColor;
	}	

/****************************************
 win_op.js
*****************************************/

<!--
	function win01(URL,Winname,Wwidth,Wheight){
		var WIN;
		WIN = window.open(URL,Winname,"width="+Wwidth+",height="+Wheight+",scrollbars=no,resizable=no,toolbar=no,location=no,directories=no,status=no");
		WIN.focus();
	}
// -->
	
<!--
	function win02(URL,Winname,Wwidth,Wheight){
		var WIN;
		WIN = window.open(URL,Winname,"width="+Wwidth+",height="+Wheight+",scrollbars=yes,resizable=yes,toolbar=no,location=no,directories=no,status=no");
		WIN.focus();
	}
// -->

<!--
	function win03(URL,Winname,Wwidth,Wheight){
		var WIN;
		WIN = window.open(URL,Winname,"width="+Wwidth+",height="+Wheight+",scrollbars=yes,resizable=yes,toolbar=no,location=no,directories=no,status=no,menubar=no");
		WIN.focus();
	}
// -->

<!--
function winSubmit(URL,formName,Winname,Wwidth,Wheight){
	WIN = window.open(URL,Winname,"width="+Wwidth+",height="+Wheight+",scrollbars=yes,resizable=yes,toolbar=no,location=no,directories=no,status=no,menubar=no");
    document.forms[formName].target = Winname;
	WIN.focus();
}
//-->

<!--
	function ChangeParent()
	{
		window.opener.location.href="../contact/index.php";
	}
//-->


<!--//
function CloseChild()
{
	window.close();
}
//-->

/****************************************
 site.js
*****************************************/

// 親ウィンドウの存在確認.
function fnIsopener() {
    var ua = navigator.userAgent;
    if( !!window.opener ) {
//			window.opener.document.getElementById('zipmsg').innerHTML = "";		//エラーメッセージクリア
        if( ua.indexOf('MSIE 4')!=-1 && ua.indexOf('Win')!=-1 ) {
            return !window.opener.closed;
        } else {
        	return typeof window.opener.document == 'object';
        }
	} else {
		return false;
	}
}

// 郵便番号入力呼び出し.
function fnCallAddress(php_url, tagname1, tagname2, input1, input2, fcs) {
	zip1 = document.form1[tagname1].value;
	zip2 = document.form1[tagname2].value;

	if(zip1.length == 3 && zip2.length == 4) {
		url = php_url + "?zip1=" + zip1 + "&zip2=" + zip2 + "&input1=" + input1 + "&input2=" + input2;
		window.open(url,"nomenu","width=500,height=350,scrollbars=yes,resizable=yes,toolbar=no,location=no,directories=no,status=no");
		if(fcs.length > 0) {
			if (document.form1[fcs]) {
				try{
					document.form1[fcs].focus();
				} catch(e) {
				}
			}
		}
	} else {
		alert("郵便番号を正しく入力して下さい。");
		try{
			if (zip1.length != 3) {
				document.form1[tagname1].focus();
			} else {
				document.form1[tagname2].focus();
			}
		} catch(e) {
		}
	}
}

// 郵便番号から検索した住所を渡す.
function fnPutAddress(input1, input2) {
	// 親ウィンドウの存在確認。.
	if(fnIsopener()) {
		if(document.form1['state'].value != "") {
			// 項目に値を入力する.
			state_id = document.form1['state'].value;
			town = document.form1['city'].value + document.form1['town'].value;
			window.opener.document.form1[input1].selectedIndex = state_id;
			window.opener.document.form1[input2].value = town;
		} else {
			try{
				// 存在しなければクリア
//				window.opener.document.form1[input1].selectedIndex = 0;
//				window.opener.document.form1[input2].value = "";
//				window.opener.document.getElementById('zipmsg').innerHTML = "該当する住所が見つかりませんでした。";
				window.opener.document.form1['zip01'].focus();
			} catch(e) {
			}
		}

	} else {
		window.close();
	}
}

function fnOpenNoMenu(URL) {
	window.open(URL,"nomenu","scrollbars=yes,resizable=yes,toolbar=no,location=no,directories=no,status=no");
}

function fnOpenWindow(URL,name,width,height) {
	window.open(URL,name,"width="+width+",height="+height+",scrollbars=yes,resizable=no,toolbar=no,location=no,directories=no,status=no");
}

function fnSetFocus(name) {
	if(document.form1[name]) {
		document.form1[name].focus();
	}
}

// セレクトボックスに項目を割り当てる.
function fnSetSelect(name1, name2, val) {
	sele1 = document.form1[name1]; 
	sele2 = document.form1[name2];
	
	if(sele1 && sele2) {
		index=sele1.selectedIndex;
		
		// セレクトボックスのクリア	
		count=sele2.options.length
		for(i = count; i >= 0; i--) {
			sele2.options[i]=null;
		}
		
		// セレクトボックスに値を割り当てる。
		len = lists[index].length
		for(i = 0; i < len; i++) {
			sele2.options[i]=new Option(lists[index][i], vals[index][i]);
			if(val != "" && vals[index][i] == val) {
				sele2.options[i].selected = true;
			}
		}
	}
}

// Enterキー入力をキャンセルする。(IEに対応)
function fnCancelEnter()
{
	if (gCssUA.indexOf("WIN") != -1 && gCssUA.indexOf("MSIE") != -1) {
		if (window.event.keyCode == 13)
		{
			return false;
		}
	}
	return true;
}

// モードとキーを指定してSUBMITを行う。
function fnModeSubmit(mode, keyname, keyid,pdctname) {

	switch(mode) {
	case 'delete_category':
		if(!window.confirm('選択したカテゴリとカテゴリ内のすべてのカテゴリを削除します　　')){
			return;
		}
		break;
	case 'delete':
		if(!window.confirm('削除しても宜しいですか？　　')){
			return;
		}
		break;
	case 'delete_order':
		if(!window.confirm('削除したデータは、元に戻せません。\n削除しても宜しいですか？')){
			return;
		}
		break;
	case 'confirm':
		if(!window.confirm('登録しても宜しいですか？　　')){
			return;
		}
		break;
	case 'delete_all':
		if(!window.confirm('検索結果をすべて削除しても宜しいですか？　　')){
			return;
		}
		break;
	case 'deletecart':
		if(!window.confirm('「' + pdctname + '」 を' + '\nお買い物カゴから削除しても宜しいですか？　　')){
			return;
		}
		mode = 'delete';
		break;
	case 'chgdeliv':
		break;
	default:
		break;
	}

	document.form1['mode'].value = mode;
	if(keyname != "" && keyid != "") {
		document.form1[keyname].value = keyid;
	}

	document.form1.submit();
}

// モードとキーを指定してSUBMITを行う。（リストから）
function fnListModeSubmit(mode, keyname, keyid) {

	if (!fnChkNum(document.form1('quantity'+keyid),'数量',1)) {
		return false;
	}
	document.form1('quantity').value = document.form1('quantity'+keyid).value;

	document.form1['mode'].value = mode;
	if(keyname != "" && keyid != "") {
		document.form1[keyname].value = keyid;
	}
	document.form1.submit();
	return true;
}

// モードとキーを指定してSUBMITを行う。
function fnModeSubmitDelete(mode, keyname, keyid, delname) {
	switch(mode) {
	case 'delete':
		if (delname!=""){
			if(!window.confirm('お届け先：' + delname + ' を削除しても宜しいですか？　　')){
				return;
			}
		} else {
			if(!window.confirm('削除しても宜しいですか？　　')){
				return;
			}
		}
		break;
	default:
		break;
	}

	document.form1['mode'].value = "delete";
	if(keyname != "" && keyid != "") {
		document.form1[keyname].value = keyid;
	}
	document.form1.submit();
}

function fnFormModeSubmit(form, mode, keyname, keyid) {
	switch(mode) {
	case 'delete':
		if(!window.confirm('削除しても宜しいですか？　　')){
			return;
		}
		break;
	case 'confirm':
		if(!window.confirm('登録しても宜しいですか？　　')){
			return;
		}
		break;
	case 'regist':
		if(!window.confirm('登録しても宜しいですか？　　')){
			return;
		}
		break;		
	case 'deletecart':
		if(!window.confirm('お買い物カゴから削除しても宜しいですか？　　')){
			return;
		}
		break;
	default:
		break;
	}
	document.forms[form]['mode'].value = mode;
	if(keyname != "" && keyid != "") {
		document.forms[form][keyname].value = keyid;
	}
//alert(document.forms[form]['mode'].value);
	document.forms[form].submit();
}

function fnSetFormSubmit(form, key, val) {
	document.forms[form][key].value = val;
	document.forms[form].submit();
	return false;
}

function fnSetFormVal(form, key, val) {
	document.forms[form][key].value = val;
}

// SUBMIT前チェック
function fnModeSubmitChk(mode, txtboxname, keyid) {

	if (txtboxname != 'quantity') {
		return true;
	}

	txtboxname = txtboxname + keyid;

	document.forms[form][txtboxname].value

}
/*****************************************************************
 *	半角数字チェック
 *
 *	@param	obj		:チェック対象項目名
 *	@param	onFocus	'1':エラーの場合項目にフォーカスする
 *  @param	zeroOK   true: '0'をOKとする
 *	@return	true	:	項目が半角数字
 *			false	: 	項目が半角数字でない
 *****************************************************************/
function fnChkNum(obj, objJnm, onFocus, zeroOK){

	var numString = "0123456789";
	var msg = "";
	
	var val = obj.value;
	if (val.length == 0) {
		msg = objJnm + "を入力してください。";
		alert(msg);
		if (onFocus == '1') {
			obj.focus();
		}
		return false;
	}

	val = fnFulltoHalf(val);		// 全角数字を半角に置換
	obj.value = val;

	for(var idx = 0 ; idx < val.length ; idx++){
		/* 0123456789以外の文字が使われている場合 */
		if(numString.indexOf(val.substring(idx,idx+1)) == -1){
			msg = objJnm + "は数字を入力してください。";
			alert(msg);
			if (onFocus == '1') {
				obj.focus();
			}
			return false;
		}
	}

	if (zeroOK) {
//
	} else {
		if (val == 0) {
			msg = objJnm + "は1以上の数字を入力してください。";
			alert(msg);
			if (onFocus == '1') {
				obj.focus();
			}
			return false;
		}
	}
	return true;
}

/*****************************************************************
 *	全角数字を半角数字に置換
 *	@return	:	置換後文字列
 *****************************************************************/
function fnFulltoHalf(val){

	var char1 = new Array("１","２","３","４","５","６","７","８","９","０");
	var char2 = new Array(1,2,3,4,5,6,7,8,9,0);
	var data = "";

	while(val.match(/[０-９]/)){     	//入力データに全角数字がある場合
		for(var count = 0; count < char1.length; count++){
				//入力データを全角数字から半角数字に置換する
			val = val.replace(char1[count], char2[count]);
		}
	}
	return val;
}


function fnChangeAction(url) {
	document.form1.action = url;
}

// ページナビで使用する。
function fnNaviPage(pageno) {
	document.form1['pageno'].value = pageno;
	document.form1.submit();
}

function fnSearchPageNavi(pageno) {
	document.form1['pageno'].value = pageno;
	document.form1['mode'].value = 'search';
	document.form1.submit();
	}

	function fnSubmit(){
	document.form1.submit();
}

// ポイント入力制限。
function fnCheckInputPoint() {
	if(document.form1['point_check']) {
		list = new Array(
						'use_point'
						);
	
		if(!document.form1['point_check'][0].checked) {
			color = "#dddddd";
			flag = true;
		} else {
			color = "";
			flag = false;
		}
		
		len = list.length
		for(i = 0; i < len; i++) {
			if(document.form1[list[i]]) {
				document.form1[list[i]].disabled = flag;
				document.form1[list[i]].style.backgroundColor = color;
			}
		}
	}
}

// 「お届け先を指定」ON/OFF切替 別のお届け先入力制限。
function fnCheckInputDeliv(shoki) {
	if(!document.form1) {
		return;
	}
	if(document.form1['deliv_check']) {
		list1 = new Array(
						'order_name01',
						'order_name02',
						'order_kana01',
						'order_kana02',
						'order_pref',
						'order_zip01',
						'order_zip02',
						'order_addr01',
						'order_addr02',
						'order_tel01',
						'order_tel02',
						'order_tel03'
						);
		list2 = new Array(
						'deliv_name01',
						'deliv_name02',
						'deliv_kana01',
						'deliv_kana02',
						'deliv_pref',
						'deliv_zip01',
						'deliv_zip02',
						'deliv_addr01',
						'deliv_addr02',
						'deliv_tel01',
						'deliv_tel02',
						'deliv_tel03'
						);
		list3 = new Array(
						'h_deliv_name01',
						'h_deliv_name02',
						'h_deliv_kana01',
						'h_deliv_kana02',
						'h_deliv_pref',
						'h_deliv_zip01',
						'h_deliv_zip02',
						'h_deliv_addr01',
						'h_deliv_addr02',
						'h_deliv_tel01',
						'h_deliv_tel02',
						'h_deliv_tel03'
						);
	
		// 有効／無効切替
		fnChangeDisabled_nomember(list2, document.form1['deliv_check'].checked);
		// 「お届け先を指定」ON/OFF切替  自分の情報をお届け先に代入
		fnInputDeliv_nomember(list1, list2, list3, document.form1['deliv_check'].checked, shoki);

		if (document.form1['deliv_check'].checked) {
			document.form1['deliv_name01'].focus();
		}

	}
}


// 購入時会員登録入力制限。
function fnCheckInputMember() {
	if(document.form1['member_check']) {
		list = new Array(
						'password',
						'password_confirm',
						'reminder',
						'reminder_answer'
						);

		if(!document.form1['member_check'].checked) {
			fnChangeDisabled(list, '#dddddd');
		} else {
			fnChangeDisabled(list, '');
		}
	}
}

// 最初に設定されていた色を保存しておく。
var g_savecolor = new Array();

function fnChangeDisabled(list, color) {
	len = list.length;
	
	for(var i = 0; i < len; i++) {
		if(document.form1[list[i]]) {
			if(color == "") {
				// 有効にする。
				document.form1[list[i]].disabled = false;
				document.form1[list[i]].style.backgroundColor = g_savecolor[list[i]];
			} else {
				// 無効にする。
				document.form1[list[i]].disabled = true;
				g_savecolor[list[i]] = document.form1[list[i]].style.backgroundColor;
				document.form1[list[i]].style.backgroundColor = color;//"#f0f0f0";	
			}			
		}
	}
}

function fnChangeDisabled_nomember(list,flg) {
	len = list.length;
	
	for(var i = 0; i < len; i++) {
		if(document.form1[list[i]]) {
			if(flg) {
				// 有効にする。
				document.form1[list[i]].disabled = false;
				document.form1[list[i]].style.backgroundColor = "#fff";
			} else {
				// 無効にする。
				document.form1[list[i]].disabled = true;
				document.form1[list[i]].style.backgroundColor = "#dddddd";	
			}			
		}
	}
}

// 「お届け先を指定」ON/OFF切替  自分の情報をお届け先に代入
function fnInputDeliv_nomember(list1, list2, list3, chkbox, shoki) {
	len = list1.length;
	
	if(!chkbox) {
		// オフ
		for(var idx = 0; idx < len; idx++) {
			if(document.form1[list1[idx]]) {
				if (!shoki) {		// 最初の表示の場合
					document.form1[list3[idx]].value = document.form1[list2[idx]].value;	// 退避
				}
//				document.form1[list2[idx]].value = document.form1[list1[idx]].value;	// 本人情報を代入
				document.form1[list2[idx]].value = "";		// クリア
			}			
		}

	} else {
		// オン
		for(var idx = 0; idx < len; idx++) {
			if(document.form1[list1[idx]]) {
				if (document.form1[list3[idx]].value != "") {
					document.form1[list2[idx]].value = document.form1[list3[idx]].value;	// 退避していたのを戻す
				}
				document.form1[list3[idx]].value = "";
			}
		}

	}
}

// ログイン時の入力チェック
function fnCheckLogin(formname) {
	var lstitem = new Array();
	
	if(formname == 'login_mypage'){
	lstitem[0] = 'mypage_login_email';
	lstitem[1] = 'mypage_login_pass';
	}else{
	lstitem[0] = 'login_email';
	lstitem[1] = 'login_pass';
	}
	var max = lstitem.length;
	var errflg = false;
	var cnt = 0;
	
	//　必須項目のチェック
	for(cnt = 0; cnt < max; cnt++) {
		if(document.forms[formname][lstitem[cnt]].value == "") {
			errflg = true;
			break;
		}
	}
	
	// 必須項目が入力されていない場合	
	if(errflg == true) {
		alert('メールアドレス/パスワードを入力して下さい。');
		document.forms[formname][lstitem[cnt]].focus();
		return false;
	}
}

// 時間の計測.
function fnPassTime(){
	end_time = new Date();
	time = end_time.getTime() - start_time.getTime();
	alert((time/1000));
}
start_time = new Date();

//親ウィンドウのページを変更する.
function fnUpdateParent(url) {
	// 親ウィンドウの存在確認
	if(fnIsopener()) {
		window.opener.location.href = url;
	} else {
		window.close();
	}		
}
//親ウィンドウのページをリロード
function fnUpdateAddr() {
	// 親ウィンドウの存在確認
	if(fnIsopener()) {
		window.opener.location.reload();
	} else {
		window.close();
	}		
}


//特定のキーをSUBMITする.
function fnKeySubmit(keyname, keyid) {
	if(keyname != "" && keyid != "") {
		document.form1[keyname].value = keyid;
	}
	document.form1.submit();
}

//文字数をカウントする。
//引数1：フォーム名称
//引数2：文字数カウント対象
//引数3：カウント結果格納対象
function fnCharCount(form,sch,cnt) {
	document.forms[form][cnt].value= document.forms[form][sch].value.length;
}


// テキストエリアのサイズを変更する.
function ChangeSize(button, TextArea, Max, Min, row_tmp){
	
	if(TextArea.rows <= Min){
		TextArea.rows=Max; button.value="小さくする"; row_tmp.value=Max;
	}else{
		TextArea.rows =Min; button.value="大きくする"; row_tmp.value=Min;
	}
}

//お届け日時指定の表示／非表示
function trOnDisp(rowNum) {
	if (document.getElementById("chk_id_"+rowNum).checked) {
		document.getElementById("trblock_"+rowNum).style.display=''; 
		document.getElementById("naka1"+rowNum).style.borderBottomColor='#DDD';
		document.getElementById("naka2"+rowNum).style.borderBottomColor='#DDD';
		document.getElementById("naka3"+rowNum).style.borderBottomColor='#DDD';
		document.getElementById("migi"+rowNum).style.borderBottomColor='#DDD';
		document.getElementById("hidari"+rowNum).style.borderBottomColor='#DDD';
	} else {
		document.getElementById("trblock_"+rowNum).style.display='none';
		document.getElementById("naka1"+rowNum).style.borderBottomColor='#999';
		document.getElementById("naka2"+rowNum).style.borderBottomColor='#999';
		document.getElementById("naka3"+rowNum).style.borderBottomColor='#999';
		document.getElementById("migi"+rowNum).style.borderBottomColor='#999';
		document.getElementById("hidari"+rowNum).style.borderBottomColor='#999';
	}
}
//お届け日時指定の非表示
function funNonDisp(count) {
	for (var idx=1;idx<=count;idx++) {
		if (document.getElementById("chk_id_"+idx).checked) {
			document.getElementById("trblock_"+idx).style.display=''; 
		} else {
			document.getElementById("trblock_"+idx).style.display='none'; 
			document.getElementById("naka1"+idx).style.borderBottomColor='#999'; 
			document.getElementById("naka2"+idx).style.borderBottomColor='#999'; 
			document.getElementById("naka3"+idx).style.borderBottomColor='#999'; 
			document.getElementById("migi"+idx).style.borderBottomColor='#999'; 
			document.getElementById("hidari"+idx).style.borderBottomColor='#999'; 
		}
	}
}
//のしチェック
function funNosiChk(chkNm,objNm) {
	if (document.getElementById(chkNm).checked) {
		document.getElementById(chkNm).checked=false;
	} else {
		document.getElementById(chkNm).checked=true;
	}
	funNosi(chkNm,objNm);
}
//のし指定の表示／非表示
function funNosi(chkNm,objNm) {
	if (document.getElementById(chkNm).checked) {
		document.getElementById(objNm).style.display=''; 
	} else {
		document.getElementById(objNm).style.display='none'; 
	}
}
//チェック
function funChk(chkNm) {
	if (document.getElementById(chkNm).checked) {
		document.getElementById(chkNm).checked=false;
	} else {
		document.getElementById(chkNm).checked=true;
	}
}
//ギフトセレクション時本人チェックボックス
function funGftHonchk(chkNm, objNm, initFlg) {

	if (document.getElementById(chkNm).checked) {
		document.getElementById(objNm).disabled = true; 
		document.getElementById(objNm).style.backgroundColor = "#dddddd";	
		if (!initFlg) {
			document.getElementById(objNm).value = document.getElementById('order_name').value;
		}
	} else {
		if (document.getElementById('order_name').value == "") {
			document.getElementById('order_name').value = document.getElementById(objNm).value; 
		}
		document.getElementById(objNm).disabled = false; 
		document.getElementById(objNm).style.backgroundColor = "#fff";	
		if (!initFlg) {
			document.getElementById(objNm).value = ""; 
			document.getElementById(objNm).focus();
		}
	}
}
//ギフトセレクション時本人チェックボックス初期処理用
function funGftHonOnload(num) {
	for (var idx=1;idx<=num;idx++) {
		if ((document.getElementById("cltg_samechk_"+idx)) && (document.getElementById("giftname_"+idx))) {
			funGftHonchk("cltg_samechk_"+idx,"giftname_"+idx, true);
		}
	}
}

//商品指定チェック
function chkProduct(count) {
	//チェックがない場合エラー
	for (var idx=1;idx<=count;idx++) {
		if (document.getElementById("pdct_chk_"+idx).checked) {
			return true;
		}
	}
	alert("商品を選択してください。");
	return false;
}
//お届け先指定チェック
function chkTodokesaki(count) {
	//チェックがない場合エラー
	for (var idx=1;idx<=count;idx++) {
		if (document.getElementById("chk_id_"+idx).checked) {
			return true;
		}
	}
	alert("お届け先を選択してください。");
	return false;
}

//submit
function funSubmit(pcount,tcount,form) {

	if (!chkProduct(pcount)) {
		return false;
	}
	if (!chkTodokesaki(tcount)) {
		return false;
	}

	form.action="/shopping/deliv.php"
	form.submit();
	return false;
}

function funCartSubmit(form) {
	form.mode.value = "customer_buystep";
	form.action="/shopping/deliv.php"
	form.submit();
	return false;
}
// レビューの確認画面で「戻る」
function funRevBack(form) {
	form.mode.value = "revback";
	form.action="/review/"
	form.submit();
	return false;
}

//tdクリックでradio on
function funTdClick(idx) {
	if (document.getElementById("pay_"+idx).checked) {
//		document.getElementById("pay_"+idx).checked = false;
	} else {
		document.getElementById("pay_"+idx).checked = true;
	}

	funChgTrColor();
	return true;
}
//選択した支払い方法の行に色
function funChgTrColor() {
	for(var idx=1;idx<=3;idx++) {
		if (document.getElementById("paytr_"+idx)) {
			if (document.getElementById("pay_"+idx).checked) {
				document.getElementById("paytr_"+idx).style.backgroundColor="#ffffcc";
			} else {
				document.getElementById("paytr_"+idx).style.backgroundColor="#faf8f0";
			}
		}
	}
}

//tdクリックでradio on
function funTdClickRdOn(objNm, rowCnt, objhNm) {
	if (!document.getElementById(objNm)) {
		return;
	}
	if (document.getElementById(objNm).checked) {
//		document.getElementById(objNm).checked = false;
	} else {
		document.getElementById(objNm).checked = true;
	}
	funTrChgColor(rowCnt, objhNm);
	return true;
}
//選択したradioの行に色
function funTrChgColor(rowCnt,objhNm) {
	//クリア
	for(var idx=1;idx<=rowCnt;idx++) {
		if (!document.getElementById("tr_"+idx)) {
			return;
		}
		document.getElementById("tr_"+idx).style.backgroundColor="#ffffff";
	}
	for(var idx=1;idx<=rowCnt;idx++) {
		if (!document.getElementById(objhNm+"_"+idx)) {
			return;
		}
		if (document.getElementById(objhNm+"_"+idx).checked) {
			document.getElementById("tr_"+idx).style.backgroundColor="#ffffcc";
			break;
		}
	}
}
//tdクリックでcheck deliv.phpのお届け先
function funTdClickChkOn(idx, issmph) {
	if (document.getElementById("chk_id_"+idx).checked) {
		document.getElementById("chk_id_"+idx).checked=false;
	} else {
		document.getElementById("chk_id_"+idx).checked=true;
	}
	funTdChkChgColor(idx, issmph);
}
//選択したcheckboxの行のtdに色
function funTdChkChgColor(idx, issmph) {
	if (!document.getElementById("hidari"+idx)) {
		return;
	}
	if (!document.getElementById("chk_id_"+idx)) {
		return;
	}
	var clr="#faf8f0";
	if (issmph==1){
		clr="#ffffff";
	}
	if (document.getElementById("chk_id_"+idx).checked) {
		document.getElementById("hidari"+idx).style.backgroundColor="#ffffcc";
		document.getElementById("naka1"+idx).style.backgroundColor="#ffffcc";
		document.getElementById("naka2"+idx).style.backgroundColor="#ffffcc";
		if (issmph==1){
			document.getElementById("naka3"+idx).style.backgroundColor="#ffffcc";
			document.getElementById("migi"+idx).style.backgroundColor="#ffffcc";
		}
	} else {
		document.getElementById("hidari"+idx).style.backgroundColor=clr;
		document.getElementById("naka1"+idx).style.backgroundColor=clr;
		document.getElementById("naka2"+idx).style.backgroundColor=clr;
		if (issmph==1){
			document.getElementById("naka3"+idx).style.backgroundColor=clr;
			document.getElementById("migi"+idx).style.backgroundColor=clr;
		}
	}
}
//mousemoveでtdに色
function funTdChgBkColor(obj, flg ,issmph) {
	var clr="#faf8f0";
	if (issmph==1){
		clr="#fff";
	}
	if (flg) {
		obj.style.backgroundColor="#ffff99";
	} else {
		obj.style.backgroundColor=clr;
	}
}

//tdクリックでcheck deliv.phpの商品
function funPdTdClickChkOn(objChkNm, idx, issmph) {
	if (document.getElementById(objChkNm).checked) {
		document.getElementById(objChkNm).checked=false;
	} else {
		document.getElementById(objChkNm).checked=true;
	}
	funPdTrChkChgColor(objChkNm, idx, issmph);
}
//選択したcheckboxの行のtrに色
function funPdTrChkChgColor(objChkNm, idx, issmph) {
	if (!document.getElementById("pd_tr_"+idx)) {
		return;
	}
	if (!document.getElementById(objChkNm)) {
		return;
	}
	var clr="#faf8f0";
	if (issmph==1){
		clr="#ffffff";
	}
	if (document.getElementById(objChkNm).checked) {
		document.getElementById("pd_tr_"+idx).style.backgroundColor="#ffffcc";
	} else {
		document.getElementById("pd_tr_"+idx).style.backgroundColor=clr;
	}
}
//選択したcheckboxの行に色 onload版
function funPdTrChkChgColor_onl(rowCnt, issmph) {
	if (!document.getElementById("pdct_chk_1")) {
		return;
	}
	var clr="#faf8f0";
	if (issmph==1){
		clr="#ffffff";
	}
	//クリア
	for(var idx=1;idx<=rowCnt;idx++) {
		if (!document.getElementById("pd_tr_"+idx)) {
			return;
		}
		document.getElementById("pd_tr_"+idx).style.backgroundColor=clr;
	}
	for(var idx=1;idx<=rowCnt;idx++) {
		if (!document.getElementById("pdct_chk_"+idx)) {
			return;
		}
		if (document.getElementById("pdct_chk_"+idx).checked) {
			document.getElementById("pd_tr_"+idx).style.backgroundColor="#ffffcc";
		}
	}
}

