if(Nm == undefined) Nm = {}; 

//========================================================================================================================

Nm.setButtonInteractionWithFigures = function(Es, Ts) {
	if(!Es.length) return;
	var fR = function(I, I_src) { return function() { I.src = I_src; }; }
	var fRover = function(a) { return function() { a.style.backgroundPosition = "0px -40px"; }; }
	var fRout = function(a) { return function() { a.style.backgroundPosition = "0px 0px"; }; }
	Es.forEach(function(E) {
		var As = E.getElementsByTagName("a");
		var img = As[0].getElementsByTagName("img")[0];
		if (img) {
			var h___src = new Image().src = img.src.replace(/(_link)?(\.png|\.gif|\.jpg)/, Ts[0] + "$2");
			As[1].addEventListener("mouseover", fR(img, h___src), false);
			As[1].addEventListener("mouseout",  fR(img, img.src), false);
		} else {
			As[0].addEventListener("mouseover", fRover(As[0]), false);
			As[0].addEventListener("mouseout", fRout(As[0]), false);
			As[1].addEventListener("mouseover", fRover(As[0]), false);
			As[1].addEventListener("mouseout", fRout(As[0]), false);
		}
	});
}

// ---------------------------------------------------------------------------------------------------------------------

document.write([
	'<style type="text/css">',
	'	.jumpList {	height: 2.1em !important;	}	',
	'	.jumpList ul {	display: none;	}	',
	'</style>'
].join(""));



document.getElementsByClassName = function(Cs)
{
	var Es = new Array();
	var aEs = this.getElementsByTagName("*") || allElements;
	Cs.split(",").forEach(function(C){
		foreach(aEs,function(E){
			var cNs = E.className.split("  ");
			if(C.indexOf(" ") > -1){
				var cNsStr = " " + cNs.sort().join(" ") + " " ;
				var argStr = " " + C.split(" ").sort().join(" ") + " ";
				if(cNsStr.indexOf(argStr) > -1) Es.push(E);
			}else for(var i = 0; i < cNs.length; i++) if(cNs[i]== C) { Es.push(E); break; }
		});
	});
	return Es;
}

Nm.setJumpSelecter = function() {
	var jLs = document.getElementsByClassName("jumpList");
	if(!jLs.length) return;
	jLs.forEach(function(jL) {
		var ____ = "････････････････････････";
		var cNs = jL.className.split(" ");
		var HTML = [
			'<form action="" method="" onsubmit="return false;">',
			'<select onchange="Nm.jump(this.options[this.options.selectedIndex]); return false;">',
			'<option value="">機種を選択してください</option>'
		];
		var ULs = jL.getElementsByTagName("ul");
		foreach(ULs, function(UL) {
			HTML.push('<option value="">' + ____ + '</option>');
			var LIs = UL.getElementsByTagName("li");
			foreach(LIs, function(LI) {
				var A = LI.getElementsByTagName("a")[0];
				HTML.push('<option');
				if(A.className == "external") HTML.push(' class="external"');
				HTML.push(' value="' + A.href + '">' + A.innerHTML + '</option>');
			});
		});
		HTML.push('</select></form>');
		jL.innerHTML = HTML.join("");
	});
}

Nm.jump = function(E) {
	if(!E.value) return;
	if(E.className == "external") open(E.value);
	else               location.href = E.value;
}

// ---------------------------------------------------------------------------------------------------------------------

Nm.setDescriptiveNavHeight = function() {
	var dNs = document.getElementsByClassName("descriptiveNav");
	if(!dNs.length) return;
	dNs.forEach(function(dN) {
		var LIs = toArray(dN.getElementsByTagName("li"));
		var Odd = 1, oLIs = new Array, eLIs = new Array;
		for(var i = 0; i < LIs.length; i++) {
			if(Odd) {
				oLIs.push(LIs[i]);
				Odd = 0;
			} else {
				eLIs.push(LIs[i]);
				Odd = 1;
			}
		}
		for(var i = 0; i < eLIs.length; i++) {
			oLIs[i].style.clear ="both";
			var oH = parseInt(oLIs[i].offsetHeight);
			var eH = parseInt(eLIs[i].offsetHeight);
			if(oH > eH) eLIs[i].style.height = (oH - 15) + "px";
			else        oLIs[i].style.height = (eH - 15) + "px";
		}
	});
}

// ---------------------------------------------------------------------------------------------------------------------

Nm.setGalleryLeadHeight = function() {
	var gSCs = document.getElementsByClassName("gallery");
	if(!gSCs.length) return;
	var pSCs = new Array;
	gSCs.forEach(function(gSC) { pSCs.push(gSC.getElementsByClassName("section")[0]); });
	if(pSCs.length < 2) return;
	var wpH = parseInt(pSCs[0].offsetHeight);
	var cmH = parseInt(pSCs[1].offsetHeight);
	if(wpH > cmH)  pSCs[1].style.height = wpH + "px";
	else           pSCs[0].style.height = cmH + "px";
}

// ---------------------------------------------------------------------------------------------------------------------

Nm.setShowCaseNavBG = function() {
	var sNs = document.getElementsByClassName("showcaseNav");
	if(!sNs.length) return;
	var DTs = new Array;
	sNs.forEach(function(sN) { DTs.push(sN.getElementsByTagName("dt")[0]); });
	if(!DTs.length) return;
	DTs.forEach(function(DT) {
		DT.style.backgroundImage = "none";
	});
}

//=========================================================================================================================

Nm.onRead.addEventListener(function() {

	Nm.setExternalLinks();
	Nm.setPageTopLinks();

	Nm.setShowCaseNavBG();

	Nm.setButtonInteractions(document.getElementsByClassName("globalNav"), ["_hover"]);
	Nm.setButtonInteractions(document.getElementsByClassName("carrierNav"), ["_hover", "_on"]);
	var mNav_ULs = document.getElementsByClassName("modelNav").concat(document.getElementsByClassName("mobileSiteNav"));
	if(mNav_ULs.length) {
		var mNav_Hs = new Array, mNav_LIs = new Array;
		mNav_ULs.forEach(function(mNav_UL) {
			mNav_Hs = mNav_Hs.concat(mNav_UL.getElementsByClassName("h"));
			mNav_LIs = mNav_LIs.concat(toArray(mNav_UL.getElementsByTagName("li")));
		});
		Nm.setButtonInteractions(mNav_Hs, ["_hover"]);
		Nm.setButtonInteractionWithFigures(mNav_LIs, ["_hover"]);
	}

	var mNav_UL_d = document.getElementById("modelNavDocomo");
	var mNav_UL_a = document.getElementById("modelNavAu");
	var mNav_UL_s = document.getElementById("modelNavSoftbank");
	if (mNav_UL_d || mNav_UL_a || mNav_UL_s) {
		var mNav_LIs_d = mNav_UL_d? mNav_UL_d.getElementsByTagName("li") : new Array();
		var mNav_LIs_a = mNav_UL_a? mNav_UL_a.getElementsByTagName("li") : new Array();
		var mNav_LIs_s = mNav_UL_s? mNav_UL_s.getElementsByTagName("li") : new Array();
		var count = (mNav_LIs_d.length >= mNav_LIs_s.length)? mNav_LIs_d.length : mNav_LIs_s.length;
		var i, h, h1, h2, h3, h4, h5, h6, p1, p2, p3, p4, p5, p6;
        var j = 0;
		for (i = 0; i < count; i += 2) {
			p1 = (i < mNav_LIs_d.length)? mNav_LIs_d[i].getElementsByClassName("hl") : null;
			p2 = (i + 1 < mNav_LIs_d.length)? mNav_LIs_d[i + 1].getElementsByClassName("hl") : null;
			p3 = (j < mNav_LIs_a.length)? mNav_LIs_a[j].getElementsByClassName("hl") : null;
			p5 = (j < mNav_LIs_s.length)? mNav_LIs_s[j].getElementsByClassName("hl") : null;

			h1 = (p1 && p1.length > 0)? p1[0].offsetHeight : 0;
			h2 = (p2 && p2.length > 0)? p2[0].offsetHeight : 0;
			h3 = (p3 && p3.length > 0)? p3[0].offsetHeight : 0;
			h5 = (p5 && p5.length > 0)? p5[0].offsetHeight : 0;
			h = h1;
			if (h2 > h) h = h2;
			if (h3 > h) h = h3;
			if (h5 > h) h = h5;
			if (p1 && p1.length > 0) p1[0].style.height = h + "px";
			if (p2 && p2.length > 0) p2[0].style.height = h + "px";
			if (p3 && p3.length > 0) p3[0].style.height = h + "px";
			if (p5 && p5.length > 0) p5[0].style.height = h + "px";

            j++;
		}
	}
	var mNav_UL_o = document.getElementById("modelNavOne");
	if (mNav_UL_o) {
		var mNav_LIs_o = mNav_UL_o.getElementsByTagName("li");
		var count = mNav_LIs_o.length;
		var i, h, h1, h2, h3, h4, p1, p2, p3, p4;
		for (i = 0; i < count; i += 4) {
			p1 = mNav_LIs_o[i].getElementsByClassName("hl");
			p2 = (i + 1 < count)? mNav_LIs_o[i + 1].getElementsByClassName("hl") : null;
			p3 = (i + 2 < count)? mNav_LIs_o[i + 2].getElementsByClassName("hl") : null;
			p4 = (i + 3 < count)? mNav_LIs_o[i + 3].getElementsByClassName("hl") : null;
			h1 = (p1 && p1.length > 0)? p1[0].offsetHeight : 0;
			h2 = (p2 && p2.length > 0)? p2[0].offsetHeight : 0;
			h3 = (p3 && p3.length > 0)? p3[0].offsetHeight : 0;
			h4 = (p4 && p4.length > 0)? p4[0].offsetHeight : 0;
			h = h1;
			if (h2 > h) h = h2;
			if (h3 > h) h = h3;
			if (h4 > h) h = h4;
			if (p1 && p1.length > 0) p1[0].style.height = h + "px";
			if (p2 && p2.length > 0) p2[0].style.height = h + "px";
			if (p3 && p3.length > 0) p3[0].style.height = h + "px";
			if (p4 && p4.length > 0) p4[0].style.height = h + "px";
		}
	}

});

// ---------------------------------------------------------------------------------------------------------------------

Nm.onLoad.addEventListener(function() {

	Nm.setJumpSelecter();

	Nm.setDescriptiveNavHeight();
	Nm.setGalleryLeadHeight();

	document.getElementsByClassName("toTop").forEach(function(tT) { tT.style.display = "block"; });

});


//=========================================================================================================================
