/*
=========================================================================================
@　メールアドレスのチェック
	"email",     labName, obj, checktype1, checktype2 .....

A　携帯メールアドレスのチェック
	"email1",    labName, obj, checktype1, checktype2 .....

	var data = [ 
				 ["email",     "メールアドレス", [frm.mailAddress], ["require", "length,12,18"] ],
				 ["email1",   "携帯メールアドレス",[frm.email],["length,0,255"] ],
				 ["password",  "パスワード",     [frm.password1, frm.password2], ["require", "alphanumeric","length,2,10"] ],
				 ["common",    "お名前",         [frm.userName], ["require", "katagana","length,3,10"] ],
				 ["common",    "お名前",         [frm.year, frm.userName2], ["length,3,10"] ],
				 ["zipcode1",  "郵便番号",       [frm.zip] ],
				 ["telephone1","電話番号",       [frm.tel1, frm.tel2, frm.tel3] ],
				 ["date",     "日付1",          [frm.userName2], ["require"] ],
				 ["date",     "日付2",          [frm.year, frm.month, frm.day] , ["require"] ],
			   ];

A　郵便番号のチェック( xxx、xxx-xx 、xxx-xxxx )
	"zipcode",   labName, obj, checktype1, checktype2 .....

B　郵便番号のチェック１( xxx-xxxx )
	"zipcode1",  labName, obj, checktype1, checktype2 .....

C　電話番号のチェック
	"telephone", labName, obj1, obj2, obj3, checktype1, checktype2 .....

D　電話番号のチェック１(市外局番 ２〜５、市内局番 １〜５、電話番号 ４〜４)
	"telephone1",labName, obj1, obj2, obj3, checktype1, checktype2 .....

E　電話番号のチェック２(2つのハイフンを含めて13以下)
	"telephone2",labName, obj1, obj2, obj3, checktype1, checktype2 .....

F　パスワードチェック
	"password",  labName, obj1, obj2, checktype1, checktype2 .....

G　日付のチェック１
	"date",      labName, obj, checktype1, checktype2 .....

H　日付のチェック２
	"date",      labName, obj1, obj2, obj3, checktype1, checktype2 .....

I　その他チェック
	"common",    labName, obj, checktype1, checktype2 .....

J　その他チェック１
	"common",    labName, obj1, obj2, checktype1, checktype2 .....

=========================================================================================
checktype
	require			: 必須入力のチェック
	katagana		: 全角片仮名のチェック
	zenletter		: 全角文字のチェック
	alphanumeric	: 半角英数字のチェック
	length,min,max	: 入力長さのチェック
	
=========================================================================================
Sample

	var frm = document.UserRegisterForm;
	var data = [ 
				 ["email",     "メールアドレス", [frm.mailAddress],               ["require", "length,12,18"]                ],
				 ["password",  "パスワード",     [frm.password1, frm.password2],  ["require", "alphanumeric","length,2,10"]  ],
				 ["common",    "お名前",         [frm.userName],                  ["require", "katagana","length,3,10"]      ],
				 ["common",    "お名前",         [frm.year, frm.userName2],       ["length,3,10"]                            ],
				 ["zipcode1",  "郵便番号",       [frm.zip]                                                                   ],
				 ["telephone1","電話番号",       [frm.tel1, frm.tel2, frm.tel3]                                              ],
				 ["date",      "日付1",          [frm.userName2],                 ["require"]                                ],
				 ["date",      "日付2",          [frm.year, frm.month, frm.day] , ["require"]                                ],
				 ["saledate",  "開催期間",       [frm.year, frm.month, frm.day,frm.endyear, frm.endmonth, frm.endday]		],
			   ];

	if(checkData(data))
	{
		document.UserRegisterForm.submit();
	}
=========================================================================================
*/


var _Com_Host_noSSL          = "";
var _Com_Host_SSL            = "";
var _Com_ContextPath         = "";
var	_Com_Goods_disCnt        = "";   //displaycount.GoodsList
var	_Com_CommentUser_disCnt  = "";   //displaycount.CommentUser
var	_Com_CommentGoods_disCnt = "";   //displaycount.CommentGoods
var	_Com_SaleList_disCnt     = "";   //displaycount.ComSaleList
var	_Com_Settlement_disCnt   = "";   //displaycount.Settlement
var	_Com_GoodsInfo_disCnt    = "";   //displaycount.GoodsInfoList
var _Com_Comment_disCnt      = "";   //displaycount.Comment

var _Message_Email ;
var _Message_Zipcode ;
var _Message_Telephone ;
var _Message_Password ;
var _Message_Date ;
var _Message_Date1 ;
var _Message_Field ;
var _Message_Numeric ;
var _Message_Require ;
var _Message_Alphanumeric ;
var _Message_Zenletter ;
var _Message_Katagana ;
var _Message_Length1 ;
var _Message_Length2 ;
var _Message_Length3 ;

var _Message_Numeric2 ;
var _Message_Numeric3 ;
var _Message_Numeric9 ;
var _Message_Length4 ;
var _Message_Katagana2 ;
var _Message_Csv;

function checkData(dataArr)
{
	var errMsg = "";
	var errObj;
	if(dataArr)
	{
		for(var i=dataArr.length-1; i>=0; i--)
		{
			if(dataArr[i] && (dataArr[i].length >= 3))
			{
				var type = dataArr[i][0];
				var name = dataArr[i][1];
				var obj  = dataArr[i][2];
				var text = obj[0].value;
				var itemMsg = "";

				// メールアドレスのチェック。
				if(type.indexOf("email") == 0)
				{
					if((text.length > 0) && (((type == "email1") && !_checkEMail_1(text)) ||
					   ((type == "email")  && !_checkEMail(text))  ) )
					{
						//XXXXの入力に誤りがあります。
						itemMsg = _Message_Email[0] + name + _Message_Email[1]; 
					}
				}
				// 郵便番号のチェック。
				else if(type.indexOf("zipcode") == 0)
				{
					if(obj.length >= 2)
					{
						var text2 = obj[1].value;
						if(text2.length > 0)
						{
							text += "-" + text2;
						}
					}
					if((text.length > 0) && (((type == "zipcode1") && !_checkZip_1(text)) ||
					                         ((type == "zipcode")  && !_checkZip(text))  ) )
					{
						//XXXXの入力に誤りがあります。
						itemMsg = _Message_Zipcode[0] + name + _Message_Zipcode[1];
					}
				}
				// 電話番号のチェック。
				else if(type.indexOf("telephone") == 0)
				{
					if(obj.length >= 3)
					{
						var text2 = obj[1].value;
						var text3 = obj[2].value;
						if(text2.length > 0)
						{
							text += "-" + text2;
						}
						if(text3.length > 0)
						{
							text += "-" + text3;
						}
					}
					if((text.length > 0) && (((type == "telephone1") && !_checkTel_1(text)) ||
					                         ((type == "telephone2") && !_checkTel_2(text)) ||
					                         ((type == "telephone")  && !_checkTel(text))  ) )
					{
						//XXXXの入力に誤りがあります。
						itemMsg = _Message_Telephone[0] + name + _Message_Telephone[1];
					}
				}
				
				//カードのチェック。
				else if (type.indexOf("card") == 0)
				{
					if(obj.length >= 4)
					{
						var text2 = obj[1].value;
						var text3 = obj[2].value;
						var text4 = obj[3].value;
						if(text2.length > 0)
						{
							text += "-" + text2;
						}
						if(text3.length > 0)
						{
							text += "-" + text3;
						}
						if(text4.length > 0)
						{
							text += "-" + text4;
						}
					}
					if ((text.length > 0) && !_checkCard(text))
					{ 
						//XXXXの入力に誤りがあります。
						itemMsg = _Message_Card[0] + name + _Message_Card[1];
					}
				}
				// パスワードチェック。
				else if(type.indexOf("password") == 0)
				{
					var text2 = "";
					if(obj.length >= 2)
					{
						text2 = obj[1].value;
					}
					if((text.length > 0) && (text != text2))
					{
						//XXXXと確認用XXXXが一致しません。
						if(name[0] && name[1])
						{
							itemMsg = _Message_Password[0] + name[0] + _Message_Password[1] + name[1] + _Message_Password[2];
						}
						else
						{
							itemMsg = _Message_Password[0] + name + _Message_Password[1] + name + _Message_Password[2];
						}
					}
					if(name[0] && name[1])
					{
						name = name[0];
					}
				}
				// 日付のチェック。
				else if(type.indexOf("date") == 0)
				{
					text  = getValue(obj[0], true);
					if(obj.length >= 3)
					{
						var text2 = getValue(obj[1], true);
						var text3 = getValue(obj[2], true);
						if(text2.length > 0)
						{
							text += "/" + text2;
						}
						if(text3.length > 0)
						{
							text += "/" + text3;
						}
					}
					if((text.length > 0) && !_checkDate(text))
					{
						if(type == ("date1"))
						{
							//
							//XXXXの指定方法に誤りがあります。
							itemMsg = _Message_Date1[0] + name + _Message_Date1[1];
						}
						else
						{
							//XXXXの入力に誤りがあります。
							itemMsg = _Message_Date[0] + name + _Message_Date[1];
						}
					}
				}
				// 半角数字の範囲チェック。
				else if(type.indexOf("field") == 0)
				{
					text  = getValue(obj[0], true);
					var text2 = "";
					if(obj.length >= 2)
					{
						text2 = getValue(obj[1], true);
						if(text.length > 0 && text2.length > 0)
						{
							if(parseInt(text,10) > parseInt(text2,10))
							{
								//XXXXの指定方法に誤りがあります。
								itemMsg = _Message_Field[0] + name + _Message_Field[1];
							}
						}
					}
				}
				
				// その他チェック。
				else if(type.indexOf("common") == 0)
				{
					text  = getValue(obj[0], false);
					for(var j=1; j<obj.length; j++)
					{
						var text2 = getValue(obj[j], false);
						text += text2;
					}
				}
				

				if(itemMsg.length == 0)
				{
					itemMsg = checkItem(name, text, dataArr[i][3]);
				}
				
				if(itemMsg.length > 0)
				{
					if(errMsg.length == 0)
					{
						errMsg = itemMsg;
					}
					else
					{
						errMsg = itemMsg + "\r\n" + errMsg;
					}
					errObj = obj[0];
				}
			}			
		}

		if(errMsg.length > 0)
		{
			alert(errMsg);
			errObj.focus();
			return false;
		}
		else
		{
			return true;
		}
	}
}

function checkItem(name, text, itemRule)
{
	if(itemRule && itemRule.length > 0)
	{
		for(var j=0; j<itemRule.length; j++)
		{
			var itemArr = itemRule[j].split(",");
			var type = itemArr[0];

			// 必須入力のチェック
			if(type.indexOf("require") == 0)
			{
				if(comTrim(text).length==0)
				{
					//XXXXを入力してください。
					return (_Message_Require[0] + name + _Message_Require[1]);
				}
			}
			// 半角英数字のチェック
			else if(type.indexOf("alphanumeric") == 0)
			{
				if(!_checkAlphanumeric(text))
				{
					//XXXXの入力に誤りがあります。
					return (_Message_Alphanumeric[0] + name + _Message_Alphanumeric[1]);
				}
			}
			// 半角数字のチェック
			else if(type.indexOf("numeric") == 0)
			{
				if(type=="numeric9")
				{
					var len = itemArr[1];
					if(!_checkNumber(text) || (len != getStringLenth(text)))
					{
						//XXXXはM桁の半角数字で入力してください。
						return (_Message_Numeric9[0] + name + _Message_Numeric9[1] + len + _Message_Numeric9[2]);
					}
				}
				else
				{
					if(!_checkNumber(text))
					{
						if(type=="numeric2")
						{
							//XXXXの入力に誤りがあります。
							return (_Message_Numeric2[0] + name + _Message_Numeric2[1]);
						}
						else if(type=="numeric3")
						{
							//XXXXは半角数字で入力してください。
							return (_Message_Numeric3[0] + name + _Message_Numeric3[1]);
						}
						else
						{
							//XXXXは半角数字で指定してください。
							return (_Message_Numeric[0] + name + _Message_Numeric[1]);
						}
					}
				}
			}
			// 全角文字のチェック
			else if(type.indexOf("zenletter") == 0)
			{
				if(!_checkZenletter(text))
				{
					//XXXXは全角文字のみで入力してください。
					return (_Message_Zenletter[0] + name + _Message_Zenletter[1]);
				}
			}
			// 全角片仮名のチェック
			else if(type.indexOf("katagana") == 0)
			{
				if(type=="katagana2")
				{
					if(!_checkKatagana2(text))
					{
						//XXXXは全角カタカナ、または許可されている全角記号で入力してください。
						return (_Message_Katagana2[0] + name + _Message_Katagana2[1]);
					}
				}
				else
				{
					if(!_checkKatagana(text))
					{
						//XXXXは全角カタカナで指定してください。	????
						//XXXXの入力に誤りがあります。
						return (_Message_Katagana[0] + name + _Message_Katagana[1]);
					}
				}
			}
			// 入力長さのチェック
			else if(type.indexOf("length") == 0)
			{
				if(itemArr.length >= 3)
				{
					var minlen = itemArr[1];
					var maxlen = itemArr[2];
					var len = getStringLenth(text);

					if((minlen > 0) && (len < minlen))
					{
						//XXXXはMM文字以上MM文字以内で入力してください。
						return (_Message_Length1[0] + name + _Message_Length1[1] + minlen + _Message_Length1[2] + maxlen + _Message_Length1[3]);
					}
					if((maxlen > 0) && (len > maxlen))
					{
						if(type == "length4")
						{
							//XXXXはMM桁以内で入力してください。
							return (_Message_Length4[0] + name + _Message_Length4[1] + maxlen + _Message_Length4[2]);
						}
						else if(type == "length2")
						{
							//XXXX全角MM文字以内もしくは半角MM文字以内で入力してください。
							return (_Message_Length2[0] + name + _Message_Length2[1] + Math.floor(maxlen / 2) + _Message_Length2[2] + maxlen + _Message_Length2[3]);
						}
						else
						{
							//XXXXは全角MM文字以内もしくは半角MM文字以内で入力してください。
							return (_Message_Length3[0] + name + _Message_Length3[1] + Math.floor(maxlen / 2) + _Message_Length3[2] + maxlen + _Message_Length3[3]);
						}
					}
				}
			}
			else if (type.indexOf("csv") == 0)
			{
				if(!_checkCsv(text))
				{
					//XXXXの入力に誤りがあります。
					return (_Message_Csv[0] + name + _Message_Csv[1]);
				}

			}
		}
	}
	return "";
}


/* =============================================================================== */

/*
 * オブジェクトの文字で取り出します。
 *
 * obj    : オブジェクト
 * 戻り値 : オブジェクトの文字
 */
function getValue(obj, isVal)
{
	var test = "";
	if(obj.type == "select-one")
	{
		if(isVal)
		{
			text = obj[obj.selectedIndex].value;
		}
		else
		{
			text = obj[obj.selectedIndex].text;
		}
	}
	else
	{
		text = obj.value;
	}
	if(!text)
	{
		text = "";
	}
	return text;
}

//trim space of left
function comLTrim(str){
    var rtnStr;
    rtnStr="";
    for (var i=0;i<str.length;i++){
        if (str.charAt(i)!=" " && str.charAt(i)!="　"){
        rtnStr=str.substr(i);
        break;
    }
    }
    return rtnStr;
}

//trim space of right
function comRTrim(str){
    var rtnStr;
    rtnStr="";
    for (var i=str.length-1;i>=0;i--){
        if (str.charAt(i)!=" " && str.charAt(i)!="　"){
            rtnStr=str.substring(0,i+1);
            break;
        }
    }
    return rtnStr;
}

//trim all space
function comTrim(str){
    return(comLTrim(comRTrim(str)));
}

/*
 * 半角・全角の混在する文字列を同じ半角換算文字長で取り出します。
 *
 * text   : 混在する文字列
 * 戻り値 : 文字長
 */
function getStringLenth(text)
{
	var len=0;

	for( var i=0; i< text.length; i++ )
	{
		if ((text.charCodeAt(i) < 128 ) || ((text.charCodeAt(i) > 65376 )&&(text.charCodeAt(i) <65440 )))
		{
			len++;
		}
		else
		{
			len +=2;
		}
	}	
	
	return (len);
}

/*
 * 半角数字チェック。
 * 半角数字かどうかを調べるには、半角数字以外かどうかを調べることで判別することができます。
 *
 * text   : チェックする文字列
 * 戻り値 : 半角数字列の場合 true, 半角数字列でない場合 false
 */
function _checkNumber(text)
{
	data = text.match(/[^0-9]+/);

	return (!data);
}



/*
 * 半角英文字のチェック。
 * 半角英文字かどうかを調べるには、半角英文字以外かどうかを調べることで判別することができます。
 *
 * text   : チェックする文字列
 * 戻り値 : 半角英文字列の場合 true, 半角英文字列でない場合 false
 */
function _checkAlphabet(text)
{
	data = text.match(/[^A-Za-z]+/);

	return (!data);
}

/*
 * 半角英数字のチェック。
 * 半角英数字かどうかを調べるには、半角英数字以外かどうかを調べることで判別することができます。
 *
 * text   : チェックする文字列
 * 戻り値 : 半角英数字列の場合 true, 半角英数字列でない場合 false
 */
function _checkAlphanumeric(text)
{
	data = text.match(/[^0-9A-Za-z]+/);

	return (!data);
}


/*
 * 全角片仮名のチェック。
 * 全角片仮名かどうかを調べるには、全角片仮名以外かどうかを調べることで判別することができます。
 *
 * text   : チェックする文字列
 * 戻り値 : 全角片仮名列の場合 true, 全角片仮名列でない場合 false
 */
function _checkKatagana(text)
{
	data = text.match(/[^ァ-ンー]+/);
	return (!data);
}

/*
 * 全角平仮名のチェック。
 * 全角平仮名かどうかを調べるには、全角平仮名以外かどうかを調べることで判別することができます。
 *
 * text   : チェックする文字列
 * 戻り値 : 全角平仮名列の場合 true, 全角平仮名列でない場合 false
 */
function _checkHiragana(text)
{
	data = text.match(/[^ぁ-ん　\s]+/);

	return (!data);
}

/*
 * 全角仮名のチェック。
 * 全角仮名かどうかを調べるには、全角仮名以外かどうかを調べることで判別することができます。
 *
 * text   : チェックする文字列
 * 戻り値 : 全角仮名列の場合 true, 全角仮名列でない場合 false
 */
function _checkZengana(text)
{
	data = text.match(/[^ぁ-んァ-ン　\s]+/);

	return (!data);
}

/*
 * 全角文字のチェック。
 * 全角文字かどうかを調べるには、全角文字以外かどうかを調べることで判別することができます。
 *
 * text   : チェックする文字列
 * 戻り値 : 全角文字名列の場合 true, 全角文字列でない場合 false
 */
function _checkZenletter(text)
{
	for (var i = 0; i < text.length; i++)
	{
        var c = text.charCodeAt(i);
        //  半角カタカナは不許可
        if (c < 256 || (c >= 0xff61 && c <= 0xff9f))
		{
          return false;
        }
    }
    return true;
}

/*
 * 日付チェック値が存在しうる日付かをチェックします。。
 *
 * text   : チェックする文字列
 * 戻り値 : 日付の場合 true,日付でない場合 false
 */

function _checkDate(text)
{
	var arrDate = text.split("/");
	if(arrDate.length == 3 && (arrDate[0] >= 1753 && arrDate[0] <= 9999) && (arrDate[1].length <= 2 && arrDate[1] > 0 && arrDate[1] <= 12) && (arrDate[2].length <= 2 && arrDate[2] > 0 && arrDate[2] <= 31))
	{	
		var date = new Date(arrDate[0] , arrDate[1] - 1 ,arrDate[2]);
		if(date.getFullYear() == arrDate[0] && (date.getMonth() == arrDate[1] - 1) && date.getDate() == arrDate[2])
		{
			return true;
		}
	}

	return false;
}

/*
 * 電話番号のチェック。
 * 電話番号は市外局番で始まり合計10桁の数値で構成されています。なお、-（ハイフン）は
 * 含まれるという条件付きであり-なしの場合はサンプルではチェックしていません。
 *
 * text   : チェックする文字列
 * 戻り値 : 有効の場合 true, 無効の場合 false
 */
function _checkTel(text)
{
    data1 = text.match(/^[0-9-]{6,9}$|^[0-9-]{12}$/);
    data2 = text.match(/^\d{1,4}-\d{4}$|^\d{2,5}-\d{1,4}-\d{4}$/);

	return (data1 && data2);
}

/*
 * カードチェック
 * ハイフンを含めて7または15
 *　text   :チェックする文字列
 * 戻り値 : カード列の場合 true, カード列でない場合 false
 */
function _checkCard(text)
{
	data1 = text.match(/^[0-9-]{7,19}$/);
	data2 = text.match(/^\d{1,4}-\d{1,4}-\d{1,4}-\d{1,4}$/);
	return (data1 && data2);
}
/*
 * 電話番号のチェック。
 * 市外局番 ２〜５、市内局番 １〜５、電話番号 ４〜４。
 * ハイフンを含めて12または13
 *
 * text   : チェックする文字列
 * 戻り値 : 有効の場合 true, 無効の場合 false
 */
function _checkTel_1(text)
{
	data1 = text.match(/^[0-9-]{12,13}$/);
	data2 = text.match(/^\d{2,5}-\d{1,5}-\d{4}$/);

	return (data1 && data2);
}

/*
 * 電話番号のチェック。
 * 2つのハイフンを含めて13以下。
 *
 * text   : チェックする文字列
 * 戻り値 : 有効の場合 true, 無効の場合 false
 */
function _checkTel_2(text)
{
    data = text.match(/^[0-9-]{1,13}$/);

	return (data);
}

/*
 * 郵便番号のチェック。
 * 郵便番号は３桁(nnn)、３桁と-２桁(xxx-xx)または３桁と-４桁(xxx-xxxx)の数値となります。
 *
 * text   : チェックする文字列
 * 戻り値 : 有効の場合 true, 無効の場合 false
 */
function _checkZip(text)
{
	data = text.match(/^\d{3}-\d{4}$|^\d{3}-\d{2}$|^\d{3}$/);

	return (data);
}

/*
 * 郵便番号のチェック。
 * 郵便番号は３桁と-４桁(xxx-xxxx)の数値となります。
 *
 * text   : チェックする文字列
 * 戻り値 : 有効の場合 true, 無効の場合 false
 */
function _checkZip_1(text)
{
	data = text.match(/^\d{3}-\d{4}$/);

	return (data);
}

/*
 * メールアドレスのチェック。
 * メールアドレスをチェックするには、状況に応じていくつかのパターンがあります。
 * サンプルでは最もシンプルな「アカウント名@ドメイン名」をチェックします。
 *
 * text   : チェックする文字列
 * 戻り値 : 有効の場合 true, 無効の場合 false
 */
function _checkEMail(text)
{
	data = text.match(/^[\s]*[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+[\s]*$/);
    //data1 = text.toLowerCase( ).match(/@docomo\.|@vodafone\.|@au\.|@tu-ka\.|@ezweb.ne.jp|@sky.tkk.ne.jp|@sky.tkc.ne.jp/);
	data1 = text.toLowerCase( ).match(/(\.|@)+(docomo.ne.jp|vodafone.ne.jp|tu-ka.ne.jp|ezweb.ne.jp|sky.tkk.ne.jp|sky.tkc.ne.jp)$/);
	return (data && !data1);
}

/*
 * 携帯メールアドレスのチェック。
 * 携帯メールアドレスをチェックするには、状況に応じていくつかのパターンがあります。
 * サンプルでは最もシンプルな「アカウント名@ドメイン名」をチェックします。
 *
 * text   : チェックする文字列
 * 戻り値 : 有効の場合 true, 無効の場合 false
 */
function _checkEMail_1(text)
{
	/* data = text.match(/^[\s]*[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+[\s]*$/); */
	data = text.match(/^[\s]*([\w-\.]+)*@[\w-]+(\.[\w-]+)+[\s]*$/);
	return (data);
}

/*
 * 
 * frm    : 
 * host   : 
 * 戻り値 : 
 */
function setActionUrl(frm, host)
{
	var urlAct = frm.action;
	if((urlAct.indexOf("http://") == 0) || (urlAct.indexOf("https://") == 0))
	{
		var startPos = urlAct.indexOf("//") + 2;
		var endPos   = urlAct.indexOf("/", startPos);
		var urlAct   = urlAct.substring(endPos);
	}
	frm.action = host + urlAct;
}

/*
 * history.back() times
 * frm    : 
 * host   : 
 * 戻り値 : 
 */
function setBackCnt(frm)
{
	var cnt = frm.gobackCnt.value;
	if(cnt == "")
	{
		cnt = "0";
	}
	cnt = parseInt(cnt) + 1;
	frm.backCnt.value = cnt;
}

/*
 * history.go()
 * frm    : 
 * host   : 
 * 戻り値 : 
 */
function goBack(frm)
{
	var cnt = frm.gobackCnt.value;
	if(cnt == "")
	{
		cnt = "0";
	}
	history.go(-1 * (parseInt(cnt) + 1));
}

/*
 * check saledate
 * frm    : 
 * host   : 
 */
function checkSaleDate(text)
{
	
	data = text.match(/^\/\/$|^\d{4}\/\/$|^\d{4}\/\d{2}\/$|^\d{4}\/\d{2}\/\d{2}$/);
	
	if (data)
	{
		data1 = text.match(/^\d{4}\/\d{2}\/\d{2}$/);
		if (data1)
		{
			if(!_checkDate(text))
			{
				return;
			}
		}
	}
	return data;
}

/*
 * compare saledate
 * frm    : 
 * host   : 
 */
function compareDate(text,text1)
{
	var startdate = text.split("/");
	var enddate = text1.split("/");
	var dateS = new Date(startdate[0] , startdate[1] - 1 ,startdate[2]);
	var dateE = new Date(enddate[0] , enddate[1] - 1 ,enddate[2]);

	if(dateS>dateE){
		return true;
	}
	
	return false
}

var is_Submit = false;

/*
 * 
 */
function ownsubmit(frm)
{
	if(canSubmit())
	{
		is_Submit = true;
		frm.submit();
	}
}

/*
 * 
 */
function canSubmit()
{
	return !is_Submit;
}

/*
 *
 */
function setInitData(noSSL, SSL, path, cnt1, cnt2, cnt3, cnt4, cnt5, cnt6, cnt7)
{
	_Com_Host_noSSL          = noSSL;
	_Com_Host_SSL            = SSL;
	_Com_ContextPath         = path;
	_Com_Goods_disCnt        = cnt1;
	_Com_CommentUser_disCnt  = cnt2;
	_Com_CommentGoods_disCnt = cnt3
	_Com_SaleList_disCnt     = cnt4;
	_Com_Settlement_disCnt   = cnt5;
	_Com_GoodsInfo_disCnt    = cnt6;
	_Com_Comment_disCnt      = cnt7;
}

function setMessageData(email, zipcode, telephone, password, date, 
						date1, numeric, field, require, alphanumeric, 
						zenletter, katagana, length1, length2, length3,
						numeric2, numeric3, numeric9, length4, katagana2,
						card,csv)
{
	_Message_Email        = email.split("#");
	_Message_Zipcode      = zipcode.split("#");
	_Message_Telephone    = telephone.split("#");
	_Message_Password     = password.split("#");
	_Message_Date         = date.split("#");
	_Message_Date1        = date1.split("#");
    _Message_Numeric      = numeric.split("#");
	_Message_Field        = field.split("#");
	_Message_Require      = require.split("#");
	_Message_Alphanumeric = alphanumeric.split("#");
	_Message_Zenletter    = zenletter.split("#");
	_Message_Katagana     = katagana.split("#");
	_Message_Length1      = length1.split("#");
	_Message_Length2      = length2.split("#");
	_Message_Length3      = length3.split("#");

	_Message_Numeric2     = numeric2.split("#");
	_Message_Numeric3     = numeric3.split("#");
	_Message_Numeric9     = numeric9.split("#");
	_Message_Length4      = length4.split("#");
	_Message_Katagana2    = katagana2.split("#");
	_Message_Card         = card.split("#");
	_Message_Csv          = csv.split("#");
}

/*
 *
 */
function submitNormal(frm)
{
	setActionUrl(frm, _Com_Host_noSSL);
	if(canSubmit())
	{
		is_Submit = true;
		frm.submit();
	}
}

/*
 *
 */
function submitSSL(frm)
{
	setActionUrl(frm, _Com_Host_SSL)
	if(canSubmit())
	{
		is_Submit = true;
		frm.submit();
	}
}

/*
 * 
 */
function fncCom( id, flg, evt )
{
	var vis = "visible";
	var intDifX = 10;
	var intDifY = 5;
   myOP = (navigator.userAgent.indexOf("Opera",0) != -1)?1:0; //OP
   myN6 = document.getElementById;  // N6 or IE
   myIE = document.all;             // IE
   myN4 = document.layers;          // N4

   if (myOP){                          // OP?
	  	obj  = document.getElementById(id).style;
		intX = intDifX + window.event.clientX;
		intY = intDifY + window.event.clientY;
		intW = document.body.clientWidth  - intX - 10;
   }else if (myIE){                    // IE?
		obj  = document.all( id ).style;
	    intX = document.body.scrollLeft || document.documentElement.scrollLeft;
	    intY = document.body.scrollTop  || document.documentElement.scrollTop;
		intX = intX + intDifX + window.event.clientX; 
		intY = intY + intDifY + window.event.clientY;
		intW = document.body.clientWidth  - intX - 10;
   }else if (myN6){                    // N6?
	  	obj  = document.getElementById(id).style;
	  	intX = intDifX + evt.clientX + window.pageXOffset;
	  	intY = intDifY + evt.clientY + window.pageYOffset;
		intW = document.body.clientWidth  - intX - 10;
   }else if (myN4){                    // N4?
		obj  = document[id];
	  	intX = intDifX + evt.x;
	  	intY = intDifY + evt.y;
		intW = document.body.clientWidth  - intX - 10;
   }
	if(intW < 100) intW = 100;
	if(intW > 300) intW = 300;
	if( flg == 0 ) vis = "hidden";
	obj.left = intX + "px";
	obj.top  = intY + "px";
	obj.width = intW + "px";
	obj.visibility = vis;
}

/* 全角カナ，．「」（全角スペース）ー―−‐／＼￥チェック */
function _checkKatagana2(strValue)
{
  strValue = comTrim(strValue);
  data = strValue.match(/[^ァ-ン，．「」（　）ー―−‐／＼￥]+/);
  return (!data);
}

/* 「<」「>」「"」「'」 チェック*/
function _checkCsv(strValue)
{
	strValue=comTrim(strValue);
	if (strValue != "")
	{
		data=strValue.match(/[\"\'<>]+/);
		return !data;
	}
	return true;
}

/* ショップ情報ページが表示する */ 
function showShopInfo(companycode,name)
{
	
	var theURL   = _Com_ContextPath+"/customer/ShopInfo.do?companyCode="+companycode;
	
	if (name != undefined)
	{
		theURL += "#" + name;
	}
	var winName  = "shopinfo";
	var features = "toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=600";
	window.open(theURL,winName,features);
}

function showSafetyPolicy(companycode)
{
	var theURL	= _Com_ContextPath+"/customer/SafetyInfo.do?companyCode="+companycode;
	var winName  = "safetyinfo";
	var features = "toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=550";
	window.open(theURL,winName,features);
}	

	/* utf.js - UTF-8 <=> UTF-16 convertion
	 *
	 * Copyright (C) 1999 Masanao Izumo <mo@goice.co.jp>
	 * Version: 1.0
	 * LastModified: Dec 25 1999
	 * This library is free.  You can redistribute it and/or modify it.
	 */
	
	/*
	 * Interfaces:
	 * utf8 = utf16to8(utf16);
	 * utf16 = utf16to8(utf8);
	 */
	
	function utf16to8(str) {
	    var out, i, len, c;
	
	    out = "";
	    len = str.length;
	    for(i = 0; i < len; i++) {
		c = str.charCodeAt(i);
		if ((c >= 0x0001) && (c <= 0x007F)) {
		    out += str.charAt(i);
		} else if (c > 0x07FF) {
		    out += String.fromCharCode(0xE0 | ((c >> 12) & 0x0F));
		    out += String.fromCharCode(0x80 | ((c >>  6) & 0x3F));
		    out += String.fromCharCode(0x80 | ((c >>  0) & 0x3F));
		} else {
		    out += String.fromCharCode(0xC0 | ((c >>  6) & 0x1F));
		    out += String.fromCharCode(0x80 | ((c >>  0) & 0x3F));
		}
	    }
	    return out;
	}
	
	function utf8to16(str) {
	    var out, i, len, c;
	    var char2, char3;
	
	    out = "";
	    len = str.length;
	    i = 0;
	    d=""
	    while(i < len) {
			c = str.charCodeAt(i++);
			d+=c
			switch(c >> 4)
			{ 
			  case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7:
			    // 0xxxxxxx
			    out += str.charAt(i-1);
			    break;
			  case 12: case 13:
			    // 110x xxxx   10xx xxxx
			    char2 = str.charCodeAt(i++);
			    out += String.fromCharCode(((c & 0x1F) << 6) | (char2 & 0x3F));
			    break;
			  case 14:
			    // 1110 xxxx  10xx xxxx  10xx xxxx
			    char2 = str.charCodeAt(i++);
			    char3 = str.charCodeAt(i++);
			    out += String.fromCharCode(((c & 0x0F) << 12) |
							   ((char2 & 0x3F) << 6) |
							   ((char3 & 0x3F) << 0));
			    break;
			}
	    }alert(d)
	
	    return out;
	}
	
	