// Swap Images Script //



function MM_preloadImages() { //v3.0

  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();

    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)

    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}

}



function MM_swapImgRestore() { //v3.0

  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;

}



function MM_findObj(n, d) { //v4.01

  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {

    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}

  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];

  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);

  if(!x && d.getElementById) x=d.getElementById(n); return x;

}



function MM_swapImage() { //v3.0

  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)

   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}

}



// Popup a Window of a nozzle //



function IC_openWindow(theURL) {

	window_handle=window.open(theURL,'closeup','width=270,height=270,resizable=yes'); 

	window_handle.focus(); 

}



// Popup a Window of nenkan.html //



function nenkan_openWindow(theURL) {

	window_handle=window.open(theURL,'closeup','width=640,height=575,resizable=yes,scrollbars=yes'); 

	window_handle.focus(); 

}



// Popup a Window of catalog.html //



function catalog_openWindow(theURL) {

	window_handle=window.open(theURL,'closeup','width=320,height=450,resizable=yes,scrollbars=yes'); 

	window_handle.focus(); 

}



// Code Number Converter Script //



function Sgscd_OnClick()

{ 

	str = toHankakuNum(document.thisForm.sc.value.toString());

	if (str.length == 7 && str.indexOf("-",0) == 3)

		str = str.substring(0, 3) + str.substring(4, 7)

	if (str.length != 6 || isNaN(str)) {

		alert("６桁の数字を入力してください");

		return false;

	}



	document.thisForm.sgscd.value = str;

	document.thisForm.textarea.value = "";

//	  document.thisForm.submit();

  	setTimeout("document.thisForm.submit()", 200);	//IEではクリックが早いとsubmitがうまく働かないため、タイマーで遅延

}



function toHankakuNum(motoText)

{

	han = "0123456789--";

	zen = "０１２３４５６７８９−ー";

	str = "";

	for (i=0; i<motoText.length; i++)

	{

		c = motoText.charAt(i);

		n = zen.indexOf(c,0);

		if (n >= 0) c = han.charAt(n);

		str += c;

	}

	return str;

}



// Zip Window //



function zipopen() {

  var zip1 = document.thisForm.elements['zip1'].value;

  var zip2 = document.thisForm.elements['zip2'].value;

  var zcd = zip1 + zip2;

  myWin=window.open("../zip.jsp?zip1="+zip1+"&zip2="+zip2,"zip","scrollbars=yes,resizable=no,width=280,height=250");

}


// Popup a Window of SVS Fig. 05.10.17//


function fig_openWindow(theURL) {

	window_handle=window.open(theURL,'','width=640,height=480,location=no,menubar=no,toolbar=no,status=no,resizable=no,scrollbars=no'); 

	window_handle.focus(); 

}

// Popup a Window of bp.html 06.01.31//



function bp_openWindow(theURL) {

	window_handle=window.open(theURL,'closeup','width=760,height=600,resizable=yes,scrollbars=yes'); 

	window_handle.focus(); 

}

// Popup a Window of graph_expl.html //



function grphexpl_openWindow(theURL) {

	window_handle=window.open(theURL,'','width=640,height=575,resizable=yes,scrollbars=yes'); 

	window_handle.focus(); 

}

function print_out() {
   /* print() が使えるブラウザかどうかを判断 */
   if (navigator.userAgent.match(/msie (\d)/i))
      v = (eval(RegExp.$1) >= 5) ? 1 : 0;
   else if (self.innerWidth)
      v = (eval(navigator.appVersion.charAt(0)) >= 4) ? 1 : 0;
   else v = 0;

   /* print() が使えるブラウザなら印刷を実行 */
   if (v) self.print();
   else alert("お使いのブラウザではこの機能は利用できません");
}

// メニュー･ロールオーバー
function rollOver(obj,val) {
	obj.className = val;
}

// URLリンク
function jumpUrl(url) {
	window.location = url;
}

// 表示モード切替
function displayMode(mode) {
	document.getElementById('submenu').style.display = mode;
}

// ポップアップメニュー
function popupMenu(obj, item, w, h) {

	var submenu = document.getElementById('submenu');

	// メニュー項目
	popupMenuItem = new Array();
	switch (item) {
	
 // さらに詳しく
case 1:
popupMenuItem.push("Easy Search Operation", "http://sgs.nozzle-network.com/en/aboutsgs/simplesearch2.html");
popupMenuItem.push("Features of the SGS", "http://sgs.nozzle-network.com/en/aboutsgs/sgsfeatures.html");
popupMenuItem.push("Easy-to-follow Search Example", "http://sgs.nozzle-network.com/en/aboutsgs/simplesearch.html");
popupMenuItem.push("SGS Case Studies", "http://sgs.nozzle-network.com/en/example/index.html");
popupMenuItem.push("SGS Pats Pending", "http://sgs.nozzle-network.com/en/patent/index.html");
popupMenuItem.push("Contact Us", "http://sgs.nozzle-network.com/en/contact/index.html");
popupMenuItem.push("Site Policy", "http://sgs.nozzle-network.com/en/misc/sitepolicy.html");
popupMenuItem.push("Service Provider", "http://sgs.nozzle-network.com/en/company/index.html?btn=1");
break;

	// サポートツール
case 2:
popupMenuItem.push("The world of Nozzles: Introduction", "http://sgs.nozzle-network.com/en/tools/know_1.html");
popupMenuItem.push("The World of Nozzles: Practical Edition", "http://sgs.nozzle-network.com/en/tools/know_practical_1.html");
popupMenuItem.push("Glossary of SGS Terms", "http://sgs.nozzle-network.com/en/tools/terms.html");
popupMenuItem.push("Nozzle Unit Converter", "http://sgs.nozzle-network.com/en/tools/unit.html");
popupMenuItem.push("SGS Search Code No. Converter", "http://sgs.nozzle-network.com/en/converter.jsp");
		break;
} 
	// メニュー作成
	var layer;
	var roop;
	var url;
	var subject;
	layer = "<div id='popmenu' style='position:absolute;top:" + h + ";left:" + w + ";'>\n";
	roop = popupMenuItem.length / 2;
	for (i=0; i<roop; i++) {
		url = i * 2 + 1;
		subject = i * 2;
		layer += "	<div id='submenu" + i + "' class='submenu01'";
		layer += "	  onclick=jumpUrl('" + popupMenuItem[url] + "')";
		layer += "	  onmouseover=rollOver(this,'submenu02');displayMode('block');";
		layer += "	  onmouseout=rollOver(this,'submenu01');displayMode('none');>" + popupMenuItem[subject] + "</div>\n";
	}
	layer += "</div>\n";

	// ポップアップメニュー表示
	submenu.style.display = 'block';
	submenu.innerHTML = layer;

}
