//===================================================================
//
//	***  All common JavaScript  ***
//
//===================================================================

	var addpath = '';
	try {
		addpath = jsppath;
	} catch (err) {}

//-----------------------------------------------------
//ie b.g. cache fix
//-----------------------------------------------------

	try {
		document.execCommand("BackgroundImageCache", false, true);
	} catch(err) {}


//-----------------------------------------------------
//magical lines for ie
//-----------------------------------------------------

	/*@cc_on _d=document;eval('var document=_d')@*/


//-----------------------------------------------------
//check whether if navigator is Mac or not
//-----------------------------------------------------

	var isMac = false;


//-----------------------------------------------------
//protect medical contents
//-----------------------------------------------------

	var hideFrag = false;

	if (document.URL.indexOf("/product/medical") != -1 &&
		document.URL.indexOf("/product/medical/promotion") == -1 &&
		document.URL.indexOf("/product/medical/about") == -1 &&
		document.URL.indexOf("/inquiry/product/medical") == -1 &&
		document.URL.indexOf("/request/product/medical") == -1
	) {
		if ( get_cookie('isRelatedMedical')  ) {
		} else {
			function localNavigation() {}
			var disableHeightLine = true;
			//
			var css = document.createElement('link');
			css.rel = "stylesheet";
			css.type = "text/css";
			css.href = addpath + "/common/css/protectMedical.css";
			document.getElementsByTagName('head')[0].appendChild(css);
			hideFrag = true;
		}
	}


	function hideMedical() {
		if ( hideFrag === true ) {
			//delete content
			document.getElementById('mainArea').innerHTML = "";
			var d = document.createElement('div');
				d.id = "hideMedicalContents";
				var s = d.style;
					s.textAlign = "center";
			var e = document.createElement('img');
				e.src = addpath + "/common/images/shared/medicalProtection.gif";
				e.width = "550";
				e.height = "383";
				e.alt = "ご利用のお客様へ  弊社の医療機器製品情報サイトは、医療関係者を対象に情報提供することを目的としております。一般の方や患者様への情報提供を目的としたものではありませんのでご了承ください。  あなたは医療関係者ですか？";
				e.border = "0";
				e.useMap = "#Map";
			var m = document.createElement('map');
				m.name = "Map";
				m.id = "Map";
			var a1 = document.createElement('area');
				a1.shape = "rect";
				a1.coords = "117,288,259,350";
				a1.href = "#";
				a1.alt = "はい";
				a1.onclick = function() {
					var timer = new Date();
					timer.setTime(timer.getTime() + ( 1 * 60 * 60 * 24 * 1000 ));
					var endDate = timer.toGMTString();
					document.cookie = "isRelatedMedical=true;expires=" + endDate + ";path=/";
					location.reload();
					return false;
				}
			var a2 = document.createElement('area');
				a2.shape = "rect";
				a2.coords = "291,288,433,350";
				a2.href = "#";
				a2.alt = "いいえ";
				a2.onclick = function() {
					history.back();
					return false;
				}
			document.getElementById('aligner').appendChild(d).appendChild(e);
			document.getElementById('aligner').appendChild(m).appendChild(a1);
			document.getElementById('aligner').appendChild(m).appendChild(a2);
		}
	}


//-----------------------------------------------------
//easy getelementbyid
//-----------------------------------------------------

	function $$(id) {
		e = document.getElementById(id);
		return e;
	}


//-----------------------------------------------------
// -load external js file(s)
//-----------------------------------------------------

	var jsFiles = new Array;
	jsFiles.push('jquery');
	jsFiles.push('localNavigation');
	jsFiles.push('loadTopics');
	jsFiles.push('loadExhibition');
	var cssFiles = new Array;
	cssFiles.push('localNavigation');
	//
	var cssLength = cssFiles.length;
	var jsLength = jsFiles.length;
	//
	document.open();
	for ( var i = 0 ; i < jsLength ; i ++ ) {
		document.write('<script type="text/javascript" src="' + addpath + '/common/js/' + jsFiles[i] + '.js"></script>')
	}
	for ( var i = 0 ; i < cssLength ; i ++ ) {
		document.write('<link rel="stylesheet" type="text/css" href="' + addpath + '/common/css/' + cssFiles[i] + '.css" />')
	}
	document.close();


//-----------------------------------------------------
// -get document path / document name
//-----------------------------------------------------

	var tmpUrl = "";
	var docpath = "";
	var docfile = "";

	tmpUrl = document.URL.split(document.domain)[1];
	tmpUrl.match(/(\/.*\/)(.*)/);
	docpath = RegExp.$1;
	docfile = ( RegExp.$2 != "" ) ? RegExp.$2 : "index.html";


//-----------------------------------------------------
// -init history back
//-----------------------------------------------------

	function init_history_back() {
		var e = document.createElement('a'), f = document.createElement('li');
		e.href = "javascript:history.back(-1)";
		e.innerHTML = "前のページへ戻る";
		f.className = "prev";
		f.appendChild(e);
		$$('footerNavigationList').appendChild(f);
	}


//-----------------------------------------------------
// -init clsoe button
//-----------------------------------------------------

	function init_close_btn() {
		var e = document.createElement('a'), f = document.createElement('li');
		e.href = "javascript:window.close()";
		e.innerHTML = "このページを閉じる";
		f.className = "close";
		f.appendChild(e);
		$$('footerNavigationList').appendChild(f);
		$$('footerNavigationList').className += " withCloseButton";
	}


//-----------------------------------------------------
// -init clsoe button
//-----------------------------------------------------

	function init_prev_btn() {
		var e = document.createElement('a'), f = document.createElement('li');
		e.href = "javascript:history.back(-1)";
		e.innerHTML = "前のページへ戻る";
		f.className = "prev";
		f.appendChild(e);
		$$('footerNavigationList').appendChild(f);
		$$('footerNavigationList').className += " withCloseButton";
	}


//-----------------------------------------------------
// -hilight global navigation
//-----------------------------------------------------

	function hilight_global_navi() {
		var category = docpath.split("/")[1];
		var childs = $$('globalNaviList').getElementsByTagName('li');
		var gCnt = childs.length;

		for ( var i = 0 ; i < gCnt ; i ++ ) {
			if ( childs[i].innerHTML.indexOf("/"+category+"/") != -1 ) {
				childs[i].firstChild.firstChild.src = childs[i].firstChild.firstChild.src.replace(".gif","_on.gif");
				break;
			}
		}
	}


//-----------------------------------------------------
// -set input area function
//-----------------------------------------------------

	function init_searchArea_action() {
		var form = document.frm_keyword || document.frm_keyword2;
		if (form.SEARCH.value  == "") {
			form.SEARCH.value  = "製品名";
		}
	}

	function set_searchArea_action() {
		if ( $$('queryWord') != undefined ) {
			$$('queryWord').onfocus = function() {
				if ( $$('queryWord').value == "製品名" ) {
					$$('queryWord').value = "";
				}
			}
			$$('queryWord').onblur = function() {
				if ( $$('queryWord').value == "" ) {
					$$('queryWord').value = "製品名";
				}
			}
		}
	}


//-----------------------------------------------------
// -set input area function
//-----------------------------------------------------

	function init_colors_searchArea() {
		if (document.productNumber.SEARCH.value  == "") {
			document.productNumber.SEARCH.value  = "品番";
		}
	}

	function set_colors_searchArea() {
		if ( $$('queryNumber') != undefined ) {
			$$('queryNumber').onfocus = function() {
				if ( $$('queryNumber').value == "品番" ) {
					$$('queryNumber').value = "";
				}
			}
			$$('queryNumber').onblur = function() {
				if ( $$('queryNumber').value == "" ) {
					$$('queryNumber').value = "品番";
				}
			}
		}
	}


//-----------------------------------------------------
// -actual search area function
//-----------------------------------------------------

	function check_form() {
		msg="";
		if(document.frm_keyword.SEARCH.value=='' || document.frm_keyword.SEARCH.value=='製品名') {
			msg=msg+"検索キーが入力されていません\n\n";
		}
		if(msg!='') {
			msg=msg+"内容を修正して、再度送信してください。";
			window.alert(msg);
		} else {
			document.frm_keyword.submit();
		}
	}

//-----------------------------------------------------
// -change iframe height function
//-----------------------------------------------------

	function change_iframe_height() {
		//alert("aa");
		$(this).height( 30 );
		//$(this).height( $(this).contents().find('#searchBlock').height() );
	}

//-----------------------------------------------------
// -get document cookie
//-----------------------------------------------------

	function get_cookie(name) {
		allcookie = document.cookie + ';'
		start1 = allcookie.indexOf(name);
		if (start1 != -1) {
			target = allcookie.substring(start1, allcookie.length);
			start2 = target.indexOf('=', 0) + 1;
			end = target.indexOf(';', start2);
			return(unescape(target.substring(start2, end)));
		}
		return("");
	}


//-----------------------------------------------------
//change font size
//-----------------------------------------------------

	function change(obj) {
		var size = obj.parentNode.id.split('fontSize')[1].toLowerCase();
		var e = document.createElement('link');
		e.rel = "stylesheet";
		e.type = "text/css";
		//
		switch ( size ) {
			case 's':
				document.cookie = "fontSize=s;expires=Fri, 31-Dec-2030 23:59:59;path=/";
				e.href = addpath + "/common/css/fontSizeS.css";
				//
				$$('fontSizeS').firstChild.className = "current";
				$$('fontSizeM').firstChild.className = "";
				$$('fontSizeL').firstChild.className = "";
				$$('header').style.fontSize = "120%";
				$$('footer').style.fontSize = "120%";
				document.body.style.fontSize = "62.5%";
			break;

			case 'm':
				document.cookie = "fontSize=m;expires=Fri, 31-Dec-2030 23:59:59;path=/";
				e.href = addpath + "/common/css/fontSizeM.css";
				//
				$$('fontSizeS').firstChild.className = "";
				$$('fontSizeM').firstChild.className = "current";
				$$('fontSizeL').firstChild.className = "";
				$$('header').style.fontSize = "100%";
				$$('footer').style.fontSize = "100%";
				document.body.style.fontSize = "75%";
			break;

			case 'l':
				document.cookie = "fontSize=l;expires=Fri, 31-Dec-2030 23:59:59;path=/";
				e.href = addpath + "/common/css/fontSizeL.css";
				//
				$$('fontSizeS').firstChild.className = "";
				$$('fontSizeM').firstChild.className = "";
				$$('fontSizeL').firstChild.className = "current";
				$$('header').style.fontSize = "85.71%";
				$$('footer').style.fontSize = "85.71%";
				document.body.style.fontSize = "87.5%";
			break;

			default:
				document.cookie = "fontSize=m;expires=Fri, 31-Dec-2030 23:59:59;path=/";
				e.href = addpath + "/common/css/fontSizeM.css";
				//
				$$('fontSizeS').firstChild.className = "";
				$$('fontSizeM').firstChild.className = "current";
				$$('fontSizeL').firstChild.className = "";
				$$('header').style.fontSize = "100%";
				$$('footer').style.fontSize = "100%";
				document.body.style.fontSize = "75%";
			break;
		}
		document.getElementsByTagName('head')[0].appendChild(e);
	}


	function attach_font_size_changer() {
		var e = document.createElement('link');
		e.rel = "stylesheet";
		e.type = "text/css";
		//
		document.write('<div id="fontSizeChanger">'+
		'<dl>'+
		'<dt><span class="clear">文字サイズ変更</span></dt>');
		switch ( get_cookie('fontSize') ) {
			case 's':
				e.href = addpath + "/common/css/fontSizeS.css";
				//
				document.write('<dd id="fontSizeS"><a class="current" href="javascript:void(0);" onclick="change(this);"><span class="clear">小</span></a></dd>'+
				'<dd id="fontSizeM"><a href="javascript:void(0);" onclick="change(this);"><span class="clear">中</span></a></dd>'+
				'<dd id="fontSizeL"><a href="javascript:void(0);" onclick="change(this);"><span class="clear">大</span></a></dd>');
			break;

			case 'm':
				e.href = addpath + "/common/css/fontSizeM.css";
				//
				document.write('<dd id="fontSizeS"><a href="javascript:void(0);" onclick="change(this);"><span class="clear">小</span></a></dd>'+
				'<dd id="fontSizeM"><a class="current" href="javascript:void(0);" onclick="change(this);"><span class="clear">中</span></a></dd>'+
				'<dd id="fontSizeL"><a href="javascript:void(0);" onclick="change(this);"><span class="clear">大</span></a></dd>');
			break;

			case 'l':
				e.href = addpath + "/common/css/fontSizeL.css";
				//
				document.write('<dd id="fontSizeS"><a href="javascript:void(0);" onclick="change(this);"><span class="clear">小</span></a></dd>'+
				'<dd id="fontSizeM"><a href="javascript:void(0);" onclick="change(this);"><span class="clear">中</span></a></dd>'+
				'<dd id="fontSizeL"><a class="current" href="javascript:void(0);" onclick="change(this);"><span class="clear">大</span></a></dd>');
			break;

			default:
				e.href = addpath + "/common/css/fontSizeM.css";
				//
				document.write('<dd id="fontSizeS"><a href="javascript:void(0);" onclick="change(this);"><span class="clear">小</span></a></dd>'+
				'<dd id="fontSizeM"><a class="current" href="javascript:void(0);" onclick="change(this);"><span class="clear">中</span></a></dd>'+
				'<dd id="fontSizeL"><a href="javascript:void(0);" onclick="change(this);"><span class="clear">大</span></a></dd>');
			break;
		}
		document.write('</dl>'+
		'<!-- /fontSizeChanger --></div>');
		document.getElementsByTagName('head')[0].appendChild(e);
	}


//-----------------------------------------------------
// init_tabNavigation
//
// write as [url]?[tabID]=3&[tabID]=2 such as [url]?hoge=2&test=3
// to use pre-open tab from other pages
//
//-----------------------------------------------------

	function init_tab() {

		//attach external css setting
		document.open();
		document.write('<link rel="stylesheet" type="text/css" href="' + addpath +  '/common/css/tab.css" />');
		document.close();

		//common variables
		var initialName = arguments[0];
		var isExistLower = ( $$(initialName+"Lower") ) ? true : false;

		//init tab(s) and set default view
		var upperChilds = $$(initialName+"Upper").getElementsByTagName('li');
		if ( isExistLower ) var lowerChilds = $$(initialName+"Lower").getElementsByTagName('li');
		if ( document.URL.indexOf('?') != -1 && document.URL.indexOf(initialName) != -1 ) {
			var targetNumber = document.URL.split('?')[1].split('&');
			var cnt = targetNumber.length;
			for ( var i = 0 ; i < cnt ; i ++ ) {
				if ( targetNumber[i].indexOf(initialName+'=') != -1 ) {
					tabNumber = targetNumber[i].split('=')[1];
					break;
				}
			}
			upperChilds[tabNumber-1].className =  "current";
			if ( isExistLower )lowerChilds[tabNumber-1].className = "current";
			$$(initialName+"BodyContent"+tabNumber).style.display = "block";
		} else {
			upperChilds[0].className =  "current";
			if ( isExistLower )lowerChilds[0].className = "current";
			$$(initialName+"BodyContent1").style.display = "block";
		}

		//set upper tab function
		for ( var i = 0 ; i < upperChilds.length ; i ++ ) {
			upperChilds[i].firstChild.onclick = function () {
				// reset
				for ( var j = 0 ; j < upperChilds.length ; j ++ ) {
					upperChilds[j].className = "";
					if ( isExistLower )lowerChilds[j].className = "";
					$$(initialName+"BodyContent"+(j+1)).style.display = "none";
				}
				// current view
				this.parentNode.className = "current";
				if ( isExistLower )lowerChilds[this.firstChild.firstChild.firstChild.href.split('#')[1].split('BodyContent')[1]-1].className = "current";
				$$(this.firstChild.firstChild.firstChild.href.split('#')[1]).style.display = "block";
				//
				return false;
			}
		}

		//set lower tab function
		if ( isExistLower ) for ( var i = 0 ; i < lowerChilds.length ; i ++ ) {
			lowerChilds[i].firstChild.onclick = function () {
				// reset
				for ( var j = 0 ; j < lowerChilds.length ; j ++ ) {
					lowerChilds[j].className = "";
					upperChilds[j].className = "";
					$$(initialName+"BodyContent"+(j+1)).style.display = "none";
				}
				// current view
				this.parentNode.className = "current";
				upperChilds[this.firstChild.firstChild.firstChild.href.split('#')[1].split('BodyContent')[1]-1].className = "current";
				$$(this.firstChild.firstChild.firstChild.href.split('#')[1]).style.display = "block";
				//
				return false;
			}
		}
	}


//-----------------------------------------------------
//load external common JavaScript file
//-----------------------------------------------------

	if( typeof disableHeightLine != 'boolean' ) {
		var jsArray = new Array;
		jsArray.push('heightLine');
		var jsDirectory = addpath + "/common/js/";
		//
		document.open();
		for ( var i = 0 ; i < jsArray.length ; i ++ ) document.write("<script type='text/javascript' src='" + jsDirectory + jsArray[0] + ".js'></script>");
		document.close();
	}



//-----------------------------------------------------
//initialize all onload events
//-----------------------------------------------------

	function init() {

		var img = document.getElementsByTagName('img');
		for ( var i = 0, imgLength = img.length ; i < imgLength ; i ++ ) {
			var cn = img[i].className.toLowerCase().split(' ');
			for ( var j = 0, varCnt = cn.length ; j < varCnt ; j ++ ) {
				if ( cn[j] == 'over' ) {
					img[i].onmouseover = function() {
						roll_over_on(this);
					}
					img[i].onmouseout = function() {
						roll_over_off(this);
					}
				}
			}
		}

		var img = document.getElementsByTagName('input');
		for ( var i = 0, imgLength = img.length ; i < imgLength ; i ++ ) {
			var cn = img[i].className.toLowerCase().split(' ');
			for ( var j = 0, varCnt = cn.length ; j < varCnt ; j ++ ) {
				if ( cn[j] == 'over' ) {
					img[i].onmouseover = function() {
						roll_over_on(this);
					}
					img[i].onmouseout = function() {
						roll_over_off(this);
					}
				}
			}
		}

		if ( isMac ) {
			var targetDiv = document.getElementsByTagName('div');
			for ( var i = 0, targetDivLength = targetDiv.length ; i < targetDivLength ; i ++ ) {
				var cn = targetDiv[i].className.toLowerCase().split(' ');
				for ( var j = 0, varCnt = cn.length ; j < varCnt ; j ++ ) {
					if ( cn[j] == 'callnumber' ) {
						targetDiv[i].className += " callNumberMac";
					}
				}
			}
		}

		if ( document.URL.indexOf('/ir/finance/management/quarter/') != -1 ) {
			var scroller = document.getElementsByTagName('div');
			for ( var i = 0, scrollerLength = scroller.length ; i < scrollerLength ; i ++ ) {
				var cn = scroller[i].className.toLowerCase().split(' ');
				for ( var j = 0, varCnt = cn.length ; j < varCnt ; j ++ ) {
					if ( cn[j] == 'scroll' ) {
						scroller[i].scrollLeft = 9999;
					}
				}
			}
		}


	}

	function roll_over_on(obj) { obj.src = obj.src.replace(/(.*)\.([a-z]{3})$/g,'$1_on.$2'); }
	function roll_over_off(obj) { obj.src = obj.src.replace(/(.*)_on\.([a-z]{3})$/g,'$1.$2'); }


//-----------------------------------------------------
//open popup
//-----------------------------------------------------

	function open_width_1_column(obj) { var subWin1 = window.open(obj.href,"sb_pressed",'resizable=yes,menubar=yes,status=yes,location=yes,toolbar=yes,scrollbars=yes,width=640,height=500');subWin1.focus(); }
	function open_width_2_column(obj) { var subWin2 = window.open(obj.href,"sb_shrinked",'resizable=yes,menubar=yes,status=yes,location=yes,toolbar=yes,scrollbars=yes,width=840,height=500');subWin2.focus(); }
	function open_width_3_column(obj) { var subWin3 = window.open(obj.href,"sb_fullSize");subWin3.focus(); }


//-----------------------------------------------------
//focus parent
//-----------------------------------------------------

	function focus_parent() {
		window.opener.focus();
	}

	function parent_locate(url) {
		if (window.opener!=undefined) {
			window.opener.location.href=url;
		} else {
			window.open(url,"sb_parent",'resizable=yes,menubar=yes,status=yes,location=yes,toolbar=yes,scrollbars=yes');
		}
		focus_parent()
	}


//-----------------------------------------------------
//define and set window name
//-----------------------------------------------------

	function setWindowName() {
		switch ( document.body.id ) {
			case "shrinked":
				window.name = "sb_shrinked";
				break;
			case "pressed":
				window.name = "sb_pressed";
				break;
			case "fullSize":
				window.name = "sb_fullSize";
				break;
			default:
				window.name = "sb_parent";
				break;
		}
	}


//-----------------------------------------------------
//attach events when loaded
//-----------------------------------------------------

	if ( window.addEventListener ) {
		isMac = ( navigator.userAgent.indexOf('Macintosh') != -1 ) ? true : false;
		window.addEventListener( "load", set_searchArea_action, false );
		window.addEventListener( "load", set_colors_searchArea, false );
		window.addEventListener( "load", init, false );
		window.addEventListener( "load", hideMedical, false );
		window.addEventListener( "load", setWindowName, false );
	} else if ( window.attachEvent ) {
		window.attachEvent( "onload", set_searchArea_action );
		window.attachEvent( "onload", set_colors_searchArea );
		window.attachEvent( "onload", init );
		window.attachEvent( "onload", hideMedical );
		window.attachEvent( "onload", setWindowName );
	} else {
		window.onload = set_searchArea_action();
		window.onload = set_colors_searchArea();
		window.onload = init();
		window.onload = hideMedical();
		window.onload = setWindowName();
	}

