function fncKaniPass(url){
	try{
		password = window.prompt("パスワードを入力してください","");
		if(!password){
			window.alert("パスワードが未入力です");
		}
		else if(password != "22"){
			window.alert("パスワードが違います");
		}
		else if(password == "22"){
			location.href = url;
		}
		else{
			window.alert("キャンセルされました");
		}
	}
	catch(e){
		window.alert("予期せぬエラーが発生しました");
	}
}

//同じウィンドウでリンク先に飛ばす場合
function fncTransition(url){
	window.location = url;
}

//別のウィンドウでリンク先に飛ばす場合
function fncTransition2(url){
	window.open(url);
}

function fncGotoTop(x, y){
	window.scroll(x, y);
}

function fncCloseSubWindow(){
	window.close();
}

function fncCheckSagyousaki(){
	if(document.getElementById("addr_same").checked == true){
		document.getElementById("sagyousaki").disabled = true;
		document.getElementById("sagyousaki").value = "";
	}
	else if(document.getElementById("addr_same").checked == false){
		document.getElementById("sagyousaki").disabled = false;
	}
}

function fncNaiyouKubetsu() {
	if(document.getElementsByClassName("kubetsu")[1].checked == true){
		document.getElementById("naiyou_kubetsu").innerHTML = "お見積もり";
		document.getElementById("sagyou_check").innerHTML = "（<input type=\"checkbox\" name=\"sagyou\" value=\"1\">&nbsp;お見積もり後作業希望</input>）"
	}
	else if(document.getElementsByClassName("kubetsu")[0].checked == true){
		document.getElementById("naiyou_kubetsu").innerHTML = "お問い合わせ";
		document.getElementById("sagyou_check").innerHTML = "";
	}
}

function fncTelFtoH(id){
	a = "";
	x = document.getElementById(id).value;
	for(i=0; i<x.length; i++) {
	cd = x.charCodeAt(i);
	if((cd >= 65296 && cd <= 65305) || (cd >= 65313 && cd <= 65338) || (cd >= 65345 && cd <= 65370)) {
	a += String.fromCharCode(cd - 65248);
	} else {
	a += x.charAt(i);
	}
	}
	document.getElementById(id).value = a;
	
	fncDeleteKakko(id);
	
	fncTelCheck(id);
}

function fncDeleteKakko(id){
	chikan1 = document.getElementById(id).value.replace("(", "");
	document.getElementById(id).value = chikan1;
	chikan2 = document.getElementById(id).value.replace(")", "");
	document.getElementById(id).value = chikan2;
	chikan3 = document.getElementById(id).value.replace("（", "");
	document.getElementById(id).value = chikan3;
	chikan4 = document.getElementById(id).value.replace("）", "");
	document.getElementById(id).value = chikan4;
}

function fncTelCheck(id){
	if(!document.getElementById(id).value.match(/^[0-9]+$/) && !document.getElementById(id).value == ""){
		window.alert("入力できない文字が含まれています。");
		document.getElementById(id).value = "";
	}
}



/*
function checkTel(telnum){
  //未入力チェック
  if(telnum == ""){
    alert("電話番号が入力されていません。"); return false;
  }

  //電話番号は、「2～5桁の数字 - 1～4桁の数字 - 4桁の数字
  //正規表現ｵﾌﾞｼﾞｪｸﾄ 電話番号
  var tel_reg = new RegExp("^\\d{2,5}-\\d{1,4}-\\d{4}$");
  //携帯電話（11桁　ハイフンあり（13桁））
  var port_reg = new RegExp("^0[0-9]0-\\d{4}-\\d{4}$"); 
  
  //携帯電話形式[0?0]の場合
  if(telnum.substring(0,1)=="0" && telnum.substr(2,1)=="0"){
    if(!telnum.match(port_reg)){
      alert("電話番号(携帯電話形式)に誤りがあります。");
      return false;
    }else{
      return true;
    }
  }else{
    //電話番号形式
    //桁数チェック(一般電話11桁または12桁（"-"含む))
    if(telnum.length==11 || telnum.length==12){
      //形式チェック
      if(!telnum.match(tel_reg)){
        alert("電話番号（一般回線形式）に誤りがあります。");
        return false;
      }else{
        return true;
      }
    }else{
        alert("電話番号(桁数)に誤りがあります。");
        return false;
    }

  }
}
*/


function fncShowOtherField(id1, id2){
	if(document.getElementById(id1).value == "1"){
		document.getElementById(id2).style.display = "block";
	}
	else{
		document.getElementById(id2).style.display = "none";
	}
	//window.alert(document.getElementById(id1).value);
}

