$(function()
	{
		var i=1;
//ターゲットブランク
	$('a[@href*="/jump.php"]').attr('target','blank');

//プリロードイメージ======================================================
	$('img[@src*="_off"]').each(
		function(){
			plImg=$(this).attr("src").split("_");
			if(plImg.length==3){
				crtFileType=plImg[2].split(".");
					$(this).attr("src",plImg[0]+"_"+plImg[1]+"_on."+crtFileType[1]);
					$(this).attr("src",plImg[0]+"_"+plImg[1]+"_off."+crtFileType[1]);
			}else if(plImg.length==2){
				crtFileType=plImg[1].split(".");
					$(this).attr("src",plImg[0]+"_on."+crtFileType[1]);
					$(this).attr("src",plImg[0]+"_off."+crtFileType[1]);
			}
		});
//メニュー切り替え========================================================
	var crtPath = document.location.pathname.split("/");//URI配列
	var pathLength = crtPath.length;
	var crtLocation = crtPath[pathLength-1];//現在位置
	var crtFilename = crtLocation;//ファイル名
	//ヘッダーメニュー----------------------------------------------------
	/*if(pathLength<=3&&$("body").attr("name")!="top-index"&&$("body").attr("name")!="campaign")
	{	//トップページ----------------------------------------------
		changeMenu('#hm-top');
	}else if(crtPath[pathLength-2]=="guide")
	{	//開通までの道----------------------------------------------
		changeMenu('#hm-road');
	}else if($("body").attr("name")=="campaign")
	{	//キャンペーン情報------------------------------------------
		changeMenu('#hm-campaign');
	}else if(crtPath[pathLength-2]=="flets"||crtPath[pathLength-2]=="provider"||crtPath[pathLength-2]=="hikari_denwa")
	{	//サービス一覧----------------------------------------------
		changeMenu('#hm-service');
	}else if(crtPath[pathLength-2]=="entry"){
		changeMenu('#hm-entry');
	}
	//右メニュー----------------------------------------------------------
	if(crtLocation == "" || crtLocation == "index.html")
	{
		crtLocation = crtPath[pathLength-2];
	}
	menuSwitch(crtLocation);
	$("#col-menu li").hover(function()
		{
			$("#crt-pos").remove();
			$(this).prepend('<div id="crt-pos"></div>');
		},function()
		{
			$("#crt-pos").remove();
			menuSwitch(crtLocation);
		});
	$("#col-menu .flets,#col-menu .prov,#col-menu .phone").hover(function()
		{
			$("#crt-pos").remove();
		},function()
		{
			menuSwitch(crtLocation);
		});*/
//ロールオーバー==========================================================
	$('img[@src*="_off"]:not([@name])').hover(
		function(){
			crtImg=$(this).attr("src").split("_");
			if(crtImg.length==3){
				crtFileType=crtImg[2].split(".");
				$(this).attr("src",crtImg[0]+"_"+crtImg[1]+"_on."+crtFileType[1]);
			}else if(crtImg.length==2){
				crtFileType=crtImg[1].split(".");
				$(this).attr("src",crtImg[0]+"_on."+crtFileType[1]);
			}
		},
		function(){
			crtImg=$(this).attr("src").split("_");
			if(crtImg.length==3){
				crtFileType=crtImg[2].split(".");
				$(this).attr("src",crtImg[0]+"_"+crtImg[1]+"_off."+crtFileType[1]);
			}else if(crtImg.length==2){
				crtFileType=crtImg[1].split(".");
				$(this).attr("src",crtImg[0]+"_off."+crtFileType[1]);
			}
		});
//STEPメニュー============================================================
	$('#step-menu img[src$="_off.gif"]').hover(
		function()
		{
			var beforeImg=$(this).attr("id").split("_");
			if(beforeImg[1]!=0)
			{
				beforeImg[1]-=1;
				var sonImgID=beforeImg[0]+"_"+beforeImg[1];
				var sonImg=$("#"+sonImgID).attr("src").split("_");
				if(sonImg[2]=="ac.gif")
				{
					$("#"+sonImgID).attr("src",sonImg[0]+"_"+sonImg[1]+"_ason.gif");
				}else{
				$("#"+sonImgID).attr("src",sonImg[0]+"_"+sonImg[1]+"_son.gif");
				}
			}
			var crtImg=$(this).attr("src").split("_");
			$(this).attr("src",crtImg[0]+"_"+crtImg[1]+"_on.gif");
		},
		function()
		{
			var crtImg=$(this).attr("src").split("_");
			$(this).attr("src",crtImg[0]+"_"+crtImg[1]+"_off.gif");
			var beforeImg=$(this).attr("id").split("_");
			if(beforeImg[1]!=0)
			{
				beforeImg[1]-=1;
				var sonImgID=beforeImg[0]+"_"+beforeImg[1];
				var sonImg=$("#"+sonImgID).attr("src").split("_");
				if(sonImg[2]=="ason.gif")
				{
					$("#"+sonImgID).attr("src",sonImg[0]+"_"+sonImg[1]+"_ac.gif");
				}else{
				$("#"+sonImgID).attr("src",sonImg[0]+"_"+sonImg[1]+"_off.gif");
				}
			}
		});
	$('#step-menu img[src$="_aoff.gif"]').hover(
		function()
		{
			var beforeImg=$(this).attr("id").split("_");
			if(beforeImg[1]!=0)
			{
				beforeImg[1]-=1;
				var sonImgID=beforeImg[0]+"_"+beforeImg[1];
				var sonImg=$("#"+sonImgID).attr("src").split("_");
				if(sonImg[2]=="ac.gif")
				{
					$("#"+sonImgID).attr("src",sonImg[0]+"_"+sonImg[1]+"_ason.gif");
				}else{
				$("#"+sonImgID).attr("src",sonImg[0]+"_"+sonImg[1]+"_son.gif");
				}
			}
			var crtImg=$(this).attr("src").split("_");
			$(this).attr("src",crtImg[0]+"_"+crtImg[1]+"_aon.gif");
		},
		function()
		{
			var crtImg=$(this).attr("src").split("_");
			$(this).attr("src",crtImg[0]+"_"+crtImg[1]+"_aoff.gif");
			var beforeImg=$(this).attr("id").split("_");
			if(beforeImg[1]!=0)
			{
				beforeImg[1]-=1;
				var sonImgID=beforeImg[0]+"_"+beforeImg[1];
				var sonImg=$("#"+sonImgID).attr("src").split("_");
				if(sonImg[2]=="ason.gif")
				{
					$("#"+sonImgID).attr("src",sonImg[0]+"_"+sonImg[1]+"_ac.gif");
				}else{
				$("#"+sonImgID).attr("src",sonImg[0]+"_"+sonImg[1]+"_off.gif");
				}
			}
		});
//STEPメニューアニメーション==============================================
		$("#st-anim").show();
		$("#st-anim").mouseover(function()
			{
				$(this).remove();
			});
//FAQ=====================================================================
		$("#faq li").each(function()
			{
				if(i%2!=0){
					if($("body").attr("id")!="step")
					{
						$(this).html('<a href="#fa-ac"><img src="../images/icon/faq_q.gif" alt="Q." width="30" height="18" border="0" />'+$(this).text()+'</a>');
					}else{
						$(this).html('<a href="#fa-ac"><img src="../../images/icon/faq_q.gif" alt="Q." width="30" height="18" border="0" />'+$(this).text()+'</a>');
					}
					$(this).addClass("que").attr("id","que-"+i);
				}else{
					$(this).hide().addClass("ans").attr("id","ans-"+i);
					if($("body").attr("id")!="step")
					{
						$(this).html('<img src="../images/icon/faq_a.gif" alt="A." width="30" height="18" border="0" />'+$(this).html());
					}else{
						$(this).html('<img src="../../images/icon/faq_a.gif" alt="A." width="30" height="18" border="0" />'+$(this).html());
					}
				}
				i++;
			});
		var crtOpen="#";
		var crtQue="#";
		$(".que").click(function()
			{
				$(".que-ac").attr("class","que");
				if($("body").attr("id")!="step")
				{
					$(".que img").attr("src","../images/icon/faq_q_ps.gif");
				}else{
					$(".que img").attr("src","../../images/icon/faq_q_ps.gif");
				}
				$(this).attr("class","que-ac");
				$(crtOpen).hide();
				var crtQue=$(this).attr("id");
				if($("body").attr("id")!="step")
				{
					$("#"+crtQue+" img").attr("src","../images/icon/faq_q.gif");
				}else{
					$("#"+crtQue+" img").attr("src","../../images/icon/faq_q.gif");
				}
				var crtQ=crtQue.split("-");
				crtQN=crtQ[1]-0+1;
				crtOpen="#ans-"+crtQN;
				$(crtOpen).fadeIn(500);
			});
//東西切り替え============================================================
	if($("body").attr("name")!="top-index")
	{
		$("#ew-button").css("display","block");
		var crtEW=$("#ew-button img").attr("src").split("/");
		var EWsrc="";//東西ボタンのURI
		var jumpURI="";//移動先のディレクトリ
		var crtArea="";//東西判定
		for(i=0;i<crtEW.length-1;i++)
		{
			EWsrc+=crtEW[i]+"/";
		}
		for(i=0;i<pathLength-1;i++)//移動先のディレクトリ
		{
			if(crtPath[i]=="east")
			{
				$("#ew-button img").attr({"src":EWsrc+"menu_EtoW_off.gif","alt":"西日本へ"});
				crtArea="east";
				jumpURI+="west/";
			}else if(crtPath[i]=="west")
			{
				$("#ew-button img").attr({"src":EWsrc+"menu_WtoE_off.gif","alt":"東日本へ"});
				crtArea="west";
				jumpURI+="east/";
			}else
			{
				jumpURI+=crtPath[i]+"/";
			}
		}
		switch (crtFilename)//移動先のファイル名
		{
			case "b_flets.html":
				if(crtArea=="east")
				{
					crtFilename="hikari_premium.html";
				}
				break;
			case "hikari_premium.html":
				crtFilename="b_flets.html";
				break;
			case "hikari_next.html":
				crtFilename="hikari_premium.html";
				break;
			case "flets_tv.html":
			case "virus_clear.html":
			case "remote_support.html":
				crtFilename="index.html";
				break;
			default:
				break;
		}
		$("#ew-button").attr("href",jumpURI+crtFilename);
		$("#ew-button img").click(function()
			{
				window.location=jumpURI+crtFilename;
			});
//東西切り替えインフォ----------------------------------------------
		$("#contents").prepend('<div id="col-ew"><div class="head"></div><div class="body"></div><div class="foot"></div></div>');
		$("#col-ew").remove();
		$("#ew-button img").hover(function()
			{
				if($(this).attr("alt")=="西日本へ")
				{
					$("#contents").prepend(
						'<div id="col-ew"><div class="head"></div><div class="body">西日本のページへ移動します。<br />【NTT西日本対象エリア】<br />富山県	石川県	福井県	静岡県	愛知県	岐阜県	三重県	滋賀県	京都府	大阪府	兵庫県	奈良県	和歌山県	鳥取県	島根県	広島県	岡山県	山口県	香川県	徳島県	愛媛県	高知県	福岡県	大分県	佐賀県	長崎県	宮崎県	熊本県	鹿児島県	沖縄県</div><div class="foot"></div></div>');
					$("#col-ew").css("display","none");
				}else if($(this).attr("alt")=="東日本へ")
				{
					$("#contents").prepend(
						'<div id="col-ew"><div class="head"></div><div class="body">東日本のページへ移動します。<br />【NTT東日本対象エリア】<br />北海道	青森県	岩手県	秋田県	宮城県	山形県	福島県	茨城県	群馬県	埼玉県	千葉県	東京都	神奈川県	新潟県	栃木県	山梨県	長野県</div><div class="foot"></div></div>');
					$("#col-ew").css("display","none");
				}
				if(jQuery.browser.msie && jQuery.browser.version<7){
					$("#col-ew").css("display","block");
				}else{
					$("#col-ew").fadeIn(100);
				}
			},function()
			{
				if(jQuery.browser.msie && jQuery.browser.version<7){
					$("#col-ew").remove();
				}else{
					$("#col-ew").fadeOut(500);
				}
			});
//東西トップページリンク
		/*pathCnt=$("#to-top").attr("href").split("/").length;
		var jumpPath="";
		for(i=0;i<pathCnt-2;i++)
		{
			jumpPath+="../";
		}
		jumpPath+="index.html";
		$("#to-top").attr("href",jumpPath);*/
	}
	$("#apart-tb").hide();
	$("#family").click(function()
	{
		$("#family-tb").show();
		$("#apart-tb").hide();
	});
	$("#apart").click(function()
	{
		$("#family-tb").hide();
		$("#apart-tb").show();
	});
});

/*呼び出し関数-----------------------------------------------------------------------------------------------------------*/
//右メニューぽっちり======================================================
function menuSwitch(lc)
{
	switch(lc)
	{
		case "flets":
					$("#menu-flets li a[href *= 'index.html']").attr("class","active").before('<div id="crt-pos"></div>');
					break;
		case "provider":
					$("#menu-prov li a[href *= 'index.html']").attr("class","active").before('<div id="crt-pos"></div>');
					break;
		case "hikari_denwa":
					$("#menu-phone li a[href *= 'index.html']").attr("class","active").before('<div id="crt-pos"></div>');
					break;
		case "east":
					$("#o-menu li a[href $= 'east']").attr("class","active").before('<div id="crt-pos"></div>');
					break;
		case "west":
					$("#o-menu li a[href $= 'west']").attr("class","active").before('<div id="crt-pos"></div>');
					break;
		default: $("#col-menu li a[href *= '"+lc+"']").attr("class","active").before('<div id="crt-pos"></div>');
					break;
	}
}
//ヘッドメニュー切り替え====================================================
function changeMenu(crtBtn)
{
	var crtMBURI="";
	var acMenu=$(crtBtn).attr("src").split("/");
	var crtMBName=acMenu[acMenu.length-1].split("_");
	for(i=0;acMenu.length-2>=i;i++)
	{
		crtMBURI+=acMenu[i]+"/";
	}
	crtMBURI+=crtMBName[0]+"_"+crtMBName[1]+"_on.gif";
	$(crtBtn).attr({"src":crtMBURI,"name":"現在位置"});
}

//年齢認証================================================================
var locDate=new Date();
var crtYear=locDate.getFullYear()-0;
var btYear;
function ageCheck(age)
{
	btYear=age.value;
	locDate=new Date();
	var crtYear=locDate.getFullYear();
	var crtAge=crtYear-btYear;
	if(crtAge<21)
	{
		if(crtAge<0)
		{
			alert("4桁の西暦でご記入ください　(例)1980");
			$("#bt-year").select();
		}else{
			$("#parent").show();
		}
			
	}else if(crtAge>120){
		alert("4桁の西暦でご記入ください　(例)1980");
		$("#bt-year").select();
	}else{
		$("#parent").hide();
	}
	$("#age").attr("value",crtAge);
	//alert(btYear);
}
//日付作成=================================================================
function changeDays(month)
{
	var crtMonth = month.value;
	$("#d31,#d30,#d29").remove();
	$("#day").append('<option value="29" id="d29">29</option><option value="30" id="d30">30</option><option value="31" id="d31">31</option>');
	//alert(crtMonth);
	if(crtMonth == "02")
	{
		if(btYear%4==0&&btYear%100!=0||btYear%400==0)
		{
			$("#d31,#d30").remove();
		}
		else
		{
			$("#d31,#d30,#d29").remove();
		}
	}
	else
	{
		if(crtMonth<8)
		{
			if(crtMonth%2==0)
			{
				$("#d31").remove();
			}
		}
		else
		{
			if(crtMonth%2!=0)
			{
				$("#d31").remove();
			}
		}
	}
}